VirtualBox

Ignore:
Timestamp:
Aug 16, 2013 11:58:57 AM (11 years ago)
Author:
vboxsync
Message:

VMM/HM: Preemption hoooks, work in progress.

File:
1 edited

Legend:

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

    r47802 r47803  
    16201620            Assert(pVCpu->hm.s.fContextUseFlags & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_GUEST_CR0));
    16211621
     1622            pVCpu->hm.s.fLeaveDone = false;
    16221623            RTThreadPreemptRestore(&PreemptState);
    16231624            break;
     
    18951896        RTThreadPreemptDisable(&PreemptState);
    18961897        fPreemptDisabled = true;
    1897         if (pVCpu->hm.s.fLeaveDone)
    1898         {
    1899             RTThreadPreemptRestore(&PreemptState);
    1900             return;
    1901         }
    1902     }
    1903 
    1904     /* Restore host FPU state if necessary and resync on next R0 reentry .*/
    1905     if (CPUMIsGuestFPUStateActive(pVCpu))
    1906     {
    1907         CPUMR0SaveGuestFPU(pVM, pVCpu, pCtx);
    1908         Assert(!CPUMIsGuestFPUStateActive(pVCpu));
    1909         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_CR0;
    1910     }
    1911 
    1912     /*
    1913      * Restore host debug registers if necessary and resync on next R0 reentry.
    1914      */
    1915 #ifdef VBOX_STRICT
    1916     if (CPUMIsHyperDebugStateActive(pVCpu))
    1917     {
    1918         PSVMVMCB pVmcb = (PSVMVMCB)pVCpu->hm.s.svm.pvVmcb;
    1919         Assert(pVmcb->ctrl.u16InterceptRdDRx == 0xffff);
    1920         Assert(pVmcb->ctrl.u16InterceptWrDRx == 0xffff);
    1921     }
    1922 #endif
    1923     if (CPUMR0DebugStateMaybeSaveGuestAndRestoreHost(pVCpu, false /* save DR6 */))
    1924         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_DEBUG;
    1925 
    1926     Assert(!CPUMIsHyperDebugStateActive(pVCpu));
    1927     Assert(!CPUMIsGuestDebugStateActive(pVCpu));
    1928 
    1929     STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatEntry);
    1930     STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatLoadGuestState);
    1931     STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExit1);
    1932     STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExit2);
    1933     STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchLongJmpToR3);
    1934 
    1935     VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_HM, VMCPUSTATE_STARTED_EXEC);
     1898    }
     1899
     1900    if (!pVCpu->hm.s.fLeaveDone)
     1901    {
     1902        /* Restore host FPU state if necessary and resync on next R0 reentry .*/
     1903        if (CPUMIsGuestFPUStateActive(pVCpu))
     1904        {
     1905            CPUMR0SaveGuestFPU(pVM, pVCpu, pCtx);
     1906            Assert(!CPUMIsGuestFPUStateActive(pVCpu));
     1907            pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_CR0;
     1908        }
     1909
     1910        /*
     1911         * Restore host debug registers if necessary and resync on next R0 reentry.
     1912         */
     1913    #ifdef VBOX_STRICT
     1914        if (CPUMIsHyperDebugStateActive(pVCpu))
     1915        {
     1916            PSVMVMCB pVmcb = (PSVMVMCB)pVCpu->hm.s.svm.pvVmcb;
     1917            Assert(pVmcb->ctrl.u16InterceptRdDRx == 0xffff);
     1918            Assert(pVmcb->ctrl.u16InterceptWrDRx == 0xffff);
     1919        }
     1920    #endif
     1921        if (CPUMR0DebugStateMaybeSaveGuestAndRestoreHost(pVCpu, false /* save DR6 */))
     1922            pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_DEBUG;
     1923
     1924        Assert(!CPUMIsHyperDebugStateActive(pVCpu));
     1925        Assert(!CPUMIsGuestDebugStateActive(pVCpu));
     1926
     1927        STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatEntry);
     1928        STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatLoadGuestState);
     1929        STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExit1);
     1930        STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExit2);
     1931        STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchLongJmpToR3);
     1932
     1933        VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_HM, VMCPUSTATE_STARTED_EXEC);
     1934
     1935        pVCpu->hm.s.fLeaveDone = true;
     1936    }
    19361937
    19371938    /* Restore preemption if we previous disabled it ourselves. */
    19381939    if (fPreemptDisabled)
    1939     {
    1940         pVCpu->hm.s.fLeaveDone = true;
    19411940        RTThreadPreemptRestore(&PreemptState);
    1942     }
    19431941}
    19441942
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