vsyscallPage.vtimeOffset = 0x400;
vsyscallPage.vgettimeofdayOffset = 0x0;
- Addr brk_point = roundUp(objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize(), PageBytes);
+ Addr brk_point = roundUp(image.maxAddr(), PageBytes);
Addr stack_base = 0x7FFFFFFFF000ULL;
Addr max_stack_size = 8 * 1024 * 1024;
Addr next_thread_stack_base = stack_base - max_stack_size;
next_thread_stack_base, mmap_end);
}
-void
-I386Process::syscall(int64_t callnum, ThreadContext *tc, Fault *fault)
-{
- PCState pc = tc->pcState();
- Addr eip = pc.pc();
- if (eip >= vsyscallPage.base &&
- eip < vsyscallPage.base + vsyscallPage.size) {
- pc.npc(vsyscallPage.base + vsyscallPage.vsysexitOffset);
- tc->pcState(pc);
- }
- X86Process::syscall(callnum, tc, fault);
-}
-
I386Process::I386Process(ProcessParams *params, ObjectFile *objFile,
SyscallDesc *_syscallDescs, int _numSyscallDescs)
vsyscallPage.vsyscallOffset = 0x400;
vsyscallPage.vsysexitOffset = 0x410;
- Addr brk_point = roundUp(objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize(), PageBytes);
+ Addr brk_point = roundUp(image.maxAddr(), PageBytes);
Addr stack_base = _gdtStart;
Addr max_stack_size = 8 * 1024 * 1024;
Addr next_thread_stack_base = stack_base - max_stack_size;
uint8_t numGDTEntries = 0;
uint64_t nullDescriptor = 0;
physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
- (uint8_t *)(&nullDescriptor), 8);
+ &nullDescriptor, 8);
numGDTEntries++;
SegDescriptor initDesc = 0;
initDesc.p = 1; // present
initDesc.l = 1; // longmode - 64 bit
initDesc.d = 0; // operand size
+ initDesc.g = 1;
initDesc.s = 1; // system segment
initDesc.limit = 0xFFFFFFFF;
initDesc.base = 0;
csLowPLDesc.dpl = 0;
uint64_t csLowPLDescVal = csLowPLDesc;
physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
- (uint8_t *)(&csLowPLDescVal), 8);
+ &csLowPLDescVal, 8);
numGDTEntries++;
dsLowPLDesc.dpl = 0;
uint64_t dsLowPLDescVal = dsLowPLDesc;
physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
- (uint8_t *)(&dsLowPLDescVal), 8);
+ &dsLowPLDescVal, 8);
numGDTEntries++;
dsDesc.dpl = 3;
uint64_t dsDescVal = dsDesc;
physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
- (uint8_t *)(&dsDescVal), 8);
+ &dsDescVal, 8);
numGDTEntries++;
csDesc.dpl = 3;
uint64_t csDescVal = csDesc;
physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
- (uint8_t *)(&csDescVal), 8);
+ &csDescVal, 8);
numGDTEntries++;
} tssDescVal = {TSSDescLow, TSSDescHigh};
physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8,
- (uint8_t *)(&tssDescVal), sizeof(tssDescVal));
+ &tssDescVal, sizeof(tssDescVal));
numGDTEntries++;
efer.sce = 1; // Enable system call extensions.
efer.lme = 1; // Enable long mode.
efer.lma = 1; // Activate long mode.
- efer.nxe = 0; // Enable nx support.
- efer.svme = 1; // Enable svm support for now.
+ efer.nxe = 1; // Enable nx support.
+ efer.svme = 0; // Enable svm support for now.
efer.ffxsr = 0; // Turn on fast fxsave and fxrstor.
tc->setMiscReg(MISCREG_EFER, efer);
CR4 cr4 = 0;
//Turn on pae.
- cr4.osxsave = 1; // Enable XSAVE and Proc Extended States
- cr4.osxmmexcpt = 1; // Operating System Unmasked Exception
+ cr4.osxsave = 0; // Enable XSAVE and Proc Extended States
+ cr4.osxmmexcpt = 0; // Operating System Unmasked Exception
cr4.osfxsr = 1; // Operating System FXSave/FSRSTOR Support
cr4.pce = 0; // Performance-Monitoring Counter Enable
cr4.pge = 0; // Page-Global Enable
tss.RSP1_high = tss.IST1_high;
tss.RSP2_low = tss.IST1_low;
tss.RSP2_high = tss.IST1_high;
- physProxy.writeBlob(tssPhysAddr, (uint8_t *)(&tss), sizeof(tss));
+ physProxy.writeBlob(tssPhysAddr, &tss, sizeof(tss));
/* Setting IDT gates */
GateDescriptorLow PFGateLow = 0;
uint64_t high;
} PFGate = {PFGateLow, PFGateHigh};
- physProxy.writeBlob(idtPhysAddr + 0xE0,
- (uint8_t *)(&PFGate), sizeof(PFGate));
+ physProxy.writeBlob(idtPhysAddr + 0xE0, &PFGate, sizeof(PFGate));
/* System call handler */
uint8_t syscallBlob[] = {
// We want 16 byte alignment
uint64_t align = 16;
- // Patch the ld_bias for dynamic executables.
- updateBias();
-
- // load object file into target memory
- objFile->loadSections(initVirtMem);
-
enum X86CpuFeature {
X86_OnboardFPU = 1 << 0,
X86_VirtualModeExtensions = 1 << 1,
// figure out argc
IntType argc = argv.size();
- IntType guestArgc = X86ISA::htog(argc);
+ IntType guestArgc = htole(argc);
// Write out the sentry void *
IntType sentry_NULL = 0;
- initVirtMem.writeBlob(sentry_base, (uint8_t*)&sentry_NULL, sentry_size);
+ initVirtMem.writeBlob(sentry_base, &sentry_NULL, sentry_size);
// Write the file name
initVirtMem.writeString(file_name_base, filename.c_str());
initVirtMem.writeString(aux_data_base, platform.c_str());
- copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
- copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+ copyStringArray(envp, envp_array_base, env_data_base,
+ LittleEndianByteOrder, initVirtMem);
+ copyStringArray(argv, argv_array_base, arg_data_base,
+ LittleEndianByteOrder, initVirtMem);
- initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
+ initVirtMem.writeBlob(argc_base, &guestArgc, intSize);
ThreadContext *tc = system->getThreadContext(contextIds[0]);
// Set the stack pointer register
return tc->readIntReg(ArgumentReg[i++]);
}
-void
-X86_64Process::setSyscallArg(ThreadContext *tc, int i, RegVal val)
-{
- assert(i < NumArgumentRegs);
- return tc->setIntReg(ArgumentReg[i], val);
-}
-
void
X86_64Process::clone(ThreadContext *old_tc, ThreadContext *new_tc,
Process *p, RegVal flags)
return retVal;
}
-void
-I386Process::setSyscallArg(ThreadContext *tc, int i, RegVal val)
-{
- assert(i < NumArgumentRegs);
- return tc->setIntReg(ArgumentReg[i], val);
-}
-
void
I386Process::clone(ThreadContext *old_tc, ThreadContext *new_tc,
Process *p, RegVal flags)