From 2367198921765848a4f5b3d020a7cc5776209f80 Mon Sep 17 00:00:00 2001 From: Brandon Potter Date: Mon, 27 Feb 2017 14:10:15 -0500 Subject: 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. --- src/arch/x86/linux/process.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/arch/x86/linux/process.cc') 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), /* 57 */ SyscallDesc("fork", unimplementedFunc), /* 58 */ SyscallDesc("vfork", unimplementedFunc), - /* 59 */ SyscallDesc("execve", unimplementedFunc), + /* 59 */ SyscallDesc("execve", execveFunc), /* 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), /* 12 */ SyscallDesc("chdir", unimplementedFunc), /* 13 */ SyscallDesc("time", timeFunc), /* 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), /* 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); +} -- cgit v1.2.3