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/riscv | |
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/riscv')
-rw-r--r-- | src/arch/riscv/process.cc | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/arch/riscv/process.cc b/src/arch/riscv/process.cc index 6bc328325..8b168cb35 100644 --- a/src/arch/riscv/process.cc +++ b/src/arch/riscv/process.cc @@ -56,16 +56,16 @@ RiscvProcess::RiscvProcess(ProcessParams * params, { // Set up stack. On RISC-V, stack starts at the top of kuseg // user address space. RISC-V stack grows down from here - stack_base = 0x7FFFFFFF; + memState->stackBase = (Addr)0x7FFFFFFF; // 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->bssBase() + objFile->bssSize(); + memState->brkPoint = objFile->bssBase() + objFile->bssSize(); // Set up region for mmaps. Start it 1GB above the top of the heap. - mmap_end = brk_point + 0x40000000L; + memState->mmapEnd = memState->brkPoint + 0x40000000L; } void @@ -124,18 +124,19 @@ RiscvProcess::argsInit(int pageSize) env_data_size += env.size() + 1; int auxv_array_size = 2 * sizeof(IntType)*auxv.size(); - stack_size = sizeof(IntType) + argv_array_size + 2 * sizeof(Addr) + - arg_data_size + 2 * sizeof(Addr); + memState->stackSize = sizeof(IntType) + argv_array_size + 2 * + sizeof(Addr) + arg_data_size + 2 * sizeof(Addr); if (!envp.empty()) { - stack_size += 2 * sizeof(Addr) + envp_array_size + 2 * sizeof(Addr) + - env_data_size; + memState->stackSize += 2 * sizeof(Addr) + envp_array_size + 2 * + sizeof(Addr) + env_data_size; } if (!auxv.empty()) - stack_size += 2 * sizeof(Addr) + auxv_array_size; - stack_min = roundDown(stack_base - stack_size, pageSize); - allocateMem(stack_min, roundUp(stack_size, pageSize)); + memState->stackSize += 2 * sizeof(Addr) + auxv_array_size; + memState->stackMin = roundDown(memState->stackBase - memState->stackSize, + pageSize); + allocateMem(memState->stackMin, roundUp(memState->stackSize, pageSize)); - Addr argv_array_base = stack_min + sizeof(IntType); + Addr argv_array_base = memState->stackMin + sizeof(IntType); Addr arg_data_base = argv_array_base + argv_array_size + 2 * sizeof(Addr); Addr envp_array_base = arg_data_base + arg_data_size; if (!envp.empty()) @@ -160,7 +161,7 @@ RiscvProcess::argsInit(int pageSize) } } - Addr sp = stack_min; + Addr sp = memState->stackMin; initVirtMem.writeBlob(sp, (uint8_t *)&argc, sizeof(IntType)); sp += sizeof(IntType); for (Addr arg_pointer: arg_pointers) { @@ -211,7 +212,7 @@ RiscvProcess::argsInit(int pageSize) } ThreadContext *tc = system->getThreadContext(contextIds[0]); - tc->setIntReg(StackPointerReg, stack_min); + tc->setIntReg(StackPointerReg, memState->stackMin); tc->pcState(getStartPC()); } |