diff options
author | Brandon Potter <brandon.potter@amd.com> | 2017-02-27 14:10:15 -0500 |
---|---|---|
committer | Brandon Potter <brandon.potter@amd.com> | 2017-02-27 14:10:15 -0500 |
commit | 2367198921765848a4f5b3d020a7cc5776209f80 (patch) | |
tree | 00cff9357d9e5f2bec277cf937e8a73944ce1c98 /src/arch/x86/linux | |
parent | 073cb266079edddec64ea8cd5169dd2cbef8f812 (diff) | |
download | gem5-2367198921765848a4f5b3d020a7cc5776209f80.tar.xz |
syscall_emul: [PATCH 15/22] add clone/execve for threading and multiprocess simulations
Modifies the clone system call and adds execve system call. Requires allowing
processes to steal thread contexts from other processes in the same system
object and the ability to detach pieces of process state (such as MemState)
to allow dynamic sharing.
Diffstat (limited to 'src/arch/x86/linux')
-rw-r--r-- | src/arch/x86/linux/process.cc | 24 | ||||
-rw-r--r-- | src/arch/x86/linux/process.hh | 7 |
2 files changed, 25 insertions, 6 deletions
diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc index 56688fc89..c2d67eb81 100644 --- a/src/arch/x86/linux/process.cc +++ b/src/arch/x86/linux/process.cc @@ -276,10 +276,10 @@ static SyscallDesc syscallDescs64[] = { /* 53 */ SyscallDesc("socketpair", unimplementedFunc), /* 54 */ SyscallDesc("setsockopt", unimplementedFunc), /* 55 */ SyscallDesc("getsockopt", unimplementedFunc), - /* 56 */ SyscallDesc("clone", cloneFunc), + /* 56 */ SyscallDesc("clone", cloneFunc<X86Linux64>), /* 57 */ SyscallDesc("fork", unimplementedFunc), /* 58 */ SyscallDesc("vfork", unimplementedFunc), - /* 59 */ SyscallDesc("execve", unimplementedFunc), + /* 59 */ SyscallDesc("execve", execveFunc<X86Linux64>), /* 60 */ SyscallDesc("exit", exitFunc), /* 61 */ SyscallDesc("wait4", unimplementedFunc), /* 62 */ SyscallDesc("kill", unimplementedFunc), @@ -438,7 +438,7 @@ static SyscallDesc syscallDescs64[] = { /* 215 */ SyscallDesc("epoll_wait_old", unimplementedFunc), /* 216 */ SyscallDesc("remap_file_pages", unimplementedFunc), /* 217 */ SyscallDesc("getdents64", unimplementedFunc), - /* 218 */ SyscallDesc("set_tid_address", unimplementedFunc), + /* 218 */ SyscallDesc("set_tid_address", setTidAddressFunc), /* 219 */ SyscallDesc("restart_syscall", unimplementedFunc), /* 220 */ SyscallDesc("semtimedop", unimplementedFunc), /* 221 */ SyscallDesc("fadvise64", unimplementedFunc), @@ -542,6 +542,12 @@ X86_64LinuxProcess::X86_64LinuxProcess(ProcessParams * params, sizeof(syscallDescs64) / sizeof(SyscallDesc)) {} +void X86_64LinuxProcess::clone(ThreadContext *old_tc, ThreadContext *new_tc, + Process *process, TheISA::IntReg flags) +{ + X86_64Process::clone(old_tc, new_tc, (X86_64Process*)process, flags); +} + static SyscallDesc syscallDescs32[] = { /* 0 */ SyscallDesc("restart_syscall", unimplementedFunc), /* 1 */ SyscallDesc("exit", exitFunc), @@ -554,7 +560,7 @@ static SyscallDesc syscallDescs32[] = { /* 8 */ SyscallDesc("creat", unimplementedFunc), /* 9 */ SyscallDesc("link", unimplementedFunc), /* 10 */ SyscallDesc("unlink", unimplementedFunc), - /* 11 */ SyscallDesc("execve", unimplementedFunc), + /* 11 */ SyscallDesc("execve", execveFunc<X86Linux32>), /* 12 */ SyscallDesc("chdir", unimplementedFunc), /* 13 */ SyscallDesc("time", timeFunc<X86Linux32>), /* 14 */ SyscallDesc("mknod", unimplementedFunc), @@ -663,7 +669,7 @@ static SyscallDesc syscallDescs32[] = { /* 117 */ SyscallDesc("ipc", unimplementedFunc), /* 118 */ SyscallDesc("fsync", unimplementedFunc), /* 119 */ SyscallDesc("sigreturn", unimplementedFunc), - /* 120 */ SyscallDesc("clone", unimplementedFunc), + /* 120 */ SyscallDesc("clone", cloneFunc<X86Linux32>), /* 121 */ SyscallDesc("setdomainname", unimplementedFunc), /* 122 */ SyscallDesc("uname", unameFunc), /* 123 */ SyscallDesc("modify_ldt", unimplementedFunc), @@ -801,7 +807,7 @@ static SyscallDesc syscallDescs32[] = { /* 255 */ SyscallDesc("epoll_ctl", unimplementedFunc), /* 256 */ SyscallDesc("epoll_wait", unimplementedFunc), /* 257 */ SyscallDesc("remap_file_pages", unimplementedFunc), - /* 258 */ SyscallDesc("set_tid_address", unimplementedFunc), + /* 258 */ SyscallDesc("set_tid_address", setTidAddressFunc), /* 259 */ SyscallDesc("timer_create", unimplementedFunc), /* 260 */ SyscallDesc("timer_settime", unimplementedFunc), /* 261 */ SyscallDesc("timer_gettime", unimplementedFunc), @@ -873,3 +879,9 @@ I386LinuxProcess::I386LinuxProcess(ProcessParams * params, ObjectFile *objFile) : I386Process(params, objFile, syscallDescs32, sizeof(syscallDescs32) / sizeof(SyscallDesc)) {} + +void I386LinuxProcess::clone(ThreadContext *old_tc, ThreadContext *new_tc, + Process *process, TheISA::IntReg flags) +{ + I386Process::clone(old_tc, new_tc, (I386Process*)process, flags); +} diff --git a/src/arch/x86/linux/process.hh b/src/arch/x86/linux/process.hh index 70370960b..bafa9cc6c 100644 --- a/src/arch/x86/linux/process.hh +++ b/src/arch/x86/linux/process.hh @@ -44,6 +44,9 @@ #include "arch/x86/process.hh" #include "sim/process.hh" +struct ProcessParams; +struct ThreadContext; + namespace X86ISA { class X86_64LinuxProcess : public X86_64Process @@ -51,6 +54,8 @@ class X86_64LinuxProcess : public X86_64Process public: /// Constructor. X86_64LinuxProcess(ProcessParams * params, ObjectFile *objFile); + void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process, + TheISA::IntReg flags); }; class I386LinuxProcess : public I386Process @@ -58,6 +63,8 @@ class I386LinuxProcess : public I386Process public: /// Constructor. I386LinuxProcess(ProcessParams * params, ObjectFile *objFile); + void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process, + TheISA::IntReg flags); }; } // namespace X86ISA |