VirtualBox

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


Ignore:
Timestamp:
Sep 2, 2013 11:54:23 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
88620
Message:

VMM: Ensure longjmps after hmR0[Vmx|Svm]LeaveSession() don't happen.

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

Legend:

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

    r48218 r48227  
    301301 * @param   pvCpuPage       Pointer to the global CPU page.
    302302 * @param   HCPhysCpuPage   Physical address of the global CPU page.
     303 * @param   fEnabledByHost  Whether the host OS has already initialized AMD-V.
    303304 * @param   pvArg           Unused on AMD-V.
    304305 */
     
    311312    AssertReturn(pvCpuPage, VERR_INVALID_PARAMETER);
    312313    NOREF(pvArg);
     314    NOREF(fEnabledByHost);
    313315
    314316    /*
     
    15871589
    15881590    LogFlowFunc(("pVM=%p pVCpu=%p\n", pVM, pVCpu));
     1591    Assert(pVCpu->hm.s.fContextUseFlags & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_HOST_GUEST_SHARED_STATE));
    15891592
    15901593    pVCpu->hm.s.fLeaveDone = false;
     
    20912094    }
    20922095
    2093     /* On our way back from ring-3 the following needs to be done. */
    2094     /** @todo This can change with preemption hooks. */
    2095     if (rcExit == VINF_EM_RAW_INTERRUPT)
    2096         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_HOST_CONTEXT;
    2097     else
    2098         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_HOST_CONTEXT | HM_CHANGED_ALL_GUEST;
     2096    /* On our way back from ring-3 reload the guest state if there is a possibility of it being changed. */
     2097    if (rcExit != VINF_EM_RAW_INTERRUPT)
     2098        pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_ALL_GUEST;
    20992099
    21002100    STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchExitToR3);
     2101
     2102    /* We do -not- want any longjmp notifications after this! We must return to ring-3 ASAP. */
     2103    VMMRZCallRing3RemoveNotification(pVCpu);
    21012104    VMMRZCallRing3Enable(pVCpu);
    21022105}
     
    30663069
    30673070    hmR0SvmExitToRing3(pVM, pVCpu, pCtx, rc);
    3068     VMMRZCallRing3RemoveNotification(pVCpu);
     3071    Assert(!VMMRZCallRing3IsNotificationSet(pVCpu));
    30693072    return rc;
    30703073}
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r48220 r48227  
    10181018    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    10191019
     1020    /* Enable VT-x if it's not already enabled by the host. */
    10201021    if (!fEnabledByHost)
    10211022    {
     
    61776178{
    61786179    HM_DISABLE_PREEMPT_IF_NEEDED();
     6180    HMVMX_ASSERT_CPU_SAFE();
    61796181    Assert(!VMMRZCallRing3IsEnabled(pVCpu));
    61806182    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     
    62996301     *        accessing APIC page in prot mode. */
    63006302
    6301     /* On our way back from ring-3 the following needs to be done. */
    6302     if (rcExit == VINF_EM_RAW_INTERRUPT)
    6303         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_HOST_CONTEXT;
    6304     else
    6305         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_HOST_CONTEXT | HM_CHANGED_ALL_GUEST;
     6303    /* On our way back from ring-3 reload the guest state if there is a possibility of it being changed. */
     6304    if (rcExit != VINF_EM_RAW_INTERRUPT)
     6305        pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_ALL_GUEST;
    63066306
    63076307    STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchExitToR3);
     6308
     6309    /* We do -not- want any longjmp notifications after this! We must return to ring-3 ASAP. */
     6310    VMMRZCallRing3RemoveNotification(pVCpu);
    63086311    VMMRZCallRing3Enable(pVCpu);
    63096312}
     
    69026905
    69036906    LogFlowFunc(("pVM=%p pVCpu=%p\n", pVM, pVCpu));
     6907    Assert(pVCpu->hm.s.fContextUseFlags & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_HOST_GUEST_SHARED_STATE));
    69046908
    69056909#ifdef VBOX_STRICT
     
    77457749
    77467750    hmR0VmxExitToRing3(pVM, pVCpu, pCtx, rc);
    7747     VMMRZCallRing3RemoveNotification(pVCpu);
     7751    Assert(!VMMRZCallRing3IsNotificationSet(pVCpu));
    77487752    return rc;
    77497753}
     
    85888592                        Assert(pVCpu->CTX_SUFF(pVM)->hm.s.vmx.pRealModeTSS);
    85898593                        Assert(PDMVmmDevHeapIsEnabled(pVCpu->CTX_SUFF(pVM)));
     8594                        Assert(CPUMIsGuestInRealModeEx(pMixedCtx));
     8595
    85908596                        rc  = hmR0VmxReadExitInstrLenVmcs(pVCpu, pVmxTransient);
    85918597                        rc |= hmR0VmxReadExitIntrErrorCodeVmcs(pVCpu, pVmxTransient);
  • trunk/src/VBox/VMM/VMMRZ/VMMRZ.cpp

    r45330 r48227  
    214214}
    215215
     216
     217/**
     218 * Checks whether there is a ring-0 callback notification active.
     219 *
     220 * @param   pVCpu   Pointer to the VMCPU.
     221 * @returns true if there the notification is active, false otherwise.
     222 */
     223VMMRZDECL(bool) VMMRZCallRing3IsNotificationSet(PVMCPU pVCpu)
     224{
     225    return !(pVCpu->vmm.s.pfnCallRing3CallbackR0 == NULL);
     226}
     227
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