1/* 2 * Copyright (c) 2003-2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 138 unchanged lines hidden (view full) --- 147 // Set pointer for next thread stack. Reserve 8M for main stack. 148 next_thread_stack_base = stack_base - (8 * 1024 * 1024); 149 150 // Set up region for mmaps. This was determined empirically and may not 151 // always be correct. 152 mmap_start = mmap_end = (Addr)0x2aaaaaaab000ULL; 153} 154 |
155void 156I386LiveProcess::syscall(int64_t callnum, ThreadContext *tc) 157{ 158 Addr eip = tc->readPC(); 159 if (eip >= vsyscallPage.base && 160 eip < vsyscallPage.base + vsyscallPage.size) { 161 tc->setNextPC(vsyscallPage.base + vsyscallPage.vsysexitOffset); 162 } 163 X86LiveProcess::syscall(callnum, tc); 164} 165 166 |
167I386LiveProcess::I386LiveProcess(LiveProcessParams *params, 168 ObjectFile *objFile, SyscallDesc *_syscallDescs, 169 int _numSyscallDescs) : 170 X86LiveProcess(params, objFile, _syscallDescs, _numSyscallDescs) 171{ |
172 _gdtStart = 0x100000000; 173 _gdtSize = VMPageSize; |
174 |
175 vsyscallPage.base = 0xffffe000ULL; 176 vsyscallPage.size = VMPageSize; 177 vsyscallPage.vsyscallOffset = 0x400; 178 vsyscallPage.vsysexitOffset = 0x410; 179 180 stack_base = vsyscallPage.base; 181 |
182 // Set pointer for next thread stack. Reserve 8M for main stack. 183 next_thread_stack_base = stack_base - (8 * 1024 * 1024); 184 185 // Set up region for mmaps. This was determined empirically and may not 186 // always be correct. 187 mmap_start = mmap_end = (Addr)0xf7ffd000ULL; 188} 189 --- 80 unchanged lines hidden (view full) --- 270 return; 271 272 argsInit(sizeof(uint32_t), VMPageSize); 273 274 /* 275 * Set up a GDT for this process. The whole GDT wouldn't really be for 276 * this process, but the only parts we care about are. 277 */ |
278 pTable->allocate(_gdtStart, _gdtSize); 279 uint64_t zero = 0; 280 assert(_gdtSize % sizeof(zero) == 0); 281 for (Addr gdtCurrent = _gdtStart; 282 gdtCurrent < _gdtStart + _gdtSize; gdtCurrent += sizeof(zero)) { 283 initVirtMem->write(gdtCurrent, zero); 284 } 285 |
286 // Set up the vsyscall page for this process. 287 pTable->allocate(vsyscallPage.base, vsyscallPage.size); 288 uint8_t vsyscallBlob[] = { 289 0x51, // push %ecx 290 0x52, // push %edp 291 0x55, // push %ebp 292 0x89, 0xe5, // mov %esp, %ebp 293 0x0f, 0x34 // sysenter 294 }; 295 initVirtMem->writeBlob(vsyscallPage.base + vsyscallPage.vsyscallOffset, 296 vsyscallBlob, sizeof(vsyscallBlob)); 297 298 uint8_t vsysexitBlob[] = { 299 0x5d, // pop %ebp 300 0x5a, // pop %edx 301 0x59, // pop %ecx 302 0xc3 // ret 303 }; 304 initVirtMem->writeBlob(vsyscallPage.base + vsyscallPage.vsysexitOffset, 305 vsysexitBlob, sizeof(vsysexitBlob)); 306 |
307 for (int i = 0; i < contextIds.size(); i++) { 308 ThreadContext * tc = system->getThreadContext(contextIds[i]); 309 310 SegAttr dataAttr = 0; 311 dataAttr.writable = 1; 312 dataAttr.readable = 1; 313 dataAttr.expandDown = 0; 314 dataAttr.dpl = 3; --- 51 unchanged lines hidden (view full) --- 366 efer.svme = 0; // Disable svm support for now. It isn't implemented. 367 efer.ffxsr = 1; // Turn on fast fxsave and fxrstor. 368 tc->setMiscReg(MISCREG_EFER, efer); 369 } 370} 371 372template<class IntType> 373void |
374X86LiveProcess::argsInit(int pageSize, 375 std::vector<AuxVector<IntType> > extraAuxvs) |
376{ 377 int intSize = sizeof(IntType); 378 379 typedef AuxVector<IntType> auxv_t; |
380 std::vector<auxv_t> auxv = extraAuxvs; |
381 382 string filename; 383 if(argv.size() < 1) 384 filename = ""; 385 else 386 filename = argv[0]; 387 388 //We want 16 byte alignment --- 254 unchanged lines hidden (view full) --- 643 stack_min = roundDown(stack_min, pageSize); 644 645// num_processes++; 646} 647 648void 649X86_64LiveProcess::argsInit(int intSize, int pageSize) 650{ |
651 std::vector<AuxVector<uint64_t> > extraAuxvs; 652 X86LiveProcess::argsInit<uint64_t>(pageSize, extraAuxvs); |
653} 654 655void 656I386LiveProcess::argsInit(int intSize, int pageSize) 657{ |
658 std::vector<AuxVector<uint32_t> > extraAuxvs; 659 //Tell the binary where the vsyscall part of the vsyscall page is. 660 extraAuxvs.push_back(AuxVector<uint32_t>(0x20, 661 vsyscallPage.base + vsyscallPage.vsyscallOffset)); 662 extraAuxvs.push_back(AuxVector<uint32_t>(0x21, vsyscallPage.base)); 663 X86LiveProcess::argsInit<uint32_t>(pageSize, extraAuxvs); |
664} 665 666void 667X86LiveProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn return_value) 668{ 669 tc->setIntReg(INTREG_RAX, return_value.value()); 670} 671 --- 27 unchanged lines hidden --- |