summaryrefslogtreecommitdiff
path: root/src/arch/x86/process.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86/process.cc')
-rw-r--r--src/arch/x86/process.cc64
1 files changed, 46 insertions, 18 deletions
diff --git a/src/arch/x86/process.cc b/src/arch/x86/process.cc
index 35ea70430..a929897ca 100644
--- a/src/arch/x86/process.cc
+++ b/src/arch/x86/process.cc
@@ -100,8 +100,17 @@ X86Process::X86Process(ProcessParams * params, ObjectFile *objFile,
: Process(params, objFile), syscallDescs(_syscallDescs),
numSyscallDescs(_numSyscallDescs)
{
- 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);
+}
+
+void X86Process::clone(ThreadContext *old_tc, ThreadContext *new_tc,
+ Process *p, TheISA::IntReg flags)
+{
+ Process::clone(old_tc, new_tc, p, flags);
+ X86Process *process = (X86Process*)p;
+ *process = *this;
}
X86_64Process::X86_64Process(ProcessParams *params, ObjectFile *objFile,
@@ -117,10 +126,10 @@ X86_64Process::X86_64Process(ProcessParams *params, ObjectFile *objFile,
// Set up stack. On X86_64 Linux, stack goes from the top of memory
// downward, less the hole for the kernel address space plus one page
// for undertermined purposes.
- stack_base = (Addr)0x7FFFFFFFF000ULL;
+ memState->stackBase = (Addr)0x7FFFFFFFF000ULL;
// 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);
// "mmap_base" is a function which defines where mmap region starts in
// the process address space.
@@ -130,7 +139,7 @@ X86_64Process::X86_64Process(ProcessParams *params, ObjectFile *objFile,
// We do not use any address space layout randomization in gem5
// therefore the random fields become zero; the smallest gap space was
// chosen but gap could potentially be much larger.
- mmap_end = (Addr)0x7FFFF7FFF000ULL;
+ memState->mmapEnd = (Addr)0x7FFFF7FFF000ULL;
}
void
@@ -159,10 +168,10 @@ I386Process::I386Process(ProcessParams *params, ObjectFile *objFile,
vsyscallPage.vsyscallOffset = 0x400;
vsyscallPage.vsysexitOffset = 0x410;
- stack_base = _gdtStart;
+ memState->stackBase = _gdtStart;
// 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);
// "mmap_base" is a function which defines where mmap region starts in
// the process address space.
@@ -172,7 +181,7 @@ I386Process::I386Process(ProcessParams *params, ObjectFile *objFile,
// We do not use any address space layout randomization in gem5
// therefore the random fields become zero; the smallest gap space was
// chosen but gap could potentially be much larger.
- mmap_end = (Addr)0xB7FFF000ULL;
+ memState->mmapEnd = (Addr)0xB7FFF000ULL;
}
SyscallDesc*
@@ -946,18 +955,21 @@ X86Process::argsInit(int pageSize,
aux_padding +
frame_size;
- stack_min = stack_base - space_needed;
- stack_min = roundDown(stack_min, align);
- stack_size = roundUp(stack_base - stack_min, pageSize);
+ memState->stackMin = memState->stackBase - space_needed;
+ memState->stackMin = roundDown(memState->stackMin, align);
+ memState->stackSize = roundUp(memState->stackBase - memState->stackMin,
+ pageSize);
// map memory
- Addr stack_end = roundDown(stack_base - stack_size, pageSize);
+ Addr stack_end = roundDown(memState->stackBase - memState->stackSize,
+ pageSize);
- DPRINTF(Stack, "Mapping the stack: 0x%x %dB\n", stack_end, stack_size);
- allocateMem(stack_end, stack_size);
+ DPRINTF(Stack, "Mapping the stack: 0x%x %dB\n",
+ stack_end, memState->stackSize);
+ allocateMem(stack_end, memState->stackSize);
// 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;
@@ -976,7 +988,7 @@ X86Process::argsInit(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
@@ -1023,14 +1035,14 @@ X86Process::argsInit(int pageSize,
ThreadContext *tc = system->getThreadContext(contextIds[0]);
//Set the stack pointer register
- tc->setIntReg(StackPointerReg, stack_min);
+ tc->setIntReg(StackPointerReg, memState->stackMin);
// There doesn't need to be any segment base added in since we're dealing
// with the flat segmentation model.
tc->pcState(getStartPC());
//Align the "stack_min" to a page boundary.
- stack_min = roundDown(stack_min, pageSize);
+ memState->stackMin = roundDown(memState->stackMin, pageSize);
}
void
@@ -1074,6 +1086,14 @@ X86_64Process::setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val)
return tc->setIntReg(ArgumentReg[i], val);
}
+void
+X86_64Process::clone(ThreadContext *old_tc, ThreadContext *new_tc,
+ Process *p, TheISA::IntReg flags)
+{
+ X86Process::clone(old_tc, new_tc, p, flags);
+ ((X86_64Process*)p)->vsyscallPage = vsyscallPage;
+}
+
X86ISA::IntReg
I386Process::getSyscallArg(ThreadContext *tc, int &i)
{
@@ -1098,3 +1118,11 @@ I386Process::setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val)
assert(i < NumArgumentRegs);
return tc->setIntReg(ArgumentReg[i], val);
}
+
+void
+I386Process::clone(ThreadContext *old_tc, ThreadContext *new_tc,
+ Process *p, TheISA::IntReg flags)
+{
+ X86Process::clone(old_tc, new_tc, p, flags);
+ ((I386Process*)p)->vsyscallPage = vsyscallPage;
+}