VirtualBox

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


Ignore:
Timestamp:
Jun 26, 2013 1:55:06 PM (11 years ago)
Author:
vboxsync
Message:

VMM/HMSVMR0: TSC offsetting.

File:
1 edited

Legend:

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

    r46798 r46804  
    193193     *  contributary exception or a page-fault. */
    194194    bool            fVectoringPF;
     195    /** Whether the TSC offset mode needs to be updated. */
     196    bool            fUpdateTscOffsetting;
    195197} SVMTRANSIENT, *PSVMTRANSIENT;
    196198/** @}  */
     
    18941896
    18951897/**
    1896  * Sets up the usage of TSC offsetting for the VCPU.
     1898 * Updates the use of TSC offsetting mode for the CPU and adjusts the necessary
     1899 * intercepts.
    18971900 *
    18981901 * @param   pVCpu       Pointer to the VMCPU.
     
    19001903 * @remarks No-long-jump zone!!!
    19011904 */
    1902 static void hmR0SvmSetupTscOffsetting(PVMCPU pVCpu)
     1905static void hmR0SvmUpdateTscOffsetting(PVMCPU pVCpu)
    19031906{
    19041907    PSVMVMCB pVmcb = (PSVMVMCB)pVCpu->hm.s.svm.pvVmcb;
     
    25842587    }
    25852588
     2589    /* Setup TSC offsetting. */
     2590    if (   pSvmTransient->fUpdateTscOffsetting
     2591        || HMR0GetCurrentCpu()->idCpu != pVCpu->hm.s.idLastCpu)
     2592    {
     2593        pSvmTransient->fUpdateTscOffsetting = false;
     2594        hmR0SvmUpdateTscOffsetting(pVCpu);
     2595    }
     2596
    25862597    /* Flush the appropriate tagged-TLB entries. */
    25872598    ASMAtomicWriteBool(&pVCpu->hm.s.fCheckedTLBFlush, true);    /* Used for TLB-shootdowns, set this across the world switch. */
     
    26622673    pVmcb->ctrl.u64VmcbCleanBits = HMSVM_VMCB_CLEAN_ALL;        /* Mark the VMCB-state cache as unmodified by VMM. */
    26632674
    2664     /* Restore host's TSC_AUX if required. */
    26652675    if (!(pVmcb->ctrl.u32InterceptCtrl1 & SVM_CTRL1_INTERCEPT_RDTSC))
    26662676    {
     2677        /* Restore host's TSC_AUX if required. */
    26672678        if (pVM->hm.s.cpuid.u32AMDFeatureEDX & X86_CPUID_EXT_FEATURE_EDX_RDTSCP)
    26682679            ASMWrMsr(MSR_K8_TSC_AUX, pVCpu->hm.s.u64HostTscAux);
    26692680
    26702681        /** @todo Find a way to fix hardcoding a guestimate.  */
    2671         TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() +
    2672                              pVmcb->ctrl.u64TSCOffset - 0x400);
     2682        TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() + pVmcb->ctrl.u64TSCOffset - 0x400);
    26732683    }
    26742684
     
    27282738
    27292739    SVMTRANSIENT SvmTransient;
     2740    SvmTransient.fUpdateTscOffsetting = true;
    27302741    uint32_t cLoops = 0;
    27312742    PSVMVMCB pVmcb  = (PSVMVMCB)pVCpu->hm.s.svm.pvVmcb;
     
    34903501    int rc = EMInterpretRdtsc(pVM, pVCpu, CPUMCTX2CORE(pCtx));
    34913502    if (RT_LIKELY(rc == VINF_SUCCESS))
     3503    {
    34923504        pCtx->rip += 2;     /* Hardcoded opcode, AMD-V doesn't give us this information. */
     3505        pSvmTransient->fUpdateTscOffsetting = true;
     3506    }
    34933507    else
    34943508    {
     
    35093523    int rc = EMInterpretRdtscp(pVCpu->CTX_SUFF(pVM), pVCpu, pCtx);
    35103524    if (RT_LIKELY(rc == VINF_SUCCESS))
     3525    {
    35113526        pCtx->rip += 3;     /* Hardcoded opcode, AMD-V doesn't give us this information. */
     3527        pSvmTransient->fUpdateTscOffsetting = true;
     3528    }
    35123529    else
    35133530    {
     
    37443761        if (pCtx->ecx == MSR_K6_EFER)
    37453762            pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_SVM_GUEST_EFER_MSR;
     3763        else if (pCtx->ecx == MSR_IA32_TSC)
     3764            pSvmTransient->fUpdateTscOffsetting = true;
    37463765    }
    37473766    else
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