VirtualBox

Changeset 79377 in vbox


Ignore:
Timestamp:
Jun 27, 2019 8:05:04 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131615
Message:

VMM/IEM: Nested VMX: bugref:9180 Use CPUMIsGuestVmxMovToCr3InterceptSet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r79372 r79377  
    618618
    619619/**
    620  * Gets a CR3 target value from the VMCS.
    621  *
    622  * @returns VBox status code.
    623  * @param   pVmcs           Pointer to the virtual VMCS.
    624  * @param   idxCr3Target    The index of the CR3-target value to retrieve.
    625  * @param   puValue         Where to store the CR3-target value.
    626  */
    627 IEM_STATIC uint64_t iemVmxVmcsGetCr3TargetValue(PCVMXVVMCS pVmcs, uint8_t idxCr3Target)
    628 {
    629     Assert(idxCr3Target < VMX_V_CR3_TARGET_COUNT);
    630     uint8_t  const  uWidth         = VMX_VMCSFIELD_WIDTH_NATURAL;
    631     uint8_t  const  uType          = VMX_VMCSFIELD_TYPE_CONTROL;
    632     uint8_t  const  uWidthType     = (uWidth << 2) | uType;
    633     uint8_t  const  uIndex         = idxCr3Target + RT_BF_GET(VMX_VMCS_CTRL_CR3_TARGET_VAL0, VMX_BF_VMCSFIELD_INDEX);
    634     Assert(uIndex <= VMX_V_VMCS_MAX_INDEX);
    635     uint16_t const  offField       = g_aoffVmcsMap[uWidthType][uIndex];
    636     uint8_t  const *pbVmcs         = (uint8_t *)pVmcs;
    637     uint8_t  const *pbField        = pbVmcs + offField;
    638     uint64_t const uCr3TargetValue = *(uint64_t *)pbField;
    639     return uCr3TargetValue;
    640 }
    641 
    642 
    643 /**
    644620 * Converts an IEM exception event type to a VMX event type.
    645621 *
     
    30463022     * See Intel spec. 25.1.3 "Instructions That Cause VM Exits Conditionally".
    30473023     */
    3048     if (pVmcs->u32ProcCtls & VMX_PROC_CTLS_CR3_LOAD_EXIT)
    3049     {
    3050         uint32_t const uCr3TargetCount = pVmcs->u32Cr3TargetCount;
    3051         Assert(uCr3TargetCount <= VMX_V_CR3_TARGET_COUNT);
    3052 
    3053         /* If the CR3-target count is 0, we must always cause a VM-exit. */
    3054         bool fIntercept = RT_BOOL(uCr3TargetCount == 0);
    3055         if (!fIntercept)
    3056         {
    3057             for (uint32_t idxCr3Target = 0; idxCr3Target < uCr3TargetCount; idxCr3Target++)
    3058             {
    3059                 uint64_t const uCr3TargetValue = iemVmxVmcsGetCr3TargetValue(pVmcs, idxCr3Target);
    3060                 if (uNewCr3 != uCr3TargetValue)
    3061                 {
    3062                     fIntercept = true;
    3063                     break;
    3064                 }
    3065             }
    3066         }
    3067 
    3068         if (fIntercept)
    3069         {
    3070             Log2(("mov_Cr_Rd: (CR3) Guest intercept -> VM-exit\n"));
    3071 
    3072             VMXVEXITINFO ExitInfo;
    3073             RT_ZERO(ExitInfo);
    3074             ExitInfo.uReason = VMX_EXIT_MOV_CRX;
    3075             ExitInfo.cbInstr = cbInstr;
    3076             ExitInfo.u64Qual = RT_BF_MAKE(VMX_BF_EXIT_QUAL_CRX_REGISTER, 3) /* CR3 */
    3077                              | RT_BF_MAKE(VMX_BF_EXIT_QUAL_CRX_ACCESS,   VMX_EXIT_QUAL_CRX_ACCESS_WRITE)
    3078                              | RT_BF_MAKE(VMX_BF_EXIT_QUAL_CRX_GENREG,   iGReg);
    3079             return iemVmxVmexitInstrWithInfo(pVCpu, &ExitInfo);
    3080         }
     3024    if (CPUMIsGuestVmxMovToCr3InterceptSet(pVCpu, uNewCr3))
     3025    {
     3026        Log2(("mov_Cr_Rd: (CR3) Guest intercept -> VM-exit\n"));
     3027
     3028        VMXVEXITINFO ExitInfo;
     3029        RT_ZERO(ExitInfo);
     3030        ExitInfo.uReason = VMX_EXIT_MOV_CRX;
     3031        ExitInfo.cbInstr = cbInstr;
     3032        ExitInfo.u64Qual = RT_BF_MAKE(VMX_BF_EXIT_QUAL_CRX_REGISTER, 3) /* CR3 */
     3033                         | RT_BF_MAKE(VMX_BF_EXIT_QUAL_CRX_ACCESS,   VMX_EXIT_QUAL_CRX_ACCESS_WRITE)
     3034                         | RT_BF_MAKE(VMX_BF_EXIT_QUAL_CRX_GENREG,   iGReg);
     3035        return iemVmxVmexitInstrWithInfo(pVCpu, &ExitInfo);
    30813036    }
    30823037
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette