VirtualBox

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


Ignore:
Timestamp:
Dec 11, 2017 2:40:02 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
119598
Message:

VMM: Nested hw.virt: Apply nested-guest TSC offset when executing the nested-guest.

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

Legend:

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

    r69216 r70056  
    184184    RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
    185185    *puValue = TMCpuTickGet(pVCpu);
     186#ifdef VBOX_WITH_NESTED_HWVIRT
     187    *puValue = CPUMApplyNestedGuestTscOffset(pVCpu, *puValue);
     188#endif
    186189    return VINF_SUCCESS;
    187190}
     
    342345     *        what we want? */
    343346    *puValue = TMCpuTickGet(pVCpu);
     347#ifdef VBOX_WITH_NESTED_HWVIRT
     348    *puValue = CPUMApplyNestedGuestTscOffset(pVCpu, *puValue);
     349#endif
    344350    return VINF_SUCCESS;
    345351}
     
    362368     *        what we want? */
    363369    *puValue = TMCpuTickGet(pVCpu);
     370#ifdef VBOX_WITH_NESTED_HWVIRT
     371    *puValue = CPUMApplyNestedGuestTscOffset(pVCpu, *puValue);
     372#endif
    364373    return VINF_SUCCESS;
    365374}
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r70000 r70056  
    26952695}
    26962696
     2697
     2698/**
     2699 * Applies the TSC offset of a nested-guest if any and returns the new TSC
     2700 * value for the guest.
     2701 *
     2702 * @returns The TSC offset after applying any nested-guest TSC offset.
     2703 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
     2704 * @param   uTicks      The guest TSC.
     2705 */
     2706VMM_INT_DECL(uint64_t) CPUMApplyNestedGuestTscOffset(PVMCPU pVCpu, uint64_t uTicks)
     2707{
     2708#ifndef IN_RC
     2709    PCCPUMCTX pCtx  = &pVCpu->cpum.s.Guest;
     2710    if (CPUMIsGuestInSvmNestedHwVirtMode(pCtx))
     2711    {
     2712        PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
     2713        return uTicks + pVmcb->ctrl.u64TSCOffset;
     2714    }
     2715
     2716    /** @todo Intel. */
     2717#else
     2718    RT_NOREF(pVCpu);
     2719#endif
     2720    return uTicks;
     2721}
     2722
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r69111 r70056  
    13151315
    13161316    uint64_t uTicks = TMCpuTickGet(pVCpu);
     1317#ifdef VBOX_WITH_NESTED_HWVIRT
     1318    uTicks = CPUMApplyNestedGuestTscOffset(pVCpu, uTicks);
     1319#endif
    13171320
    13181321    /* Same behaviour in 32 & 64 bits mode */
     
    13511354
    13521355    uint64_t uTicks = TMCpuTickGet(pVCpu);
     1356#ifdef VBOX_WITH_NESTED_HWVIRT
     1357    uTicks = CPUMApplyNestedGuestTscOffset(pVCpu, uTicks);
     1358#endif
    13531359
    13541360    /* Same behaviour in 32 & 64 bits mode */
  • trunk/src/VBox/VMM/VMMAll/HMSVMAll.cpp

    r70020 r70056  
    366366        pVmcbNstGstCtrl->u64IOPMPhysAddr          = pNstGstVmcbCache->u64IOPMPhysAddr;
    367367        pVmcbNstGstCtrl->u64MSRPMPhysAddr         = pNstGstVmcbCache->u64MSRPMPhysAddr;
     368        pVmcbNstGstCtrl->u64TSCOffset             = pNstGstVmcbCache->u64TSCOffset;
    368369        pVmcbNstGstCtrl->IntCtrl.n.u1VIntrMasking = pNstGstVmcbCache->fVIntrMasking;
    369370        pVmcbNstGstCtrl->TLBCtrl                  = pNstGstVmcbCache->TLBCtrl;
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