VirtualBox

Changeset 45347 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 4, 2013 7:39:05 PM (12 years ago)
Author:
vboxsync
Message:

VMM/VMMR0: HM bits.

File:
1 edited

Legend:

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

    r45344 r45347  
    55335533    Log(("hmR0VmxLongJmpToRing3: rcExit=%d\n", rcExit));
    55345534
     5535    int rc = hmR0VmxSaveGuestState(pVM, pVCpu, pMixedCtx);
     5536    AssertRC(rc);
     5537
     5538    /* Restore debug registers if necessary and resync on next R0 re-entry. */
     5539    if (CPUMIsGuestDebugStateActive(pVCpu))
     5540    {
     5541        CPUMR0SaveGuestDebugState(pVM, pVCpu, pMixedCtx, true /* save DR6 */);
     5542        pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_DEBUG;
     5543    }
     5544    else if (CPUMIsHyperDebugStateActive(pVCpu))
     5545    {
     5546        CPUMR0LoadHostDebugState(pVM, pVCpu);
     5547        pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_DEBUG;
     5548    }
     5549
     5550    STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchToR3);
     5551}
     5552
     5553
     5554/**
     5555 * An action requires us to go back to ring-3. This function does the necessary
     5556 * steps before we can safely return to ring-3. This is not the same as longjmps
     5557 * to ring-3, this is voluntary.
     5558 *
     5559 * @param   pVM         Pointer to the VM.
     5560 * @param   pVCpu       Pointer to the VMCPU.
     5561 * @param   pMixedCtx   Pointer to the guest-CPU context. The data may be
     5562 *                      out-of-sync. Make sure to update the required fields
     5563 *                      before using them.
     5564 * @param   rcExit      The reason for exiting to ring-3. Can be
     5565 *                      VINF_VMM_UNKNOWN_RING3_CALL.
     5566 */
     5567static void hmR0VmxExitToRing3(PVM pVM, PVMCPU pVCpu, PCPUMCTX pMixedCtx, int rcExit)
     5568{
     5569    Assert(pVM);
     5570    Assert(pVCpu);
     5571    Assert(pMixedCtx);
     5572    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     5573
     5574    /* We want to see what the guest-state was before VM-entry, don't resync here, as we will never continue guest execution.*/
     5575    if (rcExit == VERR_VMX_INVALID_GUEST_STATE)
     5576        return;
     5577
     5578    /* Please, no longjumps here (any logging shouldn't flush jump back to ring-3). NO LOGGING BEFORE THIS POINT! */
     5579    VMMRZCallRing3Disable(pVCpu);
     5580    Log(("hmR0VmxExitToRing3: rcExit=%d\n", rcExit));
     5581
     5582    /* We need to do this only while truly exiting the "inner loop" back to ring-3 and -not- for any longjmp to ring3. */
     5583    hmR0VmxUpdateTRPMTrap(pVCpu);
     5584
     5585    /* Sync. the guest state. */
     5586    hmR0VmxLongJmpToRing3(pVM, pVCpu, pMixedCtx, rcExit);
     5587
    55355588    /* We're going back to ring-3, clear the flag that we need to go back to ring-3. */
    55365589    VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_TO_R3);
    5537 
    5538     int rc = hmR0VmxSaveGuestState(pVM, pVCpu, pMixedCtx);
    5539     AssertRC(rc);
    5540 
    5541     /* Restore debug registers if necessary and resync on next R0 re-entry. */
    5542     if (CPUMIsGuestDebugStateActive(pVCpu))
    5543     {
    5544         CPUMR0SaveGuestDebugState(pVM, pVCpu, pMixedCtx, true /* save DR6 */);
    5545         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_DEBUG;
    5546     }
    5547     else if (CPUMIsHyperDebugStateActive(pVCpu))
    5548     {
    5549         CPUMR0LoadHostDebugState(pVM, pVCpu);
    5550         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_DEBUG;
    5551     }
    55525590
    55535591    /* Signal changes to the recompiler. */
     
    55655603    else
    55665604        pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_HOST_CONTEXT | HM_CHANGED_ALL_GUEST;
    5567 
    5568     STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchToR3);
    5569 }
    5570 
    5571 
    5572 /**
    5573  * An action requires us to go back to ring-3. This function does the necessary
    5574  * steps before we can safely return to ring-3. This is not the same as longjmps
    5575  * to ring-3, this is voluntary.
    5576  *
    5577  * @param   pVM         Pointer to the VM.
    5578  * @param   pVCpu       Pointer to the VMCPU.
    5579  * @param   pMixedCtx   Pointer to the guest-CPU context. The data may be
    5580  *                      out-of-sync. Make sure to update the required fields
    5581  *                      before using them.
    5582  * @param   rcExit      The reason for exiting to ring-3. Can be
    5583  *                      VINF_VMM_UNKNOWN_RING3_CALL.
    5584  */
    5585 static void hmR0VmxExitToRing3(PVM pVM, PVMCPU pVCpu, PCPUMCTX pMixedCtx, int rcExit)
    5586 {
    5587     Assert(pVM);
    5588     Assert(pVCpu);
    5589     Assert(pMixedCtx);
    5590     Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    5591 
    5592     /* We want to see what the guest-state was before VM-entry, don't resync here, as we will never continue guest execution.*/
    5593     if (rcExit == VERR_VMX_INVALID_GUEST_STATE)
    5594         return;
    5595 
    5596     /* Please, no longjumps here (any logging shouldn't flush jump back to ring-3). NO LOGGING BEFORE THIS POINT! */
    5597     VMMRZCallRing3Disable(pVCpu);
    5598     Log(("hmR0VmxExitToRing3: rcExit=%d\n", rcExit));
    5599 
    5600     /* We need to do this only while truly exiting the "inner loop" back to ring-3 and -not- for any longjmp to ring3. */
    5601     hmR0VmxUpdateTRPMTrap(pVCpu);
    5602 
    5603     /* Sync. the rest of the state before going back to ring-3. */
    5604     hmR0VmxLongJmpToRing3(pVM, pVCpu, pMixedCtx, rcExit);
    56055605
    56065606    VMMRZCallRing3Enable(pVCpu);
     
    63876387    int rc = VMXR0LoadGuestState(pVM, pVCpu, pMixedCtx);
    63886388    AssertRC(rc);
    6389     AssertMsg(pVCpu->hm.s.fContextUseFlags == 0, ("fContextUseFlags =%#x\n", pVCpu->hm.s.fContextUseFlags));
     6389    AssertMsg(!pVCpu->hm.s.fContextUseFlags, ("fContextUseFlags =%#x\n", pVCpu->hm.s.fContextUseFlags));
    63906390
    63916391    /* Cache the TPR-shadow for checking on every VM-exit if it might have changed. */
     
    66016601}
    66026602
    6603 /* Validates input parameters for VM-exit handler functions. Later change this to be debug builds only. */
    66046603#ifdef DEBUG
    66056604/* Is there some generic IPRT define for this that are not in Runtime/internal/\* ?? */
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