VirtualBox

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


Ignore:
Timestamp:
Jun 28, 2013 3:37:49 PM (11 years ago)
Author:
vboxsync
Message:

VMM/HMSVMR0: Only save/restore TSC_AUX MSR when required.

File:
1 edited

Legend:

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

    r46850 r46869  
    195195    /** Whether the TSC offset mode needs to be updated. */
    196196    bool            fUpdateTscOffsetting;
     197    /** Whether the TSC_AUX MSR needs restoring on #VMEXIT. */
     198    bool            fRestoreTscAuxMsr;
    197199} SVMTRANSIENT, *PSVMTRANSIENT;
    198200/** @}  */
     
    26202622     * This should be done -after- any RDTSCPs for obtaining the host timestamp (TM, STAM etc).
    26212623     */
     2624    pSvmTransient->fRestoreTscAuxMsr = false;
    26222625    if (    (pVM->hm.s.cpuid.u32AMDFeatureEDX & X86_CPUID_EXT_FEATURE_EDX_RDTSCP)
    26232626        && !(pVmcb->ctrl.u32InterceptCtrl2 & SVM_CTRL2_INTERCEPT_RDTSCP))
     
    26272630        int rc2 = CPUMQueryGuestMsr(pVCpu, MSR_K8_TSC_AUX, &u64GuestTscAux);
    26282631        AssertRC(rc2);
    2629         ASMWrMsr(MSR_K8_TSC_AUX, u64GuestTscAux);
     2632        if (u64GuestTscAux != pVCpu->hm.s.u64HostTscAux)
     2633        {
     2634            ASMWrMsr(MSR_K8_TSC_AUX, u64GuestTscAux);
     2635            pSvmTransient->fRestoreTscAuxMsr = true;
     2636        }
    26302637    }
    26312638}
     
    26842691    pVmcb->ctrl.u64VmcbCleanBits = HMSVM_VMCB_CLEAN_ALL;        /* Mark the VMCB-state cache as unmodified by VMM. */
    26852692
     2693    if (pSvmTransient->fRestoreTscAuxMsr)
     2694        ASMWrMsr(MSR_K8_TSC_AUX, pVCpu->hm.s.u64HostTscAux);
     2695
    26862696    if (!(pVmcb->ctrl.u32InterceptCtrl1 & SVM_CTRL1_INTERCEPT_RDTSC))
    26872697    {
    2688         /* Restore host's TSC_AUX if required. */
    2689         if (pVM->hm.s.cpuid.u32AMDFeatureEDX & X86_CPUID_EXT_FEATURE_EDX_RDTSCP)
    2690             ASMWrMsr(MSR_K8_TSC_AUX, pVCpu->hm.s.u64HostTscAux);
    2691 
    26922698        /** @todo Find a way to fix hardcoding a guestimate.  */
    26932699        TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() + pVmcb->ctrl.u64TSCOffset - 0x400);
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