2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Steve Reinhardt
39 #include "arch/utility.hh"
40 #include "base/chunk_generator.hh"
41 #include "base/trace.hh"
42 #include "config/the_isa.hh"
43 #include "cpu/base.hh"
44 #include "cpu/thread_context.hh"
45 #include "debug/SyscallVerbose.hh"
46 #include "mem/page_table.hh"
47 #include "sim/process.hh"
48 #include "sim/sim_exit.hh"
49 #include "sim/syscall_emul.hh"
50 #include "sim/system.hh"
53 using namespace TheISA
;
56 SyscallDesc::doSyscall(int callnum
, LiveProcess
*process
, ThreadContext
*tc
)
61 DPRINTFR(SyscallVerbose
,
62 "%d: %s: syscall %s called w/arguments %d,%d,%d,%d\n",
63 curTick(), tc
->getCpuPtr()->name(), name
,
64 process
->getSyscallArg(tc
, index
),
65 process
->getSyscallArg(tc
, index
),
66 process
->getSyscallArg(tc
, index
),
67 process
->getSyscallArg(tc
, index
));
69 SyscallReturn retval
= (*funcPtr
)(this, callnum
, process
, tc
);
71 DPRINTFR(SyscallVerbose
, "%d: %s: syscall %s returns %d\n",
72 curTick(),tc
->getCpuPtr()->name(), name
, retval
.value());
74 if (!(flags
& SyscallDesc::SuppressReturnValue
))
75 process
->setSyscallReturn(tc
, retval
);
80 unimplementedFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
83 fatal("syscall %s (#%d) unimplemented.", desc
->name
, callnum
);
90 ignoreFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
94 warn("ignoring syscall %s(%d, %d, ...)", desc
->name
,
95 process
->getSyscallArg(tc
, index
), process
->getSyscallArg(tc
, index
));
102 ignoreWarnOnceFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
106 warn_once("ignoring syscall %s(%d, %d, ...)", desc
->name
,
107 process
->getSyscallArg(tc
, index
), process
->getSyscallArg(tc
, index
));
114 exitFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
117 if (process
->system
->numRunningContexts() == 1) {
118 // Last running context... exit simulator
120 exitSimLoop("target called exit()",
121 process
->getSyscallArg(tc
, index
) & 0xff);
123 // other running threads... just halt this one
132 exitGroupFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
135 // really should just halt all thread contexts belonging to this
136 // process in case there's another process running...
138 exitSimLoop("target called exit()",
139 process
->getSyscallArg(tc
, index
) & 0xff);
146 getpagesizeFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
148 return (int)VMPageSize
;
153 brkFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
155 // change brk addr to first arg
157 Addr new_brk
= p
->getSyscallArg(tc
, index
);
159 // in Linux at least, brk(0) returns the current break value
160 // (note that the syscall and the glibc function have different behavior)
164 if (new_brk
> p
->brk_point
) {
165 // might need to allocate some new pages
166 for (ChunkGenerator
gen(p
->brk_point
, new_brk
- p
->brk_point
,
167 VMPageSize
); !gen
.done(); gen
.next()) {
168 if (!p
->pTable
->translate(gen
.addr()))
169 p
->allocateMem(roundDown(gen
.addr(), VMPageSize
), VMPageSize
);
171 // if the address is already there, zero it out
174 TranslatingPort
*tp
= tc
->getMemPort();
176 // split non-page aligned accesses
177 Addr next_page
= roundUp(gen
.addr(), VMPageSize
);
178 uint32_t size_needed
= next_page
- gen
.addr();
179 tp
->memsetBlob(gen
.addr(), zero
, size_needed
);
180 if (gen
.addr() + VMPageSize
> next_page
&&
181 next_page
< new_brk
&&
182 p
->pTable
->translate(next_page
))
184 size_needed
= VMPageSize
- size_needed
;
185 tp
->memsetBlob(next_page
, zero
, size_needed
);
191 p
->brk_point
= new_brk
;
192 DPRINTF(SyscallVerbose
, "Break Point changed to: %#X\n", p
->brk_point
);
198 closeFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
201 int target_fd
= p
->getSyscallArg(tc
, index
);
202 int sim_fd
= p
->sim_fd(target_fd
);
205 status
= close(sim_fd
);
207 p
->free_fd(target_fd
);
213 readFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
216 int fd
= p
->sim_fd(p
->getSyscallArg(tc
, index
));
217 Addr bufPtr
= p
->getSyscallArg(tc
, index
);
218 int nbytes
= p
->getSyscallArg(tc
, index
);
219 BufferArg
bufArg(bufPtr
, nbytes
);
221 int bytes_read
= read(fd
, bufArg
.bufferPtr(), nbytes
);
223 if (bytes_read
!= -1)
224 bufArg
.copyOut(tc
->getMemPort());
230 writeFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
233 int fd
= p
->sim_fd(p
->getSyscallArg(tc
, index
));
234 Addr bufPtr
= p
->getSyscallArg(tc
, index
);
235 int nbytes
= p
->getSyscallArg(tc
, index
);
236 BufferArg
bufArg(bufPtr
, nbytes
);
238 bufArg
.copyIn(tc
->getMemPort());
240 int bytes_written
= write(fd
, bufArg
.bufferPtr(), nbytes
);
244 return bytes_written
;
249 lseekFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
252 int fd
= p
->sim_fd(p
->getSyscallArg(tc
, index
));
253 uint64_t offs
= p
->getSyscallArg(tc
, index
);
254 int whence
= p
->getSyscallArg(tc
, index
);
256 off_t result
= lseek(fd
, offs
, whence
);
258 return (result
== (off_t
)-1) ? -errno
: result
;
263 _llseekFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
266 int fd
= p
->sim_fd(p
->getSyscallArg(tc
, index
));
267 uint64_t offset_high
= p
->getSyscallArg(tc
, index
);
268 uint32_t offset_low
= p
->getSyscallArg(tc
, index
);
269 Addr result_ptr
= p
->getSyscallArg(tc
, index
);
270 int whence
= p
->getSyscallArg(tc
, index
);
272 uint64_t offset
= (offset_high
<< 32) | offset_low
;
274 uint64_t result
= lseek(fd
, offset
, whence
);
275 result
= TheISA::htog(result
);
277 if (result
== (off_t
)-1) {
281 // The seek succeeded.
282 // Copy "result" to "result_ptr"
283 // XXX We'll assume that the size of loff_t is 64 bits on the
285 BufferArg
result_buf(result_ptr
, sizeof(result
));
286 memcpy(result_buf
.bufferPtr(), &result
, sizeof(result
));
287 result_buf
.copyOut(tc
->getMemPort());
292 return (result
== (off_t
)-1) ? -errno
: result
;
297 munmapFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
299 // given that we don't really implement mmap, munmap is really easy
304 const char *hostname
= "m5.eecs.umich.edu";
307 gethostnameFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
310 Addr bufPtr
= p
->getSyscallArg(tc
, index
);
311 int name_len
= p
->getSyscallArg(tc
, index
);
312 BufferArg
name(bufPtr
, name_len
);
314 strncpy((char *)name
.bufferPtr(), hostname
, name_len
);
316 name
.copyOut(tc
->getMemPort());
322 getcwdFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
326 Addr bufPtr
= p
->getSyscallArg(tc
, index
);
327 unsigned long size
= p
->getSyscallArg(tc
, index
);
328 BufferArg
buf(bufPtr
, size
);
330 // Is current working directory defined?
331 string cwd
= p
->getcwd();
333 if (cwd
.length() >= size
) {
337 strncpy((char *)buf
.bufferPtr(), cwd
.c_str(), size
);
338 result
= cwd
.length();
341 if (getcwd((char *)buf
.bufferPtr(), size
) != NULL
) {
342 result
= strlen((char *)buf
.bufferPtr());
349 buf
.copyOut(tc
->getMemPort());
351 return (result
== -1) ? -errno
: result
;
356 readlinkFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
361 if (!tc
->getMemPort()->tryReadString(path
, p
->getSyscallArg(tc
, index
)))
362 return (TheISA::IntReg
)-EFAULT
;
364 // Adjust path for current working directory
365 path
= p
->fullPath(path
);
367 Addr bufPtr
= p
->getSyscallArg(tc
, index
);
368 size_t bufsiz
= p
->getSyscallArg(tc
, index
);
370 BufferArg
buf(bufPtr
, bufsiz
);
372 int result
= readlink(path
.c_str(), (char *)buf
.bufferPtr(), bufsiz
);
374 buf
.copyOut(tc
->getMemPort());
376 return (result
== -1) ? -errno
: result
;
380 unlinkFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
385 if (!tc
->getMemPort()->tryReadString(path
, p
->getSyscallArg(tc
, index
)))
386 return (TheISA::IntReg
)-EFAULT
;
388 // Adjust path for current working directory
389 path
= p
->fullPath(path
);
391 int result
= unlink(path
.c_str());
392 return (result
== -1) ? -errno
: result
;
397 mkdirFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
402 if (!tc
->getMemPort()->tryReadString(path
, p
->getSyscallArg(tc
, index
)))
403 return (TheISA::IntReg
)-EFAULT
;
405 // Adjust path for current working directory
406 path
= p
->fullPath(path
);
408 mode_t mode
= p
->getSyscallArg(tc
, index
);
410 int result
= mkdir(path
.c_str(), mode
);
411 return (result
== -1) ? -errno
: result
;
415 renameFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
420 if (!tc
->getMemPort()->tryReadString(old_name
, p
->getSyscallArg(tc
, index
)))
425 if (!tc
->getMemPort()->tryReadString(new_name
, p
->getSyscallArg(tc
, index
)))
428 // Adjust path for current working directory
429 old_name
= p
->fullPath(old_name
);
430 new_name
= p
->fullPath(new_name
);
432 int64_t result
= rename(old_name
.c_str(), new_name
.c_str());
433 return (result
== -1) ? -errno
: result
;
437 truncateFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
442 if (!tc
->getMemPort()->tryReadString(path
, p
->getSyscallArg(tc
, index
)))
445 off_t length
= p
->getSyscallArg(tc
, index
);
447 // Adjust path for current working directory
448 path
= p
->fullPath(path
);
450 int result
= truncate(path
.c_str(), length
);
451 return (result
== -1) ? -errno
: result
;
455 ftruncateFunc(SyscallDesc
*desc
, int num
,
456 LiveProcess
*process
, ThreadContext
*tc
)
459 int fd
= process
->sim_fd(process
->getSyscallArg(tc
, index
));
464 off_t length
= process
->getSyscallArg(tc
, index
);
466 int result
= ftruncate(fd
, length
);
467 return (result
== -1) ? -errno
: result
;
471 truncate64Func(SyscallDesc
*desc
, int num
,
472 LiveProcess
*process
, ThreadContext
*tc
)
477 if (!tc
->getMemPort()->tryReadString(path
, process
->getSyscallArg(tc
, index
)))
480 int64_t length
= process
->getSyscallArg(tc
, index
, 64);
482 // Adjust path for current working directory
483 path
= process
->fullPath(path
);
486 int result
= truncate(path
.c_str(), length
);
488 int result
= truncate64(path
.c_str(), length
);
490 return (result
== -1) ? -errno
: result
;
494 ftruncate64Func(SyscallDesc
*desc
, int num
,
495 LiveProcess
*process
, ThreadContext
*tc
)
498 int fd
= process
->sim_fd(process
->getSyscallArg(tc
, index
));
503 int64_t length
= process
->getSyscallArg(tc
, index
, 64);
506 int result
= ftruncate(fd
, length
);
508 int result
= ftruncate64(fd
, length
);
510 return (result
== -1) ? -errno
: result
;
514 umaskFunc(SyscallDesc
*desc
, int num
, LiveProcess
*process
, ThreadContext
*tc
)
516 // Letting the simulated program change the simulator's umask seems like
517 // a bad idea. Compromise by just returning the current umask but not
518 // changing anything.
519 mode_t oldMask
= umask(0);
525 chownFunc(SyscallDesc
*desc
, int num
, LiveProcess
*p
, ThreadContext
*tc
)
530 if (!tc
->getMemPort()->tryReadString(path
, p
->getSyscallArg(tc
, index
)))
534 uint32_t owner
= p
->getSyscallArg(tc
, index
);
535 uid_t hostOwner
= owner
;
536 uint32_t group
= p
->getSyscallArg(tc
, index
);
537 gid_t hostGroup
= group
;
539 // Adjust path for current working directory
540 path
= p
->fullPath(path
);
542 int result
= chown(path
.c_str(), hostOwner
, hostGroup
);
543 return (result
== -1) ? -errno
: result
;
547 fchownFunc(SyscallDesc
*desc
, int num
, LiveProcess
*process
, ThreadContext
*tc
)
550 int fd
= process
->sim_fd(process
->getSyscallArg(tc
, index
));
556 uint32_t owner
= process
->getSyscallArg(tc
, index
);
557 uid_t hostOwner
= owner
;
558 uint32_t group
= process
->getSyscallArg(tc
, index
);
559 gid_t hostGroup
= group
;
561 int result
= fchown(fd
, hostOwner
, hostGroup
);
562 return (result
== -1) ? -errno
: result
;
567 dupFunc(SyscallDesc
*desc
, int num
, LiveProcess
*process
, ThreadContext
*tc
)
570 int fd
= process
->sim_fd(process
->getSyscallArg(tc
, index
));
574 Process::FdMap
*fdo
= process
->sim_fd_obj(fd
);
576 int result
= dup(fd
);
577 return (result
== -1) ? -errno
:
578 process
->alloc_fd(result
, fdo
->filename
, fdo
->flags
, fdo
->mode
, false);
583 fcntlFunc(SyscallDesc
*desc
, int num
, LiveProcess
*process
,
587 int fd
= process
->getSyscallArg(tc
, index
);
589 if (fd
< 0 || process
->sim_fd(fd
) < 0)
592 int cmd
= process
->getSyscallArg(tc
, index
);
595 // if we really wanted to support this, we'd need to do it
596 // in the target fd space.
597 warn("fcntl(%d, F_DUPFD) not supported, error returned\n", fd
);
600 case 1: // F_GETFD (get close-on-exec flag)
601 case 2: // F_SETFD (set close-on-exec flag)
604 case 3: // F_GETFL (get file flags)
605 case 4: // F_SETFL (set file flags)
606 // not sure if this is totally valid, but we'll pass it through
607 // to the underlying OS
608 warn("fcntl(%d, %d) passed through to host\n", fd
, cmd
);
609 return fcntl(process
->sim_fd(fd
), cmd
);
612 case 7: // F_GETLK (get lock)
613 case 8: // F_SETLK (set lock)
614 case 9: // F_SETLKW (set lock and wait)
615 // don't mess with file locking... just act like it's OK
616 warn("File lock call (fcntl(%d, %d)) ignored.\n", fd
, cmd
);
620 warn("Unknown fcntl command %d\n", cmd
);
626 fcntl64Func(SyscallDesc
*desc
, int num
, LiveProcess
*process
,
630 int fd
= process
->getSyscallArg(tc
, index
);
632 if (fd
< 0 || process
->sim_fd(fd
) < 0)
635 int cmd
= process
->getSyscallArg(tc
, index
);
638 warn("fcntl64(%d, F_GETLK64) not supported, error returned\n", fd
);
641 case 34: // F_SETLK64
642 case 35: // F_SETLKW64
643 warn("fcntl64(%d, F_SETLK(W)64) not supported, error returned\n", fd
);
647 // not sure if this is totally valid, but we'll pass it through
648 // to the underlying OS
649 warn("fcntl64(%d, %d) passed through to host\n", fd
, cmd
);
650 return fcntl(process
->sim_fd(fd
), cmd
);
656 pipePseudoFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
659 int fds
[2], sim_fds
[2];
660 int pipe_retval
= pipe(fds
);
662 if (pipe_retval
< 0) {
667 sim_fds
[0] = process
->alloc_fd(fds
[0], "PIPE-READ", O_WRONLY
, -1, true);
668 sim_fds
[1] = process
->alloc_fd(fds
[1], "PIPE-WRITE", O_RDONLY
, -1, true);
670 process
->setReadPipeSource(sim_fds
[0], sim_fds
[1]);
671 // Alpha Linux convention for pipe() is that fd[0] is returned as
672 // the return value of the function, and fd[1] is returned in r20.
673 tc
->setIntReg(SyscallPseudoReturnReg
, sim_fds
[1]);
679 getpidPseudoFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
682 // Make up a PID. There's no interprocess communication in
683 // fake_syscall mode, so there's no way for a process to know it's
684 // not getting a unique value.
686 tc
->setIntReg(SyscallPseudoReturnReg
, process
->ppid());
687 return process
->pid();
692 getuidPseudoFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
695 // Make up a UID and EUID... it shouldn't matter, and we want the
696 // simulation to be deterministic.
699 tc
->setIntReg(SyscallPseudoReturnReg
, process
->euid()); //EUID
700 return process
->uid(); // UID
705 getgidPseudoFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
708 // Get current group ID. EGID goes in r20.
709 tc
->setIntReg(SyscallPseudoReturnReg
, process
->egid()); //EGID
710 return process
->gid();
715 setuidFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
718 // can't fathom why a benchmark would call this.
720 warn("Ignoring call to setuid(%d)\n", process
->getSyscallArg(tc
, index
));
725 getpidFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
728 // Make up a PID. There's no interprocess communication in
729 // fake_syscall mode, so there's no way for a process to know it's
730 // not getting a unique value.
732 tc
->setIntReg(SyscallPseudoReturnReg
, process
->ppid()); //PID
733 return process
->pid();
737 getppidFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
740 return process
->ppid();
744 getuidFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
747 return process
->uid(); // UID
751 geteuidFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
754 return process
->euid(); // UID
758 getgidFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
761 return process
->gid();
765 getegidFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
768 return process
->egid();
773 cloneFunc(SyscallDesc
*desc
, int callnum
, LiveProcess
*process
,
777 IntReg flags
= process
->getSyscallArg(tc
, index
);
778 IntReg newStack
= process
->getSyscallArg(tc
, index
);
780 DPRINTF(SyscallVerbose
, "In sys_clone:\n");
781 DPRINTF(SyscallVerbose
, " Flags=%llx\n", flags
);
782 DPRINTF(SyscallVerbose
, " Child stack=%llx\n", newStack
);
785 if (flags
!= 0x10f00) {
786 warn("This sys_clone implementation assumes flags "
787 "CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD "
788 "(0x10f00), and may not work correctly with given flags "
792 ThreadContext
* ctc
; // child thread context
793 if ( ( ctc
= process
->findFreeContext() ) != NULL
) {
794 DPRINTF(SyscallVerbose
, " Found unallocated thread context\n");
796 ctc
->clearArchRegs();
798 // Arch-specific cloning code
799 #if THE_ISA == ALPHA_ISA or THE_ISA == X86_ISA
800 // Cloning the misc. regs for these archs is enough
801 TheISA::copyMiscRegs(tc
, ctc
);
802 #elif THE_ISA == SPARC_ISA
803 TheISA::copyRegs(tc
, ctc
);
805 // TODO: Explain what this code actually does :-)
806 ctc
->setIntReg(NumIntArchRegs
+ 6, 0);
807 ctc
->setIntReg(NumIntArchRegs
+ 4, 0);
808 ctc
->setIntReg(NumIntArchRegs
+ 3, NWindows
- 2);
809 ctc
->setIntReg(NumIntArchRegs
+ 5, NWindows
);
810 ctc
->setMiscReg(MISCREG_CWP
, 0);
811 ctc
->setIntReg(NumIntArchRegs
+ 7, 0);
812 ctc
->setMiscRegNoEffect(MISCREG_TL
, 0);
813 ctc
->setMiscRegNoEffect(MISCREG_ASI
, ASI_PRIMARY
);
815 for (int y
= 8; y
< 32; y
++)
816 ctc
->setIntReg(y
, tc
->readIntReg(y
));
817 #elif THE_ISA == ARM_ISA
818 TheISA::copyRegs(tc
, ctc
);
820 fatal("sys_clone is not implemented for this ISA\n");
823 // Set up stack register
824 ctc
->setIntReg(TheISA::StackPointerReg
, newStack
);
826 // Set up syscall return values in parent and child
827 ctc
->setIntReg(ReturnValueReg
, 0); // return value, child
829 // Alpha needs SyscallSuccessReg=0 in child
830 #if THE_ISA == ALPHA_ISA
831 ctc
->setIntReg(TheISA::SyscallSuccessReg
, 0);
834 // In SPARC/Linux, clone returns 0 on pseudo-return register if
835 // parent, non-zero if child
836 #if THE_ISA == SPARC_ISA
837 tc
->setIntReg(TheISA::SyscallPseudoReturnReg
, 0);
838 ctc
->setIntReg(TheISA::SyscallPseudoReturnReg
, 1);
841 ctc
->pcState(tc
->nextInstAddr());
845 // Should return nonzero child TID in parent's syscall return register,
846 // but for our pthread library any non-zero value will work
849 fatal("Called sys_clone, but no unallocated thread contexts found!\n");