Changeset 47803 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- Aug 16, 2013 11:58:57 AM (11 years ago)
- Location:
- trunk/src/VBox/VMM/VMMR0
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMR0.cpp
r47802 r47803 1482 1482 * @returns VBox status code. 1483 1483 * @param pVCpu Pointer to the VMCPU. 1484 * @param idCpu The identifier for the CPU the function is called on.1485 1484 */ 1486 1485 VMMR0_INT_DECL(int) HMR0LeaveEx(PVMCPU pVCpu) -
trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp
r47802 r47803 1620 1620 Assert(pVCpu->hm.s.fContextUseFlags & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_GUEST_CR0)); 1621 1621 1622 pVCpu->hm.s.fLeaveDone = false; 1622 1623 RTThreadPreemptRestore(&PreemptState); 1623 1624 break; … … 1895 1896 RTThreadPreemptDisable(&PreemptState); 1896 1897 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 } 1936 1937 1937 1938 /* Restore preemption if we previous disabled it ourselves. */ 1938 1939 if (fPreemptDisabled) 1939 {1940 pVCpu->hm.s.fLeaveDone = true;1941 1940 RTThreadPreemptRestore(&PreemptState); 1942 }1943 1941 } 1944 1942 -
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r47802 r47803 6041 6041 RTThreadPreemptDisable(&PreemptState); 6042 6042 fPreemptDisabled = true; 6043 if (pVCpu->hm.s.fLeaveDone)6044 { 6045 RTThreadPreemptRestore(&PreemptState);6046 return;6047 }6048 }6049 6050 /* Save the guest state if necessary. */6051 if (pVCpu->hm.s.vmx.fUpdatedGuestState != HMVMX_UPDATED_GUEST_ALL)6052 {6053 int rc = hmR0VmxSaveGuestState(pVCpu, pMixedCtx);6054 AssertRC(rc); 6055 Assert(pVCpu->hm.s.vmx.fUpdatedGuestState == HMVMX_UPDATED_GUEST_ALL);6056 }6057 6058 /* Restore host FPU state if necessary and resync on next R0 reentry .*/6059 if (CPUMIsGuestFPUStateActive(pVCpu))6060 {6061 CPUMR0SaveGuestFPU(pVM, pVCpu, pMixedCtx);6062 Assert(!CPUMIsGuestFPUStateActive(pVCpu)); 6063 pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_CR0;6064 }6065 6066 /* Restore host debug registers if necessary and resync on next R0 reentry. */6067 #ifdef VBOX_STRICT 6068 if (CPUMIsHyperDebugStateActive(pVCpu))6069 Assert(pVCpu->hm.s.vmx.u32ProcCtls & VMX_VMCS_CTRL_PROC_EXEC_MOV_DR_EXIT);6070 #endif 6071 if (CPUMR0DebugStateMaybeSaveGuestAndRestoreHost(pVCpu, true /* save DR6 */))6072 pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_DEBUG; 6073 Assert(!CPUMIsGuestDebugStateActive(pVCpu));6074 Assert(!CPUMIsHyperDebugStateActive(pVCpu));6075 6076 /* Restore host-state bits that VT-x only restores partially. */6077 if (pVCpu->hm.s.vmx.fRestoreHostFlags)6078 {6079 VMXRestoreHostState(pVCpu->hm.s.vmx.fRestoreHostFlags, &pVCpu->hm.s.vmx.RestoreHost); 6080 pVCpu->hm.s.vmx.fRestoreHostFlags = 0;6081 }6082 6083 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatEntry);6084 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatLoadGuestState);6085 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExit1);6086 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExit2);6087 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExitIO);6088 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExitMovCRx); 6089 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExitXcptNmi);6090 STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchLongJmpToR3); 6091 6092 VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_HM, VMCPUSTATE_STARTED_EXEC);6043 } 6044 6045 if (!pVCpu->hm.s.fLeaveDone) 6046 { 6047 /* Save the guest state if necessary. */ 6048 if (pVCpu->hm.s.vmx.fUpdatedGuestState != HMVMX_UPDATED_GUEST_ALL) 6049 { 6050 int rc = hmR0VmxSaveGuestState(pVCpu, pMixedCtx); 6051 AssertRC(rc); 6052 Assert(pVCpu->hm.s.vmx.fUpdatedGuestState == HMVMX_UPDATED_GUEST_ALL); 6053 } 6054 6055 /* Restore host FPU state if necessary and resync on next R0 reentry .*/ 6056 if (CPUMIsGuestFPUStateActive(pVCpu)) 6057 { 6058 CPUMR0SaveGuestFPU(pVM, pVCpu, pMixedCtx); 6059 Assert(!CPUMIsGuestFPUStateActive(pVCpu)); 6060 pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_CR0; 6061 } 6062 6063 /* Restore host debug registers if necessary and resync on next R0 reentry. */ 6064 #ifdef VBOX_STRICT 6065 if (CPUMIsHyperDebugStateActive(pVCpu)) 6066 Assert(pVCpu->hm.s.vmx.u32ProcCtls & VMX_VMCS_CTRL_PROC_EXEC_MOV_DR_EXIT); 6067 #endif 6068 if (CPUMR0DebugStateMaybeSaveGuestAndRestoreHost(pVCpu, true /* save DR6 */)) 6069 pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_GUEST_DEBUG; 6070 Assert(!CPUMIsGuestDebugStateActive(pVCpu)); 6071 Assert(!CPUMIsHyperDebugStateActive(pVCpu)); 6072 6073 /* Restore host-state bits that VT-x only restores partially. */ 6074 if (pVCpu->hm.s.vmx.fRestoreHostFlags) 6075 { 6076 VMXRestoreHostState(pVCpu->hm.s.vmx.fRestoreHostFlags, &pVCpu->hm.s.vmx.RestoreHost); 6077 pVCpu->hm.s.vmx.fRestoreHostFlags = 0; 6078 } 6079 6080 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatEntry); 6081 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatLoadGuestState); 6082 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExit1); 6083 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExit2); 6084 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExitIO); 6085 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExitMovCRx); 6086 STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatExitXcptNmi); 6087 STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchLongJmpToR3); 6088 6089 VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_HM, VMCPUSTATE_STARTED_EXEC); 6090 6091 pVCpu->hm.s.fLeaveDone = true; 6092 } 6093 6093 6094 6094 /* Restore preemption if we previous disabled it ourselves. */ 6095 6095 if (fPreemptDisabled) 6096 {6097 pVCpu->hm.s.fLeaveDone = true;6098 6096 RTThreadPreemptRestore(&PreemptState); 6099 }6100 6097 } 6101 6098
Note:
See TracChangeset
for help on using the changeset viewer.