- Timestamp:
- Jun 20, 2018 4:08:42 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 123137
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/nem.h
r72555 r72634 55 55 VMMR3DECL(const char *) NEMR3GetExitName(uint32_t uExit); 56 56 VMMR3_INT_DECL(VBOXSTRICTRC) NEMR3RunGC(PVM pVM, PVMCPU pVCpu); 57 VMMR3_INT_DECL(bool) NEMR3CanExecuteGuest(PVM pVM, PVMCPU pVCpu , PCPUMCTX pCtx);57 VMMR3_INT_DECL(bool) NEMR3CanExecuteGuest(PVM pVM, PVMCPU pVCpu); 58 58 VMMR3_INT_DECL(bool) NEMR3SetSingleInstruction(PVM pVM, PVMCPU pVCpu, bool fEnable); 59 59 VMMR3_INT_DECL(void) NEMR3NotifyFF(PVM pVM, PVMCPU pVCpu, uint32_t fFlags); -
trunk/src/VBox/VMM/VMMAll/CPUMAllMsrs.cpp
r72522 r72634 6333 6333 } 6334 6334 6335 6335 6336 /** 6336 6337 * Fast way for HM to access the IA32_SPEC_CTRL register. -
trunk/src/VBox/VMM/VMMR3/EM.cpp
r72606 r72634 194 194 pVCpu->em.s.idxContinueExitRec = UINT16_MAX; 195 195 196 pVCpu->em.s.pCtx = CPUMQueryGuestCtxPtr(pVCpu);197 196 #ifdef VBOX_WITH_RAW_MODE 198 197 if (VM_IS_RAW_MODE_ENABLED(pVM)) … … 1235 1234 { 1236 1235 #ifdef LOG_ENABLED 1237 PCPUMCTX pCtx = pVCpu->em.s.pCtx;1238 1236 uint32_t cpl = CPUMGetGuestCPL(pVCpu); 1239 1237 1240 if (p Ctx->eflags.Bits.u1VM)1241 Log(("EMV86: %04X:%08X IF=%d\n", p Ctx->cs.Sel, pCtx->eip, pCtx->eflags.Bits.u1IF));1238 if (pVCpu->cpum.GstCtx.eflags.Bits.u1VM) 1239 Log(("EMV86: %04X:%08X IF=%d\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF)); 1242 1240 else 1243 Log(("EMR%d: %04X:%08X ESP=%08X IF=%d CR0=%x eflags=%x\n", cpl, p Ctx->cs.Sel, pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, (uint32_t)pCtx->cr0, pCtx->eflags.u));1241 Log(("EMR%d: %04X:%08X ESP=%08X IF=%d CR0=%x eflags=%x\n", cpl, pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.esp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, (uint32_t)pVCpu->cpum.GstCtx.cr0, pVCpu->cpum.GstCtx.eflags.u)); 1244 1242 #endif 1245 1243 STAM_REL_PROFILE_ADV_START(&pVCpu->em.s.StatREMTotal, a); … … 1354 1352 || rc == VERR_IEM_INSTR_NOT_IMPLEMENTED) 1355 1353 { 1356 EMSTATE enmNewState = emR3Reschedule(pVM, pVCpu , pVCpu->em.s.pCtx);1354 EMSTATE enmNewState = emR3Reschedule(pVM, pVCpu); 1357 1355 if (enmNewState != EMSTATE_REM && enmNewState != EMSTATE_IEM_THEN_REM) 1358 1356 { … … 1411 1409 if (!(++cLoops & 7)) 1412 1410 { 1413 EMSTATE enmCheck = emR3Reschedule(pVM, pVCpu , pVCpu->em.s.pCtx);1411 EMSTATE enmCheck = emR3Reschedule(pVM, pVCpu); 1414 1412 if ( enmCheck != EMSTATE_REM 1415 1413 && enmCheck != EMSTATE_IEM_THEN_REM) … … 1448 1446 DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, "RSS"); 1449 1447 emR3RemStep(pVM, pVCpu); 1450 if (emR3Reschedule(pVM, pVCpu , pVCpu->em.s.pCtx) != EMSTATE_REM)1448 if (emR3Reschedule(pVM, pVCpu) != EMSTATE_REM) 1451 1449 break; 1452 1450 } … … 1495 1493 } 1496 1494 1497 EMSTATE enmNewState = emR3Reschedule(pVM, pVCpu , pVCpu->em.s.pCtx);1495 EMSTATE enmNewState = emR3Reschedule(pVM, pVCpu); 1498 1496 if (enmNewState != EMSTATE_REM && enmNewState != EMSTATE_IEM_THEN_REM) 1499 1497 { … … 1528 1526 * @param pVM The cross context VM structure. 1529 1527 * @param pVCpu The cross context virtual CPU structure. 1530 * @param pCtx Pointer to the guest CPU context.1531 1528 */ 1532 EMSTATE emR3Reschedule(PVM pVM, PVMCPU pVCpu , PCPUMCTX pCtx)1529 EMSTATE emR3Reschedule(PVM pVM, PVMCPU pVCpu) 1533 1530 { 1534 1531 /* … … 1554 1551 /* !!! THIS MUST BE IN SYNC WITH remR3CanExecuteRaw !!! */ 1555 1552 1556 X86EFLAGS EFlags = p Ctx->eflags;1553 X86EFLAGS EFlags = pVCpu->cpum.GstCtx.eflags; 1557 1554 if (!VM_IS_RAW_MODE_ENABLED(pVM)) 1558 1555 { … … 1561 1558 if (VM_IS_HM_ENABLED(pVM)) 1562 1559 { 1563 if (HMR3CanExecuteGuest(pVM, pCtx))1560 if (HMR3CanExecuteGuest(pVM, &pVCpu->cpum.GstCtx)) 1564 1561 return EMSTATE_HM; 1565 1562 } 1566 else if (NEMR3CanExecuteGuest(pVM, pVCpu , pCtx))1563 else if (NEMR3CanExecuteGuest(pVM, pVCpu)) 1567 1564 return EMSTATE_NEM; 1568 1565 … … 1597 1594 1598 1595 /** @todo check up the X86_CR0_AM flag in respect to raw mode!!! We're probably not emulating it right! */ 1599 uint32_t u32CR0 = p Ctx->cr0;1596 uint32_t u32CR0 = pVCpu->cpum.GstCtx.cr0; 1600 1597 if ((u32CR0 & (X86_CR0_PG | X86_CR0_PE)) != (X86_CR0_PG | X86_CR0_PE)) 1601 1598 { … … 1604 1601 } 1605 1602 1606 if (p Ctx->cr4 & X86_CR4_PAE)1603 if (pVCpu->cpum.GstCtx.cr4 & X86_CR4_PAE) 1607 1604 { 1608 1605 uint32_t u32Dummy, u32Features; … … 1613 1610 } 1614 1611 1615 unsigned uSS = p Ctx->ss.Sel;1616 if ( p Ctx->eflags.Bits.u1VM1612 unsigned uSS = pVCpu->cpum.GstCtx.ss.Sel; 1613 if ( pVCpu->cpum.GstCtx.eflags.Bits.u1VM 1617 1614 || (uSS & X86_SEL_RPL) == 3) 1618 1615 { … … 1655 1652 // Let's start with pure 32 bits ring 0 code first 1656 1653 /** @todo What's pure 32-bit mode? flat? */ 1657 if ( !(p Ctx->ss.Attr.n.u1DefBig)1658 || !(p Ctx->cs.Attr.n.u1DefBig))1654 if ( !(pVCpu->cpum.GstCtx.ss.Attr.n.u1DefBig) 1655 || !(pVCpu->cpum.GstCtx.cs.Attr.n.u1DefBig)) 1659 1656 { 1660 1657 Log2(("raw r0 mode refused: SS/CS not 32bit\n")); … … 1670 1667 1671 1668 # ifdef VBOX_WITH_RAW_MODE 1672 if (PATMShouldUseRawMode(pVM, (RTGCPTR)p Ctx->eip))1669 if (PATMShouldUseRawMode(pVM, (RTGCPTR)pVCpu->cpum.GstCtx.eip)) 1673 1670 { 1674 1671 Log2(("raw r0 mode forced: patch code\n")); 1675 1672 # ifdef VBOX_WITH_SAFE_STR 1676 Assert(p Ctx->tr.Sel);1673 Assert(pVCpu->cpum.GstCtx.tr.Sel); 1677 1674 # endif 1678 1675 return EMSTATE_RAW; … … 1702 1699 * Stale hidden selectors means raw-mode is unsafe (being very careful). 1703 1700 */ 1704 if (p Ctx->cs.fFlags & CPUMSELREG_FLAGS_STALE)1701 if (pVCpu->cpum.GstCtx.cs.fFlags & CPUMSELREG_FLAGS_STALE) 1705 1702 { 1706 1703 Log2(("raw mode refused: stale CS\n")); 1707 1704 return EMSTATE_REM; 1708 1705 } 1709 if (p Ctx->ss.fFlags & CPUMSELREG_FLAGS_STALE)1706 if (pVCpu->cpum.GstCtx.ss.fFlags & CPUMSELREG_FLAGS_STALE) 1710 1707 { 1711 1708 Log2(("raw mode refused: stale SS\n")); 1712 1709 return EMSTATE_REM; 1713 1710 } 1714 if (p Ctx->ds.fFlags & CPUMSELREG_FLAGS_STALE)1711 if (pVCpu->cpum.GstCtx.ds.fFlags & CPUMSELREG_FLAGS_STALE) 1715 1712 { 1716 1713 Log2(("raw mode refused: stale DS\n")); 1717 1714 return EMSTATE_REM; 1718 1715 } 1719 if (p Ctx->es.fFlags & CPUMSELREG_FLAGS_STALE)1716 if (pVCpu->cpum.GstCtx.es.fFlags & CPUMSELREG_FLAGS_STALE) 1720 1717 { 1721 1718 Log2(("raw mode refused: stale ES\n")); 1722 1719 return EMSTATE_REM; 1723 1720 } 1724 if (p Ctx->fs.fFlags & CPUMSELREG_FLAGS_STALE)1721 if (pVCpu->cpum.GstCtx.fs.fFlags & CPUMSELREG_FLAGS_STALE) 1725 1722 { 1726 1723 Log2(("raw mode refused: stale FS\n")); 1727 1724 return EMSTATE_REM; 1728 1725 } 1729 if (p Ctx->gs.fFlags & CPUMSELREG_FLAGS_STALE)1726 if (pVCpu->cpum.GstCtx.gs.fFlags & CPUMSELREG_FLAGS_STALE) 1730 1727 { 1731 1728 Log2(("raw mode refused: stale GS\n")); … … 1734 1731 1735 1732 # ifdef VBOX_WITH_SAFE_STR 1736 if (p Ctx->tr.Sel == 0)1733 if (pVCpu->cpum.GstCtx.tr.Sel == 0) 1737 1734 { 1738 1735 Log(("Raw mode refused -> TR=0\n")); … … 1827 1824 * @returns VBox status code. 1828 1825 * @param pVCpu The cross context virtual CPU structure. 1829 * @param pCtx Pointer to the nested-guest CPU context.1830 1826 * @param pfResched Where to store whether a reschedule is required. 1831 1827 * @param pfInject Where to store whether an interrupt was injected (and if 1832 1828 * a wake up is pending). 1833 1829 */ 1834 static int emR3NstGstInjectIntr(PVMCPU pVCpu, PCPUMCTX pCtx,bool *pfResched, bool *pfInject)1830 static int emR3NstGstInjectIntr(PVMCPU pVCpu, bool *pfResched, bool *pfInject) 1835 1831 { 1836 1832 *pfResched = false; 1837 1833 *pfInject = false; 1838 if (CPUMIsGuestInSvmNestedHwVirtMode( pCtx))1834 if (CPUMIsGuestInSvmNestedHwVirtMode(&pVCpu->cpum.GstCtx)) 1839 1835 { 1840 1836 PVM pVM = pVCpu->CTX_SUFF(pVM); 1841 Assert(p Ctx->hwvirt.fGif);1842 bool fVirtualGif = CPUMGetSvmNstGstVGif( pCtx);1837 Assert(pVCpu->cpum.GstCtx.hwvirt.fGif); 1838 bool fVirtualGif = CPUMGetSvmNstGstVGif(&pVCpu->cpum.GstCtx); 1843 1839 #ifdef VBOX_WITH_RAW_MODE 1844 fVirtualGif &= !PATMIsPatchGCAddr(pVM, p Ctx->eip);1840 fVirtualGif &= !PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip); 1845 1841 #endif 1846 1842 if (fVirtualGif) 1847 1843 { 1848 if (CPUMCanSvmNstGstTakePhysIntr(pVCpu, pCtx))1844 if (CPUMCanSvmNstGstTakePhysIntr(pVCpu, &pVCpu->cpum.GstCtx)) 1849 1845 { 1850 1846 Assert(pVCpu->em.s.enmState != EMSTATE_WAIT_SIPI); 1851 1847 if (VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC)) 1852 1848 { 1853 if (CPUMIsGuestSvmCtrlInterceptSet(pVCpu, pCtx, SVM_CTRL_INTERCEPT_INTR))1849 if (CPUMIsGuestSvmCtrlInterceptSet(pVCpu, &pVCpu->cpum.GstCtx, SVM_CTRL_INTERCEPT_INTR)) 1854 1850 { 1855 1851 VBOXSTRICTRC rcStrict = IEMExecSvmVmexit(pVCpu, SVM_EXIT_INTR, 0, 0); … … 1889 1885 1890 1886 if ( VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_INTERRUPT_NESTED_GUEST) 1891 && CPUMCanSvmNstGstTakeVirtIntr(pVCpu, pCtx))1887 && CPUMCanSvmNstGstTakeVirtIntr(pVCpu, &pVCpu->cpum.GstCtx)) 1892 1888 { 1893 if (CPUMIsGuestSvmCtrlInterceptSet(pVCpu, pCtx, SVM_CTRL_INTERCEPT_VINTR))1889 if (CPUMIsGuestSvmCtrlInterceptSet(pVCpu, &pVCpu->cpum.GstCtx, SVM_CTRL_INTERCEPT_VINTR)) 1894 1890 { 1895 1891 VBOXSTRICTRC rcStrict = IEMExecSvmVmexit(pVCpu, SVM_EXIT_VINTR, 0, 0); … … 1910 1906 1911 1907 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_NESTED_GUEST); 1912 uint8_t const uNstGstVector = CPUMGetSvmNstGstInterrupt( pCtx);1908 uint8_t const uNstGstVector = CPUMGetSvmNstGstInterrupt(&pVCpu->cpum.GstCtx); 1913 1909 AssertMsg(uNstGstVector > 0 && uNstGstVector <= X86_XCPT_LAST, ("Invalid VINTR vector %#x\n", uNstGstVector)); 1914 1910 TRPMAssertTrap(pVCpu, uNstGstVector, TRPM_HARDWARE_INT); … … 1923 1919 } 1924 1920 1925 if (CPUMIsGuestInVmxNestedHwVirtMode( pCtx))1921 if (CPUMIsGuestInVmxNestedHwVirtMode(&pVCpu->cpum.GstCtx)) 1926 1922 { /** @todo Nested VMX. */ } 1927 1923 … … 2052 2048 Log(("Forced action VMCPU_FF_CSAM_SCAN_PAGE\n")); 2053 2049 CPUM_IMPORT_EXTRN_RCSTRICT(pVCpu, ~CPUMCTX_EXTRN_KEEPER_MASK, rc); 2054 PCPUMCTX pCtx = pVCpu->em.s.pCtx; 2055 CSAMR3CheckCodeEx(pVM, pCtx, pCtx->eip); 2050 CSAMR3CheckCodeEx(pVM, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.eip); 2056 2051 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_CSAM_SCAN_PAGE); 2057 2052 } … … 2255 2250 { 2256 2251 Assert(!HMR3IsEventPending(pVCpu)); 2257 PCPUMCTX pCtx = pVCpu->em.s.pCtx;2258 2252 #ifdef VBOX_WITH_NESTED_HWVIRT_SVM 2259 if (CPUMIsGuestInNestedHwVirtMode( pCtx))2253 if (CPUMIsGuestInNestedHwVirtMode(&pVCpu->cpum.GstCtx)) 2260 2254 { 2261 2255 bool fResched, fInject; 2262 rc2 = emR3NstGstInjectIntr(pVCpu, pCtx,&fResched, &fInject);2256 rc2 = emR3NstGstInjectIntr(pVCpu, &fResched, &fInject); 2263 2257 if (fInject) 2264 2258 { … … 2277 2271 if ( VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC) 2278 2272 #ifdef VBOX_WITH_NESTED_HWVIRT_SVM 2279 && p Ctx->hwvirt.fGif2273 && pVCpu->cpum.GstCtx.hwvirt.fGif 2280 2274 #endif 2281 2275 #ifdef VBOX_WITH_RAW_MODE 2282 && !PATMIsPatchGCAddr(pVM, p Ctx->eip)2283 #endif 2284 && p Ctx->eflags.Bits.u1IF)2276 && !PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip) 2277 #endif 2278 && pVCpu->cpum.GstCtx.eflags.Bits.u1IF) 2285 2279 { 2286 2280 Assert(pVCpu->em.s.enmState != EMSTATE_WAIT_SIPI); … … 2507 2501 pVCpu->em.s.enmState = pVCpu->em.s.enmPrevState; 2508 2502 else 2509 pVCpu->em.s.enmState = emR3Reschedule(pVM, pVCpu , pVCpu->em.s.pCtx);2503 pVCpu->em.s.enmState = emR3Reschedule(pVM, pVCpu); 2510 2504 pVCpu->em.s.cIemThenRemInstructions = 0; 2511 2505 Log(("EMR3ExecuteVM: enmState=%s\n", emR3GetStateName(pVCpu->em.s.enmState))); … … 2635 2629 case VINF_EM_RESCHEDULE: 2636 2630 { 2637 EMSTATE enmState = emR3Reschedule(pVM, pVCpu , pVCpu->em.s.pCtx);2631 EMSTATE enmState = emR3Reschedule(pVM, pVCpu); 2638 2632 Log2(("EMR3ExecuteVM: VINF_EM_RESCHEDULE: %d -> %d (%s)\n", enmOldState, enmState, emR3GetStateName(enmState))); 2639 2633 if (pVCpu->em.s.enmState != enmState && enmState == EMSTATE_IEM_THEN_REM) … … 2679 2673 if (pVCpu->idCpu == 0) 2680 2674 { 2681 EMSTATE enmState = emR3Reschedule(pVM, pVCpu , pVCpu->em.s.pCtx);2675 EMSTATE enmState = emR3Reschedule(pVM, pVCpu); 2682 2676 Log2(("EMR3ExecuteVM: VINF_EM_RESET: %d -> %d (%s)\n", enmOldState, enmState, emR3GetStateName(enmState))); 2683 2677 if (pVCpu->em.s.enmState != enmState && enmState == EMSTATE_IEM_THEN_REM) -
trunk/src/VBox/VMM/VMMR3/EMHM.cpp
r72598 r72634 64 64 * Internal Functions * 65 65 *********************************************************************************************************************************/ 66 static int emR3HmHandleRC(PVM pVM, PVMCPU pVCpu, int rc); 66 67 DECLINLINE(int) emR3HmExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC = VINF_SUCCESS); 67 68 static int emR3HmExecuteIOInstruction(PVM pVM, PVMCPU pVCpu); 68 static int emR3HmForcedActions(PVM pVM, PVMCPU pVCpu , PCPUMCTX pCtx);69 static int emR3HmForcedActions(PVM pVM, PVMCPU pVCpu); 69 70 70 71 #define EMHANDLERC_WITH_HM … … 91 92 VMMR3_INT_DECL(VBOXSTRICTRC) EMR3HmSingleInstruction(PVM pVM, PVMCPU pVCpu, uint32_t fFlags) 92 93 { 93 PCPUMCTX pCtx = pVCpu->em.s.pCtx;94 94 Assert(!(fFlags & ~EM_ONE_INS_FLAGS_MASK)); 95 95 96 if (!HMR3CanExecuteGuest(pVM, pCtx))96 if (!HMR3CanExecuteGuest(pVM, &pVCpu->cpum.GstCtx)) 97 97 return VINF_EM_RESCHEDULE; 98 98 99 uint64_t const uOldRip = p Ctx->rip;99 uint64_t const uOldRip = pVCpu->cpum.GstCtx.rip; 100 100 for (;;) 101 101 { … … 106 106 || VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_HIGH_PRIORITY_PRE_RAW_MASK)) 107 107 { 108 VBOXSTRICTRC rcStrict = emR3HmForcedActions(pVM, pVCpu , pCtx);108 VBOXSTRICTRC rcStrict = emR3HmForcedActions(pVM, pVCpu); 109 109 if (rcStrict != VINF_SUCCESS) 110 110 { … … 136 136 if (rcStrict != VINF_SUCCESS && (rcStrict < VINF_EM_FIRST || rcStrict > VINF_EM_LAST)) 137 137 { 138 rcStrict = emR3HmHandleRC(pVM, pVCpu, pCtx,VBOXSTRICTRC_TODO(rcStrict));138 rcStrict = emR3HmHandleRC(pVM, pVCpu, VBOXSTRICTRC_TODO(rcStrict)); 139 139 Log(("EMR3HmSingleInstruction: emR3HmHandleRC -> %Rrc\n", VBOXSTRICTRC_VAL(rcStrict))); 140 140 } … … 145 145 if ( (rcStrict != VINF_SUCCESS && rcStrict != VINF_EM_DBG_STEPPED) 146 146 || !(fFlags & EM_ONE_INS_FLAGS_RIP_CHANGE) 147 || p Ctx->rip != uOldRip)148 { 149 if (rcStrict == VINF_SUCCESS && p Ctx->rip != uOldRip)147 || pVCpu->cpum.GstCtx.rip != uOldRip) 148 { 149 if (rcStrict == VINF_SUCCESS && pVCpu->cpum.GstCtx.rip != uOldRip) 150 150 rcStrict = VINF_EM_DBG_STEPPED; 151 Log(("EMR3HmSingleInstruction: returns %Rrc (rip %llx -> %llx)\n", VBOXSTRICTRC_VAL(rcStrict), uOldRip, p Ctx->rip));151 Log(("EMR3HmSingleInstruction: returns %Rrc (rip %llx -> %llx)\n", VBOXSTRICTRC_VAL(rcStrict), uOldRip, pVCpu->cpum.GstCtx.rip)); 152 152 CPUM_IMPORT_EXTRN_RET(pVCpu, ~CPUMCTX_EXTRN_KEEPER_MASK); 153 153 return rcStrict; … … 174 174 #endif 175 175 { 176 NOREF(rcRC); 177 176 178 #ifdef LOG_ENABLED 177 PCPUMCTX pCtx = pVCpu->em.s.pCtx;178 #endif179 NOREF(rcRC);180 181 #ifdef LOG_ENABLED182 179 /* 183 180 * Log it. 184 181 */ 185 Log(("EMINS: %04x:%RGv RSP=%RGv\n", p Ctx->cs.Sel, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));182 Log(("EMINS: %04x:%RGv RSP=%RGv\n", pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip, (RTGCPTR)pVCpu->cpum.GstCtx.rsp)); 186 183 if (pszPrefix) 187 184 { … … 269 266 static int emR3HmExecuteIOInstruction(PVM pVM, PVMCPU pVCpu) 270 267 { 271 PCPUMCTX pCtx = pVCpu->em.s.pCtx;272 273 268 STAM_PROFILE_START(&pVCpu->em.s.StatIOEmu, a); 274 269 … … 281 276 * Try to restart the io instruction that was refused in ring-0. 282 277 */ 283 rcStrict = HMR3RestartPendingIOInstr(pVM, pVCpu, pCtx);278 rcStrict = HMR3RestartPendingIOInstr(pVM, pVCpu, &pVCpu->cpum.GstCtx); 284 279 if (IOM_SUCCESS(rcStrict)) 285 280 { … … 324 319 * @param pVM The cross context VM structure. 325 320 * @param pVCpu The cross context virtual CPU structure. 326 * @param pCtx Pointer to the guest CPU context. 327 */ 328 static int emR3HmForcedActions(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 321 */ 322 static int emR3HmForcedActions(PVM pVM, PVMCPU pVCpu) 329 323 { 330 324 /* … … 335 329 CPUM_IMPORT_EXTRN_RET(pVCpu, CPUMCTX_EXTRN_CR0 | CPUMCTX_EXTRN_CR3 | CPUMCTX_EXTRN_CR4); 336 330 Assert(pVCpu->em.s.enmState != EMSTATE_WAIT_SIPI); 337 int rc = PGMSyncCR3(pVCpu, p Ctx->cr0, pCtx->cr3, pCtx->cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3));331 int rc = PGMSyncCR3(pVCpu, pVCpu->cpum.GstCtx.cr0, pVCpu->cpum.GstCtx.cr3, pVCpu->cpum.GstCtx.cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3)); 338 332 if (RT_FAILURE(rc)) 339 333 return rc; … … 347 341 /** @todo this should be skipped! */ 348 342 CPUM_IMPORT_EXTRN_RET(pVCpu, CPUMCTX_EXTRN_CS | CPUMCTX_EXTRN_SS); 349 rc = PGMPrefetchPage(pVCpu, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE( pCtx), pCtx->rip));343 rc = PGMPrefetchPage(pVCpu, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), pVCpu->cpum.GstCtx.rip)); 350 344 if (rc == VINF_SUCCESS) 351 rc = PGMPrefetchPage(pVCpu, SELMToFlat(pVM, DISSELREG_SS, CPUMCTX2CORE( pCtx), pCtx->rsp));345 rc = PGMPrefetchPage(pVCpu, SELMToFlat(pVM, DISSELREG_SS, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), pVCpu->cpum.GstCtx.rsp)); 352 346 if (rc != VINF_SUCCESS) 353 347 { … … 357 351 return rc; 358 352 } 359 rc = PGMSyncCR3(pVCpu, p Ctx->cr0, pCtx->cr3, pCtx->cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3));353 rc = PGMSyncCR3(pVCpu, pVCpu->cpum.GstCtx.cr0, pVCpu->cpum.GstCtx.cr3, pVCpu->cpum.GstCtx.cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3)); 360 354 if (RT_FAILURE(rc)) 361 355 return rc; … … 408 402 { 409 403 int rc = VERR_IPE_UNINITIALIZED_STATUS; 410 PCPUMCTX pCtx = pVCpu->em.s.pCtx; 411 412 LogFlow(("emR3HmExecute%d: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pCtx->cs.Sel, (RTGCPTR)pCtx->rip)); 404 405 LogFlow(("emR3HmExecute%d: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip)); 413 406 *pfFFDone = false; 414 407 … … 427 420 428 421 /* Check if a forced reschedule is pending. */ 429 if (HMR3IsRescheduleRequired(pVM, pCtx))422 if (HMR3IsRescheduleRequired(pVM, &pVCpu->cpum.GstCtx)) 430 423 { 431 424 rc = VINF_EM_RESCHEDULE; … … 442 435 || VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_HIGH_PRIORITY_PRE_RAW_MASK)) 443 436 { 444 rc = emR3HmForcedActions(pVM, pVCpu , pCtx);437 rc = emR3HmForcedActions(pVM, pVCpu); 445 438 if (rc != VINF_SUCCESS) 446 439 break; … … 452 445 */ 453 446 if (TRPMHasTrap(pVCpu)) 454 Log(("CPU%d: Pending hardware interrupt=0x%x cs:rip=%04X:%RGv\n", pVCpu->idCpu, TRPMGetTrapNo(pVCpu), p Ctx->cs.Sel, (RTGCPTR)pCtx->rip));447 Log(("CPU%d: Pending hardware interrupt=0x%x cs:rip=%04X:%RGv\n", pVCpu->idCpu, TRPMGetTrapNo(pVCpu), pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip)); 455 448 456 449 uint32_t cpl = CPUMGetGuestCPL(pVCpu); 457 450 if (pVM->cCpus == 1) 458 451 { 459 if (p Ctx->eflags.Bits.u1VM)460 Log(("HWV86: %08X IF=%d\n", p Ctx->eip, pCtx->eflags.Bits.u1IF));461 else if (CPUMIsGuestIn64BitCodeEx( pCtx))462 Log(("HWR%d: %04X:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, p Ctx->cs.Sel, (RTGCPTR)pCtx->rip, pCtx->rsp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));452 if (pVCpu->cpum.GstCtx.eflags.Bits.u1VM) 453 Log(("HWV86: %08X IF=%d\n", pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF)); 454 else if (CPUMIsGuestIn64BitCodeEx(&pVCpu->cpum.GstCtx)) 455 Log(("HWR%d: %04X:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rsp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->cpum.GstCtx.eflags.Bits.u2IOPL, (uint32_t)pVCpu->cpum.GstCtx.cr0, (uint32_t)pVCpu->cpum.GstCtx.cr4, (uint32_t)pVCpu->cpum.GstCtx.msrEFER)); 463 456 else 464 Log(("HWR%d: %04X:%08X ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, p Ctx->cs.Sel, pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));457 Log(("HWR%d: %04X:%08X ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.esp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->cpum.GstCtx.eflags.Bits.u2IOPL, (uint32_t)pVCpu->cpum.GstCtx.cr0, (uint32_t)pVCpu->cpum.GstCtx.cr4, (uint32_t)pVCpu->cpum.GstCtx.msrEFER)); 465 458 } 466 459 else 467 460 { 468 if (p Ctx->eflags.Bits.u1VM)469 Log(("HWV86-CPU%d: %08X IF=%d\n", pVCpu->idCpu, p Ctx->eip, pCtx->eflags.Bits.u1IF));470 else if (CPUMIsGuestIn64BitCodeEx( pCtx))471 Log(("HWR%d-CPU%d: %04X:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, p Ctx->cs.Sel, (RTGCPTR)pCtx->rip, pCtx->rsp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));461 if (pVCpu->cpum.GstCtx.eflags.Bits.u1VM) 462 Log(("HWV86-CPU%d: %08X IF=%d\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF)); 463 else if (CPUMIsGuestIn64BitCodeEx(&pVCpu->cpum.GstCtx)) 464 Log(("HWR%d-CPU%d: %04X:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rsp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->cpum.GstCtx.eflags.Bits.u2IOPL, (uint32_t)pVCpu->cpum.GstCtx.cr0, (uint32_t)pVCpu->cpum.GstCtx.cr4, (uint32_t)pVCpu->cpum.GstCtx.msrEFER)); 472 465 else 473 Log(("HWR%d-CPU%d: %04X:%08X ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, p Ctx->cs.Sel, pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));466 Log(("HWR%d-CPU%d: %04X:%08X ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.esp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->cpum.GstCtx.eflags.Bits.u2IOPL, (uint32_t)pVCpu->cpum.GstCtx.cr0, (uint32_t)pVCpu->cpum.GstCtx.cr4, (uint32_t)pVCpu->cpum.GstCtx.msrEFER)); 474 467 } 475 468 #endif /* LOG_ENABLED */ … … 510 503 break; 511 504 512 rc = emR3HmHandleRC(pVM, pVCpu, pCtx,rc);505 rc = emR3HmHandleRC(pVM, pVCpu, rc); 513 506 if (rc != VINF_SUCCESS) 514 507 break; -
trunk/src/VBox/VMM/VMMR3/EMR3Nem.cpp
r72580 r72634 64 64 * Internal Functions * 65 65 *********************************************************************************************************************************/ 66 static int emR3NemHandleRC(PVM pVM, PVMCPU pVCpu, int rc); 66 67 DECLINLINE(int) emR3NemExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC = VINF_SUCCESS); 67 68 static int emR3NemExecuteIOInstruction(PVM pVM, PVMCPU pVCpu); 68 static int emR3NemForcedActions(PVM pVM, PVMCPU pVCpu , PCPUMCTX pCtx);69 static int emR3NemForcedActions(PVM pVM, PVMCPU pVCpu); 69 70 70 71 #define EMHANDLERC_WITH_NEM … … 91 92 VBOXSTRICTRC emR3NemSingleInstruction(PVM pVM, PVMCPU pVCpu, uint32_t fFlags) 92 93 { 93 Assert(pVCpu->em.s.pCtx == &pVCpu->cpum.GstCtx);94 94 Assert(!(fFlags & ~EM_ONE_INS_FLAGS_MASK)); 95 95 96 if (!NEMR3CanExecuteGuest(pVM, pVCpu , &pVCpu->cpum.GstCtx))96 if (!NEMR3CanExecuteGuest(pVM, pVCpu)) 97 97 return VINF_EM_RESCHEDULE; 98 98 … … 106 106 || VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_HIGH_PRIORITY_PRE_RAW_MASK)) 107 107 { 108 VBOXSTRICTRC rcStrict = emR3NemForcedActions(pVM, pVCpu , &pVCpu->cpum.GstCtx);108 VBOXSTRICTRC rcStrict = emR3NemForcedActions(pVM, pVCpu); 109 109 if (rcStrict != VINF_SUCCESS) 110 110 { … … 136 136 if (rcStrict != VINF_SUCCESS && (rcStrict < VINF_EM_FIRST || rcStrict > VINF_EM_LAST)) 137 137 { 138 rcStrict = emR3NemHandleRC(pVM, pVCpu, &pVCpu->cpum.GstCtx,VBOXSTRICTRC_TODO(rcStrict));138 rcStrict = emR3NemHandleRC(pVM, pVCpu, VBOXSTRICTRC_TODO(rcStrict)); 139 139 Log(("emR3NemSingleInstruction: emR3NemHandleRC -> %Rrc\n", VBOXSTRICTRC_VAL(rcStrict))); 140 140 } … … 176 176 #endif 177 177 { 178 #if defined(LOG_ENABLED)179 PCPUMCTX pCtx = pVCpu->em.s.pCtx;180 #endif181 178 NOREF(rcRC); 182 179 … … 185 182 * Log it. 186 183 */ 187 Log(("EMINS: %04x:%RGv RSP=%RGv\n", p Ctx->cs.Sel, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));184 Log(("EMINS: %04x:%RGv RSP=%RGv\n", pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip, (RTGCPTR)pVCpu->cpum.GstCtx.rsp)); 188 185 if (pszPrefix) 189 186 { … … 308 305 * @param pVM The cross context VM structure. 309 306 * @param pVCpu The cross context virtual CPU structure. 310 * @param pCtx Pointer to the guest CPU context. 311 */ 312 static int emR3NemForcedActions(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 307 */ 308 static int emR3NemForcedActions(PVM pVM, PVMCPU pVCpu) 313 309 { 314 310 #ifdef VBOX_WITH_RAW_MODE … … 345 341 return VINF_EM_NO_MEMORY; 346 342 347 RT_NOREF_PV(pCtx);348 343 return VINF_SUCCESS; 349 344 } … … 367 362 { 368 363 VBOXSTRICTRC rcStrict = VERR_IPE_UNINITIALIZED_STATUS; 369 PCPUMCTX pCtx = pVCpu->em.s.pCtx; 370 371 LogFlow(("emR3NemExecute%d: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pCtx->cs.Sel, (RTGCPTR)pCtx->rip)); 364 365 LogFlow(("emR3NemExecute%d: (cs:eip=%04x:%RGv)\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip)); 372 366 *pfFFDone = false; 373 367 … … 383 377 #if 0 384 378 /* Check if a forced reschedule is pending. */ 385 if (NEMR3IsRescheduleRequired(pV M, pCtx))379 if (NEMR3IsRescheduleRequired(pVCpu)) 386 380 { 387 381 rcStrict = VINF_EM_RESCHEDULE; … … 396 390 || VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_HIGH_PRIORITY_PRE_RAW_MASK)) 397 391 { 398 rcStrict = emR3NemForcedActions(pVM, pVCpu , pCtx);392 rcStrict = emR3NemForcedActions(pVM, pVCpu); 399 393 if (rcStrict != VINF_SUCCESS) 400 394 break; … … 406 400 */ 407 401 if (TRPMHasTrap(pVCpu)) 408 Log(("CPU%d: Pending hardware interrupt=0x%x cs:rip=%04X:%RGv\n", pVCpu->idCpu, TRPMGetTrapNo(pVCpu), p Ctx->cs.Sel, (RTGCPTR)pCtx->rip));402 Log(("CPU%d: Pending hardware interrupt=0x%x cs:rip=%04X:%RGv\n", pVCpu->idCpu, TRPMGetTrapNo(pVCpu), pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip)); 409 403 410 404 uint32_t cpl = CPUMGetGuestCPL(pVCpu); 411 405 if (pVM->cCpus == 1) 412 406 { 413 if (p Ctx->eflags.Bits.u1VM)414 Log(("NEMV86: %08x IF=%d\n", p Ctx->eip, pCtx->eflags.Bits.u1IF));415 else if (CPUMIsGuestIn64BitCodeEx( pCtx))416 Log(("NEMR%d: %04x:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, p Ctx->cs.Sel, (RTGCPTR)pCtx->rip, pCtx->rsp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));407 if (pVCpu->cpum.GstCtx.eflags.Bits.u1VM) 408 Log(("NEMV86: %08x IF=%d\n", pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF)); 409 else if (CPUMIsGuestIn64BitCodeEx(&pVCpu->cpum.GstCtx)) 410 Log(("NEMR%d: %04x:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rsp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->cpum.GstCtx.eflags.Bits.u2IOPL, (uint32_t)pVCpu->cpum.GstCtx.cr0, (uint32_t)pVCpu->cpum.GstCtx.cr4, (uint32_t)pVCpu->cpum.GstCtx.msrEFER)); 417 411 else 418 Log(("NEMR%d: %04x:%08x ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, p Ctx->cs.Sel, pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));412 Log(("NEMR%d: %04x:%08x ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.esp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->cpum.GstCtx.eflags.Bits.u2IOPL, (uint32_t)pVCpu->cpum.GstCtx.cr0, (uint32_t)pVCpu->cpum.GstCtx.cr4, (uint32_t)pVCpu->cpum.GstCtx.msrEFER)); 419 413 } 420 414 else 421 415 { 422 if (p Ctx->eflags.Bits.u1VM)423 Log(("NEMV86-CPU%d: %08x IF=%d\n", pVCpu->idCpu, p Ctx->eip, pCtx->eflags.Bits.u1IF));424 else if (CPUMIsGuestIn64BitCodeEx( pCtx))425 Log(("NEMR%d-CPU%d: %04x:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, p Ctx->cs.Sel, (RTGCPTR)pCtx->rip, pCtx->rsp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));416 if (pVCpu->cpum.GstCtx.eflags.Bits.u1VM) 417 Log(("NEMV86-CPU%d: %08x IF=%d\n", pVCpu->idCpu, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF)); 418 else if (CPUMIsGuestIn64BitCodeEx(&pVCpu->cpum.GstCtx)) 419 Log(("NEMR%d-CPU%d: %04x:%RGv ESP=%RGv IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rsp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->cpum.GstCtx.eflags.Bits.u2IOPL, (uint32_t)pVCpu->cpum.GstCtx.cr0, (uint32_t)pVCpu->cpum.GstCtx.cr4, (uint32_t)pVCpu->cpum.GstCtx.msrEFER)); 426 420 else 427 Log(("NEMR%d-CPU%d: %04x:%08x ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, p Ctx->cs.Sel, pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, pCtx->eflags.Bits.u2IOPL, (uint32_t)pCtx->cr0, (uint32_t)pCtx->cr4, (uint32_t)pCtx->msrEFER));421 Log(("NEMR%d-CPU%d: %04x:%08x ESP=%08X IF=%d IOPL=%d CR0=%x CR4=%x EFER=%x\n", cpl, pVCpu->idCpu, pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.esp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->cpum.GstCtx.eflags.Bits.u2IOPL, (uint32_t)pVCpu->cpum.GstCtx.cr0, (uint32_t)pVCpu->cpum.GstCtx.cr4, (uint32_t)pVCpu->cpum.GstCtx.msrEFER)); 428 422 } 429 423 #endif /* LOG_ENABLED */ … … 464 458 break; 465 459 466 rcStrict = emR3NemHandleRC(pVM, pVCpu, pCtx,VBOXSTRICTRC_TODO(rcStrict));460 rcStrict = emR3NemHandleRC(pVM, pVCpu, VBOXSTRICTRC_TODO(rcStrict)); 467 461 if (rcStrict != VINF_SUCCESS) 468 462 break; … … 494 488 * status over import errors. 495 489 */ 496 if (p Ctx->fExtrn)497 { 498 int rcImport = NEMImportStateOnDemand(pVCpu, pCtx, pCtx->fExtrn);490 if (pVCpu->cpum.GstCtx.fExtrn) 491 { 492 int rcImport = NEMImportStateOnDemand(pVCpu, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.fExtrn); 499 493 AssertReturn(RT_SUCCESS(rcImport) || RT_FAILURE_NP(rcStrict), rcImport); 500 494 } -
trunk/src/VBox/VMM/VMMR3/EMRaw.cpp
r72488 r72634 61 61 * Internal Functions * 62 62 *********************************************************************************************************************************/ 63 static int emR3RawForcedActions(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); 63 static int emR3RawHandleRC(PVM pVM, PVMCPU pVCpu, int rc); 64 static int emR3RawForcedActions(PVM pVM, PVMCPU pVCpu); 64 65 DECLINLINE(int) emR3RawExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC = VINF_SUCCESS); 65 66 static int emR3RawGuestTrap(PVM pVM, PVMCPU pVCpu); 66 static int emR3RawPatchTrap(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx,int gcret);67 static int emR3RawPatchTrap(PVM pVM, PVMCPU pVCpu, int gcret); 67 68 static int emR3RawPrivileged(PVM pVM, PVMCPU pVCpu); 68 69 static int emR3RawExecuteIOInstruction(PVM pVM, PVMCPU pVCpu); 69 70 static int emR3RawRingSwitch(PVM pVM, PVMCPU pVCpu); 71 static int emR3RawUpdateForceFlag(PVM pVM, PVMCPU pVCpu, int rc); 70 72 71 73 #define EMHANDLERC_WITH_PATM … … 124 126 { 125 127 int rc; 126 PCPUMCTX pCtx = pVCpu->em.s.pCtx;127 128 Assert(pVCpu->em.s.enmState == EMSTATE_DEBUG_HYPER); 128 Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr\n", p Ctx->cs.Sel, pCtx->eip, pCtx->eflags));129 Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags)); 129 130 130 131 /* … … 134 135 CPUMSetHyperEFlags(pVCpu, CPUMGetHyperEFlags(pVCpu) | X86_EFL_RF); 135 136 rc = VMMR3ResumeHyper(pVM, pVCpu); 136 Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr - returned from GC with rc=%Rrc\n", p Ctx->cs.Sel, pCtx->eip, pCtx->eflags, rc));137 Log(("emR3RawResumeHyper: cs:eip=%RTsel:%RGr efl=%RGr - returned from GC with rc=%Rrc\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags, rc)); 137 138 rc = CPUMRawLeave(pVCpu, rc); 138 139 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK); … … 142 143 */ 143 144 rc = VBOXSTRICTRC_TODO(emR3HighPriorityPostForcedActions(pVM, pVCpu, rc)); 144 rc = emR3RawHandleRC(pVM, pVCpu, pCtx,rc);145 rc = emR3RawUpdateForceFlag(pVM, pVCpu, pCtx,rc);145 rc = emR3RawHandleRC(pVM, pVCpu, rc); 146 rc = emR3RawUpdateForceFlag(pVM, pVCpu, rc); 146 147 return rc; 147 148 } … … 161 162 || pVCpu->em.s.enmState == EMSTATE_DEBUG_GUEST_REM); 162 163 int rc; 163 PCPUMCTX pCtx = pVCpu->em.s.pCtx;164 164 bool fGuest = pVCpu->em.s.enmState != EMSTATE_DEBUG_HYPER; 165 165 #ifndef DEBUG_sander … … 175 175 || VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_HIGH_PRIORITY_PRE_RAW_MASK)) 176 176 { 177 rc = emR3RawForcedActions(pVM, pVCpu , pCtx);177 rc = emR3RawForcedActions(pVM, pVCpu); 178 178 VBOXVMM_EM_FF_RAW_RET(pVCpu, rc); 179 179 if (rc != VINF_SUCCESS) … … 222 222 */ 223 223 rc = VBOXSTRICTRC_TODO(emR3HighPriorityPostForcedActions(pVM, pVCpu, rc)); 224 rc = emR3RawHandleRC(pVM, pVCpu, pCtx,rc);225 rc = emR3RawUpdateForceFlag(pVM, pVCpu, pCtx,rc);224 rc = emR3RawHandleRC(pVM, pVCpu, rc); 225 rc = emR3RawUpdateForceFlag(pVM, pVCpu, rc); 226 226 return rc; 227 227 } … … 273 273 #endif 274 274 { 275 PCPUMCTX pCtx = pVCpu->em.s.pCtx;276 275 int rc; 277 276 … … 293 292 * to allow us execute the code in REM. 294 293 */ 295 if (PATMIsPatchGCAddr(pVM, p Ctx->eip))296 { 297 Log(("emR3RawExecuteInstruction: In patch block. eip=%RRv\n", (RTRCPTR)p Ctx->eip));294 if (PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)) 295 { 296 Log(("emR3RawExecuteInstruction: In patch block. eip=%RRv\n", (RTRCPTR)pVCpu->cpum.GstCtx.eip)); 298 297 299 298 RTGCPTR uNewEip; 300 rc = PATMR3HandleTrap(pVM, pCtx, pCtx->eip, &uNewEip);299 rc = PATMR3HandleTrap(pVM, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.eip, &uNewEip); 301 300 switch (rc) 302 301 { … … 307 306 case VINF_SUCCESS: 308 307 Log(("emR3RawExecuteInstruction: Executing instruction starting at new address %RGv IF=%d VMIF=%x\n", 309 uNewEip, p Ctx->eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags));310 p Ctx->eip = uNewEip;311 Assert(p Ctx->eip);312 313 if (p Ctx->eflags.Bits.u1IF)308 uNewEip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags)); 309 pVCpu->cpum.GstCtx.eip = uNewEip; 310 Assert(pVCpu->cpum.GstCtx.eip); 311 312 if (pVCpu->cpum.GstCtx.eflags.Bits.u1IF) 314 313 { 315 314 /* … … 331 330 case VINF_PATCH_EMULATE_INSTR: 332 331 Log(("emR3RawExecuteInstruction: Emulate patched instruction at %RGv IF=%d VMIF=%x\n", 333 uNewEip, p Ctx->eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags));334 p Ctx->eip = uNewEip;332 uNewEip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags)); 333 pVCpu->cpum.GstCtx.eip = uNewEip; 335 334 return emR3RawExecuteInstruction(pVM, pVCpu, "PATCHIR"); 336 335 … … 340 339 case VERR_PATCH_DISABLED: 341 340 Log(("emR3RawExecuteInstruction: Disabled patch -> new eip %RGv IF=%d VMIF=%x\n", 342 uNewEip, p Ctx->eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags));343 p Ctx->eip = uNewEip;344 if (p Ctx->eflags.Bits.u1IF)341 uNewEip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags)); 342 pVCpu->cpum.GstCtx.eip = uNewEip; 343 if (pVCpu->cpum.GstCtx.eflags.Bits.u1IF) 345 344 { 346 345 /* … … 369 368 #define VBOX_WITH_FIRST_IEM_STEP_B 370 369 #if defined(VBOX_WITH_FIRST_IEM_STEP_B) || !defined(VBOX_WITH_REM) 371 Log(("EMINS: %04x:%RGv RSP=%RGv\n", p Ctx->cs.Sel, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));370 Log(("EMINS: %04x:%RGv RSP=%RGv\n", pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip, (RTGCPTR)pVCpu->cpum.GstCtx.rsp)); 372 371 STAM_PROFILE_START(&pVCpu->em.s.StatIEMEmu, a); 373 372 rc = VBOXSTRICTRC_TODO(IEMExecOne(pVCpu)); … … 385 384 STAM_PROFILE_START(&pVCpu->em.s.StatREMEmu, b); 386 385 # ifndef VBOX_WITH_FIRST_IEM_STEP_B 387 Log(("EMINS[rem]: %04x:%RGv RSP=%RGv\n", p Ctx->cs.Sel, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));386 Log(("EMINS[rem]: %04x:%RGv RSP=%RGv\n", pVCpu->cpum.GstCtx.cs.Sel, (RTGCPTR)pVCpu->cpum.GstCtx.rip, (RTGCPTR)pVCpu->cpum.GstCtx.rsp)); 388 387 //# elif defined(DEBUG_bird) 389 388 // AssertFailed(); … … 457 456 static int emR3RawGuestTrap(PVM pVM, PVMCPU pVCpu) 458 457 { 459 PCPUMCTX pCtx = pVCpu->em.s.pCtx;460 461 458 /* 462 459 * Get the trap info. … … 484 481 uint32_t uCpl = CPUMGetGuestCPL(pVCpu); 485 482 if ( uCpl == 0 486 && PATMIsPatchGCAddr(pVM, p Ctx->eip))487 { 488 LogFlow(("emR3RawGuestTrap: trap %#x in patch code; eip=%08x\n", u8TrapNo, p Ctx->eip));489 return emR3RawPatchTrap(pVM, pVCpu, pCtx,rc);483 && PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)) 484 { 485 LogFlow(("emR3RawGuestTrap: trap %#x in patch code; eip=%08x\n", u8TrapNo, pVCpu->cpum.GstCtx.eip)); 486 return emR3RawPatchTrap(pVM, pVCpu, rc); 490 487 } 491 488 #endif … … 512 509 ? TRPM_TRAP_HAS_ERRORCODE 513 510 : TRPM_TRAP_NO_ERRORCODE; 514 rc = TRPMForwardTrap(pVCpu, CPUMCTX2CORE( pCtx), u8TrapNo, uErrorCode, enmError, TRPM_TRAP, -1);511 rc = TRPMForwardTrap(pVCpu, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), u8TrapNo, uErrorCode, enmError, TRPM_TRAP, -1); 515 512 if (rc == VINF_SUCCESS /* Don't use RT_SUCCESS */) 516 513 { … … 526 523 */ 527 524 /** @todo move this up before the dispatching? */ 528 if ( (p Ctx->ss.Sel & X86_SEL_RPL) <= 1529 && !p Ctx->eflags.Bits.u1VM)530 { 531 Assert(!PATMIsPatchGCAddr(pVM, p Ctx->eip));532 CSAMR3CheckCodeEx(pVM, pCtx, pCtx->eip);525 if ( (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) <= 1 526 && !pVCpu->cpum.GstCtx.eflags.Bits.u1VM) 527 { 528 Assert(!PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)); 529 CSAMR3CheckCodeEx(pVM, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.eip); 533 530 } 534 531 … … 542 539 */ 543 540 DISCPUSTATE cpu; 544 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pCtx->rip, &cpu, "Guest Trap (#UD): ");541 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.rip, &cpu, "Guest Trap (#UD): "); 545 542 if ( RT_SUCCESS(rc) 546 543 && (cpu.pCurInstr->uOpcode == OP_MONITOR || cpu.pCurInstr->uOpcode == OP_MWAIT)) … … 553 550 AssertRC(rc); 554 551 555 rc = VBOXSTRICTRC_TODO(EMInterpretInstructionDisasState(pVCpu, &cpu, CPUMCTX2CORE(pCtx), 0, EMCODETYPE_SUPERVISOR)); 552 rc = VBOXSTRICTRC_TODO(EMInterpretInstructionDisasState(pVCpu, &cpu, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), 553 0, EMCODETYPE_SUPERVISOR)); 556 554 if (RT_SUCCESS(rc)) 557 555 return rc; … … 568 566 * I/O access. We can easily handle those in RC. */ 569 567 DISCPUSTATE cpu; 570 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pCtx->rip, &cpu, "Guest Trap: ");568 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.rip, &cpu, "Guest Trap: "); 571 569 if ( RT_SUCCESS(rc) 572 570 && (cpu.pCurInstr->fOpType & DISOPTYPE_PORTIO)) … … 591 589 int rc2 = PGMGstGetPage(pVCpu, uCR2, &fFlags, &GCPhys); 592 590 Log(("emR3RawGuestTrap: cs:eip=%04x:%08x: trap=%02x err=%08x cr2=%08x cr0=%08x%s: Phys=%RGp fFlags=%08llx %s %s %s%s rc2=%d\n", 593 p Ctx->cs.Sel, pCtx->eip, u8TrapNo, uErrorCode, uCR2, (uint32_t)pCtx->cr0,591 pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, u8TrapNo, uErrorCode, uCR2, (uint32_t)pVCpu->cpum.GstCtx.cr0, 594 592 (enmType == TRPM_SOFTWARE_INT) ? " software" : "", GCPhys, fFlags, 595 593 fFlags & X86_PTE_P ? "P " : "NP", fFlags & X86_PTE_US ? "U" : "S", … … 602 600 */ 603 601 if (u8TrapNo == 14 /* #PG */) 604 p Ctx->cr2 = uCR2;602 pVCpu->cpum.GstCtx.cr2 = uCR2; 605 603 606 604 return VINF_EM_RESCHEDULE_REM; … … 620 618 int rc; 621 619 DISCPUSTATE Cpu; 622 PCPUMCTX pCtx = pVCpu->em.s.pCtx;623 620 624 621 /* 625 622 * sysenter, syscall & callgate 626 623 */ 627 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pCtx->rip, &Cpu, "RSWITCH: ");624 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.rip, &Cpu, "RSWITCH: "); 628 625 if (RT_SUCCESS(rc)) 629 626 { 630 627 if (Cpu.pCurInstr->uOpcode == OP_SYSENTER) 631 628 { 632 if (p Ctx->SysEnter.cs != 0)629 if (pVCpu->cpum.GstCtx.SysEnter.cs != 0) 633 630 { 634 rc = PATMR3InstallPatch(pVM, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE( pCtx), pCtx->eip),631 rc = PATMR3InstallPatch(pVM, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), pVCpu->cpum.GstCtx.eip), 635 632 CPUMGetGuestCodeBits(pVCpu) == 32 ? PATMFL_CODE32 : 0); 636 633 if (RT_SUCCESS(rc)) … … 674 671 * @param pVM The cross context VM structure. 675 672 * @param pVCpu The cross context virtual CPU structure. 676 * @param pCtx Pointer to the guest CPU context.677 673 * @param gcret GC return code. 678 674 */ 679 static int emR3RawPatchTrap(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx,int gcret)675 static int emR3RawPatchTrap(PVM pVM, PVMCPU pVCpu, int gcret) 680 676 { 681 677 uint8_t u8TrapNo; … … 685 681 RTGCUINTPTR uCR2; 686 682 687 Assert(PATMIsPatchGCAddr(pVM, p Ctx->eip));683 Assert(PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)); 688 684 689 685 if (gcret == VINF_PATM_PATCH_INT3) … … 723 719 724 720 DISCPUSTATE Cpu; 725 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pCtx->eip, &Cpu, "Patch code: ");721 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.eip, &Cpu, "Patch code: "); 726 722 if ( RT_SUCCESS(rc) 727 723 && Cpu.pCurInstr->uOpcode == OP_IRET) … … 730 726 731 727 /* Iret crashes are bad as we have already changed the flags on the stack */ 732 rc = PGMPhysSimpleReadGCPtr(pVCpu, &eip, p Ctx->esp, 4);733 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &selCS, p Ctx->esp+4, 4);734 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &uEFlags, p Ctx->esp+8, 4);728 rc = PGMPhysSimpleReadGCPtr(pVCpu, &eip, pVCpu->cpum.GstCtx.esp, 4); 729 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &selCS, pVCpu->cpum.GstCtx.esp+4, 4); 730 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &uEFlags, pVCpu->cpum.GstCtx.esp+8, 4); 735 731 if (rc == VINF_SUCCESS) 736 732 { … … 740 736 uint32_t selSS, esp; 741 737 742 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &esp, p Ctx->esp + 12, 4);743 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &selSS, p Ctx->esp + 16, 4);738 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &esp, pVCpu->cpum.GstCtx.esp + 12, 4); 739 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &selSS, pVCpu->cpum.GstCtx.esp + 16, 4); 744 740 745 741 if (uEFlags & X86_EFL_VM) 746 742 { 747 743 uint32_t selDS, selES, selFS, selGS; 748 rc = PGMPhysSimpleReadGCPtr(pVCpu, &selES, p Ctx->esp + 20, 4);749 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &selDS, p Ctx->esp + 24, 4);750 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &selFS, p Ctx->esp + 28, 4);751 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &selGS, p Ctx->esp + 32, 4);744 rc = PGMPhysSimpleReadGCPtr(pVCpu, &selES, pVCpu->cpum.GstCtx.esp + 20, 4); 745 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &selDS, pVCpu->cpum.GstCtx.esp + 24, 4); 746 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &selFS, pVCpu->cpum.GstCtx.esp + 28, 4); 747 rc |= PGMPhysSimpleReadGCPtr(pVCpu, &selGS, pVCpu->cpum.GstCtx.esp + 32, 4); 752 748 if (rc == VINF_SUCCESS) 753 749 { … … 765 761 #endif /* LOG_ENABLED */ 766 762 Log(("emR3RawPatchTrap: in patch: eip=%08x: trap=%02x err=%08x cr2=%08x cr0=%08x\n", 767 p Ctx->eip, u8TrapNo, uErrorCode, uCR2, (uint32_t)pCtx->cr0));763 pVCpu->cpum.GstCtx.eip, u8TrapNo, uErrorCode, uCR2, (uint32_t)pVCpu->cpum.GstCtx.cr0)); 768 764 769 765 RTGCPTR uNewEip; 770 rc = PATMR3HandleTrap(pVM, pCtx, pCtx->eip, &uNewEip);766 rc = PATMR3HandleTrap(pVM, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.eip, &uNewEip); 771 767 switch (rc) 772 768 { … … 781 777 Log(("emR3RawPatchTrap: Virtual IF flag disabled!!\n")); 782 778 783 p Ctx->eip = uNewEip;784 AssertRelease(p Ctx->eip);785 786 if (p Ctx->eflags.Bits.u1IF)779 pVCpu->cpum.GstCtx.eip = uNewEip; 780 AssertRelease(pVCpu->cpum.GstCtx.eip); 781 782 if (pVCpu->cpum.GstCtx.eflags.Bits.u1IF) 787 783 { 788 784 /* Windows XP lets irets fault intentionally and then takes action based on the opcode; an … … 790 786 */ 791 787 if ( u8TrapNo == X86_XCPT_GP 792 && PATMIsInt3Patch(pVM, p Ctx->eip, NULL, NULL))788 && PATMIsInt3Patch(pVM, pVCpu->cpum.GstCtx.eip, NULL, NULL)) 793 789 { 794 790 /** @todo move to PATMR3HandleTrap */ 795 Log(("Possible Windows XP iret fault at %08RX32\n", p Ctx->eip));796 PATMR3RemovePatch(pVM, p Ctx->eip);791 Log(("Possible Windows XP iret fault at %08RX32\n", pVCpu->cpum.GstCtx.eip)); 792 PATMR3RemovePatch(pVM, pVCpu->cpum.GstCtx.eip); 797 793 } 798 794 … … 812 808 case VINF_PATCH_EMULATE_INSTR: 813 809 Log(("emR3RawPatchTrap: Emulate patched instruction at %RGv IF=%d VMIF=%x\n", 814 uNewEip, p Ctx->eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags));815 p Ctx->eip = uNewEip;816 AssertRelease(p Ctx->eip);810 uNewEip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags)); 811 pVCpu->cpum.GstCtx.eip = uNewEip; 812 AssertRelease(pVCpu->cpum.GstCtx.eip); 817 813 return emR3RawExecuteInstruction(pVM, pVCpu, "PATCHEMUL: "); 818 814 … … 823 819 if (!(pVCpu->em.s.pPatmGCState->uVMFlags & X86_EFL_IF)) 824 820 Log(("emR3RawPatchTrap: Virtual IF flag disabled!!\n")); 825 p Ctx->eip = uNewEip;826 AssertRelease(p Ctx->eip);827 828 if (p Ctx->eflags.Bits.u1IF)821 pVCpu->cpum.GstCtx.eip = uNewEip; 822 AssertRelease(pVCpu->cpum.GstCtx.eip); 823 824 if (pVCpu->cpum.GstCtx.eflags.Bits.u1IF) 829 825 { 830 826 /* … … 861 857 static int emR3RawPrivileged(PVM pVM, PVMCPU pVCpu) 862 858 { 863 PCPUMCTX pCtx = pVCpu->em.s.pCtx; 864 865 Assert(!pCtx->eflags.Bits.u1VM); 859 Assert(!pVCpu->cpum.GstCtx.eflags.Bits.u1VM); 866 860 867 861 if (PATMIsEnabled(pVM)) … … 870 864 * Check if in patch code. 871 865 */ 872 if (PATMR3IsInsidePatchJump(pVM, p Ctx->eip, NULL))866 if (PATMR3IsInsidePatchJump(pVM, pVCpu->cpum.GstCtx.eip, NULL)) 873 867 { 874 868 #ifdef LOG_ENABLED 875 869 DBGFR3_INFO_LOG(pVM, pVCpu, "cpumguest", "PRIV"); 876 870 #endif 877 AssertMsgFailed(("FATAL ERROR: executing random instruction inside generated patch jump %08x\n", p Ctx->eip));871 AssertMsgFailed(("FATAL ERROR: executing random instruction inside generated patch jump %08x\n", pVCpu->cpum.GstCtx.eip)); 878 872 return VERR_EM_RAW_PATCH_CONFLICT; 879 873 } 880 if ( (p Ctx->ss.Sel & X86_SEL_RPL) == 0881 && !p Ctx->eflags.Bits.u1VM882 && !PATMIsPatchGCAddr(pVM, p Ctx->eip))883 { 884 int rc = PATMR3InstallPatch(pVM, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE( pCtx), pCtx->eip),874 if ( (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) == 0 875 && !pVCpu->cpum.GstCtx.eflags.Bits.u1VM 876 && !PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)) 877 { 878 int rc = PATMR3InstallPatch(pVM, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), pVCpu->cpum.GstCtx.eip), 885 879 CPUMGetGuestCodeBits(pVCpu) == 32 ? PATMFL_CODE32 : 0); 886 880 if (RT_SUCCESS(rc)) … … 896 890 897 891 #ifdef LOG_ENABLED 898 if (!PATMIsPatchGCAddr(pVM, p Ctx->eip))892 if (!PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)) 899 893 { 900 894 DBGFR3_INFO_LOG(pVM, pVCpu, "cpumguest", "PRIV"); … … 909 903 int rc; 910 904 911 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pCtx->rip, &Cpu, "PRIV: ");905 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.rip, &Cpu, "PRIV: "); 912 906 if (RT_SUCCESS(rc)) 913 907 { … … 924 918 case OP_CLI: 925 919 STAM_COUNTER_INC(&pStats->StatCli); 926 emR3RecordCli(pVM, pVCpu, p Ctx->rip);920 emR3RecordCli(pVM, pVCpu, pVCpu->cpum.GstCtx.rip); 927 921 break; 928 922 case OP_STI: … … 988 982 } 989 983 #endif /* VBOX_WITH_STATISTICS */ 990 if ( (p Ctx->ss.Sel & X86_SEL_RPL) == 0991 && !p Ctx->eflags.Bits.u1VM984 if ( (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) == 0 985 && !pVCpu->cpum.GstCtx.eflags.Bits.u1VM 992 986 && CPUMGetGuestCodeBits(pVCpu) == 32) 993 987 { … … 996 990 { 997 991 case OP_CLI: 998 p Ctx->eflags.u32 &= ~X86_EFL_IF;992 pVCpu->cpum.GstCtx.eflags.u32 &= ~X86_EFL_IF; 999 993 Assert(Cpu.cbInstr == 1); 1000 p Ctx->rip += Cpu.cbInstr;994 pVCpu->cpum.GstCtx.rip += Cpu.cbInstr; 1001 995 STAM_PROFILE_STOP(&pVCpu->em.s.StatPrivEmu, a); 1002 996 return VINF_EM_RESCHEDULE_REM; /* must go to the recompiler now! */ 1003 997 1004 998 case OP_STI: 1005 p Ctx->eflags.u32 |= X86_EFL_IF;1006 EMSetInhibitInterruptsPC(pVCpu, p Ctx->rip + Cpu.cbInstr);999 pVCpu->cpum.GstCtx.eflags.u32 |= X86_EFL_IF; 1000 EMSetInhibitInterruptsPC(pVCpu, pVCpu->cpum.GstCtx.rip + Cpu.cbInstr); 1007 1001 Assert(Cpu.cbInstr == 1); 1008 p Ctx->rip += Cpu.cbInstr;1002 pVCpu->cpum.GstCtx.rip += Cpu.cbInstr; 1009 1003 STAM_PROFILE_STOP(&pVCpu->em.s.StatPrivEmu, a); 1010 1004 return VINF_SUCCESS; 1011 1005 1012 1006 case OP_HLT: 1013 if (PATMIsPatchGCAddr(pVM, p Ctx->eip))1007 if (PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)) 1014 1008 { 1015 1009 PATMTRANSSTATE enmState; 1016 RTGCPTR pOrgInstrGC = PATMR3PatchToGCPtr(pVM, p Ctx->eip, &enmState);1010 RTGCPTR pOrgInstrGC = PATMR3PatchToGCPtr(pVM, pVCpu->cpum.GstCtx.eip, &enmState); 1017 1011 1018 1012 if (enmState == PATMTRANS_OVERWRITTEN) … … 1021 1015 Assert(rc == VERR_PATCH_DISABLED); 1022 1016 /* Conflict detected, patch disabled */ 1023 Log(("emR3RawPrivileged: detected conflict -> disabled patch at %08RX32\n", p Ctx->eip));1017 Log(("emR3RawPrivileged: detected conflict -> disabled patch at %08RX32\n", pVCpu->cpum.GstCtx.eip)); 1024 1018 1025 1019 enmState = PATMTRANS_SAFE; … … 1027 1021 1028 1022 /* The translation had better be successful. Otherwise we can't recover. */ 1029 AssertReleaseMsg(pOrgInstrGC && enmState != PATMTRANS_OVERWRITTEN, ("Unable to translate instruction address at %08RX32\n", p Ctx->eip));1023 AssertReleaseMsg(pOrgInstrGC && enmState != PATMTRANS_OVERWRITTEN, ("Unable to translate instruction address at %08RX32\n", pVCpu->cpum.GstCtx.eip)); 1030 1024 if (enmState != PATMTRANS_OVERWRITTEN) 1031 p Ctx->eip = pOrgInstrGC;1025 pVCpu->cpum.GstCtx.eip = pOrgInstrGC; 1032 1026 } 1033 1027 /* no break; we could just return VINF_EM_HALT here */ … … 1037 1031 case OP_MOV_DR: 1038 1032 #ifdef LOG_ENABLED 1039 if (PATMIsPatchGCAddr(pVM, p Ctx->eip))1033 if (PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)) 1040 1034 { 1041 1035 DBGFR3_INFO_LOG(pVM, pVCpu, "cpumguest", "PRIV"); … … 1044 1038 #endif 1045 1039 1046 rc = VBOXSTRICTRC_TODO(EMInterpretInstructionDisasState(pVCpu, &Cpu, CPUMCTX2CORE(pCtx), 0, EMCODETYPE_SUPERVISOR)); 1040 rc = VBOXSTRICTRC_TODO(EMInterpretInstructionDisasState(pVCpu, &Cpu, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), 1041 0, EMCODETYPE_SUPERVISOR)); 1047 1042 if (RT_SUCCESS(rc)) 1048 1043 { … … 1056 1051 * us to go to the recompiler. 1057 1052 */ 1058 if ( PATMIsPatchGCAddr(pVM, p Ctx->rip)1059 && (p Ctx->cr0 & (X86_CR0_WP|X86_CR0_PG|X86_CR0_PE)) != (X86_CR0_WP|X86_CR0_PG|X86_CR0_PE))1053 if ( PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.rip) 1054 && (pVCpu->cpum.GstCtx.cr0 & (X86_CR0_WP|X86_CR0_PG|X86_CR0_PE)) != (X86_CR0_WP|X86_CR0_PG|X86_CR0_PE)) 1060 1055 { 1061 1056 PATMTRANSSTATE enmState; 1062 RTGCPTR pOrgInstrGC = PATMR3PatchToGCPtr(pVM, p Ctx->rip, &enmState);1063 1064 Log(("Force recompiler switch due to cr0 (%RGp) update rip=%RGv -> %RGv (enmState=%d)\n", p Ctx->cr0, pCtx->rip, pOrgInstrGC, enmState));1057 RTGCPTR pOrgInstrGC = PATMR3PatchToGCPtr(pVM, pVCpu->cpum.GstCtx.rip, &enmState); 1058 1059 Log(("Force recompiler switch due to cr0 (%RGp) update rip=%RGv -> %RGv (enmState=%d)\n", pVCpu->cpum.GstCtx.cr0, pVCpu->cpum.GstCtx.rip, pOrgInstrGC, enmState)); 1065 1060 if (enmState == PATMTRANS_OVERWRITTEN) 1066 1061 { … … 1068 1063 Assert(rc == VERR_PATCH_DISABLED); 1069 1064 /* Conflict detected, patch disabled */ 1070 Log(("emR3RawPrivileged: detected conflict -> disabled patch at %RGv\n", (RTGCPTR)p Ctx->rip));1065 Log(("emR3RawPrivileged: detected conflict -> disabled patch at %RGv\n", (RTGCPTR)pVCpu->cpum.GstCtx.rip)); 1071 1066 enmState = PATMTRANS_SAFE; 1072 1067 } 1073 1068 /* The translation had better be successful. Otherwise we can't recover. */ 1074 AssertReleaseMsg(pOrgInstrGC && enmState != PATMTRANS_OVERWRITTEN, ("Unable to translate instruction address at %RGv\n", (RTGCPTR)p Ctx->rip));1069 AssertReleaseMsg(pOrgInstrGC && enmState != PATMTRANS_OVERWRITTEN, ("Unable to translate instruction address at %RGv\n", (RTGCPTR)pVCpu->cpum.GstCtx.rip)); 1075 1070 if (enmState != PATMTRANS_OVERWRITTEN) 1076 p Ctx->rip = pOrgInstrGC;1071 pVCpu->cpum.GstCtx.rip = pOrgInstrGC; 1077 1072 } 1078 1073 … … 1089 1084 } 1090 1085 1091 if (PATMIsPatchGCAddr(pVM, p Ctx->eip))1092 return emR3RawPatchTrap(pVM, pVCpu, pCtx,VINF_PATM_PATCH_TRAP_GP);1086 if (PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)) 1087 return emR3RawPatchTrap(pVM, pVCpu, VINF_PATM_PATCH_TRAP_GP); 1093 1088 1094 1089 return emR3RawExecuteInstruction(pVM, pVCpu, "PRIV"); … … 1111 1106 * @param pVM The cross context VM structure. 1112 1107 * @param pVCpu The cross context virtual CPU structure. 1113 * @param pCtx Pointer to the guest CPU context.1114 1108 * @param rc The result code. 1115 1109 */ 1116 int emR3RawUpdateForceFlag(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, int rc)1110 static int emR3RawUpdateForceFlag(PVM pVM, PVMCPU pVCpu, int rc) 1117 1111 { 1118 if (PATMIsPatchGCAddr(pVM, p Ctx->eip)) /** @todo check cs selector base/type */1112 if (PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)) /** @todo check cs selector base/type */ 1119 1113 { 1120 1114 /* ignore reschedule attempts. */ … … 1145 1139 VMMR3_INT_DECL(int) EMR3CheckRawForcedActions(PVM pVM, PVMCPU pVCpu) 1146 1140 { 1147 int rc = emR3RawForcedActions(pVM, pVCpu , pVCpu->em.s.pCtx);1141 int rc = emR3RawForcedActions(pVM, pVCpu); 1148 1142 VBOXVMM_EM_FF_RAW_RET(pVCpu, rc); 1149 1143 return rc; … … 1160 1154 * @param pVM The cross context VM structure. 1161 1155 * @param pVCpu The cross context virtual CPU structure. 1162 * @param pCtx Pointer to the guest CPU context.1163 1156 */ 1164 static int emR3RawForcedActions(PVM pVM, PVMCPU pVCpu , PCPUMCTX pCtx)1157 static int emR3RawForcedActions(PVM pVM, PVMCPU pVCpu) 1165 1158 { 1166 1159 /* … … 1193 1186 && CSAMIsEnabled(pVM)) 1194 1187 { 1195 int rc = PGMSyncCR3(pVCpu, p Ctx->cr0, pCtx->cr3, pCtx->cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3));1188 int rc = PGMSyncCR3(pVCpu, pVCpu->cpum.GstCtx.cr0, pVCpu->cpum.GstCtx.cr3, pVCpu->cpum.GstCtx.cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3)); 1196 1189 if (RT_FAILURE(rc)) 1197 1190 return rc; … … 1219 1212 { 1220 1213 Assert(pVCpu->em.s.enmState != EMSTATE_WAIT_SIPI); 1221 int rc = PGMSyncCR3(pVCpu, p Ctx->cr0, pCtx->cr3, pCtx->cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3));1214 int rc = PGMSyncCR3(pVCpu, pVCpu->cpum.GstCtx.cr0, pVCpu->cpum.GstCtx.cr3, pVCpu->cpum.GstCtx.cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3)); 1222 1215 if (RT_FAILURE(rc)) 1223 1216 return rc == VERR_PGM_NO_HYPERVISOR_ADDRESS ? VINF_EM_RESCHEDULE_REM : rc; … … 1227 1220 /* Prefetch pages for EIP and ESP. */ 1228 1221 /** @todo This is rather expensive. Should investigate if it really helps at all. */ 1229 rc = PGMPrefetchPage(pVCpu, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE( pCtx), pCtx->rip));1222 rc = PGMPrefetchPage(pVCpu, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), pVCpu->cpum.GstCtx.rip)); 1230 1223 if (rc == VINF_SUCCESS) 1231 rc = PGMPrefetchPage(pVCpu, SELMToFlat(pVM, DISSELREG_SS, CPUMCTX2CORE( pCtx), pCtx->rsp));1224 rc = PGMPrefetchPage(pVCpu, SELMToFlat(pVM, DISSELREG_SS, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), pVCpu->cpum.GstCtx.rsp)); 1232 1225 if (rc != VINF_SUCCESS) 1233 1226 { … … 1237 1230 return rc; 1238 1231 } 1239 rc = PGMSyncCR3(pVCpu, p Ctx->cr0, pCtx->cr3, pCtx->cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3));1232 rc = PGMSyncCR3(pVCpu, pVCpu->cpum.GstCtx.cr0, pVCpu->cpum.GstCtx.cr3, pVCpu->cpum.GstCtx.cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3)); 1240 1233 if (RT_FAILURE(rc)) 1241 1234 return rc; … … 1288 1281 1289 1282 int rc = VERR_IPE_UNINITIALIZED_STATUS; 1290 PCPUMCTX pCtx = pVCpu->em.s.pCtx; 1291 LogFlow(("emR3RawExecute: (cs:eip=%04x:%08x)\n", pCtx->cs.Sel, pCtx->eip)); 1283 LogFlow(("emR3RawExecute: (cs:eip=%04x:%08x)\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip)); 1292 1284 pVCpu->em.s.fForceRAW = false; 1293 1285 *pfFFDone = false; … … 1308 1300 */ 1309 1301 #ifdef VBOX_STRICT 1310 Assert(p Ctx->eflags.Bits.u1VM || (pCtx->ss.Sel & X86_SEL_RPL) == 3 || (pCtx->ss.Sel & X86_SEL_RPL) == 01311 || (EMIsRawRing1Enabled(pVM) && (p Ctx->ss.Sel & X86_SEL_RPL) == 1));1312 AssertMsg( (p Ctx->eflags.u32 & X86_EFL_IF)1313 || PATMShouldUseRawMode(pVM, (RTGCPTR)p Ctx->eip),1314 ("Tried to execute code with IF at EIP=%08x!\n", p Ctx->eip));1302 Assert(pVCpu->cpum.GstCtx.eflags.Bits.u1VM || (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) == 3 || (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) == 0 1303 || (EMIsRawRing1Enabled(pVM) && (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) == 1)); 1304 AssertMsg( (pVCpu->cpum.GstCtx.eflags.u32 & X86_EFL_IF) 1305 || PATMShouldUseRawMode(pVM, (RTGCPTR)pVCpu->cpum.GstCtx.eip), 1306 ("Tried to execute code with IF at EIP=%08x!\n", pVCpu->cpum.GstCtx.eip)); 1315 1307 if ( !VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL) 1316 1308 && PGMMapHasConflicts(pVM)) … … 1328 1320 || VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_HIGH_PRIORITY_PRE_RAW_MASK)) 1329 1321 { 1330 rc = emR3RawForcedActions(pVM, pVCpu , pCtx);1322 rc = emR3RawForcedActions(pVM, pVCpu); 1331 1323 VBOXVMM_EM_FF_RAW_RET(pVCpu, rc); 1332 1324 if (rc != VINF_SUCCESS) … … 1349 1341 * Scan code before executing it. Don't bother with user mode or V86 code 1350 1342 */ 1351 if ( (p Ctx->ss.Sel & X86_SEL_RPL) <= 11352 && !p Ctx->eflags.Bits.u1VM1353 && !PATMIsPatchGCAddr(pVM, p Ctx->eip))1343 if ( (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) <= 1 1344 && !pVCpu->cpum.GstCtx.eflags.Bits.u1VM 1345 && !PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)) 1354 1346 { 1355 1347 STAM_PROFILE_ADV_SUSPEND(&pVCpu->em.s.StatRAWEntry, b); 1356 CSAMR3CheckCodeEx(pVM, pCtx, pCtx->eip);1348 CSAMR3CheckCodeEx(pVM, &pVCpu->cpum.GstCtx, pVCpu->cpum.GstCtx.eip); 1357 1349 STAM_PROFILE_ADV_RESUME(&pVCpu->em.s.StatRAWEntry, b); 1358 1350 if ( VM_FF_IS_PENDING(pVM, VM_FF_HIGH_PRIORITY_PRE_RAW_MASK) 1359 1351 || VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_HIGH_PRIORITY_PRE_RAW_MASK)) 1360 1352 { 1361 rc = emR3RawForcedActions(pVM, pVCpu , pCtx);1353 rc = emR3RawForcedActions(pVM, pVCpu); 1362 1354 VBOXVMM_EM_FF_RAW_RET(pVCpu, rc); 1363 1355 if (rc != VINF_SUCCESS) … … 1374 1366 */ 1375 1367 PPATMGCSTATE pGCState = PATMR3QueryGCStateHC(pVM); 1376 if (p Ctx->eflags.Bits.u1VM)1377 Log(("RV86: %04x:%08x IF=%d VMFlags=%x\n", p Ctx->cs.Sel, pCtx->eip, pCtx->eflags.Bits.u1IF, pGCState->uVMFlags));1378 else if ((p Ctx->ss.Sel & X86_SEL_RPL) == 1)1368 if (pVCpu->cpum.GstCtx.eflags.Bits.u1VM) 1369 Log(("RV86: %04x:%08x IF=%d VMFlags=%x\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pGCState->uVMFlags)); 1370 else if ((pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) == 1) 1379 1371 Log(("RR0: %x:%08x ESP=%x:%08x EFL=%x IF=%d/%d VMFlags=%x PIF=%d CPL=%d (Scanned=%d)\n", 1380 p Ctx->cs.Sel, pCtx->eip, pCtx->ss.Sel, pCtx->esp, CPUMRawGetEFlags(pVCpu), !!(pGCState->uVMFlags & X86_EFL_IF), pCtx->eflags.Bits.u1IF,1381 pGCState->uVMFlags, pGCState->fPIF, (p Ctx->ss.Sel & X86_SEL_RPL), CSAMIsPageScanned(pVM, (RTGCPTR)pCtx->eip)));1372 pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.ss.Sel, pVCpu->cpum.GstCtx.esp, CPUMRawGetEFlags(pVCpu), !!(pGCState->uVMFlags & X86_EFL_IF), pVCpu->cpum.GstCtx.eflags.Bits.u1IF, 1373 pGCState->uVMFlags, pGCState->fPIF, (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL), CSAMIsPageScanned(pVM, (RTGCPTR)pVCpu->cpum.GstCtx.eip))); 1382 1374 # ifdef VBOX_WITH_RAW_RING1 1383 else if ((p Ctx->ss.Sel & X86_SEL_RPL) == 2)1384 Log(("RR1: %x:%08x ESP=%x:%08x IF=%d VMFlags=%x CPL=%x\n", p Ctx->cs.Sel, pCtx->eip, pCtx->ss.Sel, pCtx->esp, pCtx->eflags.Bits.u1IF, pGCState->uVMFlags, (pCtx->ss.Sel & X86_SEL_RPL)));1375 else if ((pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) == 2) 1376 Log(("RR1: %x:%08x ESP=%x:%08x IF=%d VMFlags=%x CPL=%x\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.ss.Sel, pVCpu->cpum.GstCtx.esp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pGCState->uVMFlags, (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL))); 1385 1377 # endif 1386 else if ((p Ctx->ss.Sel & X86_SEL_RPL) == 3)1387 Log(("RR3: %x:%08x ESP=%x:%08x IF=%d VMFlags=%x\n", p Ctx->cs.Sel, pCtx->eip, pCtx->ss.Sel, pCtx->esp, pCtx->eflags.Bits.u1IF, pGCState->uVMFlags));1378 else if ((pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) == 3) 1379 Log(("RR3: %x:%08x ESP=%x:%08x IF=%d VMFlags=%x\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.ss.Sel, pVCpu->cpum.GstCtx.esp, pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pGCState->uVMFlags)); 1388 1380 #endif /* LOG_ENABLED */ 1389 1381 … … 1397 1389 { 1398 1390 STAM_PROFILE_START(&pVCpu->em.s.StatRAWExec, c); 1399 VBOXVMM_EM_RAW_RUN_PRE(pVCpu, pCtx);1391 VBOXVMM_EM_RAW_RUN_PRE(pVCpu, &pVCpu->cpum.GstCtx); 1400 1392 rc = VMMR3RawRunGC(pVM, pVCpu); 1401 VBOXVMM_EM_RAW_RUN_RET(pVCpu, pCtx, rc);1393 VBOXVMM_EM_RAW_RUN_RET(pVCpu, &pVCpu->cpum.GstCtx, rc); 1402 1394 STAM_PROFILE_STOP(&pVCpu->em.s.StatRAWExec, c); 1403 1395 } … … 1413 1405 1414 1406 LogFlow(("RR%u-E: %08x ESP=%08x EFL=%x IF=%d/%d VMFlags=%x PIF=%d\n", 1415 (p Ctx->ss.Sel & X86_SEL_RPL), pCtx->eip, pCtx->esp, CPUMRawGetEFlags(pVCpu),1416 !!(pGCState->uVMFlags & X86_EFL_IF), p Ctx->eflags.Bits.u1IF, pGCState->uVMFlags, pGCState->fPIF));1407 (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL), pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.esp, CPUMRawGetEFlags(pVCpu), 1408 !!(pGCState->uVMFlags & X86_EFL_IF), pVCpu->cpum.GstCtx.eflags.Bits.u1IF, pGCState->uVMFlags, pGCState->fPIF)); 1417 1409 LogFlow(("VMMR3RawRunGC returned %Rrc\n", rc)); 1418 1410 … … 1450 1442 1451 1443 default: 1452 if (PATMIsPatchGCAddr(pVM, p Ctx->eip) && !(pCtx->eflags.u32 & X86_EFL_TF))1444 if (PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip) && !(pVCpu->cpum.GstCtx.eflags.u32 & X86_EFL_TF)) 1453 1445 LogIt(0, LOG_GROUP_PATM, ("Patch code interrupted at %RRv for reason %Rrc\n", (RTRCPTR)CPUMGetGuestEIP(pVCpu), rc)); 1454 1446 break; … … 1474 1466 break; 1475 1467 } 1476 rc = emR3RawHandleRC(pVM, pVCpu, pCtx,rc);1468 rc = emR3RawHandleRC(pVM, pVCpu, rc); 1477 1469 if (rc != VINF_SUCCESS) 1478 1470 { 1479 rc = emR3RawUpdateForceFlag(pVM, pVCpu, pCtx,rc);1471 rc = emR3RawUpdateForceFlag(pVM, pVCpu, rc); 1480 1472 if (rc != VINF_SUCCESS) 1481 1473 { … … 1495 1487 || VMCPU_FF_IS_PENDING(pVCpu, ~VMCPU_FF_HIGH_PRIORITY_PRE_RAW_MASK)) 1496 1488 { 1497 Assert(p Ctx->eflags.Bits.u1VM || (pCtx->ss.Sel & X86_SEL_RPL) != (EMIsRawRing1Enabled(pVM) ? 2U : 1U));1489 Assert(pVCpu->cpum.GstCtx.eflags.Bits.u1VM || (pVCpu->cpum.GstCtx.ss.Sel & X86_SEL_RPL) != (EMIsRawRing1Enabled(pVM) ? 2U : 1U)); 1498 1490 1499 1491 STAM_REL_PROFILE_ADV_SUSPEND(&pVCpu->em.s.StatRAWTotal, a); … … 1504 1496 && rc != VINF_EM_RESCHEDULE_RAW) 1505 1497 { 1506 rc = emR3RawUpdateForceFlag(pVM, pVCpu, pCtx,rc);1498 rc = emR3RawUpdateForceFlag(pVM, pVCpu, rc); 1507 1499 if (rc != VINF_SUCCESS) 1508 1500 { -
trunk/src/VBox/VMM/VMMR3/NEMR3.cpp
r72575 r72634 364 364 365 365 366 VMMR3_INT_DECL(bool) NEMR3CanExecuteGuest(PVM pVM, PVMCPU pVCpu , PCPUMCTX pCtx)366 VMMR3_INT_DECL(bool) NEMR3CanExecuteGuest(PVM pVM, PVMCPU pVCpu) 367 367 { 368 368 Assert(VM_IS_NEM_ENABLED(pVM)); 369 369 #ifdef VBOX_WITH_NATIVE_NEM 370 return nemR3NativeCanExecuteGuest(pVM, pVCpu , pCtx);371 #else 372 NOREF(pVM); NOREF(pVCpu); NOREF(pCtx);370 return nemR3NativeCanExecuteGuest(pVM, pVCpu); 371 #else 372 NOREF(pVM); NOREF(pVCpu); 373 373 return false; 374 374 #endif -
trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp
r72555 r72634 2277 2277 2278 2278 2279 bool nemR3NativeCanExecuteGuest(PVM pVM, PVMCPU pVCpu , PCPUMCTX pCtx)2280 { 2281 NOREF(pVM); NOREF(pVCpu); NOREF(pCtx);2279 bool nemR3NativeCanExecuteGuest(PVM pVM, PVMCPU pVCpu) 2280 { 2281 NOREF(pVM); NOREF(pVCpu); 2282 2282 return true; 2283 2283 } -
trunk/src/VBox/VMM/include/EMHandleRCTmpl.h
r72580 r72634 25 25 26 26 /** 27 * Process a subset of the raw-mode and hmreturn codes.27 * Process a subset of the raw-mode, HM and NEM return codes. 28 28 * 29 29 * Since we have to share this with raw-mode single stepping, this inline … … 35 35 * @param pVM The cross context VM structure. 36 36 * @param pVCpu The cross context virtual CPU structure. 37 * @param pCtx Pointer to the guest CPU context.38 37 * @param rc The return code. 39 38 */ 40 39 #ifdef EMHANDLERC_WITH_PATM 41 int emR3RawHandleRC(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx,int rc)40 int emR3RawHandleRC(PVM pVM, PVMCPU pVCpu, int rc) 42 41 #elif defined(EMHANDLERC_WITH_HM) || defined(DOXYGEN_RUNNING) 43 int emR3HmHandleRC(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx,int rc)42 int emR3HmHandleRC(PVM pVM, PVMCPU pVCpu, int rc) 44 43 #elif defined(EMHANDLERC_WITH_NEM) 45 int emR3NemHandleRC(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx,int rc)44 int emR3NemHandleRC(PVM pVM, PVMCPU pVCpu, int rc) 46 45 #endif 47 46 { 48 NOREF(pCtx);49 50 47 switch (rc) 51 48 { … … 77 74 * Got a trap which needs dispatching. 78 75 */ 79 if (PATMR3IsInsidePatchJump(pVM, p Ctx->eip, NULL))76 if (PATMR3IsInsidePatchJump(pVM, pVCpu->cpum.GstCtx.eip, NULL)) 80 77 { 81 78 AssertReleaseMsgFailed(("FATAL ERROR: executing random instruction inside generated patch jump %08X\n", CPUMGetGuestEIP(pVCpu))); … … 91 88 case VINF_PATM_PATCH_TRAP_PF: 92 89 case VINF_PATM_PATCH_INT3: 93 rc = emR3RawPatchTrap(pVM, pVCpu, pCtx,rc);90 rc = emR3RawPatchTrap(pVM, pVCpu, rc); 94 91 break; 95 92 96 93 case VINF_PATM_DUPLICATE_FUNCTION: 97 Assert(PATMIsPatchGCAddr(pVM, p Ctx->eip));98 rc = PATMR3DuplicateFunctionRequest(pVM, pCtx);94 Assert(PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)); 95 rc = PATMR3DuplicateFunctionRequest(pVM, &pVCpu->cpum.GstCtx); 99 96 AssertRC(rc); 100 97 rc = VINF_SUCCESS; … … 118 115 */ 119 116 case VINF_PATM_HC_MMIO_PATCH_READ: 120 rc = PATMR3InstallPatch(pVM, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE( pCtx), pCtx->eip),117 rc = PATMR3InstallPatch(pVM, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(&pVCpu->cpum.GstCtx), pVCpu->cpum.GstCtx.eip), 121 118 PATMFL_MMIO_ACCESS 122 119 | (CPUMGetGuestCodeBits(pVCpu) == 32 ? PATMFL_CODE32 : 0)); … … 167 164 case VINF_PGM_CHANGE_MODE: 168 165 CPUM_ASSERT_NOT_EXTRN(pVCpu, CPUMCTX_EXTRN_CR0 | CPUMCTX_EXTRN_CR3 | CPUMCTX_EXTRN_CR4 | CPUMCTX_EXTRN_EFER); 169 rc = PGMChangeMode(pVCpu, p Ctx->cr0, pCtx->cr4, pCtx->msrEFER);166 rc = PGMChangeMode(pVCpu, pVCpu->cpum.GstCtx.cr0, pVCpu->cpum.GstCtx.cr4, pVCpu->cpum.GstCtx.msrEFER); 170 167 if (rc == VINF_SUCCESS) 171 168 rc = VINF_EM_RESCHEDULE; … … 188 185 case VINF_EM_RAW_RING_SWITCH_INT: 189 186 Assert(TRPMHasTrap(pVCpu)); 190 Assert(!PATMIsPatchGCAddr(pVM, p Ctx->eip));187 Assert(!PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)); 191 188 192 189 if (TRPMHasTrap(pVCpu)) … … 260 257 */ 261 258 case VINF_EM_RAW_EMULATE_IO_BLOCK: 262 rc = HMR3EmulateIoBlock(pVM, pCtx);259 rc = HMR3EmulateIoBlock(pVM, &pVCpu->cpum.GstCtx); 263 260 break; 264 261 265 262 case VINF_EM_HM_PATCH_TPR_INSTR: 266 rc = HMR3PatchTprInstr(pVM, pVCpu, pCtx);263 rc = HMR3PatchTprInstr(pVM, pVCpu, &pVCpu->cpum.GstCtx); 267 264 break; 268 265 #endif … … 313 310 case VINF_EM_RAW_IRET_TRAP: 314 311 /* We will not go to the recompiler if EIP points to patch code. */ 315 if (PATMIsPatchGCAddr(pVM, p Ctx->eip))312 if (PATMIsPatchGCAddr(pVM, pVCpu->cpum.GstCtx.eip)) 316 313 { 317 p Ctx->eip = PATMR3PatchToGCPtr(pVM, (RTGCPTR)pCtx->eip, 0);314 pVCpu->cpum.GstCtx.eip = PATMR3PatchToGCPtr(pVM, (RTGCPTR)pVCpu->cpum.GstCtx.eip, 0); 318 315 } 319 316 LogFlow(("emR3RawHandleRC: %Rrc -> %Rrc\n", rc, VINF_EM_RESCHEDULE_REM)); -
trunk/src/VBox/VMM/include/EMInternal.h
r72583 r72634 399 399 RTR3PTR R3PtrPaddingNoRaw; 400 400 #endif 401 402 /** Pointer to the guest CPUM state. (R3 Ptr) 403 * @deprecated Use pVCpu->cpum.GstCtx! */ 404 R3PTRTYPE(PCPUMCTX) pCtx; 405 401 RTR3PTR R3PtrNullPadding; /**< Used to be pCtx. */ 406 402 #if GC_ARCH_BITS == 64 407 403 RTGCPTR aPadding1; … … 550 546 /** @} */ 551 547 552 int emR3InitDbg(PVM pVM); 553 554 int emR3HmExecute(PVM pVM, PVMCPU pVCpu, bool *pfFFDone); 555 VBOXSTRICTRC emR3NemExecute(PVM pVM, PVMCPU pVCpu, bool *pfFFDone); 556 int emR3RawExecute(PVM pVM, PVMCPU pVCpu, bool *pfFFDone); 557 558 int emR3RawHandleRC(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, int rc); 559 int emR3HmHandleRC(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, int rc); 560 int emR3NemHandleRC(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, int rc); 561 562 EMSTATE emR3Reschedule(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); 563 int emR3ForcedActions(PVM pVM, PVMCPU pVCpu, int rc); 564 VBOXSTRICTRC emR3HighPriorityPostForcedActions(PVM pVM, PVMCPU pVCpu, VBOXSTRICTRC rc); 565 566 int emR3RawUpdateForceFlag(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, int rc); 567 int emR3RawResumeHyper(PVM pVM, PVMCPU pVCpu); 568 int emR3RawStep(PVM pVM, PVMCPU pVCpu); 569 570 VBOXSTRICTRC emR3NemSingleInstruction(PVM pVM, PVMCPU pVCpu, uint32_t fFlags); 571 572 int emR3SingleStepExecRem(PVM pVM, PVMCPU pVCpu, uint32_t cIterations); 573 574 bool emR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu); 575 576 VBOXSTRICTRC emR3ExecutePendingIoPortWrite(PVM pVM, PVMCPU pVCpu); 577 VBOXSTRICTRC emR3ExecutePendingIoPortRead(PVM pVM, PVMCPU pVCpu); 548 int emR3InitDbg(PVM pVM); 549 550 int emR3HmExecute(PVM pVM, PVMCPU pVCpu, bool *pfFFDone); 551 VBOXSTRICTRC emR3NemExecute(PVM pVM, PVMCPU pVCpu, bool *pfFFDone); 552 int emR3RawExecute(PVM pVM, PVMCPU pVCpu, bool *pfFFDone); 553 554 EMSTATE emR3Reschedule(PVM pVM, PVMCPU pVCpu); 555 int emR3ForcedActions(PVM pVM, PVMCPU pVCpu, int rc); 556 VBOXSTRICTRC emR3HighPriorityPostForcedActions(PVM pVM, PVMCPU pVCpu, VBOXSTRICTRC rc); 557 558 int emR3RawResumeHyper(PVM pVM, PVMCPU pVCpu); 559 int emR3RawStep(PVM pVM, PVMCPU pVCpu); 560 561 VBOXSTRICTRC emR3NemSingleInstruction(PVM pVM, PVMCPU pVCpu, uint32_t fFlags); 562 563 int emR3SingleStepExecRem(PVM pVM, PVMCPU pVCpu, uint32_t cIterations); 564 565 bool emR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu); 566 567 VBOXSTRICTRC emR3ExecutePendingIoPortWrite(PVM pVM, PVMCPU pVCpu); 568 VBOXSTRICTRC emR3ExecutePendingIoPortRead(PVM pVM, PVMCPU pVCpu); 578 569 579 570 RT_C_DECLS_END -
trunk/src/VBox/VMM/include/NEMInternal.h
r72575 r72634 398 398 void nemR3NativeResetCpu(PVMCPU pVCpu, bool fInitIpi); 399 399 VBOXSTRICTRC nemR3NativeRunGC(PVM pVM, PVMCPU pVCpu); 400 bool nemR3NativeCanExecuteGuest(PVM pVM, PVMCPU pVCpu , PCPUMCTX pCtx);400 bool nemR3NativeCanExecuteGuest(PVM pVM, PVMCPU pVCpu); 401 401 bool nemR3NativeSetSingleInstruction(PVM pVM, PVMCPU pVCpu, bool fEnable); 402 402 void nemR3NativeNotifyFF(PVM pVM, PVMCPU pVCpu, uint32_t fFlags); -
trunk/src/VBox/VMM/testcase/tstVMStruct.h
r72494 r72634 272 272 GEN_CHECK_SIZE(EM); 273 273 GEN_CHECK_OFF(EM, offVM); 274 GEN_CHECK_OFF(EMCPU, pCtx);275 274 GEN_CHECK_OFF(EMCPU, enmState); 276 275 GEN_CHECK_OFF(EMCPU, fForceRAW);
Note:
See TracChangeset
for help on using the changeset viewer.