VirtualBox

Changeset 72079 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 2, 2018 5:15:20 AM (7 years ago)
Author:
vboxsync
Message:

VMM/HMSVM: Added hmR0SvmNstGstUndoTscOffset as counterpart of HMSvmNstGstApplyTscOffset.

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

Legend:

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

    r72065 r72079  
    210210 *          using hardware-assisted SVM.
    211211 *
    212  * @sa      CPUMApplyNestedGuestTscOffset.
     212 * @note    If you make any changes to this function, please check if
     213 *          hmR0SvmNstGstUndoTscOffset() needs adjusting.
     214 *
     215 * @sa      CPUMApplyNestedGuestTscOffset(), hmR0SvmNstGstUndoTscOffset().
    213216 */
    214217VMM_INT_DECL(uint64_t) HMSvmNstGstApplyTscOffset(PVMCPU pVCpu, uint64_t uTicks)
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r72066 r72079  
    44704470}
    44714471
     4472
    44724473#ifdef VBOX_WITH_NESTED_HWVIRT
     4474/**
     4475 * Undoes the TSC offset applied for an SVM nested-guest and returns the TSC
     4476 * value for the guest.
     4477 *
     4478 * @returns The TSC offset after undoing any nested-guest TSC offset.
     4479 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
     4480 * @param   uTicks      The nested-guest TSC.
     4481 *
     4482 * @note    If you make any changes to this function, please check if
     4483 *          hmR0SvmNstGstUndoTscOffset() needs adjusting.
     4484 *
     4485 * @sa      HMSvmNstGstApplyTscOffset().
     4486 */
     4487DECLINLINE(uint64_t) hmR0SvmNstGstUndoTscOffset(PVMCPU pVCpu, PCPUMCTX pCtx, uint64_t uTicks)
     4488{
     4489    Assert(pCtx->hwvirt.svm.fHMCachedVmcb); RT_NOREF(pCtx);
     4490    PCSVMNESTEDVMCBCACHE pVmcbNstGstCache = &pVCpu->hm.s.svm.NstGstVmcbCache;
     4491    return uTicks - pVmcbNstGstCache->u64TSCOffset;
     4492}
     4493
     4494
    44734495/**
    44744496 * Wrapper for running the nested-guest code in AMD-V.
     
    45304552        else
    45314553        {
    4532             /*
    4533              * Undo what we did in hmR0SvmUpdateTscOffsetting() and HMSvmNstGstApplyTscOffset()
    4534              * but don't restore the nested-guest VMCB TSC offset here. It shall eventually be
    4535              * restored on #VMEXIT in HMSvmNstGstVmExitNotify().
    4536              */
    4537             PCSVMNESTEDVMCBCACHE pVmcbNstGstCache = hmR0SvmGetNestedVmcbCache(pVCpu, pMixedCtx);
    4538             TMCpuTickSetLastSeen(pVCpu, uHostTsc + pVmcbCtrl->u64TSCOffset - pVmcbNstGstCache->u64TSCOffset);
     4554            /* The nested-guest VMCB TSC offset shall eventually be restored on #VMEXIT via HMSvmNstGstVmExitNotify(). */
     4555            uint64_t const uGstTsc = hmR0SvmNstGstUndoTscOffset(pVCpu, pMixedCtx, uHostTsc + pVmcbCtrl->u64TSCOffset);
     4556            TMCpuTickSetLastSeen(pVCpu, uGstTsc);
    45394557        }
    45404558    }
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