VirtualBox

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


Ignore:
Timestamp:
Aug 30, 2013 5:26:51 PM (11 years ago)
Author:
vboxsync
Message:

VMM/HMVMXR0: Make code more robust regarding longjmps in awkward places.

File:
1 edited

Legend:

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

    r48194 r48205  
    73187318
    73197319    /*
     7320     * No longjmps to ring-3 from this point on!!!
     7321     * Asserts() will still longjmp to ring-3 (but won't return), which is intentional, better than a kernel panic.
     7322     * This also disables flushing of the R0-logger instance (if any).
     7323     */
     7324    VMMRZCallRing3Disable(pVCpu);
     7325
     7326    /*
    73207327     * We disable interrupts so that we don't miss any interrupts that would flag preemption (IPI/timers etc.)
    73217328     * when thread-context hooks aren't used and we've been running with preemption disabled for a while.
     
    73327339    {
    73337340        ASMSetFlags(pVmxTransient->uEflags);
     7341        VMMRZCallRing3Enable(pVCpu);
    73347342        STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchHmToR3FF);
    73357343        return VINF_EM_RAW_TO_R3;
     
    73387346    {
    73397347        ASMSetFlags(pVmxTransient->uEflags);
     7348        VMMRZCallRing3Enable(pVCpu);
    73407349        STAM_COUNTER_INC(&pVCpu->hm.s.StatPendingHostIrq);
    73417350        return VINF_EM_RAW_INTERRUPT;
     
    73437352
    73447353    /*
    7345      * No more longjmps or returns to ring-3 (that can continue guest execution) from this point!!!
    7346      *
    73477354     * Event injection might result in triple-faulting the VM (real-on-v86 case), which is why it's
    73487355     * done here and not in hmR0VmxPreRunGuestCommitted() which doesn't expect failures.
     
    73507357    rc = hmR0VmxInjectPendingEvent(pVCpu, pMixedCtx);
    73517358    if (RT_UNLIKELY(rc != VINF_SUCCESS))
     7359    {
    73527360        ASMSetFlags(pVmxTransient->uEflags);
    7353     return rc;
     7361        VMMRZCallRing3Enable(pVCpu);
     7362        return rc;
     7363    }
     7364
     7365    return VINF_SUCCESS;
    73547366}
    73557367
     
    74907502
    74917503    STAM_PROFILE_ADV_STOP_START(&pVCpu->hm.s.StatInGC, &pVCpu->hm.s.StatExit1, x);
    7492     TMNotifyEndOfExecution(pVCpu);                              /* Notify TM that the guest is no longer running. */
     7504    TMNotifyEndOfExecution(pVCpu);                                    /* Notify TM that the guest is no longer running. */
    74937505    Assert(!(ASMGetFlags() & X86_EFL_IF));
    74947506    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_HM);
    74957507
    74967508    pVCpu->hm.s.vmx.fRestoreHostFlags |= VMX_RESTORE_HOST_REQUIRED;   /* Host state messed up by VT-x, we must restore. */
    7497     pVCpu->hm.s.vmx.uVmcsState |= HMVMX_VMCS_STATE_LAUNCHED;    /* Use VMRESUME instead of VMLAUNCH in the next run. */
    7498     ASMSetFlags(pVmxTransient->uEflags);                        /* Enable interrupts. */
    7499     VMMRZCallRing3Enable(pVCpu);                                /* It is now safe to do longjmps to ring-3!!! */
     7509    pVCpu->hm.s.vmx.uVmcsState |= HMVMX_VMCS_STATE_LAUNCHED;          /* Use VMRESUME instead of VMLAUNCH in the next run. */
     7510    ASMSetFlags(pVmxTransient->uEflags);                              /* Enable interrupts. */
     7511    VMMRZCallRing3Enable(pVCpu);                                      /* It is now safe to do longjmps to ring-3!!! */
    75007512
    75017513    /* Save the basic VM-exit reason. Refer Intel spec. 24.9.1 "Basic VM-exit Information". */
     
    75707582            break;
    75717583
    7572         /*
    7573          * No longjmps to ring-3 from this point on!!!
    7574          * Asserts() will still longjmp to ring-3 (but won't return), which is intentional, better than a kernel panic.
    7575          * This also disables flushing of the R0-logger instance (if any).
    7576          */
    7577         VMMRZCallRing3Disable(pVCpu);
    75787584        hmR0VmxPreRunGuestCommitted(pVM, pVCpu, pCtx, &VmxTransient);
    7579 
    75807585        rc = hmR0VmxRunGuest(pVM, pVCpu, pCtx);
    75817586        /* The guest-CPU context is now outdated, 'pCtx' is to be treated as 'pMixedCtx' from this point on!!! */
    75827587
    7583         /*
    7584          * Restore any residual host-state and save any bits shared between host and guest into the guest-CPU state.
    7585          * This will also re-enable longjmps to ring-3 when it has reached a safe point!!!
    7586          */
     7588        /* Restore any residual host-state and save any bits shared between host and guest into the guest-CPU state. */
    75877589        hmR0VmxPostRunGuest(pVM, pVCpu, pCtx, &VmxTransient, rc);
    7588         if (RT_UNLIKELY(rc != VINF_SUCCESS))        /* Check for errors with running the VM (VMLAUNCH/VMRESUME). */
     7590
     7591        /* Check for errors with running the VM (VMLAUNCH/VMRESUME). */
     7592        if (RT_UNLIKELY(rc != VINF_SUCCESS))
    75897593        {
    75907594            STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatExit1, x);
     
    76507654            break;
    76517655
    7652         /*
    7653          * No longjmps to ring-3 from this point on!!!
    7654          * Asserts() will still longjmp to ring-3 (but won't return), which is intentional, better than a kernel panic.
    7655          * This also disables flushing of the R0-logger instance (if any).
    7656          */
    7657         VMMRZCallRing3Disable(pVCpu);
    76587656        hmR0VmxPreRunGuestCommitted(pVM, pVCpu, pCtx, &VmxTransient);
    7659 
    76607657        rc = hmR0VmxRunGuest(pVM, pVCpu, pCtx);
    76617658        /* The guest-CPU context is now outdated, 'pCtx' is to be treated as 'pMixedCtx' from this point on!!! */
    76627659
    7663         /*
    7664          * Restore any residual host-state and save any bits shared between host and guest into the guest-CPU state.
    7665          * This will also re-enable longjmps to ring-3 when it has reached a safe point!!!
    7666          */
     7660        /* Restore any residual host-state and save any bits shared between host and guest into the guest-CPU state. */
    76677661        hmR0VmxPostRunGuest(pVM, pVCpu, pCtx, &VmxTransient, rc);
    7668         if (RT_UNLIKELY(rc != VINF_SUCCESS))        /* Check for errors with running the VM (VMLAUNCH/VMRESUME). */
     7662
     7663        /* Check for errors with running the VM (VMLAUNCH/VMRESUME). */
     7664        if (RT_UNLIKELY(rc != VINF_SUCCESS))
    76697665        {
    76707666            STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatExit1, x);
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