Changeset 73471 in vbox for trunk/src/VBox/VMM/VMMR3/VMM.cpp
- Timestamp:
- Aug 3, 2018 12:11:07 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124098
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/VMM.cpp
r73203 r73471 2472 2472 PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu); 2473 2473 AssertReturn(pVCpu, VERR_INVALID_PARAMETER); 2474 2474 AssertReturn(cbRead < ~(size_t)0 / 2, VERR_INVALID_PARAMETER); 2475 2476 int rc; 2475 2477 #ifdef VMM_R0_SWITCH_STACK 2476 2478 RTHCUINTPTR off = R0Addr - MMHyperCCToR0(pVM, pVCpu->vmm.s.pbEMTStackR3); … … 2478 2480 RTHCUINTPTR off = pVCpu->vmm.s.CallRing3JmpBufR0.cbSavedStack - (pVCpu->vmm.s.CallRing3JmpBufR0.SpCheck - R0Addr); 2479 2481 #endif 2480 if ( off > VMM_STACK_SIZE 2481 || off + cbRead >= VMM_STACK_SIZE) 2482 return VERR_INVALID_POINTER; 2483 2484 memcpy(pvBuf, &pVCpu->vmm.s.pbEMTStackR3[off], cbRead); 2485 return VINF_SUCCESS; 2482 if ( off < VMM_STACK_SIZE 2483 && off + cbRead <= VMM_STACK_SIZE) 2484 { 2485 memcpy(pvBuf, &pVCpu->vmm.s.pbEMTStackR3[off], cbRead); 2486 rc = VINF_SUCCESS; 2487 } 2488 else 2489 rc = VERR_INVALID_POINTER; 2490 2491 /* Supply the setjmp return RIP/EIP. */ 2492 if ( pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation + sizeof(RTR0UINTPTR) > R0Addr 2493 && pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation < R0Addr + cbRead) 2494 { 2495 uint8_t const *pbSrc = (uint8_t const *)&pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcValue; 2496 size_t cbSrc = sizeof(pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcValue); 2497 size_t offDst = 0; 2498 if (R0Addr < pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation) 2499 offDst = pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation - R0Addr; 2500 else if (R0Addr > pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation) 2501 { 2502 size_t offSrc = R0Addr - pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation; 2503 Assert(offSrc < cbSrc); 2504 pbSrc -= offSrc; 2505 cbSrc -= offSrc; 2506 } 2507 if (cbSrc > cbRead - offDst) 2508 cbSrc = cbRead - offDst; 2509 memcpy((uint8_t *)pvBuf + offDst, pbSrc, cbSrc); 2510 2511 if (cbSrc == cbRead) 2512 rc = VINF_SUCCESS; 2513 } 2514 2515 return rc; 2516 } 2517 2518 2519 /** 2520 * Used by the DBGF stack unwinder to initialize the register state. 2521 * 2522 * @param pUVM The user mode VM handle. 2523 * @param idCpu The ID of the CPU being unwound. 2524 * @param pState The unwind state to initialize. 2525 */ 2526 VMMR3_INT_DECL(void) VMMR3InitR0StackUnwindState(PUVM pUVM, VMCPUID idCpu, struct RTDBGUNWINDSTATE *pState) 2527 { 2528 PVMCPU pVCpu = VMMR3GetCpuByIdU(pUVM, idCpu); 2529 AssertReturnVoid(pVCpu); 2530 2531 /* 2532 * Locate the resume point on the stack. 2533 */ 2534 #ifdef VMM_R0_SWITCH_STACK 2535 uint32_t off = VMMR0JMPBUF.SpResume - MMHyperCCToR0(pVM, pVCpu->vmm.s.pbEMTStackR3); 2536 AssertReturnVoid(off < VMM_STACK_SIZE); 2537 #else 2538 uint32_t off = 0; 2539 #endif 2540 2541 #ifdef RT_ARCH_AMD64 2542 /* 2543 * This code must match the .resume stuff in VMMR0JmpA-amd64.asm exactly. 2544 */ 2545 # ifdef VBOX_STRICT 2546 Assert(*(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off] == UINT32_C(0x7eadf00d)); 2547 off += 8; /* RESUME_MAGIC */ 2548 # endif 2549 # ifdef RT_OS_WINDOWS 2550 off += 0xa0; /* XMM6 thru XMM15 */ 2551 # endif 2552 pState->u.x86.uRFlags = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2553 off += 8; 2554 pState->u.x86.auRegs[X86_GREG_xBX] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2555 off += 8; 2556 # ifdef RT_OS_WINDOWS 2557 pState->u.x86.auRegs[X86_GREG_xSI] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2558 off += 8; 2559 pState->u.x86.auRegs[X86_GREG_xDI] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2560 off += 8; 2561 # endif 2562 pState->u.x86.auRegs[X86_GREG_x12] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2563 off += 8; 2564 pState->u.x86.auRegs[X86_GREG_x13] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2565 off += 8; 2566 pState->u.x86.auRegs[X86_GREG_x14] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2567 off += 8; 2568 pState->u.x86.auRegs[X86_GREG_x15] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2569 off += 8; 2570 pState->u.x86.auRegs[X86_GREG_xBP] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2571 off += 8; 2572 pState->uPc = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2573 off += 8; 2574 2575 #elif defined(RT_ARCH_X86) 2576 /* 2577 * This code must match the .resume stuff in VMMR0JmpA-x86.asm exactly. 2578 */ 2579 # ifdef VBOX_STRICT 2580 Assert(*(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off] == UINT32_C(0x7eadf00d)); 2581 off += 4; /* RESUME_MAGIC */ 2582 # endif 2583 pState->u.x86.uRFlags = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2584 off += 4; 2585 pState->u.x86.auRegs[X86_GREG_xBX] = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2586 off += 4; 2587 pState->u.x86.auRegs[X86_GREG_xSI] = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2588 off += 4; 2589 pState->u.x86.auRegs[X86_GREG_xDI] = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2590 off += 4; 2591 pState->u.x86.auRegs[X86_GREG_xBP] = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2592 off += 4; 2593 pState->uPc = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off]; 2594 off += 4; 2595 #else 2596 # error "Port me" 2597 #endif 2598 2599 /* 2600 * This is all we really need here, though the above helps if the assembly 2601 * doesn't contain unwind info (currently only on win/64, so that is useful). 2602 */ 2603 pState->u.x86.auRegs[X86_GREG_xBP] = pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp; 2604 pState->u.x86.auRegs[X86_GREG_xSP] = pVCpu->vmm.s.CallRing3JmpBufR0.SpResume; 2486 2605 } 2487 2606
Note:
See TracChangeset
for help on using the changeset viewer.