VirtualBox

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


Ignore:
Timestamp:
Aug 29, 2013 9:39:53 AM (11 years ago)
Author:
vboxsync
Message:

VMM/HMVMXR0: Safer longjmp coverage, only restore host state when altered by VT-x.
VMM/HMSVMR0: Exit normally while getting errors during the world-switch.

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

Legend:

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

    r48135 r48140  
    29262926    ASMSetFlags(pSvmTransient->uEflags);                        /* Enable interrupts. */
    29272927
    2928     VMMRZCallRing3SetNotification(pVCpu, hmR0SvmCallRing3Callback, pMixedCtx);
    29292928    VMMRZCallRing3Enable(pVCpu);                                /* It is now safe to do longjmps to ring-3!!! */
    29302929
     
    29752974    Assert(VMMRZCallRing3IsEnabled(pVCpu));
    29762975    HMSVM_ASSERT_PREEMPT_SAFE();
     2976    VMMRZCallRing3SetNotification(pVCpu, hmR0SvmCallRing3Callback, pCtx);
    29772977
    29782978    SVMTRANSIENT SvmTransient;
     
    29992999         */
    30003000        VMMRZCallRing3Disable(pVCpu);
    3001         VMMRZCallRing3RemoveNotification(pVCpu);
    30023001        hmR0SvmPreRunGuestCommitted(pVM, pVCpu, pCtx, &SvmTransient);
    30033002
     
    30163015            STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatExit1, x);
    30173016            hmR0SvmReportWorldSwitchError(pVM, pVCpu, rc, pCtx);
    3018             return rc;
     3017            break;
    30193018        }
    30203019
     
    30393038    else if (rc == VINF_EM_RESET)
    30403039        rc = VINF_EM_TRIPLE_FAULT;
     3040
    30413041    hmR0SvmExitToRing3(pVM, pVCpu, pCtx, rc);
     3042    VMMRZCallRing3RemoveNotification(pVCpu);
    30423043    return rc;
    30433044}
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r48135 r48140  
    60916091    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    60926092    Assert(!VMMRZCallRing3IsEnabled(pVCpu));
    6093     Assert(VMMR0IsLogFlushDisabled(pVCpu));
    60946093
    60956094    RTCPUID idCpu = RTMpCpuId();
     
    61236122
    61246123    /* Restore host-state bits that VT-x only restores partially. */
    6125     if (pVCpu->hm.s.vmx.fRestoreHostFlags)
     6124    if (   (pVCpu->hm.s.vmx.fRestoreHostFlags & VMX_RESTORE_HOST_REQUIRED)
     6125        && (pVCpu->hm.s.vmx.fRestoreHostFlags & ~VMX_RESTORE_HOST_REQUIRED))
    61266126    {
    61276127        Log4Func(("Restoring Host State: fRestoreHostFlags=%#RX32 HostCpuId=%u\n", pVCpu->hm.s.vmx.fRestoreHostFlags, idCpu));
     
    75267526        /** @todo Find a way to fix hardcoding a guestimate.  */
    75277527        TMCpuTickSetLastSeen(pVCpu, ASMReadTSC()
    7528                              + pVCpu->hm.s.vmx.u64TSCOffset - 0x400 /* guestimate of world switch overhead in clock ticks */);
     7528                             + pVCpu->hm.s.vmx.u64TSCOffset - 0x400   /* guestimate of world switch overhead in clock ticks */);
    75297529    }
    75307530
     
    75347534    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_HM);
    75357535
     7536    pVCpu->hm.s.vmx.fRestoreHostFlags |= VMX_RESTORE_HOST_REQUIRED;   /* Host state messed up by VT-x, we must restore. */
    75367537    pVCpu->hm.s.vmx.uVmcsState |= HMVMX_VMCS_STATE_LAUNCHED;    /* Use VMRESUME instead of VMLAUNCH in the next run. */
    75377538    ASMSetFlags(pVmxTransient->uEflags);                        /* Enable interrupts. */
    7538 
    7539     VMMRZCallRing3SetNotification(pVCpu, hmR0VmxCallRing3Callback, pMixedCtx);
    75407539    VMMRZCallRing3Enable(pVCpu);                                /* It is now safe to do longjmps to ring-3!!! */
    75417540
     
    76177616         */
    76187617        VMMRZCallRing3Disable(pVCpu);
    7619         VMMRZCallRing3RemoveNotification(pVCpu);
    76207618        hmR0VmxPreRunGuestCommitted(pVM, pVCpu, pCtx, &VmxTransient);
    76217619
     
    76987696         */
    76997697        VMMRZCallRing3Disable(pVCpu);
    7700         VMMRZCallRing3RemoveNotification(pVCpu);
    77017698        hmR0VmxPreRunGuestCommitted(pVM, pVCpu, pCtx, &VmxTransient);
    77027699
     
    77707767{
    77717768    Assert(VMMRZCallRing3IsEnabled(pVCpu));
     7769    Assert(pVCpu->hm.s.vmx.fUpdatedGuestState == HMVMX_UPDATED_GUEST_ALL);
    77727770    HMVMX_ASSERT_PREEMPT_SAFE();
     7771
     7772    VMMRZCallRing3SetNotification(pVCpu, hmR0VmxCallRing3Callback, pCtx);
    77737773
    77747774    int rc;
     
    77827782    else if (rc == VINF_EM_RESET)
    77837783        rc = VINF_EM_TRIPLE_FAULT;
     7784
    77847785    hmR0VmxExitToRing3(pVM, pVCpu, pCtx, rc);
     7786    VMMRZCallRing3RemoveNotification(pVCpu);
    77857787    return rc;
    77867788}
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