VirtualBox

Changeset 54712 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Mar 11, 2015 12:54:03 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
98876
Message:

VMM: Clear idHostCpu mapping while deregistering the context-hooks rather than in HMR0Leave().
Simplified HMR0_[DISABLE|RESTORE]_PREEMPT_IF_NEEDED() and made VMMR0ThreadCtxHooksDeregister() check before deregistering the
hook rather than asking the caller to do it each time.

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

Legend:

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

    r54600 r54712  
    14271427    /* Clear it while leaving HM context, hmPokeCpuForTlbFlush() relies on this. */
    14281428    pVCpu->hm.s.idEnteredCpu = NIL_RTCPUID;
    1429 
    1430     /* Clear the VCPU <-> host CPU mapping as we've left HM context (for the preemption hook case). */
    1431     ASMAtomicWriteU32(&pVCpu->idHostCpu, NIL_RTCPUID);
    14321429
    14331430    return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r54308 r54712  
    20972097
    20982098    /* Deregister hook now that we've left HM context before re-enabling preemption. */
    2099     if (VMMR0ThreadCtxHooksAreRegistered(pVCpu))
    2100         VMMR0ThreadCtxHooksDeregister(pVCpu);
     2099    VMMR0ThreadCtxHooksDeregister(pVCpu);
    21012100
    21022101    /* Leave HM context. This takes care of local init (term). */
     
    21542153        CPUMR0DebugStateMaybeSaveGuestAndRestoreHost(pVCpu, false /* save DR6 */);
    21552154
    2156         /* Deregister hook now that we've left HM context before re-enabling preemption. */
    2157         if (VMMR0ThreadCtxHooksAreRegistered(pVCpu))
    2158             VMMR0ThreadCtxHooksDeregister(pVCpu);
     2155        /* Deregister the hook now that we've left HM context before re-enabling preemption. */
     2156        VMMR0ThreadCtxHooksDeregister(pVCpu);
    21592157
    21602158        /* Leave HM context. This takes care of local init (term). */
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r54650 r54712  
    71087108
    71097109    /* Deregister hook now that we've left HM context before re-enabling preemption. */
    7110     /** @todo This is bad. Deregistering here means we need to VMCLEAR always
     7110    /** @todo Deregistering here means we need to VMCLEAR always
    71117111     *        (longjmp/exit-to-r3) in VT-x which is not efficient. */
    7112     if (VMMR0ThreadCtxHooksAreRegistered(pVCpu))
    7113         VMMR0ThreadCtxHooksDeregister(pVCpu);
     7112    VMMR0ThreadCtxHooksDeregister(pVCpu);
    71147113
    71157114    /* Leave HM context. This takes care of local init (term). */
     
    72787277        }
    72797278
    7280         if (VMMR0ThreadCtxHooksAreRegistered(pVCpu))
    7281             VMMR0ThreadCtxHooksDeregister(pVCpu);
     7279        VMMR0ThreadCtxHooksDeregister(pVCpu);
    72827280
    72837281        HMR0LeaveCpu(pVCpu);
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r54552 r54712  
    510510VMMR0DECL(int) VMMR0ThreadCtxHooksDeregister(PVMCPU pVCpu)
    511511{
    512     return RTThreadCtxHooksDeregister(pVCpu->vmm.s.hR0ThreadCtx);
     512    if (pVCpu->vmm.s.hR0ThreadCtx != NIL_RTTHREADCTX)
     513    {
     514        Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     515        int rc = RTThreadCtxHooksDeregister(pVCpu->vmm.s.hR0ThreadCtx);
     516        AssertRCReturn(rc, rc);
     517    }
     518
     519    /* Clear the VCPU <-> host CPU mapping as we've left HM context. See @bugref{7726} comment #19. */
     520    ASMAtomicWriteU32(&pVCpu->idHostCpu, NIL_RTCPUID);
     521    return VINF_SUCCESS;
    513522}
    514523
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