summaryrefslogtreecommitdiff
path: root/src/arch/sparc
diff options
context:
space:
mode:
authorBrandon Potter <brandon.potter@amd.com>2017-02-27 14:10:15 -0500
committerBrandon Potter <brandon.potter@amd.com>2017-02-27 14:10:15 -0500
commit2367198921765848a4f5b3d020a7cc5776209f80 (patch)
tree00cff9357d9e5f2bec277cf937e8a73944ce1c98 /src/arch/sparc
parent073cb266079edddec64ea8cd5169dd2cbef8f812 (diff)
downloadgem5-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/sparc')
-rw-r--r--src/arch/sparc/linux/syscalls.cc4
-rw-r--r--src/arch/sparc/process.cc28
-rw-r--r--src/arch/sparc/process.hh8
3 files changed, 21 insertions, 19 deletions
diff --git a/src/arch/sparc/linux/syscalls.cc b/src/arch/sparc/linux/syscalls.cc
index 6825b2abb..7fdc922ef 100644
--- a/src/arch/sparc/linux/syscalls.cc
+++ b/src/arch/sparc/linux/syscalls.cc
@@ -305,7 +305,7 @@ SyscallDesc SparcLinuxProcess::syscall32Descs[] = {
/* 214 */ SyscallDesc("sysinfo", sysinfoFunc<Sparc32Linux>), // 32 bit
/* 215 */ SyscallDesc("ipc", unimplementedFunc), // 32 bit
/* 216 */ SyscallDesc("sigreturn", unimplementedFunc), // 32 bit
- /* 217 */ SyscallDesc("clone", cloneFunc),
+ /* 217 */ SyscallDesc("clone", cloneFunc<Sparc32Linux>),
/* 218 */ SyscallDesc("ioprio_get", unimplementedFunc), // 32 bit
/* 219 */ SyscallDesc("adjtimex", unimplementedFunc), // 32 bit
/* 220 */ SyscallDesc("sigprocmask", unimplementedFunc), // 32 bit
@@ -611,7 +611,7 @@ SyscallDesc SparcLinuxProcess::syscallDescs[] = {
/* 214 */ SyscallDesc("sysinfo", sysinfoFunc<SparcLinux>),
/* 215 */ SyscallDesc("ipc", unimplementedFunc),
/* 216 */ SyscallDesc("sigreturn", unimplementedFunc),
- /* 217 */ SyscallDesc("clone", cloneFunc),
+ /* 217 */ SyscallDesc("clone", cloneFunc<SparcLinux>),
/* 218 */ SyscallDesc("ioprio_get", unimplementedFunc),
/* 219 */ SyscallDesc("adjtimex", unimplementedFunc),
/* 220 */ SyscallDesc("sigprocmask", unimplementedFunc),
diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc
index a8359a9ce..a64bc587f 100644
--- a/src/arch/sparc/process.cc
+++ b/src/arch/sparc/process.cc
@@ -59,11 +59,12 @@ SparcProcess::SparcProcess(ProcessParams * params, ObjectFile *objFile,
{
// XXX all the below need to be updated for SPARC - Ali
- 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 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);
// Initialize these to 0s
fillStart = 0;
@@ -324,15 +325,16 @@ SparcProcess::argsInit(int pageSize)
aux_padding +
frame_size;
- 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;
// Allocate space for the stack
- 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 file_name_base = sentry_base - file_name_size;
IntType env_data_base = file_name_base - env_data_size;
IntType arg_data_base = env_data_base - arg_data_size;
@@ -356,9 +358,9 @@ SparcProcess::argsInit(int pageSize)
DPRINTF(Stack, "%#x - argv array\n", argv_array_base);
DPRINTF(Stack, "%#x - argc \n", argc_base);
DPRINTF(Stack, "%#x - window save\n", window_save_base);
- DPRINTF(Stack, "%#x - stack min\n", stack_min);
+ DPRINTF(Stack, "%#x - stack min\n", memState->stackMin);
- assert(window_save_base == stack_min);
+ assert(window_save_base == memState->stackMin);
// write contents to stack
@@ -397,7 +399,7 @@ SparcProcess::argsInit(int pageSize)
// Set up space for the trap handlers into the processes address space.
// Since the stack grows down and there is reserved address space abov
// it, we can put stuff above it and stay out of the way.
- fillStart = stack_base;
+ fillStart = memState->stackBase;
spillStart = fillStart + sizeof(MachInst) * numFillInsts;
ThreadContext *tc = system->getThreadContext(contextIds[0]);
@@ -405,7 +407,7 @@ SparcProcess::argsInit(int pageSize)
// assert(NumArgumentRegs >= 2);
// tc->setIntReg(ArgumentReg[0], argc);
// tc->setIntReg(ArgumentReg[1], argv_array_base);
- tc->setIntReg(StackPointerReg, stack_min - StackBias);
+ tc->setIntReg(StackPointerReg, memState->stackMin - StackBias);
// %g1 is a pointer to a function that should be run at exit. Since we
// don't have anything like that, it should be set to 0.
@@ -414,7 +416,7 @@ SparcProcess::argsInit(int pageSize)
tc->pcState(getStartPC());
// Align the "stack_min" to a page boundary.
- stack_min = roundDown(stack_min, pageSize);
+ memState->stackMin = roundDown(memState->stackMin, pageSize);
}
void
diff --git a/src/arch/sparc/process.hh b/src/arch/sparc/process.hh
index efdc0f443..96901fde3 100644
--- a/src/arch/sparc/process.hh
+++ b/src/arch/sparc/process.hh
@@ -79,10 +79,10 @@ class Sparc32Process : public SparcProcess
{
// Set up stack. On SPARC Linux, stack goes from the top of memory
// downward, less the hole for the kernel address space.
- stack_base = (Addr)0xf0000000ULL;
+ memState->stackBase = (Addr)0xf0000000ULL;
// Set up region for mmaps.
- mmap_end = 0x70000000;
+ memState->mmapEnd = 0x70000000;
}
void initState();
@@ -109,10 +109,10 @@ class Sparc64Process : public SparcProcess
{
// Set up stack. On SPARC Linux, stack goes from the top of memory
// downward, less the hole for the kernel address space.
- stack_base = (Addr)0x80000000000ULL;
+ memState->stackBase = (Addr)0x80000000000ULL;
// Set up region for mmaps.
- mmap_end = 0xfffff80000000000ULL;
+ memState->mmapEnd = 0xfffff80000000000ULL;
}
void initState();