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/alpha/linux/process.cc | 2 +- src/arch/alpha/process.cc | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src/arch/alpha') diff --git a/src/arch/alpha/linux/process.cc b/src/arch/alpha/linux/process.cc index 4a5dbd24f..dbfbcaf6a 100644 --- a/src/arch/alpha/linux/process.cc +++ b/src/arch/alpha/linux/process.cc @@ -440,7 +440,7 @@ SyscallDesc AlphaLinuxProcess::syscallDescs[] = { /* 309 */ SyscallDesc("get_kernel_syms", unimplementedFunc), /* 310 */ SyscallDesc("syslog", unimplementedFunc), /* 311 */ SyscallDesc("reboot", unimplementedFunc), - /* 312 */ SyscallDesc("clone", cloneFunc), + /* 312 */ SyscallDesc("clone", cloneFunc), /* 313 */ SyscallDesc("uselib", unimplementedFunc), /* 314 */ SyscallDesc("mlock", unimplementedFunc), /* 315 */ SyscallDesc("munlock", unimplementedFunc), diff --git a/src/arch/alpha/process.cc b/src/arch/alpha/process.cc index 582dbb57d..64d0b54a9 100644 --- a/src/arch/alpha/process.cc +++ b/src/arch/alpha/process.cc @@ -50,19 +50,20 @@ using namespace std; AlphaProcess::AlphaProcess(ProcessParams *params, ObjectFile *objFile) : Process(params, objFile) { - brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize(); - brk_point = roundUp(brk_point, PageBytes); + memState->brkPoint = objFile->dataBase() + objFile->dataSize() + + objFile->bssSize(); + memState->brkPoint = roundUp(memState->brkPoint, PageBytes); // Set up stack. On Alpha, stack goes below text section. This // code should get moved to some architecture-specific spot. - stack_base = objFile->textBase() - (409600+4096); + memState->stackBase = objFile->textBase() - (409600+4096); // Set up region for mmaps. Tru64 seems to start just above 0 and // grow up from there. - mmap_end = 0x10000; + memState->mmapEnd = 0x10000; // Set pointer for next thread stack. Reserve 8M for main stack. - next_thread_stack_base = stack_base - (8 * 1024 * 1024); + memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024); } @@ -130,15 +131,15 @@ AlphaProcess::argsInit(int intSize, int pageSize) space_needed = 32*1024; // set bottom of stack - stack_min = stack_base - space_needed; + memState->stackMin = memState->stackBase - space_needed; // align it - stack_min = roundDown(stack_min, pageSize); - stack_size = stack_base - stack_min; + memState->stackMin = roundDown(memState->stackMin, pageSize); + memState->stackSize = memState->stackBase - memState->stackMin; // map memory - allocateMem(stack_min, roundUp(stack_size, pageSize)); + allocateMem(memState->stackMin, roundUp(memState->stackSize, pageSize)); // map out initial stack contents - Addr argv_array_base = stack_min + intSize; // room for argc + Addr argv_array_base = memState->stackMin + intSize; // room for argc Addr envp_array_base = argv_array_base + argv_array_size; Addr auxv_array_base = envp_array_base + envp_array_size; Addr arg_data_base = auxv_array_base + auxv_array_size; @@ -153,7 +154,7 @@ AlphaProcess::argsInit(int intSize, int pageSize) else panic("Unknown int size"); - initVirtMem.writeBlob(stack_min, (uint8_t*)&argc, intSize); + initVirtMem.writeBlob(memState->stackMin, (uint8_t*)&argc, intSize); copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); @@ -170,7 +171,7 @@ AlphaProcess::argsInit(int intSize, int pageSize) setSyscallArg(tc, 0, argc); setSyscallArg(tc, 1, argv_array_base); - tc->setIntReg(StackPointerReg, stack_min); + tc->setIntReg(StackPointerReg, memState->stackMin); tc->pcState(getStartPC()); } -- cgit v1.2.3