Changeset 74620 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Oct 5, 2018 4:14:45 AM (6 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h
r74618 r74620 5215 5215 if ( iCrReg == 0 5216 5216 || iCrReg == 4) 5217 crX = iemVmx GetMaskedCrX(pVCpu, iCrReg, crX);5217 crX = iemVmxMaskCr0CR4(pVCpu, iCrReg, crX); 5218 5218 } 5219 5219 #endif … … 5749 5749 if (IEM_VMX_IS_NON_ROOT_MODE(pVCpu)) 5750 5750 { 5751 if ( iCrReg == 0)5752 {5753 IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR0);5754 VBOXSTRICTRC rcStrict = iemVmxVmexitInstrMov Cr0Write(pVCpu, pVCpu->cpum.GstCtx.cr0, &uNewCrX, iGReg, cbInstr);5751 if ( iCrReg == 0 5752 || iCrReg == 4) 5753 { 5754 VBOXSTRICTRC rcStrict = iemVmxVmexitInstrMovToCr0Cr4(pVCpu, iCrReg, &uNewCrX, iGReg, cbInstr); 5755 5755 if (rcStrict != VINF_VMX_INTERCEPT_NOT_ACTIVE) 5756 5756 return rcStrict; -
trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h
r74619 r74620 901 901 902 902 /** 903 * Gets the nested-guest CR0/CR4 mask subjected to the corresponding guest/host mask904 * and the read-shadow.903 * Masks the nested-guest CR0/CR4 mask subjected to the corresponding guest/host 904 * mask and the read-shadow. 905 905 * 906 906 * @returns The masked CR0/CR4. … … 909 909 * @param uGuestCrX The current guest CR0 or guest CR4. 910 910 */ 911 IEM_STATIC uint64_t iemVmx GetMaskedCrX(PVMCPU pVCpu, uint8_t iCrReg, uint64_t uGuestCrX)911 IEM_STATIC uint64_t iemVmxMaskCr0CR4(PVMCPU pVCpu, uint8_t iCrReg, uint64_t uGuestCrX) 912 912 { 913 913 Assert(IEM_VMX_IS_NON_ROOT_MODE(pVCpu)); … … 2952 2952 2953 2953 /** 2954 * VMX VM-exit handler for VM-exits due to 'Mov CR0, GReg' (CR0 write). 2954 * VMX VM-exit handler for VM-exits due to 'Mov CR0, GReg' and 'Mov CR4, GReg' 2955 * (CR0/CR4 write). 2955 2956 * 2956 2957 * @returns Strict VBox status code. 2957 2958 * @param pVCpu The cross context virtual CPU structure. 2958 * @param puNewCr0 Pointer to the new CR0 value. Will be updated if no 2959 * VM-exit is triggered. 2960 * @param iGReg The general register to load the CR0 value from. 2959 * @param iCrReg The control register (either CR0 or CR4). 2960 * @param uGuestCrX The current guest CR0/CR4. 2961 * @param puNewCrX Pointer to the new CR0/CR4 value. Will be updated 2962 * if no VM-exit is triggered. 2963 * @param iGReg The general register to load the CR0/CR4 value from. 2961 2964 * @param cbInstr The instruction length in bytes. 2962 2965 */ 2963 IEM_STATIC VBOXSTRICTRC iemVmxVmexitInstrMov Cr0Write(PVMCPU pVCpu, uint64_t uGuestCr0, uint64_t *puNewCr0, uint8_t iGReg,2966 IEM_STATIC VBOXSTRICTRC iemVmxVmexitInstrMovToCr0Cr4(PVMCPU pVCpu, uint8_t iCrReg, uint64_t *puNewCrX, uint8_t iGReg, 2964 2967 uint8_t cbInstr) 2965 2968 { 2969 Assert(puNewCrX); 2970 Assert(iCrReg == 0 || iCrReg == 4); 2971 2966 2972 PCVMXVVMCS pVmcs = pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs); 2967 2973 Assert(pVmcs); 2968 Assert(puNewCr0); 2969 2970 uint32_t const fGstHostMask = pVmcs->u64Cr0Mask.u; 2971 uint32_t const fReadShadow = pVmcs->u64Cr0ReadShadow.u; 2972 2973 /* 2974 * For any CR0 bit owned by the host (in the CR0 guest/host mask), if the 2974 2975 uint64_t uGuestCrX; 2976 uint64_t fGstHostMask; 2977 uint64_t fReadShadow; 2978 if (iCrReg == 0) 2979 { 2980 IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR0); 2981 uGuestCrX = pVCpu->cpum.GstCtx.cr0; 2982 fGstHostMask = pVmcs->u64Cr0Mask.u; 2983 fReadShadow = pVmcs->u64Cr0ReadShadow.u; 2984 } 2985 else 2986 { 2987 IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR4); 2988 uGuestCrX = pVCpu->cpum.GstCtx.cr4; 2989 fGstHostMask = pVmcs->u64Cr4Mask.u; 2990 fReadShadow = pVmcs->u64Cr4ReadShadow.u; 2991 } 2992 2993 /* 2994 * For any CR0/CR4 bit owned by the host (in the CR0/CR4 guest/host mask), if the 2975 2995 * corresponding bits differ between the source operand and the read-shadow, 2976 2996 * we must cause a VM-exit. … … 2978 2998 * See Intel spec. 25.1.3 "Instructions That Cause VM Exits Conditionally". 2979 2999 */ 2980 if ((fReadShadow & fGstHostMask) != (*puNewCr 0& fGstHostMask))2981 { 2982 Log2(("mov_Cr_Rd: Guest intercept -> VM-exit\n"));3000 if ((fReadShadow & fGstHostMask) != (*puNewCrX & fGstHostMask)) 3001 { 3002 Log2(("mov_Cr_Rd: (CR%u) Guest intercept -> VM-exit\n", iCrReg)); 2983 3003 2984 3004 VMXVEXITINFO ExitInfo; … … 2987 3007 ExitInfo.cbInstr = cbInstr; 2988 3008 2989 ExitInfo.u64Qual = RT_BF_MAKE(VMX_BF_EXIT_QUAL_CRX_REGISTER, 0) /* CR0 */3009 ExitInfo.u64Qual = RT_BF_MAKE(VMX_BF_EXIT_QUAL_CRX_REGISTER, iCrReg) 2990 3010 | RT_BF_MAKE(VMX_BF_EXIT_QUAL_CRX_ACCESS, VMX_EXIT_QUAL_CRX_ACCESS_WRITE) 2991 3011 | RT_BF_MAKE(VMX_BF_EXIT_QUAL_CRX_GENREG, iGReg); … … 2994 3014 2995 3015 /* 2996 * If Mov-to-CR0 did not cause a VM-exit, any bits owned by the host must not2997 * be modified the instruction.3016 * If the Mov-to-CR0/CR4 did not cause a VM-exit, any bits owned by the host 3017 * must not be modified the instruction. 2998 3018 * 2999 3019 * See Intel Spec. 25.3 "Changes To Instruction Behavior In VMX Non-root Operation". 3000 3020 */ 3001 *puNewCr 0 = (uGuestCr0 & fGstHostMask) | (*puNewCr0& ~fGstHostMask);3021 *puNewCrX = (uGuestCrX & fGstHostMask) | (*puNewCrX & ~fGstHostMask); 3002 3022 3003 3023 return VINF_VMX_INTERCEPT_NOT_ACTIVE;
Note:
See TracChangeset
for help on using the changeset viewer.