process.cc (7441:be2acdfb8bdc) process.cc (8149:12bd3ad81f9d)
1/*
2 * Copyright (c) 2010 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 183 unchanged lines hidden (view full) ---

192 /* 112 */ SyscallDesc("unused#112", unimplementedFunc),
193 /* 113 */ SyscallDesc("syscall", unimplementedFunc),
194 /* 114 */ SyscallDesc("wait4", unimplementedFunc),
195 /* 115 */ SyscallDesc("swapoff", unimplementedFunc),
196 /* 116 */ SyscallDesc("sysinfo", sysinfoFunc<ArmLinux>),
197 /* 117 */ SyscallDesc("ipc", unimplementedFunc),
198 /* 118 */ SyscallDesc("fsync", unimplementedFunc),
199 /* 119 */ SyscallDesc("sigreturn", unimplementedFunc),
1/*
2 * Copyright (c) 2010 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 183 unchanged lines hidden (view full) ---

192 /* 112 */ SyscallDesc("unused#112", unimplementedFunc),
193 /* 113 */ SyscallDesc("syscall", unimplementedFunc),
194 /* 114 */ SyscallDesc("wait4", unimplementedFunc),
195 /* 115 */ SyscallDesc("swapoff", unimplementedFunc),
196 /* 116 */ SyscallDesc("sysinfo", sysinfoFunc<ArmLinux>),
197 /* 117 */ SyscallDesc("ipc", unimplementedFunc),
198 /* 118 */ SyscallDesc("fsync", unimplementedFunc),
199 /* 119 */ SyscallDesc("sigreturn", unimplementedFunc),
200 /* 120 */ SyscallDesc("clone", unimplementedFunc),
200 /* 120 */ SyscallDesc("clone", cloneFunc),
201 /* 121 */ SyscallDesc("setdomainname", unimplementedFunc),
202 /* 122 */ SyscallDesc("uname", unameFunc),
203 /* 123 */ SyscallDesc("unused#123", unimplementedFunc),
204 /* 124 */ SyscallDesc("adjtimex", unimplementedFunc),
205 /* 125 */ SyscallDesc("mprotect", ignoreFunc),
206 /* 126 */ SyscallDesc("sigprocmask", unimplementedFunc),
207 /* 127 */ SyscallDesc("unused#127", unimplementedFunc),
208 /* 128 */ SyscallDesc("init_module", unimplementedFunc),

--- 25 unchanged lines hidden (view full) ---

234 /* 154 */ SyscallDesc("sched_setparam", unimplementedFunc),
235 /* 155 */ SyscallDesc("sched_getparam", unimplementedFunc),
236 /* 156 */ SyscallDesc("sched_setscheduler", unimplementedFunc),
237 /* 157 */ SyscallDesc("sched_getscheduler", unimplementedFunc),
238 /* 158 */ SyscallDesc("sched_yield", unimplementedFunc),
239 /* 159 */ SyscallDesc("sched_get_priority_max", unimplementedFunc),
240 /* 160 */ SyscallDesc("sched_get_priority_min", unimplementedFunc),
241 /* 161 */ SyscallDesc("sched_rr_get_interval", unimplementedFunc),
201 /* 121 */ SyscallDesc("setdomainname", unimplementedFunc),
202 /* 122 */ SyscallDesc("uname", unameFunc),
203 /* 123 */ SyscallDesc("unused#123", unimplementedFunc),
204 /* 124 */ SyscallDesc("adjtimex", unimplementedFunc),
205 /* 125 */ SyscallDesc("mprotect", ignoreFunc),
206 /* 126 */ SyscallDesc("sigprocmask", unimplementedFunc),
207 /* 127 */ SyscallDesc("unused#127", unimplementedFunc),
208 /* 128 */ SyscallDesc("init_module", unimplementedFunc),

--- 25 unchanged lines hidden (view full) ---

234 /* 154 */ SyscallDesc("sched_setparam", unimplementedFunc),
235 /* 155 */ SyscallDesc("sched_getparam", unimplementedFunc),
236 /* 156 */ SyscallDesc("sched_setscheduler", unimplementedFunc),
237 /* 157 */ SyscallDesc("sched_getscheduler", unimplementedFunc),
238 /* 158 */ SyscallDesc("sched_yield", unimplementedFunc),
239 /* 159 */ SyscallDesc("sched_get_priority_max", unimplementedFunc),
240 /* 160 */ SyscallDesc("sched_get_priority_min", unimplementedFunc),
241 /* 161 */ SyscallDesc("sched_rr_get_interval", unimplementedFunc),
242 /* 162 */ SyscallDesc("nanosleep", unimplementedFunc),
242 /* 162 */ SyscallDesc("nanosleep", ignoreWarnOnceFunc),
243 /* 163 */ SyscallDesc("mremap", mremapFunc<ArmLinux>), // ARM-specific
244 /* 164 */ SyscallDesc("setresuid", unimplementedFunc),
245 /* 165 */ SyscallDesc("getresuid", unimplementedFunc),
246 /* 166 */ SyscallDesc("unused#166", unimplementedFunc),
247 /* 167 */ SyscallDesc("unused#167", unimplementedFunc),
248 /* 168 */ SyscallDesc("poll", unimplementedFunc),
249 /* 169 */ SyscallDesc("nfsservctl", unimplementedFunc),
250 /* 170 */ SyscallDesc("setresgid", unimplementedFunc),
251 /* 171 */ SyscallDesc("getresgid", unimplementedFunc),
252 /* 172 */ SyscallDesc("prctl", unimplementedFunc),
253 /* 173 */ SyscallDesc("rt_sigreturn", unimplementedFunc),
243 /* 163 */ SyscallDesc("mremap", mremapFunc<ArmLinux>), // ARM-specific
244 /* 164 */ SyscallDesc("setresuid", unimplementedFunc),
245 /* 165 */ SyscallDesc("getresuid", unimplementedFunc),
246 /* 166 */ SyscallDesc("unused#166", unimplementedFunc),
247 /* 167 */ SyscallDesc("unused#167", unimplementedFunc),
248 /* 168 */ SyscallDesc("poll", unimplementedFunc),
249 /* 169 */ SyscallDesc("nfsservctl", unimplementedFunc),
250 /* 170 */ SyscallDesc("setresgid", unimplementedFunc),
251 /* 171 */ SyscallDesc("getresgid", unimplementedFunc),
252 /* 172 */ SyscallDesc("prctl", unimplementedFunc),
253 /* 173 */ SyscallDesc("rt_sigreturn", unimplementedFunc),
254 /* 174 */ SyscallDesc("rt_sigaction", ignoreFunc),
255 /* 175 */ SyscallDesc("rt_sigprocmask", unimplementedFunc),
254 /* 174 */ SyscallDesc("rt_sigaction", ignoreWarnOnceFunc),
255 /* 175 */ SyscallDesc("rt_sigprocmask", ignoreWarnOnceFunc),
256 /* 176 */ SyscallDesc("rt_sigpending", unimplementedFunc),
257 /* 177 */ SyscallDesc("rt_sigtimedwait", unimplementedFunc),
258 /* 178 */ SyscallDesc("rt_sigqueueinfo", ignoreFunc),
259 /* 179 */ SyscallDesc("rt_sigsuspend", unimplementedFunc),
260 /* 180 */ SyscallDesc("pread64", unimplementedFunc),
261 /* 181 */ SyscallDesc("pwrite64", unimplementedFunc),
262 /* 182 */ SyscallDesc("chown", unimplementedFunc),
263 /* 183 */ SyscallDesc("getcwd", getcwdFunc),

--- 48 unchanged lines hidden (view full) ---

312 /* 232 */ SyscallDesc("listxattr", unimplementedFunc),
313 /* 233 */ SyscallDesc("llistxattr", unimplementedFunc),
314 /* 234 */ SyscallDesc("flistxattr", unimplementedFunc),
315 /* 235 */ SyscallDesc("removexattr", unimplementedFunc),
316 /* 236 */ SyscallDesc("lremovexattr", unimplementedFunc),
317 /* 237 */ SyscallDesc("fremovexattr", unimplementedFunc),
318 /* 238 */ SyscallDesc("tkill", unimplementedFunc),
319 /* 239 */ SyscallDesc("sendfile64", unimplementedFunc),
256 /* 176 */ SyscallDesc("rt_sigpending", unimplementedFunc),
257 /* 177 */ SyscallDesc("rt_sigtimedwait", unimplementedFunc),
258 /* 178 */ SyscallDesc("rt_sigqueueinfo", ignoreFunc),
259 /* 179 */ SyscallDesc("rt_sigsuspend", unimplementedFunc),
260 /* 180 */ SyscallDesc("pread64", unimplementedFunc),
261 /* 181 */ SyscallDesc("pwrite64", unimplementedFunc),
262 /* 182 */ SyscallDesc("chown", unimplementedFunc),
263 /* 183 */ SyscallDesc("getcwd", getcwdFunc),

--- 48 unchanged lines hidden (view full) ---

312 /* 232 */ SyscallDesc("listxattr", unimplementedFunc),
313 /* 233 */ SyscallDesc("llistxattr", unimplementedFunc),
314 /* 234 */ SyscallDesc("flistxattr", unimplementedFunc),
315 /* 235 */ SyscallDesc("removexattr", unimplementedFunc),
316 /* 236 */ SyscallDesc("lremovexattr", unimplementedFunc),
317 /* 237 */ SyscallDesc("fremovexattr", unimplementedFunc),
318 /* 238 */ SyscallDesc("tkill", unimplementedFunc),
319 /* 239 */ SyscallDesc("sendfile64", unimplementedFunc),
320 /* 240 */ SyscallDesc("futex", unimplementedFunc),
320 /* 240 */ SyscallDesc("futex", ignoreWarnOnceFunc),
321 /* 241 */ SyscallDesc("sched_setaffinity", unimplementedFunc),
322 /* 242 */ SyscallDesc("sched_getaffinity", unimplementedFunc),
323 /* 243 */ SyscallDesc("io_setup", unimplementedFunc),
324 /* 244 */ SyscallDesc("io_destory", unimplementedFunc),
325 /* 245 */ SyscallDesc("io_getevents", unimplementedFunc),
326 /* 246 */ SyscallDesc("io_submit", unimplementedFunc),
327 /* 247 */ SyscallDesc("io_cancel", unimplementedFunc),
328 /* 248 */ SyscallDesc("exit_group", exitGroupFunc),

--- 122 unchanged lines hidden (view full) ---

451setTLSFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
452 ThreadContext *tc)
453{
454 int index = 0;
455 uint32_t tlsPtr = process->getSyscallArg(tc, index);
456
457 tc->getMemPort()->writeBlob(ArmLinuxProcess::commPage + 0x0ff0,
458 (uint8_t *)&tlsPtr, sizeof(tlsPtr));
321 /* 241 */ SyscallDesc("sched_setaffinity", unimplementedFunc),
322 /* 242 */ SyscallDesc("sched_getaffinity", unimplementedFunc),
323 /* 243 */ SyscallDesc("io_setup", unimplementedFunc),
324 /* 244 */ SyscallDesc("io_destory", unimplementedFunc),
325 /* 245 */ SyscallDesc("io_getevents", unimplementedFunc),
326 /* 246 */ SyscallDesc("io_submit", unimplementedFunc),
327 /* 247 */ SyscallDesc("io_cancel", unimplementedFunc),
328 /* 248 */ SyscallDesc("exit_group", exitGroupFunc),

--- 122 unchanged lines hidden (view full) ---

451setTLSFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
452 ThreadContext *tc)
453{
454 int index = 0;
455 uint32_t tlsPtr = process->getSyscallArg(tc, index);
456
457 tc->getMemPort()->writeBlob(ArmLinuxProcess::commPage + 0x0ff0,
458 (uint8_t *)&tlsPtr, sizeof(tlsPtr));
459 tc->setMiscReg(MISCREG_TPIDRURO,tlsPtr);
459 return 0;
460}
461
462SyscallDesc ArmLinuxProcess::privSyscallDescs[] = {
463 /* 1 */ SyscallDesc("breakpoint", unimplementedFunc),
464 /* 2 */ SyscallDesc("cacheflush", unimplementedFunc),
465 /* 3 */ SyscallDesc("usr26", unimplementedFunc),
466 /* 4 */ SyscallDesc("usr32", unimplementedFunc),

--- 36 unchanged lines hidden (view full) ---

503void
504ArmLinuxProcess::startup()
505{
506 ArmLiveProcess::startup();
507 pTable->allocate(commPage, PageBytes);
508 ThreadContext *tc = system->getThreadContext(contextIds[0]);
509
510 uint8_t swiNeg1[] = {
460 return 0;
461}
462
463SyscallDesc ArmLinuxProcess::privSyscallDescs[] = {
464 /* 1 */ SyscallDesc("breakpoint", unimplementedFunc),
465 /* 2 */ SyscallDesc("cacheflush", unimplementedFunc),
466 /* 3 */ SyscallDesc("usr26", unimplementedFunc),
467 /* 4 */ SyscallDesc("usr32", unimplementedFunc),

--- 36 unchanged lines hidden (view full) ---

504void
505ArmLinuxProcess::startup()
506{
507 ArmLiveProcess::startup();
508 pTable->allocate(commPage, PageBytes);
509 ThreadContext *tc = system->getThreadContext(contextIds[0]);
510
511 uint8_t swiNeg1[] = {
511 0xff, 0xff, 0xff, 0xef //swi -1
512 0xff, 0xff, 0xff, 0xef // swi -1
512 };
513
514 // Fill this page with swi -1 so we'll no if we land in it somewhere.
515 for (Addr addr = 0; addr < PageBytes; addr += sizeof(swiNeg1)) {
516 tc->getMemPort()->writeBlob(commPage + addr,
517 swiNeg1, sizeof(swiNeg1));
518 }
519
520 // We don't have barriers, so just return.
521 // @todo Add a barrrier in this code
522 uint8_t memory_barrier[] =
523 {
513 };
514
515 // Fill this page with swi -1 so we'll no if we land in it somewhere.
516 for (Addr addr = 0; addr < PageBytes; addr += sizeof(swiNeg1)) {
517 tc->getMemPort()->writeBlob(commPage + addr,
518 swiNeg1, sizeof(swiNeg1));
519 }
520
521 // We don't have barriers, so just return.
522 // @todo Add a barrrier in this code
523 uint8_t memory_barrier[] =
524 {
524 0x0e, 0xf0, 0xa0, 0xe1 //usr_ret lr
525 0x5f, 0xf0, 0x7f, 0xf5, // dmb
526 0x0e, 0xf0, 0xa0, 0xe1 // return
525 };
526 tc->getMemPort()->writeBlob(commPage + 0x0fa0, memory_barrier,
527 sizeof(memory_barrier));
528
529 // This -should- be atomic, but I don't think all the support that we'd
530 // need is implemented. There should also be memory barriers around it.
531 // @todo replace this with ldrex/strex and dmb
532 uint8_t cmpxchg[] =
533 {
527 };
528 tc->getMemPort()->writeBlob(commPage + 0x0fa0, memory_barrier,
529 sizeof(memory_barrier));
530
531 // This -should- be atomic, but I don't think all the support that we'd
532 // need is implemented. There should also be memory barriers around it.
533 // @todo replace this with ldrex/strex and dmb
534 uint8_t cmpxchg[] =
535 {
534 0x00, 0x30, 0x92, 0xe5, //ldr r3, [r2]
535 0x00, 0x30, 0x53, 0xe0, //subs r3, r3, r0
536 0x00, 0x10, 0x82, 0x05, //streq r1, [r2]
537 0x03, 0x00, 0xa0, 0xe1, //mov r0, r3
538 0x0e, 0xf0, 0xa0, 0xe1 //usr_ret lr
536 0x9f, 0x3f, 0x92, 0xe1, // ldrex r3, [r2]
537 0x00, 0x30, 0x53, 0xe0, // subs r3, r3, r0
538 0x91, 0x3f, 0x82, 0x01, // strexeq r3, r1, [r2]
539 0x01, 0x00, 0x33, 0x03, // teqeq r3, #1
540 0xfa, 0xff, 0xff, 0x0a, // beq 1b
541 0x00, 0x00, 0x73, 0xe2, // rsbs r0, r3, #0
542 0x5f, 0xf0, 0x7f, 0xf5, // dmb
543 0x0e, 0xf0, 0xa0, 0xe1 // return
539 };
540 tc->getMemPort()->writeBlob(commPage + 0x0fc0, cmpxchg, sizeof(cmpxchg));
541
542 uint8_t get_tls[] =
543 {
544 };
545 tc->getMemPort()->writeBlob(commPage + 0x0fc0, cmpxchg, sizeof(cmpxchg));
546
547 uint8_t get_tls[] =
548 {
544 0x08, 0x00, 0x9f, 0xe5, //ldr r0, [pc, #(16 - 8)]
545 0x0e, 0xf0, 0xa0, 0xe1 //usr_ret lr
549 // read user read-only thread id register
550 0x70, 0x0f, 0x1d, 0xee, // mrc p15, 0, r0, c13, c0, 3
551 0x0e, 0xf0, 0xa0, 0xe1 // return
546 };
547 tc->getMemPort()->writeBlob(commPage + 0x0fe0, get_tls, sizeof(get_tls));
548}
549
550ArmISA::IntReg
551ArmLinuxProcess::getSyscallArg(ThreadContext *tc, int &i)
552{
553 // Linux apparently allows more parameter than the ABI says it should.

--- 13 unchanged lines hidden ---
552 };
553 tc->getMemPort()->writeBlob(commPage + 0x0fe0, get_tls, sizeof(get_tls));
554}
555
556ArmISA::IntReg
557ArmLinuxProcess::getSyscallArg(ThreadContext *tc, int &i)
558{
559 // Linux apparently allows more parameter than the ABI says it should.

--- 13 unchanged lines hidden ---