Changeset 68434 in vbox
- Timestamp:
- Aug 17, 2017 8:28:18 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 117577
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/HMSVMAll.cpp
r68433 r68434 350 350 { 351 351 PSVMVMCBCTRL pVmcbNstGstCtrl = &pVmcbNstGst->ctrl; 352 PSVMVMCBSTATESAVE pVmcbNstGstState = &pVmcbNstGst->guest;352 PSVMVMCBSTATESAVE pVmcbNstGstState = &pVmcbNstGst->guest; 353 353 pVmcbNstGstCtrl->u16InterceptRdCRx = pNstGstVmcbCache->u16InterceptRdCRx; 354 354 pVmcbNstGstCtrl->u16InterceptWrCRx = pNstGstVmcbCache->u16InterceptWrCRx; -
trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp
r68433 r68434 1374 1374 AssertRC(rc); 1375 1375 pVmcbNstGst->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_CRX_EFER; 1376 Log4(("hmR0SvmLoadGuestControlRegsNested: CR3=%#RX64 to HC phys CR3=%#RHp\n", pCtx->cr3, pVmcbNstGst->guest.u64CR3)); 1376 1377 HMCPU_CF_CLEAR(pVCpu, HM_CHANGED_GUEST_CR3); 1377 1378 } … … 1795 1796 * well and handle it accordingly. 1796 1797 * 1798 * @param pVCpu The cross context virtual CPU structure. 1797 1799 * @param pVmcb Pointer to the VM control block. 1798 1800 * @param pVmcbNstGst Pointer to the nested-guest VM control block. 1799 1801 */ 1800 static void hmR0SvmMergeIntercepts(PCSVMVMCB pVmcb, PSVMVMCB pVmcbNstGst) 1801 { 1802 pVmcbNstGst->ctrl.u16InterceptRdCRx |= pVmcb->ctrl.u16InterceptRdCRx; 1803 pVmcbNstGst->ctrl.u16InterceptWrCRx |= pVmcb->ctrl.u16InterceptWrCRx; 1804 1805 /** @todo Figure out debugging with nested-guests, till then just intercept 1806 * all DR[0-15] accesses. */ 1807 pVmcbNstGst->ctrl.u16InterceptRdDRx |= 0xffff; 1808 pVmcbNstGst->ctrl.u16InterceptWrDRx |= 0xffff; 1809 1810 pVmcbNstGst->ctrl.u32InterceptXcpt |= pVmcb->ctrl.u32InterceptXcpt; 1811 pVmcbNstGst->ctrl.u64InterceptCtrl |= pVmcb->ctrl.u64InterceptCtrl 1812 | HMSVM_MANDATORY_NESTED_GUEST_CTRL_INTERCEPTS; 1813 1814 Assert((pVmcbNstGst->ctrl.u64InterceptCtrl & HMSVM_MANDATORY_GUEST_CTRL_INTERCEPTS) == HMSVM_MANDATORY_GUEST_CTRL_INTERCEPTS); 1802 static void hmR0SvmLoadGuestXcptInterceptsNested(PVMCPU pVCpu, PSVMVMCB pVmcb, PSVMVMCB pVmcbNstGst) 1803 { 1804 if (HMCPU_CF_IS_PENDING(pVCpu, HM_CHANGED_GUEST_XCPT_INTERCEPTS)) 1805 { 1806 hmR0SvmLoadGuestXcptIntercepts(pVCpu, pVmcb); 1807 1808 pVmcbNstGst->ctrl.u16InterceptRdCRx |= pVmcb->ctrl.u16InterceptRdCRx; 1809 pVmcbNstGst->ctrl.u16InterceptWrCRx |= pVmcb->ctrl.u16InterceptWrCRx; 1810 1811 /** @todo Figure out debugging with nested-guests, till then just intercept 1812 * all DR[0-15] accesses. */ 1813 pVmcbNstGst->ctrl.u16InterceptRdDRx |= 0xffff; 1814 pVmcbNstGst->ctrl.u16InterceptWrDRx |= 0xffff; 1815 1816 pVmcbNstGst->ctrl.u32InterceptXcpt |= pVmcb->ctrl.u32InterceptXcpt; 1817 pVmcbNstGst->ctrl.u64InterceptCtrl |= pVmcb->ctrl.u64InterceptCtrl 1818 | HMSVM_MANDATORY_NESTED_GUEST_CTRL_INTERCEPTS; 1819 1820 Assert( (pVmcbNstGst->ctrl.u64InterceptCtrl & HMSVM_MANDATORY_GUEST_CTRL_INTERCEPTS) 1821 == HMSVM_MANDATORY_GUEST_CTRL_INTERCEPTS); 1822 1823 Assert(!HMCPU_CF_IS_PENDING(pVCpu, HM_CHANGED_GUEST_XCPT_INTERCEPTS)); 1824 } 1815 1825 } 1816 1826 #endif … … 2029 2039 #ifdef VBOX_WITH_NESTED_HWVIRT 2030 2040 /** 2031 * Caches the nested-guest VMCB fields before we modify them for executi ng the2032 * nested-guest under SVM R0.2041 * Caches the nested-guest VMCB fields before we modify them for execution using 2042 * hardware-assisted SVM. 2033 2043 * 2034 2044 * @param pCtx Pointer to the guest-CPU context. … … 2039 2049 { 2040 2050 PSVMVMCB pVmcbNstGst = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); 2041 P SVMVMCBCTRLpVmcbNstGstCtrl = &pVmcbNstGst->ctrl;2042 P SVMVMCBSTATESAVEpVmcbNstGstState = &pVmcbNstGst->guest;2051 PCSVMVMCBCTRL pVmcbNstGstCtrl = &pVmcbNstGst->ctrl; 2052 PCSVMVMCBSTATESAVE pVmcbNstGstState = &pVmcbNstGst->guest; 2043 2053 PSVMNESTEDVMCBCACHE pNstGstVmcbCache = &pVCpu->hm.s.svm.NstGstVmcbCache; 2044 2054 … … 2060 2070 2061 2071 /** 2062 * Sets up the nested-guest for hardware-assisted SVM execution.2072 * Sets up the nested-guest VMCB for execution using hardware-assisted SVM. 2063 2073 * 2064 2074 * @param pVCpu The cross context virtual CPU structure. 2065 2075 * @param pCtx Pointer to the guest-CPU context. 2066 2076 */ 2077 static void hmR0SvmVmRunSetupVmcb(PVMCPU pVCpu, PCPUMCTX pCtx) 2078 { 2079 RT_NOREF(pVCpu); 2080 PSVMVMCB pVmcbNstGst = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); 2081 PSVMVMCBCTRL pVmcbNstGstCtrl = &pVmcbNstGst->ctrl; 2082 2083 /* 2084 * First cache the nested-guest VMCB fields we may potentially modify. 2085 */ 2086 hmR0SvmVmRunCacheVmcb(pVCpu, pCtx); 2087 2088 /* 2089 * The IOPM of the nested-guest can be ignored because the the guest always 2090 * intercepts all IO port accesses. Thus, we'll swap to the guest IOPM rather 2091 * into the nested-guest one and swap it back on the #VMEXIT. 2092 */ 2093 pVmcbNstGstCtrl->u64IOPMPhysAddr = g_HCPhysIOBitmap; 2094 2095 /* 2096 * Load the host-physical address into the MSRPM rather than the nested-guest 2097 * physical address (currently we trap all MSRs in the nested-guest). 2098 */ 2099 pVmcbNstGstCtrl->u64MSRPMPhysAddr = g_HCPhysNstGstMsrBitmap; 2100 } 2101 2102 2103 /** 2104 * Sets up the nested-guest for hardware-assisted SVM execution. 2105 * 2106 * @param pVCpu The cross context virtual CPU structure. 2107 * @param pCtx Pointer to the guest-CPU context. 2108 * 2109 * @remarks This must be called only after the guest exceptions are up to date as 2110 * otherwise we risk overwriting the guest exceptions with the nested-guest 2111 * exceptions. 2112 */ 2067 2113 static void hmR0SvmLoadGuestVmcbNested(PVMCPU pVCpu, PCPUMCTX pCtx) 2068 2114 { 2069 2115 if (HMCPU_CF_IS_PENDING(pVCpu, HM_CHANGED_SVM_NESTED_GUEST)) 2070 2116 { 2071 /* 2072 * Cache the nested-guest VMCB fields before we start modifying them below. 2073 */ 2074 hmR0SvmVmRunCacheVmcb(pVCpu, pCtx); 2075 2076 PSVMVMCB pVmcbNstGst = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); 2077 PSVMVMCBCTRL pVmcbNstGstCtrl = &pVmcbNstGst->ctrl; 2078 2079 /* 2080 * The IOPM of the nested-guest can be ignored because the the guest always 2081 * intercepts all IO port accesses. Thus, we'll swap to the guest IOPM rather 2082 * into the nested-guest one and swap it back on the #VMEXIT. 2083 */ 2084 pVmcbNstGstCtrl->u64IOPMPhysAddr = g_HCPhysIOBitmap; 2085 2086 /* 2087 * Load the host-physical address into the MSRPM rather than the nested-guest 2088 * physical address. 2089 */ 2090 pVmcbNstGstCtrl->u64MSRPMPhysAddr = g_HCPhysNstGstMsrBitmap; 2091 2092 /* 2093 * Merge the guest exception intercepts in to the nested-guest ones. 2094 */ 2095 PCSVMVMCB pVmcb = pVCpu->hm.s.svm.pVmcb; 2096 hmR0SvmMergeIntercepts(pVmcb, pVmcbNstGst); 2097 2117 hmR0SvmVmRunSetupVmcb(pVCpu, pCtx); 2098 2118 HMCPU_CF_CLEAR(pVCpu, HM_CHANGED_SVM_NESTED_GUEST); 2099 2119 } … … 2114 2134 STAM_PROFILE_ADV_START(&pVCpu->hm.s.StatLoadGuestState, x); 2115 2135 2116 /*2117 * Load guest intercepts first into the guest VMCB as later we may merge2118 * them into the nested-guest VMCB further below.2119 */2120 {2121 PSVMVMCB pVmcb = pVCpu->hm.s.svm.pVmcb;2122 hmR0SvmLoadGuestXcptIntercepts(pVCpu, pVmcb);2123 }2124 2125 2136 PSVMVMCB pVmcbNstGst = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); 2126 2137 Assert(pVmcbNstGst); … … 2131 2142 if (!pVCpu->hm.s.svm.NstGstVmcbCache.fVmrunEmulatedInR0) 2132 2143 { 2133 /* hmR0SvmLoadGuestVmcbNested needs to be called first which caches the VMCB fields and adjusts others. */2144 /* First, we need to setup the nested-guest VMCB for hardware-assisted SVM execution. */ 2134 2145 hmR0SvmLoadGuestVmcbNested(pVCpu, pCtx); 2135 2146 2136 hmR0SvmLoadGuestControlRegsNested(pVCpu, pVmcbNstGst, pCtx);2137 2147 hmR0SvmLoadGuestSegmentRegs(pVCpu, pVmcbNstGst, pCtx); 2138 2148 hmR0SvmLoadGuestMsrs(pVCpu, pVmcbNstGst, pCtx); … … 2144 2154 } 2145 2155 2156 hmR0SvmLoadGuestControlRegsNested(pVCpu, pVmcbNstGst, pCtx); 2146 2157 hmR0SvmLoadGuestApicStateNested(pVCpu, pVmcbNstGst); 2158 2159 PSVMVMCB pVmcb = pVCpu->hm.s.svm.pVmcb; 2160 hmR0SvmLoadGuestXcptInterceptsNested(pVCpu, pVmcb, pVmcbNstGst); 2147 2161 2148 2162 int rc = hmR0SvmSetupVMRunHandler(pVCpu); … … 5804 5818 /** 5805 5819 * Performs a \#VMEXIT when the VMRUN was emulating using hmR0SvmExecVmrun and 5806 * optionally then through SVM R0execution.5820 * optionally went ahead with hardware-assisted SVM execution. 5807 5821 * 5808 5822 * @returns VBox status code. … … 5814 5828 /* 5815 5829 * Restore the modifications we did to the nested-guest VMCB in order 5816 * to execut e the nested-guest in SVM R0.5830 * to executing the nested-guesting using hardware-assisted SVM. 5817 5831 */ 5818 5832 PSVMVMCB pVmcbNstGst = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); … … 5878 5892 5879 5893 /** 5880 * Setup execution of the nested-guest in SVM R0.5894 * Setup the nested-guest for hardware-assisted SVM execution. 5881 5895 * 5882 5896 * @returns VBox status code. … … 6001 6015 if (fLongModeWithPaging) 6002 6016 uValidEfer |= MSR_K6_EFER_LMA; 6003 6004 /*6005 * Set up the nested-guest for executing it using hardware-assisted SVM.6006 */6007 hmR0SvmLoadGuestVmcbNested(pVCpu, pCtx);6008 6017 6009 6018 /* … … 6074 6083 6075 6084 /* 6085 * Set up the nested-guest for executing it using hardware-assisted SVM. 6086 */ 6087 hmR0SvmVmRunSetupVmcb(pVCpu, pCtx); 6088 6089 /* 6076 6090 * VMRUN loads a subset of the guest-CPU state (see above) and nothing else. Ensure 6077 6091 * hmR0SvmLoadGuestStateNested doesn't need to load anything back to the VMCB cache … … 6086 6100 PSVMNESTEDVMCBCACHE pNstGstVmcbCache = &pVCpu->hm.s.svm.NstGstVmcbCache; 6087 6101 pNstGstVmcbCache->fVmrunEmulatedInR0 = true; 6102 6103 /* 6104 * We flag a CR3 change to ensure loading the host-physical address of CR3 into 6105 * the nested-guest VMCB in hmR0SvmLoadGuestControlRegsNested. 6106 */ 6088 6107 HMCPU_CF_CLEAR(pVCpu, HM_CHANGED_ALL_GUEST); 6089 HMCPU_CF_SET(pVCpu, HM_CHANGED_HOST_GUEST_SHARED_STATE );6108 HMCPU_CF_SET(pVCpu, HM_CHANGED_HOST_GUEST_SHARED_STATE | HM_CHANGED_GUEST_CR3); 6090 6109 6091 6110 /*
Note:
See TracChangeset
for help on using the changeset viewer.