VirtualBox

Changeset 79874 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Jul 19, 2019 9:15:09 AM (6 years ago)
Author:
vboxsync
Message:

VMM/HM: Nested VMX: bugref:9180 We need to flush the TLB when the VMX APIC-access page address changes (when we switch to/from guest/nested-guest).

Location:
trunk/src/VBox/VMM
Files:
3 edited

Legend:

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

    r79715 r79874  
    13251325     */
    13261326    pVCpu->hm.s.vmx.fMergedNstGstCtls = false;
     1327
     1328    /*
     1329     * Flush the TLB before entering the outer guest execution (mainly required since the
     1330     * APIC-access guest-physical address would have changed and probably more things in
     1331     * the future).
     1332     */
     1333    pVCpu->hm.s.vmx.fSwitchedNstGstFlushTlb = true;
    13271334}
    13281335
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r79872 r79874  
    30343034        HMVMX_SET_TAGGED_TLB_FLUSHED();
    30353035    }
     3036    else if (pVCpu->hm.s.vmx.fSwitchedNstGstFlushTlb)
     3037    {
     3038        /*
     3039         * The nested-guest specifies its own guest-physical address to use as the APIC-access
     3040         * address which requires flushing the TLB of EPT cached structures.
     3041         *
     3042         * See Intel spec. 28.3.3.4 "Guidelines for Use of the INVEPT Instruction".
     3043         */
     3044        hmR0VmxFlushEpt(pVCpu, pVmcsInfo, pVM->hm.s.vmx.enmTlbFlushEpt);
     3045        pVCpu->hm.s.vmx.fSwitchedNstGstFlushTlb = false;
     3046        STAM_COUNTER_INC(&pVCpu->hm.s.StatFlushTlbNstGst);
     3047        HMVMX_SET_TAGGED_TLB_FLUSHED();
     3048    }
     3049
    30363050
    30373051    pVCpu->hm.s.fForceTLBFlush = false;
     
    30913105    }
    30923106
     3107    /* Check for TLB flushes while switching to/from a nested-guest. */
     3108    if (pVCpu->hm.s.vmx.fSwitchedNstGstFlushTlb)
     3109    {
     3110        pVCpu->hm.s.fForceTLBFlush = true;
     3111        pVCpu->hm.s.vmx.fSwitchedNstGstFlushTlb = false;
     3112        STAM_COUNTER_INC(&pVCpu->hm.s.StatFlushTlbNstGst);
     3113    }
     3114
    30933115    pVCpu->hm.s.idLastCpu   = pHostCpu->idCpu;
    30943116    pVCpu->hm.s.cTlbFlushes = pHostCpu->cTlbFlushes;
     
    31423164        pVCpu->hm.s.fForceTLBFlush = true;
    31433165        STAM_COUNTER_INC(&pVCpu->hm.s.StatFlushTlb);
     3166    }
     3167
     3168    /* Check for TLB flushes while switching to/from a nested-guest. */
     3169    if (pVCpu->hm.s.vmx.fSwitchedNstGstFlushTlb)
     3170    {
     3171        pVCpu->hm.s.fForceTLBFlush = true;
     3172        pVCpu->hm.s.vmx.fSwitchedNstGstFlushTlb = false;
     3173        STAM_COUNTER_INC(&pVCpu->hm.s.StatFlushTlbNstGst);
    31443174    }
    31453175
     
    1095910989    pVmcsInfoNstGst->u32XcptPFMatch = u32XcptPFMatch;
    1096010990    pVmcsInfoNstGst->HCPhysVirtApic = HCPhysVirtApic;
     10991
     10992    /*
     10993     * We need to flush the TLB if we are switching the API-access page address.
     10994     * See Intel spec. 28.3.3.4 "Guidelines for Use of the INVEPT Instruction".
     10995     */
     10996    if (u32ProcCtls2 & VMX_PROC_CTLS2_VIRT_APIC_ACCESS)
     10997        pVCpu->hm.s.vmx.fSwitchedNstGstFlushTlb = true;
    1096110998
    1096210999    /*
  • trunk/src/VBox/VMM/include/HMInternal.h

    r79873 r79874  
    994994            /** Whether the nested-guest VMCS has been copied to the shadow VMCS. */
    995995            bool                        fCopiedNstGstToShadowVmcs;
     996            /** Whether flushing the TLB is required due to switching to/from the
     997             *  nested-geust. */
     998            bool                        fSwitchedNstGstFlushTlb;
    996999            /** Alignment. */
    997             bool                        afAlignment0[5];
     1000            bool                        afAlignment0[4];
    9981001            /** Cached guest APIC-base MSR for identifying when to map the APIC-access page. */
    9991002            uint64_t                    u64GstMsrApicBase;
Note: See TracChangeset for help on using the changeset viewer.

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