Changeset 78715 in vbox for trunk/include/VBox/vmm
- Timestamp:
- May 24, 2019 11:16:11 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/cpum.h
r78688 r78715 2163 2163 PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs); 2164 2164 Assert(pVmcs); 2165 Assert(CPUMIsGuestInVmx RootMode(pCtx));2165 Assert(CPUMIsGuestInVmxNonRootMode(pCtx)); 2166 2166 uint64_t const uGstCr0 = pCtx->cr0; 2167 2167 uint64_t const fGstHostMask = pVmcs->u64Cr0Mask.u; … … 2189 2189 PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs); 2190 2190 Assert(pVmcs); 2191 Assert(CPUMIsGuestInVmx RootMode(pCtx));2191 Assert(CPUMIsGuestInVmxNonRootMode(pCtx)); 2192 2192 uint64_t const uGstCr4 = pCtx->cr4; 2193 2193 uint64_t const fGstHostMask = pVmcs->u64Cr4Mask.u; 2194 2194 uint64_t const fReadShadow = pVmcs->u64Cr4ReadShadow.u; 2195 2195 return (fReadShadow & fGstHostMask) | (uGstCr4 & ~fGstHostMask); 2196 } 2197 2198 2199 /** 2200 * Checks whether the LMSW access causes a VM-exit or not. 2201 * 2202 * @returns @c true if the LMSW access causes a VM-exit, @c false otherwise. 2203 * @param pVCpu The cross context virtual CPU structure of the calling EMT. 2204 * @param pCtx Pointer to the context. 2205 * @param uNewMsw The LMSW source operand (the Machine Status Word). 2206 */ 2207 DECLINLINE(bool) CPUMIsGuestVmxLmswInterceptSet(PVMCPU pVCpu, PCCPUMCTX pCtx, uint16_t uNewMsw) 2208 { 2209 /* 2210 * LMSW VM-exits are subject to the CR0 guest/host mask and the CR0 read shadow. 2211 * 2212 * See Intel spec. 24.6.6 "Guest/Host Masks and Read Shadows for CR0 and CR4". 2213 * See Intel spec. 25.1.3 "Instructions That Cause VM Exits Conditionally". 2214 */ 2215 RT_NOREF(pVCpu); 2216 PCVMXVVMCS pVmcs = pCtx->hwvirt.vmx.CTX_SUFF(pVmcs); 2217 Assert(pVmcs); 2218 Assert(CPUMIsGuestInVmxNonRootMode(pCtx)); 2219 2220 uint32_t const fGstHostMask = pVmcs->u64Cr0Mask.u; 2221 uint32_t const fReadShadow = pVmcs->u64Cr0ReadShadow.u; 2222 2223 /* 2224 * LMSW can never clear CR0.PE but it may set it. Hence, we handle the 2225 * CR0.PE case first, before the rest of the bits in the MSW. 2226 * 2227 * If CR0.PE is owned by the host and CR0.PE differs between the 2228 * MSW (source operand) and the read-shadow, we must cause a VM-exit. 2229 */ 2230 if ( (fGstHostMask & X86_CR0_PE) 2231 && (uNewMsw & X86_CR0_PE) 2232 && !(fReadShadow & X86_CR0_PE)) 2233 return true; 2234 2235 /* 2236 * If CR0.MP, CR0.EM or CR0.TS is owned by the host, and the corresponding 2237 * bits differ between the MSW (source operand) and the read-shadow, we must 2238 * cause a VM-exit. 2239 */ 2240 uint32_t const fGstHostLmswMask = fGstHostMask & (X86_CR0_MP | X86_CR0_EM | X86_CR0_TS); 2241 if ((fReadShadow & fGstHostLmswMask) != (uNewMsw & fGstHostLmswMask)) 2242 return true; 2243 2244 return false; 2196 2245 } 2197 2246
Note:
See TracChangeset
for help on using the changeset viewer.