process.cc (13915:24ae4ea846c9) | process.cc (14010:0e1e887507c0) |
---|---|
1/* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * Copyright (c) 2007 The Hewlett-Packard Development Company 4 * All rights reserved. 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating --- 225 unchanged lines hidden (view full) --- 234 Addr pfHandlerPhysAddr = system->allocPhysPages(1); 235 236 /* 237 * Set up the gdt. 238 */ 239 uint8_t numGDTEntries = 0; 240 uint64_t nullDescriptor = 0; 241 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, | 1/* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * Copyright (c) 2007 The Hewlett-Packard Development Company 4 * All rights reserved. 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating --- 225 unchanged lines hidden (view full) --- 234 Addr pfHandlerPhysAddr = system->allocPhysPages(1); 235 236 /* 237 * Set up the gdt. 238 */ 239 uint8_t numGDTEntries = 0; 240 uint64_t nullDescriptor = 0; 241 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, |
242 (uint8_t *)(&nullDescriptor), 8); | 242 &nullDescriptor, 8); |
243 numGDTEntries++; 244 245 SegDescriptor initDesc = 0; 246 initDesc.type.codeOrData = 0; // code or data type 247 initDesc.type.c = 0; // conforming 248 initDesc.type.r = 1; // readable 249 initDesc.dpl = 0; // privilege 250 initDesc.p = 1; // present --- 4 unchanged lines hidden (view full) --- 255 initDesc.base = 0; 256 257 //64 bit code segment 258 SegDescriptor csLowPLDesc = initDesc; 259 csLowPLDesc.type.codeOrData = 1; 260 csLowPLDesc.dpl = 0; 261 uint64_t csLowPLDescVal = csLowPLDesc; 262 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, | 243 numGDTEntries++; 244 245 SegDescriptor initDesc = 0; 246 initDesc.type.codeOrData = 0; // code or data type 247 initDesc.type.c = 0; // conforming 248 initDesc.type.r = 1; // readable 249 initDesc.dpl = 0; // privilege 250 initDesc.p = 1; // present --- 4 unchanged lines hidden (view full) --- 255 initDesc.base = 0; 256 257 //64 bit code segment 258 SegDescriptor csLowPLDesc = initDesc; 259 csLowPLDesc.type.codeOrData = 1; 260 csLowPLDesc.dpl = 0; 261 uint64_t csLowPLDescVal = csLowPLDesc; 262 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, |
263 (uint8_t *)(&csLowPLDescVal), 8); | 263 &csLowPLDescVal, 8); |
264 265 numGDTEntries++; 266 267 SegSelector csLowPL = 0; 268 csLowPL.si = numGDTEntries - 1; 269 csLowPL.rpl = 0; 270 271 //64 bit data segment 272 SegDescriptor dsLowPLDesc = initDesc; 273 dsLowPLDesc.type.codeOrData = 0; 274 dsLowPLDesc.dpl = 0; 275 uint64_t dsLowPLDescVal = dsLowPLDesc; 276 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, | 264 265 numGDTEntries++; 266 267 SegSelector csLowPL = 0; 268 csLowPL.si = numGDTEntries - 1; 269 csLowPL.rpl = 0; 270 271 //64 bit data segment 272 SegDescriptor dsLowPLDesc = initDesc; 273 dsLowPLDesc.type.codeOrData = 0; 274 dsLowPLDesc.dpl = 0; 275 uint64_t dsLowPLDescVal = dsLowPLDesc; 276 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, |
277 (uint8_t *)(&dsLowPLDescVal), 8); | 277 &dsLowPLDescVal, 8); |
278 279 numGDTEntries++; 280 281 SegSelector dsLowPL = 0; 282 dsLowPL.si = numGDTEntries - 1; 283 dsLowPL.rpl = 0; 284 285 //64 bit data segment 286 SegDescriptor dsDesc = initDesc; 287 dsDesc.type.codeOrData = 0; 288 dsDesc.dpl = 3; 289 uint64_t dsDescVal = dsDesc; 290 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, | 278 279 numGDTEntries++; 280 281 SegSelector dsLowPL = 0; 282 dsLowPL.si = numGDTEntries - 1; 283 dsLowPL.rpl = 0; 284 285 //64 bit data segment 286 SegDescriptor dsDesc = initDesc; 287 dsDesc.type.codeOrData = 0; 288 dsDesc.dpl = 3; 289 uint64_t dsDescVal = dsDesc; 290 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, |
291 (uint8_t *)(&dsDescVal), 8); | 291 &dsDescVal, 8); |
292 293 numGDTEntries++; 294 295 SegSelector ds = 0; 296 ds.si = numGDTEntries - 1; 297 ds.rpl = 3; 298 299 //64 bit code segment 300 SegDescriptor csDesc = initDesc; 301 csDesc.type.codeOrData = 1; 302 csDesc.dpl = 3; 303 uint64_t csDescVal = csDesc; 304 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, | 292 293 numGDTEntries++; 294 295 SegSelector ds = 0; 296 ds.si = numGDTEntries - 1; 297 ds.rpl = 3; 298 299 //64 bit code segment 300 SegDescriptor csDesc = initDesc; 301 csDesc.type.codeOrData = 1; 302 csDesc.dpl = 3; 303 uint64_t csDescVal = csDesc; 304 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, |
305 (uint8_t *)(&csDescVal), 8); | 305 &csDescVal, 8); |
306 307 numGDTEntries++; 308 309 SegSelector cs = 0; 310 cs.si = numGDTEntries - 1; 311 cs.rpl = 3; 312 313 SegSelector scall = 0; --- 16 unchanged lines hidden (view full) --- 330 TSSDescHigh.base = bits(TSSVirtAddr, 63, 32); 331 332 struct TSSDesc { 333 uint64_t low; 334 uint64_t high; 335 } tssDescVal = {TSSDescLow, TSSDescHigh}; 336 337 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, | 306 307 numGDTEntries++; 308 309 SegSelector cs = 0; 310 cs.si = numGDTEntries - 1; 311 cs.rpl = 3; 312 313 SegSelector scall = 0; --- 16 unchanged lines hidden (view full) --- 330 TSSDescHigh.base = bits(TSSVirtAddr, 63, 32); 331 332 struct TSSDesc { 333 uint64_t low; 334 uint64_t high; 335 } tssDescVal = {TSSDescLow, TSSDescHigh}; 336 337 physProxy.writeBlob(gdtPhysAddr + numGDTEntries * 8, |
338 (uint8_t *)(&tssDescVal), sizeof(tssDescVal)); | 338 &tssDescVal, sizeof(tssDescVal)); |
339 340 numGDTEntries++; 341 342 SegSelector tssSel = 0; 343 tssSel.si = numGDTEntries - 1; 344 345 uint64_t tss_base_addr = (TSSDescHigh.base << 32) | TSSDescLow.base; 346 uint64_t tss_limit = TSSDescLow.limit; --- 148 unchanged lines hidden (view full) --- 495 tss.IST1_low = IST_start; 496 tss.IST1_high = IST_start >> 32; 497 tss.RSP0_low = tss.IST1_low; 498 tss.RSP0_high = tss.IST1_high; 499 tss.RSP1_low = tss.IST1_low; 500 tss.RSP1_high = tss.IST1_high; 501 tss.RSP2_low = tss.IST1_low; 502 tss.RSP2_high = tss.IST1_high; | 339 340 numGDTEntries++; 341 342 SegSelector tssSel = 0; 343 tssSel.si = numGDTEntries - 1; 344 345 uint64_t tss_base_addr = (TSSDescHigh.base << 32) | TSSDescLow.base; 346 uint64_t tss_limit = TSSDescLow.limit; --- 148 unchanged lines hidden (view full) --- 495 tss.IST1_low = IST_start; 496 tss.IST1_high = IST_start >> 32; 497 tss.RSP0_low = tss.IST1_low; 498 tss.RSP0_high = tss.IST1_high; 499 tss.RSP1_low = tss.IST1_low; 500 tss.RSP1_high = tss.IST1_high; 501 tss.RSP2_low = tss.IST1_low; 502 tss.RSP2_high = tss.IST1_high; |
503 physProxy.writeBlob(tssPhysAddr, (uint8_t *)(&tss), sizeof(tss)); | 503 physProxy.writeBlob(tssPhysAddr, &tss, sizeof(tss)); |
504 505 /* Setting IDT gates */ 506 GateDescriptorLow PFGateLow = 0; 507 PFGateLow.offsetHigh = bits(PFHandlerVirtAddr, 31, 16); 508 PFGateLow.offsetLow = bits(PFHandlerVirtAddr, 15, 0); 509 PFGateLow.selector = csLowPL; 510 PFGateLow.p = 1; 511 PFGateLow.dpl = 0; 512 PFGateLow.type = 0xe; // gate interrupt type 513 PFGateLow.IST = 0; // setting IST to 0 and using RSP0 514 515 GateDescriptorHigh PFGateHigh = 0; 516 PFGateHigh.offset = bits(PFHandlerVirtAddr, 63, 32); 517 518 struct { 519 uint64_t low; 520 uint64_t high; 521 } PFGate = {PFGateLow, PFGateHigh}; 522 | 504 505 /* Setting IDT gates */ 506 GateDescriptorLow PFGateLow = 0; 507 PFGateLow.offsetHigh = bits(PFHandlerVirtAddr, 31, 16); 508 PFGateLow.offsetLow = bits(PFHandlerVirtAddr, 15, 0); 509 PFGateLow.selector = csLowPL; 510 PFGateLow.p = 1; 511 PFGateLow.dpl = 0; 512 PFGateLow.type = 0xe; // gate interrupt type 513 PFGateLow.IST = 0; // setting IST to 0 and using RSP0 514 515 GateDescriptorHigh PFGateHigh = 0; 516 PFGateHigh.offset = bits(PFHandlerVirtAddr, 63, 32); 517 518 struct { 519 uint64_t low; 520 uint64_t high; 521 } PFGate = {PFGateLow, PFGateHigh}; 522 |
523 physProxy.writeBlob(idtPhysAddr + 0xE0, 524 (uint8_t *)(&PFGate), sizeof(PFGate)); | 523 physProxy.writeBlob(idtPhysAddr + 0xE0, &PFGate, sizeof(PFGate)); |
525 526 /* System call handler */ 527 uint8_t syscallBlob[] = { 528 // mov %rax, (0xffffc90000005600) 529 0x48, 0xa3, 0x00, 0x60, 0x00, 530 0x00, 0x00, 0xc9, 0xff, 0xff, 531 // sysret 532 0x48, 0x0f, 0x07 --- 461 unchanged lines hidden (view full) --- 994 // write contents to stack 995 996 // figure out argc 997 IntType argc = argv.size(); 998 IntType guestArgc = X86ISA::htog(argc); 999 1000 // Write out the sentry void * 1001 IntType sentry_NULL = 0; | 524 525 /* System call handler */ 526 uint8_t syscallBlob[] = { 527 // mov %rax, (0xffffc90000005600) 528 0x48, 0xa3, 0x00, 0x60, 0x00, 529 0x00, 0x00, 0xc9, 0xff, 0xff, 530 // sysret 531 0x48, 0x0f, 0x07 --- 461 unchanged lines hidden (view full) --- 993 // write contents to stack 994 995 // figure out argc 996 IntType argc = argv.size(); 997 IntType guestArgc = X86ISA::htog(argc); 998 999 // Write out the sentry void * 1000 IntType sentry_NULL = 0; |
1002 initVirtMem.writeBlob(sentry_base, (uint8_t*)&sentry_NULL, sentry_size); | 1001 initVirtMem.writeBlob(sentry_base, &sentry_NULL, sentry_size); |
1003 1004 // Write the file name 1005 initVirtMem.writeString(file_name_base, filename.c_str()); 1006 1007 // Fix up the aux vectors which point to data 1008 assert(auxv[auxv.size() - 3].type == M5_AT_RANDOM); 1009 auxv[auxv.size() - 3].val = aux_data_base; 1010 assert(auxv[auxv.size() - 2].type == M5_AT_EXECFN); --- 13 unchanged lines hidden (view full) --- 1024 initVirtMem.write(auxv_array_end, zero); 1025 auxv_array_end += sizeof(zero); 1026 1027 initVirtMem.writeString(aux_data_base, platform.c_str()); 1028 1029 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); 1030 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); 1031 | 1002 1003 // Write the file name 1004 initVirtMem.writeString(file_name_base, filename.c_str()); 1005 1006 // Fix up the aux vectors which point to data 1007 assert(auxv[auxv.size() - 3].type == M5_AT_RANDOM); 1008 auxv[auxv.size() - 3].val = aux_data_base; 1009 assert(auxv[auxv.size() - 2].type == M5_AT_EXECFN); --- 13 unchanged lines hidden (view full) --- 1023 initVirtMem.write(auxv_array_end, zero); 1024 auxv_array_end += sizeof(zero); 1025 1026 initVirtMem.writeString(aux_data_base, platform.c_str()); 1027 1028 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); 1029 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); 1030 |
1032 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize); | 1031 initVirtMem.writeBlob(argc_base, &guestArgc, intSize); |
1033 1034 ThreadContext *tc = system->getThreadContext(contextIds[0]); 1035 // Set the stack pointer register 1036 tc->setIntReg(StackPointerReg, stack_min); 1037 1038 // There doesn't need to be any segment base added in since we're dealing 1039 // with the flat segmentation model. 1040 tc->pcState(getStartPC()); --- 84 unchanged lines hidden --- | 1032 1033 ThreadContext *tc = system->getThreadContext(contextIds[0]); 1034 // Set the stack pointer register 1035 tc->setIntReg(StackPointerReg, stack_min); 1036 1037 // There doesn't need to be any segment base added in since we're dealing 1038 // with the flat segmentation model. 1039 tc->pcState(getStartPC()); --- 84 unchanged lines hidden --- |