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/power/process.cc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/arch/power/process.cc') diff --git a/src/arch/power/process.cc b/src/arch/power/process.cc index 7359fbf9a..5a32218ef 100644 --- a/src/arch/power/process.cc +++ b/src/arch/power/process.cc @@ -51,17 +51,18 @@ using namespace PowerISA; PowerProcess::PowerProcess(ProcessParams *params, ObjectFile *objFile) : Process(params, objFile) { - 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 = 0x70000000L; + memState->mmapEnd = 0x70000000L; } void @@ -185,15 +186,16 @@ PowerProcess::argsInit(int intSize, int pageSize) 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 - uint32_t sentry_base = stack_base - sentry_size; + uint32_t sentry_base = memState->stackBase - sentry_size; uint32_t aux_data_base = sentry_base - aux_data_size; uint32_t env_data_base = aux_data_base - env_data_size; uint32_t arg_data_base = env_data_base - arg_data_size; @@ -212,7 +214,7 @@ PowerProcess::argsInit(int intSize, int pageSize) 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 @@ -257,12 +259,12 @@ PowerProcess::argsInit(int intSize, int pageSize) ThreadContext *tc = system->getThreadContext(contextIds[0]); //Set the stack pointer register - tc->setIntReg(StackPointerReg, stack_min); + tc->setIntReg(StackPointerReg, memState->stackMin); tc->pcState(getStartPC()); //Align the "stack_min" to a page boundary. - stack_min = roundDown(stack_min, pageSize); + memState->stackMin = roundDown(memState->stackMin, pageSize); } PowerISA::IntReg -- cgit v1.2.3