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/arm | |
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/arm')
-rw-r--r-- | src/arch/arm/linux/process.cc | 2 | ||||
-rw-r--r-- | src/arch/arm/process.cc | 41 |
2 files changed, 23 insertions, 20 deletions
diff --git a/src/arch/arm/linux/process.cc b/src/arch/arm/linux/process.cc index b8f40be81..9bca571e5 100644 --- a/src/arch/arm/linux/process.cc +++ b/src/arch/arm/linux/process.cc @@ -241,7 +241,7 @@ static SyscallDesc syscallDescs32[] = { /* 117 */ SyscallDesc("ipc", unimplementedFunc), /* 118 */ SyscallDesc("fsync", unimplementedFunc), /* 119 */ SyscallDesc("sigreturn", unimplementedFunc), - /* 120 */ SyscallDesc("clone", cloneFunc), + /* 120 */ SyscallDesc("clone", cloneFunc<ArmLinux32>), /* 121 */ SyscallDesc("setdomainname", unimplementedFunc), /* 122 */ SyscallDesc("uname", unameFunc32), /* 123 */ SyscallDesc("unused#123", unimplementedFunc), diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc index 2fd5cc935..fd0243c44 100644 --- a/src/arch/arm/process.cc +++ b/src/arch/arm/process.cc @@ -70,34 +70,36 @@ ArmProcess32::ArmProcess32(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch) : ArmProcess(params, objFile, _arch) { - stack_base = 0xbf000000L; + memState->stackBase = 0xbf000000L; // 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); // Set up break point (Top of Heap) - 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 region for mmaps. For now, start at bottom of kuseg space. - mmap_end = 0x40000000L; + memState->mmapEnd = 0x40000000L; } ArmProcess64::ArmProcess64(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch) : ArmProcess(params, objFile, _arch) { - stack_base = 0x7fffff0000L; + memState->stackBase = 0x7fffff0000L; // 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); // Set up break point (Top of Heap) - 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 region for mmaps. For now, start at bottom of kuseg space. - mmap_end = 0x4000000000L; + memState->mmapEnd = 0x4000000000L; } void @@ -300,15 +302,16 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex) int space_needed = frame_size + aux_padding; - stack_min = stack_base - space_needed; - stack_min = roundDown(stack_min, align); - stack_size = stack_base - stack_min; + memState->stackMin = memState->stackBase - space_needed; + memState->stackMin = roundDown(memState->stackMin, align); + memState->stackSize = memState->stackBase - memState->stackMin; // map memory - allocateMem(roundDown(stack_min, pageSize), roundUp(stack_size, pageSize)); + allocateMem(roundDown(memState->stackMin, pageSize), + roundUp(memState->stackSize, pageSize)); // map out initial stack contents - IntType sentry_base = stack_base - sentry_size; + IntType sentry_base = memState->stackBase - sentry_size; IntType aux_data_base = sentry_base - aux_data_size; IntType env_data_base = aux_data_base - env_data_size; IntType arg_data_base = env_data_base - arg_data_size; @@ -329,7 +332,7 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex) DPRINTF(Stack, "0x%x - envp array\n", envp_array_base); DPRINTF(Stack, "0x%x - argv array\n", argv_array_base); DPRINTF(Stack, "0x%x - argc \n", argc_base); - DPRINTF(Stack, "0x%x - stack min\n", stack_min); + DPRINTF(Stack, "0x%x - stack min\n", memState->stackMin); // write contents to stack @@ -375,7 +378,7 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex) ThreadContext *tc = system->getThreadContext(contextIds[0]); //Set the stack pointer register - tc->setIntReg(spIndex, stack_min); + tc->setIntReg(spIndex, memState->stackMin); //A pointer to a function to run when the program exits. We'll set this //to zero explicitly to make sure this isn't used. tc->setIntReg(ArgumentReg0, 0); @@ -401,8 +404,8 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex) pc.set(getStartPC() & ~mask(1)); tc->pcState(pc); - //Align the "stack_min" to a page boundary. - stack_min = roundDown(stack_min, pageSize); + //Align the "stackMin" to a page boundary. + memState->stackMin = roundDown(memState->stackMin, pageSize); } ArmISA::IntReg |