VirtualBox

Changeset 79489 in vbox


Ignore:
Timestamp:
Jul 3, 2019 8:02:20 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131753
Message:

VMM/HMVMXR0: Nested VMX: bugref:9180 Don't add/remove the TSC_AUX MSR during VM-entry because we might transition to executing the nested-guest after the VM-exit. So add during VM-entry and remove on the VM-exit to make sure the MSR bitmap permissions are what they should be in case we transition to executing a nested-guest.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r79488 r79489  
    280280     *  external interrupt or NMI. */
    281281    bool                fVectoringPF;
    282     bool                afAlignment0[3];
     282    /** Whether the TSC_AUX MSR needs to be removed from the auto-load/store MSR
     283     *  area after VM-exit. */
     284    bool                fRemoveTscAuxMsr;
     285    bool                afAlignment0[2];
    283286
    284287    /** The VMCS info. object. */
     
    1174711750     * host CPU ticks till the next virtual sync deadline (for the dynamic case).
    1174811751     */
    11749     if (pVmcsInfo->u32ProcCtls2 & VMX_PROC_CTLS2_RDTSCP)
    11750     {
    11751         if (!(pVmcsInfo->u32ProcCtls & VMX_PROC_CTLS_RDTSC_EXIT))
    11752         {
    11753             /** @todo NSTVMX: This might be broken wrt to merging MSR permissions when
    11754              *        transitioning to executing the nested-guest. We should probably remove
    11755              *        the dynamically added MSRs somehow. */
    11756             hmR0VmxImportGuestState(pVCpu, pVmcsInfo, CPUMCTX_EXTRN_TSC_AUX);
    11757             /* NB: Because we call hmR0VmxAddAutoLoadStoreMsr with fUpdateHostMsr=true,
    11758                it's safe even after hmR0VmxUpdateAutoLoadHostMsrs has already been done. */
    11759             int rc = hmR0VmxAddAutoLoadStoreMsr(pVCpu, pVmxTransient, MSR_K8_TSC_AUX, CPUMGetGuestTscAux(pVCpu),
    11760                                                 true /* fSetReadWrite */, true /* fUpdateHostMsr */);
    11761             AssertRC(rc);
    11762         }
    11763         else
    11764             hmR0VmxRemoveAutoLoadStoreMsr(pVCpu, pVmxTransient, MSR_K8_TSC_AUX);
     11752    if (    (pVmcsInfo->u32ProcCtls2 & VMX_PROC_CTLS2_RDTSCP)
     11753        && !(pVmcsInfo->u32ProcCtls & VMX_PROC_CTLS_RDTSC_EXIT))
     11754    {
     11755        /** @todo NSTVMX: This might be broken wrt to merging MSR permissions when
     11756         *        transitioning to executing the nested-guest. We should probably remove
     11757         *        the dynamically added MSRs somehow. */
     11758        hmR0VmxImportGuestState(pVCpu, pVmcsInfo, CPUMCTX_EXTRN_TSC_AUX);
     11759
     11760        /* NB: Because we call hmR0VmxAddAutoLoadStoreMsr with fUpdateHostMsr=true,
     11761           it's safe even after hmR0VmxUpdateAutoLoadHostMsrs has already been done. */
     11762        int rc = hmR0VmxAddAutoLoadStoreMsr(pVCpu, pVmxTransient, MSR_K8_TSC_AUX, CPUMGetGuestTscAux(pVCpu),
     11763                                            true /* fSetReadWrite */, true /* fUpdateHostMsr */);
     11764        AssertRC(rc);
     11765        Assert(!pVmxTransient->fRemoveTscAuxMsr);
     11766        pVmxTransient->fRemoveTscAuxMsr = true;
    1176511767    }
    1176611768
     
    1185111853    pVmxTransient->uExitReason    = VMX_EXIT_REASON_BASIC(uExitReason);
    1185211854    pVmxTransient->fVMEntryFailed = VMX_EXIT_REASON_HAS_ENTRY_FAILED(uExitReason);
     11855
     11856    /*
     11857     * Remove the TSC_AUX MSR from the auto-load/store MSR area and reset any MSR
     11858     * bitmap permissions, if it was added before VM-entry.
     11859     */
     11860    if (pVmxTransient->fRemoveTscAuxMsr)
     11861    {
     11862        hmR0VmxRemoveAutoLoadStoreMsr(pVCpu, pVmxTransient, MSR_K8_TSC_AUX);
     11863        pVmxTransient->fRemoveTscAuxMsr = false;
     11864    }
    1185311865
    1185411866    /*
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