VirtualBox

Changeset 70782 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Jan 29, 2018 7:46:15 AM (7 years ago)
Author:
vboxsync
Message:

VMM: Nested Hw.virt: Pick up the TSC offset from the original VMCB while applying the nested-guest TSC offset, rather
than the potentially modified VMCB.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
2 edited

Legend:

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

    r70781 r70782  
    27152715/**
    27162716 * Applies the TSC offset of a nested-guest if any and returns the new TSC
    2717  * value for the guest.
     2717 * value for the guest (or nested-guest).
    27182718 *
    27192719 * @returns The TSC offset after applying any nested-guest TSC offset.
    27202720 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
    27212721 * @param   uTicks      The guest TSC.
     2722 *
     2723 * @sa      HMSvmNstGstApplyTscOffset.
    27222724 */
    27232725VMM_INT_DECL(uint64_t) CPUMApplyNestedGuestTscOffset(PVMCPU pVCpu, uint64_t uTicks)
    27242726{
    27252727#ifndef IN_RC
    2726     PCCPUMCTX pCtx  = &pVCpu->cpum.s.Guest;
     2728    PCCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
    27272729    if (CPUMIsGuestInSvmNestedHwVirtMode(pCtx))
    27282730    {
    2729         PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    2730         return uTicks + pVmcb->ctrl.u64TSCOffset;
     2731        if (!pCtx->hwvirt.svm.fHMCachedVmcb)
     2732        {
     2733            PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
     2734            return uTicks + pVmcb->ctrl.u64TSCOffset;
     2735        }
     2736        return HMSvmNstGstApplyTscOffset(pVCpu, uTicks);
    27312737    }
    27322738
  • trunk/src/VBox/VMM/VMMAll/HMSVMAll.cpp

    r70781 r70782  
    202202    return HMIsEnabled(pVM) && fVGif && fUseVGif;
    203203}
     204
     205
     206/**
     207 * Applies the TSC offset of an SVM nested-guest if any and returns the new TSC
     208 * value for the nested-guest.
     209 *
     210 * @returns The TSC offset after applying any nested-guest TSC offset.
     211 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
     212 * @param   uTicks      The guest TSC.
     213 *
     214 * @remarks This function looks at the VMCB cache rather than directly at the
     215 *          nested-guest VMCB. The latter may have been modified for executing
     216 *          using hardware-assisted SVM.
     217 *
     218 * @sa      CPUMApplyNestedGuestTscOffset.
     219 */
     220VMM_INT_DECL(uint64_t) HMSvmNstGstApplyTscOffset(PVMCPU pVCpu, uint64_t uTicks)
     221{
     222    PCCPUMCTX pCtx = &pVCpu->cpum.GstCtx;
     223    Assert(CPUMIsGuestInSvmNestedHwVirtMode(pCtx));
     224    Assert(pCtx->hwvirt.svm.fHMCachedVmcb);
     225    NOREF(pCtx);
     226    PCSVMNESTEDVMCBCACHE pVmcbNstGstCache = &pVCpu->hm.s.svm.NstGstVmcbCache;
     227    return uTicks + pVmcbNstGstCache->u64TSCOffset;
     228}
    204229#endif /* !IN_RC */
    205230
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