Changeset 76482 in vbox for trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
- Timestamp:
- Dec 26, 2018 3:49:56 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r76477 r76482 1119 1119 * 1120 1120 * @returns VBox status code. 1121 * @param pHostCpu Pointer to the global CPU info struct.1121 * @param pHostCpu The HM physical-CPU structure. 1122 1122 * @param pVM The cross context VM structure. Can be 1123 1123 * NULL after a host resume operation. … … 1130 1130 * @param pHwvirtMsrs Pointer to the hardware-virtualization MSRs. 1131 1131 */ 1132 VMMR0DECL(int) VMXR0EnableCpu(PHM GLOBALCPUINFOpHostCpu, PVM pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage, bool fEnabledByHost,1132 VMMR0DECL(int) VMXR0EnableCpu(PHMPHYSCPU pHostCpu, PVM pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage, bool fEnabledByHost, 1133 1133 PCSUPHWVIRTMSRS pHwvirtMsrs) 1134 1134 { … … 1169 1169 * 1170 1170 * @returns VBox status code. 1171 * @param pHostCpu Pointer to the global CPU info struct.1172 1171 * @param pvCpuPage Pointer to the VMXON region. 1173 1172 * @param HCPhysCpuPage Physical address of the VMXON region. … … 1176 1175 * similar was used to enable VT-x on the host. 1177 1176 */ 1178 VMMR0DECL(int) VMXR0DisableCpu( PHMGLOBALCPUINFO pHostCpu,void *pvCpuPage, RTHCPHYS HCPhysCpuPage)1179 { 1180 RT_NOREF 3(pHostCpu,pvCpuPage, HCPhysCpuPage);1177 VMMR0DECL(int) VMXR0DisableCpu(void *pvCpuPage, RTHCPHYS HCPhysCpuPage) 1178 { 1179 RT_NOREF2(pvCpuPage, HCPhysCpuPage); 1181 1180 1182 1181 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD)); … … 1411 1410 static bool hmR0VmxIsAutoLoadStoreGuestMsr(PVMCPU pVCpu, uint32_t uMsr) 1412 1411 { 1413 PVMXAUTOMSR pGuestMsr = (PVMXAUTOMSR)pVCpu->hm.s.vmx.pvGuestMsr;1414 uint32_t 1412 PVMXAUTOMSR pGuestMsr = (PVMXAUTOMSR)pVCpu->hm.s.vmx.pvGuestMsr; 1413 uint32_t const cMsrs = pVCpu->hm.s.vmx.cMsrs; 1415 1414 1416 1415 for (uint32_t i = 0; i < cMsrs; i++, pGuestMsr++) … … 1435 1434 PVMXAUTOMSR pHostMsr = (PVMXAUTOMSR)pVCpu->hm.s.vmx.pvHostMsr; 1436 1435 PVMXAUTOMSR pGuestMsr = (PVMXAUTOMSR)pVCpu->hm.s.vmx.pvGuestMsr; 1437 uint32_t cMsrs= pVCpu->hm.s.vmx.cMsrs;1436 uint32_t const cMsrs = pVCpu->hm.s.vmx.cMsrs; 1438 1437 1439 1438 for (uint32_t i = 0; i < cMsrs; i++, pHostMsr++, pGuestMsr++) … … 1894 1893 * case where neither EPT nor VPID is supported by the CPU. 1895 1894 * 1896 * @param p VCpu The cross context virtualCPU structure.1897 * @param p Cpu Pointer to the global HM struct.1895 * @param pHostCpu The HM physical-CPU structure. 1896 * @param pVCpu The cross context virtual CPU structure. 1898 1897 * 1899 1898 * @remarks Called with interrupts disabled. 1900 1899 */ 1901 static void hmR0VmxFlushTaggedTlbNone(P VMCPU pVCpu, PHMGLOBALCPUINFO pCpu)1900 static void hmR0VmxFlushTaggedTlbNone(PHMPHYSCPU pHostCpu, PVMCPU pVCpu) 1902 1901 { 1903 1902 AssertPtr(pVCpu); 1904 AssertPtr(p Cpu);1903 AssertPtr(pHostCpu); 1905 1904 1906 1905 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_TLB_FLUSH); 1907 1906 1908 Assert(p Cpu->idCpu != NIL_RTCPUID);1909 pVCpu->hm.s.idLastCpu = p Cpu->idCpu;1910 pVCpu->hm.s.cTlbFlushes = p Cpu->cTlbFlushes;1907 Assert(pHostCpu->idCpu != NIL_RTCPUID); 1908 pVCpu->hm.s.idLastCpu = pHostCpu->idCpu; 1909 pVCpu->hm.s.cTlbFlushes = pHostCpu->cTlbFlushes; 1911 1910 pVCpu->hm.s.fForceTLBFlush = false; 1912 1911 return; … … 1917 1916 * Flushes the tagged-TLB entries for EPT+VPID CPUs as necessary. 1918 1917 * 1919 * @param pVCpu The cross context virtualCPU structure.1920 * @param pCpu Pointer to the global HM CPU struct.1918 * @param pHostCpu The HM physical-CPU structure. 1919 * @param pVCpu The cross context virtual CPU structure. 1921 1920 * 1922 1921 * @remarks All references to "ASID" in this function pertains to "VPID" in Intel's … … 1926 1925 * @remarks Called with interrupts disabled. 1927 1926 */ 1928 static void hmR0VmxFlushTaggedTlbBoth(P VMCPU pVCpu, PHMGLOBALCPUINFO pCpu)1927 static void hmR0VmxFlushTaggedTlbBoth(PHMPHYSCPU pHostCpu, PVMCPU pVCpu) 1929 1928 { 1930 1929 #ifdef VBOX_WITH_STATISTICS … … 1940 1939 #endif 1941 1940 1942 AssertPtr(pCpu);1943 1941 AssertPtr(pVCpu); 1944 Assert(pCpu->idCpu != NIL_RTCPUID); 1942 AssertPtr(pHostCpu); 1943 Assert(pHostCpu->idCpu != NIL_RTCPUID); 1945 1944 1946 1945 PVM pVM = pVCpu->CTX_SUFF(pVM); … … 1955 1954 * cannot reuse the current ASID anymore. 1956 1955 */ 1957 if ( pVCpu->hm.s.idLastCpu != p Cpu->idCpu1958 || pVCpu->hm.s.cTlbFlushes != p Cpu->cTlbFlushes)1959 { 1960 ++p Cpu->uCurrentAsid;1961 if (p Cpu->uCurrentAsid >= pVM->hm.s.uMaxAsid)1962 { 1963 p Cpu->uCurrentAsid = 1;/* Wraparound to 1; host uses 0. */1964 p Cpu->cTlbFlushes++;/* All VCPUs that run on this host CPU must use a new VPID. */1965 p Cpu->fFlushAsidBeforeUse = true;/* All VCPUs that run on this host CPU must flush their new VPID before use. */1966 } 1967 1968 pVCpu->hm.s.uCurrentAsid = p Cpu->uCurrentAsid;1969 pVCpu->hm.s.idLastCpu = p Cpu->idCpu;1970 pVCpu->hm.s.cTlbFlushes = p Cpu->cTlbFlushes;1956 if ( pVCpu->hm.s.idLastCpu != pHostCpu->idCpu 1957 || pVCpu->hm.s.cTlbFlushes != pHostCpu->cTlbFlushes) 1958 { 1959 ++pHostCpu->uCurrentAsid; 1960 if (pHostCpu->uCurrentAsid >= pVM->hm.s.uMaxAsid) 1961 { 1962 pHostCpu->uCurrentAsid = 1; /* Wraparound to 1; host uses 0. */ 1963 pHostCpu->cTlbFlushes++; /* All VCPUs that run on this host CPU must use a new VPID. */ 1964 pHostCpu->fFlushAsidBeforeUse = true; /* All VCPUs that run on this host CPU must flush their new VPID before use. */ 1965 } 1966 1967 pVCpu->hm.s.uCurrentAsid = pHostCpu->uCurrentAsid; 1968 pVCpu->hm.s.idLastCpu = pHostCpu->idCpu; 1969 pVCpu->hm.s.cTlbFlushes = pHostCpu->cTlbFlushes; 1971 1970 1972 1971 /* … … 1998 1997 HMVMX_UPDATE_FLUSH_SKIPPED_STAT(); 1999 1998 2000 Assert(pVCpu->hm.s.idLastCpu == p Cpu->idCpu);2001 Assert(pVCpu->hm.s.cTlbFlushes == p Cpu->cTlbFlushes);2002 AssertMsg(pVCpu->hm.s.cTlbFlushes == p Cpu->cTlbFlushes,2003 ("Flush count mismatch for cpu %d (%u vs %u)\n", p Cpu->idCpu, pVCpu->hm.s.cTlbFlushes, pCpu->cTlbFlushes));2004 AssertMsg(p Cpu->uCurrentAsid >= 1 && pCpu->uCurrentAsid < pVM->hm.s.uMaxAsid,2005 ("Cpu[%u] uCurrentAsid=%u cTlbFlushes=%u pVCpu->idLastCpu=%u pVCpu->cTlbFlushes=%u\n", p Cpu->idCpu,2006 p Cpu->uCurrentAsid, pCpu->cTlbFlushes, pVCpu->hm.s.idLastCpu, pVCpu->hm.s.cTlbFlushes));1999 Assert(pVCpu->hm.s.idLastCpu == pHostCpu->idCpu); 2000 Assert(pVCpu->hm.s.cTlbFlushes == pHostCpu->cTlbFlushes); 2001 AssertMsg(pVCpu->hm.s.cTlbFlushes == pHostCpu->cTlbFlushes, 2002 ("Flush count mismatch for cpu %d (%u vs %u)\n", pHostCpu->idCpu, pVCpu->hm.s.cTlbFlushes, pHostCpu->cTlbFlushes)); 2003 AssertMsg(pHostCpu->uCurrentAsid >= 1 && pHostCpu->uCurrentAsid < pVM->hm.s.uMaxAsid, 2004 ("Cpu[%u] uCurrentAsid=%u cTlbFlushes=%u pVCpu->idLastCpu=%u pVCpu->cTlbFlushes=%u\n", pHostCpu->idCpu, 2005 pHostCpu->uCurrentAsid, pHostCpu->cTlbFlushes, pVCpu->hm.s.idLastCpu, pVCpu->hm.s.cTlbFlushes)); 2007 2006 AssertMsg(pVCpu->hm.s.uCurrentAsid >= 1 && pVCpu->hm.s.uCurrentAsid < pVM->hm.s.uMaxAsid, 2008 ("Cpu[%u] pVCpu->uCurrentAsid=%u\n", p Cpu->idCpu, pVCpu->hm.s.uCurrentAsid));2007 ("Cpu[%u] pVCpu->uCurrentAsid=%u\n", pHostCpu->idCpu, pVCpu->hm.s.uCurrentAsid)); 2009 2008 2010 2009 /* Update VMCS with the VPID. */ … … 2019 2018 * Flushes the tagged-TLB entries for EPT CPUs as necessary. 2020 2019 * 2021 * @ returns VBox status code.2020 * @param pHostCpu The HM physical-CPU structure. 2022 2021 * @param pVCpu The cross context virtual CPU structure. 2023 * @param pCpu Pointer to the global HM CPU struct.2024 2022 * 2025 2023 * @remarks Called with interrupts disabled. 2026 2024 */ 2027 static void hmR0VmxFlushTaggedTlbEpt(P VMCPU pVCpu, PHMGLOBALCPUINFO pCpu)2025 static void hmR0VmxFlushTaggedTlbEpt(PHMPHYSCPU pHostCpu, PVMCPU pVCpu) 2028 2026 { 2029 2027 AssertPtr(pVCpu); 2030 AssertPtr(p Cpu);2031 Assert(p Cpu->idCpu != NIL_RTCPUID);2028 AssertPtr(pHostCpu); 2029 Assert(pHostCpu->idCpu != NIL_RTCPUID); 2032 2030 AssertMsg(pVCpu->CTX_SUFF(pVM)->hm.s.fNestedPaging, ("hmR0VmxFlushTaggedTlbEpt cannot be invoked without NestedPaging.")); 2033 2031 AssertMsg(!pVCpu->CTX_SUFF(pVM)->hm.s.vmx.fVpid, ("hmR0VmxFlushTaggedTlbEpt cannot be invoked with VPID.")); … … 2037 2035 * A change in the TLB flush count implies the host CPU is online after a suspend/resume. 2038 2036 */ 2039 if ( pVCpu->hm.s.idLastCpu != p Cpu->idCpu2040 || pVCpu->hm.s.cTlbFlushes != p Cpu->cTlbFlushes)2037 if ( pVCpu->hm.s.idLastCpu != pHostCpu->idCpu 2038 || pVCpu->hm.s.cTlbFlushes != pHostCpu->cTlbFlushes) 2041 2039 { 2042 2040 pVCpu->hm.s.fForceTLBFlush = true; … … 2051 2049 } 2052 2050 2053 pVCpu->hm.s.idLastCpu = p Cpu->idCpu;2054 pVCpu->hm.s.cTlbFlushes = p Cpu->cTlbFlushes;2051 pVCpu->hm.s.idLastCpu = pHostCpu->idCpu; 2052 pVCpu->hm.s.cTlbFlushes = pHostCpu->cTlbFlushes; 2055 2053 2056 2054 if (pVCpu->hm.s.fForceTLBFlush) … … 2065 2063 * Flushes the tagged-TLB entries for VPID CPUs as necessary. 2066 2064 * 2067 * @ returns VBox status code.2065 * @param pHostCpu The HM physical-CPU structure. 2068 2066 * @param pVCpu The cross context virtual CPU structure. 2069 * @param pCpu Pointer to the global HM CPU struct.2070 2067 * 2071 2068 * @remarks Called with interrupts disabled. 2072 2069 */ 2073 static void hmR0VmxFlushTaggedTlbVpid(P VMCPU pVCpu, PHMGLOBALCPUINFO pCpu)2070 static void hmR0VmxFlushTaggedTlbVpid(PHMPHYSCPU pHostCpu, PVMCPU pVCpu) 2074 2071 { 2075 2072 AssertPtr(pVCpu); 2076 AssertPtr(p Cpu);2077 Assert(p Cpu->idCpu != NIL_RTCPUID);2073 AssertPtr(pHostCpu); 2074 Assert(pHostCpu->idCpu != NIL_RTCPUID); 2078 2075 AssertMsg(pVCpu->CTX_SUFF(pVM)->hm.s.vmx.fVpid, ("hmR0VmxFlushTlbVpid cannot be invoked without VPID.")); 2079 2076 AssertMsg(!pVCpu->CTX_SUFF(pVM)->hm.s.fNestedPaging, ("hmR0VmxFlushTlbVpid cannot be invoked with NestedPaging")); … … 2085 2082 * cannot reuse the current ASID anymore. 2086 2083 */ 2087 if ( pVCpu->hm.s.idLastCpu != p Cpu->idCpu2088 || pVCpu->hm.s.cTlbFlushes != p Cpu->cTlbFlushes)2084 if ( pVCpu->hm.s.idLastCpu != pHostCpu->idCpu 2085 || pVCpu->hm.s.cTlbFlushes != pHostCpu->cTlbFlushes) 2089 2086 { 2090 2087 pVCpu->hm.s.fForceTLBFlush = true; … … 2098 2095 * If we ever support VPID flush combinations other than ALL or SINGLE-context (see 2099 2096 * hmR0VmxSetupTaggedTlb()) we would need to explicitly flush in this case (add an 2100 * fExplicitFlush = true here and change the p Cpu->fFlushAsidBeforeUse check below to2097 * fExplicitFlush = true here and change the pHostCpu->fFlushAsidBeforeUse check below to 2101 2098 * include fExplicitFlush's too) - an obscure corner case. 2102 2099 */ … … 2106 2103 2107 2104 PVM pVM = pVCpu->CTX_SUFF(pVM); 2108 pVCpu->hm.s.idLastCpu = p Cpu->idCpu;2105 pVCpu->hm.s.idLastCpu = pHostCpu->idCpu; 2109 2106 if (pVCpu->hm.s.fForceTLBFlush) 2110 2107 { 2111 ++p Cpu->uCurrentAsid;2112 if (p Cpu->uCurrentAsid >= pVM->hm.s.uMaxAsid)2113 { 2114 p Cpu->uCurrentAsid = 1;/* Wraparound to 1; host uses 0 */2115 p Cpu->cTlbFlushes++;/* All VCPUs that run on this host CPU must use a new VPID. */2116 p Cpu->fFlushAsidBeforeUse = true;/* All VCPUs that run on this host CPU must flush their new VPID before use. */2108 ++pHostCpu->uCurrentAsid; 2109 if (pHostCpu->uCurrentAsid >= pVM->hm.s.uMaxAsid) 2110 { 2111 pHostCpu->uCurrentAsid = 1; /* Wraparound to 1; host uses 0 */ 2112 pHostCpu->cTlbFlushes++; /* All VCPUs that run on this host CPU must use a new VPID. */ 2113 pHostCpu->fFlushAsidBeforeUse = true; /* All VCPUs that run on this host CPU must flush their new VPID before use. */ 2117 2114 } 2118 2115 2119 2116 pVCpu->hm.s.fForceTLBFlush = false; 2120 pVCpu->hm.s.cTlbFlushes = p Cpu->cTlbFlushes;2121 pVCpu->hm.s.uCurrentAsid = p Cpu->uCurrentAsid;2122 if (p Cpu->fFlushAsidBeforeUse)2117 pVCpu->hm.s.cTlbFlushes = pHostCpu->cTlbFlushes; 2118 pVCpu->hm.s.uCurrentAsid = pHostCpu->uCurrentAsid; 2119 if (pHostCpu->fFlushAsidBeforeUse) 2123 2120 { 2124 2121 if (pVM->hm.s.vmx.enmTlbFlushVpid == VMXTLBFLUSHVPID_SINGLE_CONTEXT) … … 2127 2124 { 2128 2125 hmR0VmxFlushVpid(pVCpu, VMXTLBFLUSHVPID_ALL_CONTEXTS, 0 /* GCPtr */); 2129 p Cpu->fFlushAsidBeforeUse = false;2126 pHostCpu->fFlushAsidBeforeUse = false; 2130 2127 } 2131 2128 else … … 2137 2134 } 2138 2135 2139 AssertMsg(pVCpu->hm.s.cTlbFlushes == p Cpu->cTlbFlushes,2140 ("Flush count mismatch for cpu %d (%u vs %u)\n", p Cpu->idCpu, pVCpu->hm.s.cTlbFlushes, pCpu->cTlbFlushes));2141 AssertMsg(p Cpu->uCurrentAsid >= 1 && pCpu->uCurrentAsid < pVM->hm.s.uMaxAsid,2142 ("Cpu[%u] uCurrentAsid=%u cTlbFlushes=%u pVCpu->idLastCpu=%u pVCpu->cTlbFlushes=%u\n", p Cpu->idCpu,2143 p Cpu->uCurrentAsid, pCpu->cTlbFlushes, pVCpu->hm.s.idLastCpu, pVCpu->hm.s.cTlbFlushes));2136 AssertMsg(pVCpu->hm.s.cTlbFlushes == pHostCpu->cTlbFlushes, 2137 ("Flush count mismatch for cpu %d (%u vs %u)\n", pHostCpu->idCpu, pVCpu->hm.s.cTlbFlushes, pHostCpu->cTlbFlushes)); 2138 AssertMsg(pHostCpu->uCurrentAsid >= 1 && pHostCpu->uCurrentAsid < pVM->hm.s.uMaxAsid, 2139 ("Cpu[%u] uCurrentAsid=%u cTlbFlushes=%u pVCpu->idLastCpu=%u pVCpu->cTlbFlushes=%u\n", pHostCpu->idCpu, 2140 pHostCpu->uCurrentAsid, pHostCpu->cTlbFlushes, pVCpu->hm.s.idLastCpu, pVCpu->hm.s.cTlbFlushes)); 2144 2141 AssertMsg(pVCpu->hm.s.uCurrentAsid >= 1 && pVCpu->hm.s.uCurrentAsid < pVM->hm.s.uMaxAsid, 2145 ("Cpu[%u] pVCpu->uCurrentAsid=%u\n", p Cpu->idCpu, pVCpu->hm.s.uCurrentAsid));2142 ("Cpu[%u] pVCpu->uCurrentAsid=%u\n", pHostCpu->idCpu, pVCpu->hm.s.uCurrentAsid)); 2146 2143 2147 2144 int rc = VMXWriteVmcs32(VMX_VMCS16_VPID, pVCpu->hm.s.uCurrentAsid); … … 2153 2150 * Flushes the guest TLB entry based on CPU capabilities. 2154 2151 * 2155 * @param pVCpu The cross context virtual CPU structure. 2156 * @param pCpu Pointer to the global HM CPU struct. 2157 */ 2158 DECLINLINE(void) hmR0VmxFlushTaggedTlb(PVMCPU pVCpu, PHMGLOBALCPUINFO pCpu) 2152 * @param pHostCpu The HM physical-CPU structure. 2153 * @param pVCpu The cross context virtual CPU structure. 2154 * 2155 * @remarks Called with interrupts disabled. 2156 */ 2157 DECLINLINE(void) hmR0VmxFlushTaggedTlb(PHMPHYSCPU pHostCpu, PVMCPU pVCpu) 2159 2158 { 2160 2159 #ifdef HMVMX_ALWAYS_FLUSH_TLB … … 2164 2163 switch (pVM->hm.s.vmx.enmTlbFlushType) 2165 2164 { 2166 case VMXTLBFLUSHTYPE_EPT_VPID: hmR0VmxFlushTaggedTlbBoth(p VCpu, pCpu); break;2167 case VMXTLBFLUSHTYPE_EPT: hmR0VmxFlushTaggedTlbEpt(p VCpu, pCpu); break;2168 case VMXTLBFLUSHTYPE_VPID: hmR0VmxFlushTaggedTlbVpid(p VCpu, pCpu); break;2169 case VMXTLBFLUSHTYPE_NONE: hmR0VmxFlushTaggedTlbNone(p VCpu, pCpu); break;2165 case VMXTLBFLUSHTYPE_EPT_VPID: hmR0VmxFlushTaggedTlbBoth(pHostCpu, pVCpu); break; 2166 case VMXTLBFLUSHTYPE_EPT: hmR0VmxFlushTaggedTlbEpt(pHostCpu, pVCpu); break; 2167 case VMXTLBFLUSHTYPE_VPID: hmR0VmxFlushTaggedTlbVpid(pHostCpu, pVCpu); break; 2168 case VMXTLBFLUSHTYPE_NONE: hmR0VmxFlushTaggedTlbNone(pHostCpu, pVCpu); break; 2170 2169 default: 2171 2170 AssertMsgFailed(("Invalid flush-tag function identifier\n")); … … 2821 2820 hmR0VmxUpdateErrorRecord(pVCpu, rc), rc); 2822 2821 2823 pVCpu->hm.s.vmx. uVmcsState = HMVMX_VMCS_STATE_CLEAR;2822 pVCpu->hm.s.vmx.fVmcsState = HMVMX_VMCS_STATE_CLEAR; 2824 2823 2825 2824 hmR0VmxUpdateErrorRecord(pVCpu, rc); … … 4982 4981 * See MSDN "Configuring Programs for 64-bit/x64 Software Conventions / Register Usage". 4983 4982 */ 4984 bool const fResumeVM = RT_BOOL(pVCpu->hm.s.vmx. uVmcsState & HMVMX_VMCS_STATE_LAUNCHED);4983 bool const fResumeVM = RT_BOOL(pVCpu->hm.s.vmx.fVmcsState & HMVMX_VMCS_STATE_LAUNCHED); 4985 4984 /** @todo Add stats for resume vs launch. */ 4986 4985 PVM pVM = pVCpu->CTX_SUFF(pVM); … … 5284 5283 #endif 5285 5284 5286 P HMGLOBALCPUINFO pCpu = hmR0GetCurrentCpu();5287 RTHCPHYS HCPhysCpuPage = p Cpu->HCPhysMemObj;5285 PCHMPHYSCPU pHostCpu = hmR0GetCurrentCpu(); 5286 RTHCPHYS HCPhysCpuPage = pHostCpu->HCPhysMemObj; 5288 5287 5289 5288 /* Clear VMCS. Marking it inactive, clearing implementation-specific data and writing VMCS data back to memory. */ 5290 5289 VMXClearVmcs(pVCpu->hm.s.vmx.HCPhysVmcs); 5291 pVCpu->hm.s.vmx. uVmcsState = HMVMX_VMCS_STATE_CLEAR;5290 pVCpu->hm.s.vmx.fVmcsState = HMVMX_VMCS_STATE_CLEAR; 5292 5291 5293 5292 /* Leave VMX Root Mode. */ … … 5323 5322 rc2 = VMXActivateVmcs(pVCpu->hm.s.vmx.HCPhysVmcs); 5324 5323 AssertRC(rc2); 5325 pVCpu->hm.s.vmx. uVmcsState = HMVMX_VMCS_STATE_ACTIVE;5324 pVCpu->hm.s.vmx.fVmcsState = HMVMX_VMCS_STATE_ACTIVE; 5326 5325 Assert(!(ASMGetFlags() & X86_EFL_IF)); 5327 5326 ASMSetFlags(fOldEFlags); … … 5345 5344 NOREF(fResume); 5346 5345 5347 P HMGLOBALCPUINFO pCpu= hmR0GetCurrentCpu();5348 RTHCPHYS HCPhysCpuPage = pCpu->HCPhysMemObj;5346 PCHMPHYSCPU pHostCpu = hmR0GetCurrentCpu(); 5347 RTHCPHYS const HCPhysCpuPage = pHostCpu->HCPhysMemObj; 5349 5348 5350 5349 #ifdef VBOX_WITH_CRASHDUMP_MAGIC … … 7211 7210 * context. 7212 7211 */ 7213 if (pVCpu->hm.s.vmx. uVmcsState & HMVMX_VMCS_STATE_ACTIVE)7212 if (pVCpu->hm.s.vmx.fVmcsState & HMVMX_VMCS_STATE_ACTIVE) 7214 7213 { 7215 7214 int rc = VMXClearVmcs(pVCpu->hm.s.vmx.HCPhysVmcs); 7216 7215 AssertRCReturn(rc, rc); 7217 7216 7218 pVCpu->hm.s.vmx. uVmcsState = HMVMX_VMCS_STATE_CLEAR;7217 pVCpu->hm.s.vmx.fVmcsState = HMVMX_VMCS_STATE_CLEAR; 7219 7218 Log4Func(("Cleared Vmcs. HostCpuId=%u\n", idCpu)); 7220 7219 } 7221 Assert(!(pVCpu->hm.s.vmx. uVmcsState & HMVMX_VMCS_STATE_LAUNCHED));7220 Assert(!(pVCpu->hm.s.vmx.fVmcsState & HMVMX_VMCS_STATE_LAUNCHED)); 7222 7221 NOREF(idCpu); 7223 7222 … … 7413 7412 pVCpu->hm.s.vmx.fUpdatedHostMsrs = false; 7414 7413 VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_HM, VMCPUSTATE_STARTED_EXEC); 7415 if (pVCpu->hm.s.vmx. uVmcsState & HMVMX_VMCS_STATE_ACTIVE)7414 if (pVCpu->hm.s.vmx.fVmcsState & HMVMX_VMCS_STATE_ACTIVE) 7416 7415 { 7417 7416 VMXClearVmcs(pVCpu->hm.s.vmx.HCPhysVmcs); 7418 pVCpu->hm.s.vmx. uVmcsState = HMVMX_VMCS_STATE_CLEAR;7417 pVCpu->hm.s.vmx.fVmcsState = HMVMX_VMCS_STATE_CLEAR; 7419 7418 } 7420 7419 … … 8027 8026 * @returns VBox status code. 8028 8027 * @param pVCpu The cross context virtual CPU structure. 8029 * @param pHostCpu Pointer to the global CPU info struct. 8030 */ 8031 VMMR0DECL(int) VMXR0Enter(PVMCPU pVCpu, PHMGLOBALCPUINFO pHostCpu) 8028 */ 8029 VMMR0DECL(int) VMXR0Enter(PVMCPU pVCpu) 8032 8030 { 8033 8031 AssertPtr(pVCpu); 8034 8032 Assert(pVCpu->CTX_SUFF(pVM)->hm.s.vmx.fSupported); 8035 8033 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD)); 8036 RT_NOREF(pHostCpu);8037 8034 8038 8035 LogFlowFunc(("pVCpu=%p\n", pVCpu)); … … 8053 8050 * Load the VCPU's VMCS as the current (and active) one. 8054 8051 */ 8055 Assert(pVCpu->hm.s.vmx. uVmcsState & HMVMX_VMCS_STATE_CLEAR);8052 Assert(pVCpu->hm.s.vmx.fVmcsState & HMVMX_VMCS_STATE_CLEAR); 8056 8053 int rc = VMXActivateVmcs(pVCpu->hm.s.vmx.HCPhysVmcs); 8057 if (RT_FAILURE(rc)) 8058 return rc; 8059 8060 pVCpu->hm.s.vmx.uVmcsState = HMVMX_VMCS_STATE_ACTIVE; 8061 pVCpu->hm.s.fLeaveDone = false; 8062 Log4Func(("Activated Vmcs. HostCpuId=%u\n", RTMpCpuId())); 8063 8064 return VINF_SUCCESS; 8054 if (RT_SUCCESS(rc)) 8055 { 8056 pVCpu->hm.s.vmx.fVmcsState = HMVMX_VMCS_STATE_ACTIVE; 8057 pVCpu->hm.s.fLeaveDone = false; 8058 Log4Func(("Activated Vmcs. HostCpuId=%u\n", RTMpCpuId())); 8059 } 8060 return rc; 8065 8061 } 8066 8062 … … 8131 8127 8132 8128 /* Load the active VMCS as the current one. */ 8133 if (pVCpu->hm.s.vmx. uVmcsState & HMVMX_VMCS_STATE_CLEAR)8129 if (pVCpu->hm.s.vmx.fVmcsState & HMVMX_VMCS_STATE_CLEAR) 8134 8130 { 8135 8131 rc = VMXActivateVmcs(pVCpu->hm.s.vmx.HCPhysVmcs); 8136 8132 AssertRC(rc); NOREF(rc); 8137 pVCpu->hm.s.vmx. uVmcsState = HMVMX_VMCS_STATE_ACTIVE;8133 pVCpu->hm.s.vmx.fVmcsState = HMVMX_VMCS_STATE_ACTIVE; 8138 8134 Log4Func(("Resumed: Activated Vmcs. HostCpuId=%u\n", RTMpCpuId())); 8139 8135 } … … 8693 8689 pVmxTransient->u8GuestTpr = pVCpu->hm.s.vmx.pbVirtApic[XAPIC_OFF_TPR]; 8694 8690 8695 PHM GLOBALCPUINFO pCpu= hmR0GetCurrentCpu();8696 RTCPUID idCurrentCpu = pCpu->idCpu;8691 PHMPHYSCPU pHostCpu = hmR0GetCurrentCpu(); 8692 RTCPUID idCurrentCpu = pHostCpu->idCpu; 8697 8693 if ( pVmxTransient->fUpdateTscOffsettingAndPreemptTimer 8698 8694 || idCurrentCpu != pVCpu->hm.s.idLastCpu) … … 8703 8699 8704 8700 ASMAtomicWriteBool(&pVCpu->hm.s.fCheckedTLBFlush, true); /* Used for TLB flushing, set this across the world switch. */ 8705 hmR0VmxFlushTaggedTlb(p VCpu, pCpu);/* Invalidate the appropriate guest entries from the TLB. */8701 hmR0VmxFlushTaggedTlb(pHostCpu, pVCpu); /* Invalidate the appropriate guest entries from the TLB. */ 8706 8702 Assert(idCurrentCpu == pVCpu->hm.s.idLastCpu); 8707 8703 pVCpu->hm.s.vmx.LastError.idCurrentCpu = idCurrentCpu; /* Update the error reporting info. with the current host CPU. */ … … 8800 8796 #endif 8801 8797 #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS) 8802 /* The 64-on-32 switcher maintains uVmcsState on its own and we need to leave it alone here. */8798 /* The 64-on-32 switcher maintains fVmcsState on its own and we need to leave it alone here. */ 8803 8799 if (pVCpu->hm.s.vmx.pfnStartVM != VMXR0SwitcherStartVM64) 8804 pVCpu->hm.s.vmx. uVmcsState |= HMVMX_VMCS_STATE_LAUNCHED; /* Use VMRESUME instead of VMLAUNCH in the next run. */8800 pVCpu->hm.s.vmx.fVmcsState |= HMVMX_VMCS_STATE_LAUNCHED; /* Use VMRESUME instead of VMLAUNCH in the next run. */ 8805 8801 #else 8806 pVCpu->hm.s.vmx. uVmcsState |= HMVMX_VMCS_STATE_LAUNCHED; /* Use VMRESUME instead of VMLAUNCH in the next run. */8802 pVCpu->hm.s.vmx.fVmcsState |= HMVMX_VMCS_STATE_LAUNCHED; /* Use VMRESUME instead of VMLAUNCH in the next run. */ 8807 8803 #endif 8808 8804 #ifdef VBOX_STRICT … … 9274 9270 } else do { } while (0) 9275 9271 9276 SET_ONLY_XBM_IF_EITHER_EN(EXIT_TASK_SWITCH, VMX_EXIT_TASK_SWITCH); 9277 SET_ONLY_XBM_IF_EITHER_EN(EXIT_VMX_EPT_VIOLATION, VMX_EXIT_EPT_VIOLATION); 9278 SET_ONLY_XBM_IF_EITHER_EN(EXIT_VMX_EPT_MISCONFIG, VMX_EXIT_EPT_MISCONFIG); 9279 SET_ONLY_XBM_IF_EITHER_EN(EXIT_VMX_VAPIC_ACCESS, VMX_EXIT_APIC_ACCESS); 9280 SET_ONLY_XBM_IF_EITHER_EN(EXIT_VMX_VAPIC_WRITE, VMX_EXIT_APIC_WRITE); 9281 9282 SET_ONLY_XBM_IF_EITHER_EN(INSTR_CPUID, VMX_EXIT_CPUID); 9272 SET_ONLY_XBM_IF_EITHER_EN(EXIT_TASK_SWITCH, VMX_EXIT_TASK_SWITCH); /* unconditional */ 9273 SET_ONLY_XBM_IF_EITHER_EN(EXIT_VMX_EPT_VIOLATION, VMX_EXIT_EPT_VIOLATION); /* unconditional */ 9274 SET_ONLY_XBM_IF_EITHER_EN(EXIT_VMX_EPT_MISCONFIG, VMX_EXIT_EPT_MISCONFIG); /* unconditional (unless #VE) */ 9275 SET_ONLY_XBM_IF_EITHER_EN(EXIT_VMX_VAPIC_ACCESS, VMX_EXIT_APIC_ACCESS); /* feature dependent, nothing to enable here */ 9276 SET_ONLY_XBM_IF_EITHER_EN(EXIT_VMX_VAPIC_WRITE, VMX_EXIT_APIC_WRITE); /* feature dependent, nothing to enable here */ 9277 9278 SET_ONLY_XBM_IF_EITHER_EN(INSTR_CPUID, VMX_EXIT_CPUID); /* unconditional */ 9283 9279 SET_ONLY_XBM_IF_EITHER_EN( EXIT_CPUID, VMX_EXIT_CPUID); 9284 SET_ONLY_XBM_IF_EITHER_EN(INSTR_GETSEC, VMX_EXIT_GETSEC); 9280 SET_ONLY_XBM_IF_EITHER_EN(INSTR_GETSEC, VMX_EXIT_GETSEC); /* unconditional */ 9285 9281 SET_ONLY_XBM_IF_EITHER_EN( EXIT_GETSEC, VMX_EXIT_GETSEC); 9286 9282 SET_CPE1_XBM_IF_EITHER_EN(INSTR_HALT, VMX_EXIT_HLT, VMX_PROC_CTLS_HLT_EXIT); /* paranoia */ 9287 9283 SET_ONLY_XBM_IF_EITHER_EN( EXIT_HALT, VMX_EXIT_HLT); 9288 SET_ONLY_XBM_IF_EITHER_EN(INSTR_INVD, VMX_EXIT_INVD); 9284 SET_ONLY_XBM_IF_EITHER_EN(INSTR_INVD, VMX_EXIT_INVD); /* unconditional */ 9289 9285 SET_ONLY_XBM_IF_EITHER_EN( EXIT_INVD, VMX_EXIT_INVD); 9290 9286 SET_CPE1_XBM_IF_EITHER_EN(INSTR_INVLPG, VMX_EXIT_INVLPG, VMX_PROC_CTLS_INVLPG_EXIT); … … 9294 9290 SET_CPE1_XBM_IF_EITHER_EN(INSTR_RDTSC, VMX_EXIT_RDTSC, VMX_PROC_CTLS_RDTSC_EXIT); 9295 9291 SET_ONLY_XBM_IF_EITHER_EN( EXIT_RDTSC, VMX_EXIT_RDTSC); 9296 SET_ONLY_XBM_IF_EITHER_EN(INSTR_RSM, VMX_EXIT_RSM); 9292 SET_ONLY_XBM_IF_EITHER_EN(INSTR_RSM, VMX_EXIT_RSM); /* unconditional */ 9297 9293 SET_ONLY_XBM_IF_EITHER_EN( EXIT_RSM, VMX_EXIT_RSM); 9298 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMM_CALL, VMX_EXIT_VMCALL); 9294 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMM_CALL, VMX_EXIT_VMCALL); /* unconditional */ 9299 9295 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMM_CALL, VMX_EXIT_VMCALL); 9300 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMCLEAR, VMX_EXIT_VMCLEAR); 9296 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMCLEAR, VMX_EXIT_VMCLEAR); /* unconditional */ 9301 9297 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_VMCLEAR, VMX_EXIT_VMCLEAR); 9302 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMLAUNCH, VMX_EXIT_VMLAUNCH); 9298 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMLAUNCH, VMX_EXIT_VMLAUNCH); /* unconditional */ 9303 9299 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_VMLAUNCH, VMX_EXIT_VMLAUNCH); 9304 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMPTRLD, VMX_EXIT_VMPTRLD); 9300 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMPTRLD, VMX_EXIT_VMPTRLD); /* unconditional */ 9305 9301 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_VMPTRLD, VMX_EXIT_VMPTRLD); 9306 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMPTRST, VMX_EXIT_VMPTRST); 9302 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMPTRST, VMX_EXIT_VMPTRST); /* unconditional */ 9307 9303 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_VMPTRST, VMX_EXIT_VMPTRST); 9308 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMREAD, VMX_EXIT_VMREAD); 9304 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMREAD, VMX_EXIT_VMREAD); /* unconditional */ 9309 9305 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_VMREAD, VMX_EXIT_VMREAD); 9310 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMRESUME, VMX_EXIT_VMRESUME); 9306 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMRESUME, VMX_EXIT_VMRESUME); /* unconditional */ 9311 9307 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_VMRESUME, VMX_EXIT_VMRESUME); 9312 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMWRITE, VMX_EXIT_VMWRITE); 9308 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMWRITE, VMX_EXIT_VMWRITE); /* unconditional */ 9313 9309 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_VMWRITE, VMX_EXIT_VMWRITE); 9314 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMXOFF, VMX_EXIT_VMXOFF); 9310 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMXOFF, VMX_EXIT_VMXOFF); /* unconditional */ 9315 9311 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_VMXOFF, VMX_EXIT_VMXOFF); 9316 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMXON, VMX_EXIT_VMXON); 9312 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMXON, VMX_EXIT_VMXON); /* unconditional */ 9317 9313 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_VMXON, VMX_EXIT_VMXON); 9318 9314 … … 9400 9396 SET_ONLY_XBM_IF_EITHER_EN( EXIT_LTR, VMX_EXIT_LDTR_TR_ACCESS); 9401 9397 9402 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_INVEPT, VMX_EXIT_INVEPT); 9398 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_INVEPT, VMX_EXIT_INVEPT); /* unconditional */ 9403 9399 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_INVEPT, VMX_EXIT_INVEPT); 9404 9400 SET_CPE1_XBM_IF_EITHER_EN(INSTR_RDTSCP, VMX_EXIT_RDTSCP, VMX_PROC_CTLS_RDTSC_EXIT); 9405 9401 SET_ONLY_XBM_IF_EITHER_EN( EXIT_RDTSCP, VMX_EXIT_RDTSCP); 9406 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_INVVPID, VMX_EXIT_INVVPID); 9402 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_INVVPID, VMX_EXIT_INVVPID); /* unconditional */ 9407 9403 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_INVVPID, VMX_EXIT_INVVPID); 9408 9404 SET_CPE2_XBM_IF_EITHER_EN(INSTR_WBINVD, VMX_EXIT_WBINVD, VMX_PROC_CTLS2_WBINVD_EXIT); 9409 9405 SET_ONLY_XBM_IF_EITHER_EN( EXIT_WBINVD, VMX_EXIT_WBINVD); 9410 SET_ONLY_XBM_IF_EITHER_EN(INSTR_XSETBV, VMX_EXIT_XSETBV); 9406 SET_ONLY_XBM_IF_EITHER_EN(INSTR_XSETBV, VMX_EXIT_XSETBV); /* unconditional */ 9411 9407 SET_ONLY_XBM_IF_EITHER_EN( EXIT_XSETBV, VMX_EXIT_XSETBV); 9412 9408 SET_CPE2_XBM_IF_EITHER_EN(INSTR_RDRAND, VMX_EXIT_RDRAND, VMX_PROC_CTLS2_RDRAND_EXIT); … … 9414 9410 SET_CPE1_XBM_IF_EITHER_EN(INSTR_VMX_INVPCID, VMX_EXIT_INVPCID, VMX_PROC_CTLS_INVLPG_EXIT); 9415 9411 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_INVPCID, VMX_EXIT_INVPCID); 9416 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMFUNC, VMX_EXIT_VMFUNC); 9412 SET_ONLY_XBM_IF_EITHER_EN(INSTR_VMX_VMFUNC, VMX_EXIT_VMFUNC); /* unconditional for the current setup */ 9417 9413 SET_ONLY_XBM_IF_EITHER_EN( EXIT_VMX_VMFUNC, VMX_EXIT_VMFUNC); 9418 9414 SET_CPE2_XBM_IF_EITHER_EN(INSTR_RDSEED, VMX_EXIT_RDSEED, VMX_PROC_CTLS2_RDSEED_EXIT); 9419 9415 SET_ONLY_XBM_IF_EITHER_EN( EXIT_RDSEED, VMX_EXIT_RDSEED); 9420 SET_ONLY_XBM_IF_EITHER_EN(INSTR_XSAVES, VMX_EXIT_XSAVES); 9416 SET_ONLY_XBM_IF_EITHER_EN(INSTR_XSAVES, VMX_EXIT_XSAVES); /* unconditional (enabled by host, guest cfg) */ 9421 9417 SET_ONLY_XBM_IF_EITHER_EN(EXIT_XSAVES, VMX_EXIT_XSAVES); 9422 SET_ONLY_XBM_IF_EITHER_EN(INSTR_XRSTORS, VMX_EXIT_XRSTORS); 9418 SET_ONLY_XBM_IF_EITHER_EN(INSTR_XRSTORS, VMX_EXIT_XRSTORS); /* unconditional (enabled by host, guest cfg) */ 9423 9419 SET_ONLY_XBM_IF_EITHER_EN( EXIT_XRSTORS, VMX_EXIT_XRSTORS); 9424 9420 … … 11967 11963 } 11968 11964 else 11969 AssertMsg(rcStrict == VINF_CPUM_R3_MSR_READ, ("Unexpected IEMExecDecodedRdmsr status: %Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));11965 AssertMsg(rcStrict == VINF_CPUM_R3_MSR_READ, ("Unexpected IEMExecDecodedRdmsr rc (%Rrc)\n", VBOXSTRICTRC_VAL(rcStrict))); 11970 11966 11971 11967 return rcStrict; … … 12110 12106 } 12111 12107 else 12112 AssertMsg(rcStrict == VINF_CPUM_R3_MSR_WRITE, ("Unexpected IEMExecDecodedWrmsr status: %Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));12108 AssertMsg(rcStrict == VINF_CPUM_R3_MSR_WRITE, ("Unexpected IEMExecDecodedWrmsr rc (%Rrc)\n", VBOXSTRICTRC_VAL(rcStrict))); 12113 12109 12114 12110 return rcStrict; … … 13232 13228 if ( !pVCpu->hm.s.fTrapXcptGpForLovelyMesaDrv 13233 13229 || !hmR0VmxIsMesaDrvGp(pVCpu, pVmxTransient, pCtx)) 13234 hmR0VmxSetPendingEvent(pVCpu, VMX_ENTRY_INT_INFO_FROM_EXIT_INT_INFO(pVmxTransient->uExitIntInfo), pVmxTransient->cbInstr,13235 pVmxTransient-> uExitIntErrorCode, 0 /* GCPtrFaultAddress */);13230 hmR0VmxSetPendingEvent(pVCpu, VMX_ENTRY_INT_INFO_FROM_EXIT_INT_INFO(pVmxTransient->uExitIntInfo), 13231 pVmxTransient->cbInstr, pVmxTransient->uExitIntErrorCode, 0 /* GCPtrFaultAddress */); 13236 13232 else 13237 13233 rc = hmR0VmxHandleMesaDrvGp(pVCpu, pVmxTransient, pCtx);
Note:
See TracChangeset
for help on using the changeset viewer.