Changeset 58913 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Nov 29, 2015 10:22:48 PM (9 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMR0.cpp
r58912 r58913 90 90 DECLR0CALLBACKMEMBER(void, pfnThreadCtxCallback, (RTTHREADCTXEVENT enmEvent, PVMCPU pVCpu, bool fGlobalInit)); 91 91 DECLR0CALLBACKMEMBER(int, pfnSaveHostState, (PVM pVM, PVMCPU pVCpu)); 92 DECLR0CALLBACKMEMBER( int,pfnRunGuestCode, (PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx));92 DECLR0CALLBACKMEMBER(VBOXSTRICTRC,pfnRunGuestCode, (PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)); 93 93 DECLR0CALLBACKMEMBER(int, pfnEnableCpu, (PHMGLOBALCPUINFO pCpu, PVM pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage, 94 94 bool fEnabledByHost, void *pvArg)); … … 272 272 } 273 273 274 static DECLCALLBACK( int) hmR0DummyRunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)274 static DECLCALLBACK(VBOXSTRICTRC) hmR0DummyRunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 275 275 { 276 276 NOREF(pVM); NOREF(pVCpu); NOREF(pCtx); … … 1466 1466 * Runs guest code in a hardware accelerated VM. 1467 1467 * 1468 * @returns VBox status code. 1468 * @returns Strict VBox status code. (VBOXSTRICTRC isn't used because it's 1469 * called from setjmp assembly.) 1469 1470 * @param pVM The cross context VM structure. 1470 1471 * @param pVCpu The cross context virtual CPU structure. … … 1492 1493 #endif 1493 1494 1494 int rc= g_HmR0.pfnRunGuestCode(pVM, pVCpu, CPUMQueryGuestCtxPtr(pVCpu));1495 VBOXSTRICTRC rcStrict = g_HmR0.pfnRunGuestCode(pVM, pVCpu, CPUMQueryGuestCtxPtr(pVCpu)); 1495 1496 1496 1497 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE 1497 1498 PGMRZDynMapReleaseAutoSet(pVCpu); 1498 1499 #endif 1499 return rc;1500 return VBOXSTRICTRC_VAL(rcStrict); 1500 1501 } 1501 1502 -
trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp
r58658 r58913 3469 3469 * Runs the guest code using AMD-V. 3470 3470 * 3471 * @returns VBox status code.3471 * @returns Strict VBox status code. 3472 3472 * @param pVM The cross context VM structure. 3473 3473 * @param pVCpu The cross context virtual CPU structure. 3474 3474 * @param pCtx Pointer to the guest-CPU context. 3475 3475 */ 3476 VMMR0DECL( int) SVMR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)3476 VMMR0DECL(VBOXSTRICTRC) SVMR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 3477 3477 { 3478 3478 Assert(VMMRZCallRing3IsEnabled(pVCpu)); -
trunk/src/VBox/VMM/VMMR0/HMSVMR0.h
r58123 r58913 48 48 VMMR0DECL(int) SVMR0TermVM(PVM pVM); 49 49 VMMR0DECL(int) SVMR0SetupVM(PVM pVM); 50 VMMR0DECL( int)SVMR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);50 VMMR0DECL(VBOXSTRICTRC) SVMR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); 51 51 VMMR0DECL(int) SVMR0SaveHostState(PVM pVM, PVMCPU pVCpu); 52 52 -
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r58912 r58913 4776 4776 * Wrapper for running the guest code in VT-x. 4777 4777 * 4778 * @returns VBox st rict status code.4778 * @returns VBox status code, no informational status codes. 4779 4779 * @param pVM The cross context VM structure. 4780 4780 * @param pVCpu The cross context virtual CPU structure. … … 4793 4793 /** @todo Add stats for resume vs launch. */ 4794 4794 #ifdef VBOX_WITH_KERNEL_USING_XMM 4795 returnHMR0VMXStartVMWrapXMM(fResumeVM, pCtx, &pVCpu->hm.s.vmx.VMCSCache, pVM, pVCpu, pVCpu->hm.s.vmx.pfnStartVM);4795 int rc = HMR0VMXStartVMWrapXMM(fResumeVM, pCtx, &pVCpu->hm.s.vmx.VMCSCache, pVM, pVCpu, pVCpu->hm.s.vmx.pfnStartVM); 4796 4796 #else 4797 returnpVCpu->hm.s.vmx.pfnStartVM(fResumeVM, pCtx, &pVCpu->hm.s.vmx.VMCSCache, pVM, pVCpu);4797 int rc = pVCpu->hm.s.vmx.pfnStartVM(fResumeVM, pCtx, &pVCpu->hm.s.vmx.VMCSCache, pVM, pVCpu); 4798 4798 #endif 4799 AssertMsg(rc <= VINF_SUCCESS, ("%Rrc\n", rc)); 4800 return rc; 4799 4801 } 4800 4802 … … 5055 5057 * Executes the specified handler in 64-bit mode. 5056 5058 * 5057 * @returns VBox status code .5059 * @returns VBox status code (no informational status codes). 5058 5060 * @param pVM The cross context VM structure. 5059 5061 * @param pVCpu The cross context virtual CPU structure. … … 7093 7095 * VINF_VMM_UNKNOWN_RING3_CALL. 7094 7096 */ 7095 static int hmR0VmxExitToRing3(PVM pVM, PVMCPU pVCpu, PCPUMCTX pMixedCtx, intrcExit)7097 static int hmR0VmxExitToRing3(PVM pVM, PVMCPU pVCpu, PCPUMCTX pMixedCtx, VBOXSTRICTRC rcExit) 7096 7098 { 7097 7099 Assert(pVM); … … 7110 7112 /* Please, no longjumps here (any logging shouldn't flush jump back to ring-3). NO LOGGING BEFORE THIS POINT! */ 7111 7113 VMMRZCallRing3Disable(pVCpu); 7112 Log4(("hmR0VmxExitToRing3: pVCpu=%p idCpu=%RU32 rcExit=%d\n", pVCpu, pVCpu->idCpu, rcExit));7114 Log4(("hmR0VmxExitToRing3: pVCpu=%p idCpu=%RU32 rcExit=%d\n", pVCpu, pVCpu->idCpu, VBOXSTRICTRC_VAL(rcExit))); 7113 7115 7114 7116 /* We need to do this only while truly exiting the "inner loop" back to ring-3 and -not- for any longjmp to ring3. */ … … 7124 7126 /* If we're emulating an instruction, we shouldn't have any TRPM traps pending 7125 7127 and if we're injecting an event we should have a TRPM trap pending. */ 7126 AssertMsg(rcExit != VINF_EM_RAW_INJECT_TRPM_EVENT || TRPMHasTrap(pVCpu), ("%Rrc\n", rcExit));7128 AssertMsg(rcExit != VINF_EM_RAW_INJECT_TRPM_EVENT || TRPMHasTrap(pVCpu), ("%Rrc\n", VBOXSTRICTRC_VAL(rcExit))); 7127 7129 #ifndef DEBUG_bird /* Triggered after firing an NMI against NT4SP1, possibly a tripple fault in progress. */ 7128 AssertMsg(rcExit != VINF_EM_RAW_EMULATE_INSTR || !TRPMHasTrap(pVCpu), ("%Rrc\n", rcExit));7130 AssertMsg(rcExit != VINF_EM_RAW_EMULATE_INSTR || !TRPMHasTrap(pVCpu), ("%Rrc\n", VBOXSTRICTRC_VAL(rcExit))); 7129 7131 #endif 7130 7132 … … 8721 8723 * @note Mostly the same as hmR0VmxRunGuestCodeStep(). 8722 8724 */ 8723 static inthmR0VmxRunGuestCodeNormal(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)8725 static VBOXSTRICTRC hmR0VmxRunGuestCodeNormal(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 8724 8726 { 8725 8727 VMXTRANSIENT VmxTransient; 8726 8728 VmxTransient.fUpdateTscOffsettingAndPreemptTimer = true; 8727 int rc= VERR_INTERNAL_ERROR_5;8729 VBOXSTRICTRC rcStrict = VERR_INTERNAL_ERROR_5; 8728 8730 uint32_t cLoops = 0; 8729 8731 … … 8736 8738 to ring-3. This bugger disables interrupts on VINF_SUCCESS! */ 8737 8739 STAM_PROFILE_ADV_START(&pVCpu->hm.s.StatEntry, x); 8738 rc = hmR0VmxPreRunGuest(pVM, pVCpu, pCtx, &VmxTransient, false /* fStepping */);8739 if (rc != VINF_SUCCESS)8740 rcStrict = hmR0VmxPreRunGuest(pVM, pVCpu, pCtx, &VmxTransient, false /* fStepping */); 8741 if (rcStrict != VINF_SUCCESS) 8740 8742 break; 8741 8743 8742 8744 hmR0VmxPreRunGuestCommitted(pVM, pVCpu, pCtx, &VmxTransient); 8743 rc= hmR0VmxRunGuest(pVM, pVCpu, pCtx);8745 int rcRun = hmR0VmxRunGuest(pVM, pVCpu, pCtx); 8744 8746 /* The guest-CPU context is now outdated, 'pCtx' is to be treated as 'pMixedCtx' from this point on!!! */ 8745 8747 8746 8748 /* Restore any residual host-state and save any bits shared between host 8747 8749 and guest into the guest-CPU state. Re-enables interrupts! */ 8748 hmR0VmxPostRunGuest(pVM, pVCpu, pCtx, &VmxTransient, rc);8750 hmR0VmxPostRunGuest(pVM, pVCpu, pCtx, &VmxTransient, VBOXSTRICTRC_TODO(rcStrict)); 8749 8751 8750 8752 /* Check for errors with running the VM (VMLAUNCH/VMRESUME). */ 8751 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 8753 if (RT_SUCCESS(rcRun)) 8754 { /* very likely */ } 8755 else 8752 8756 { 8753 8757 STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatExit1, x); 8754 hmR0VmxReportWorldSwitchError(pVM, pVCpu, rc , pCtx, &VmxTransient);8755 return rc ;8758 hmR0VmxReportWorldSwitchError(pVM, pVCpu, rcRun, pCtx, &VmxTransient); 8759 return rcRun; 8756 8760 } 8757 8761 … … 8764 8768 8765 8769 VBOXVMM_R0_HMVMX_VMEXIT_NOCTX(pVCpu, pCtx, VmxTransient.uExitReason); 8766 if (RT_UNLIKELY(VBOXVMM_R0_HMVMX_VMEXIT_ENABLED())) 8770 if (RT_LIKELY(!VBOXVMM_R0_HMVMX_VMEXIT_ENABLED())) 8771 { /* likely */ } 8772 else 8767 8773 { 8768 8774 hmR0VmxReadExitQualificationVmcs(pVCpu, &VmxTransient); … … 8773 8779 /* Handle the VM-exit. */ 8774 8780 #ifdef HMVMX_USE_FUNCTION_TABLE 8775 rc = g_apfnVMExitHandlers[VmxTransient.uExitReason](pVCpu, pCtx, &VmxTransient);8781 rcStrict = g_apfnVMExitHandlers[VmxTransient.uExitReason](pVCpu, pCtx, &VmxTransient); 8776 8782 #else 8777 rc = hmR0VmxHandleExit(pVCpu, pCtx, &VmxTransient, VmxTransient.uExitReason);8783 rcStrict = hmR0VmxHandleExit(pVCpu, pCtx, &VmxTransient, VmxTransient.uExitReason); 8778 8784 #endif 8779 8785 STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatExit2, x); 8780 if (rc != VINF_SUCCESS)8781 break;8782 if (cLoops >pVM->hm.s.cMaxResumeLoops)8783 {8786 if (rcStrict == VINF_SUCCESS) 8787 { 8788 if (cLoops <= pVM->hm.s.cMaxResumeLoops) 8789 continue; /* likely */ 8784 8790 STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchMaxResumeLoops); 8785 rc = VINF_EM_RAW_INTERRUPT;8786 break;8787 }8791 rcStrict = VINF_EM_RAW_INTERRUPT; 8792 } 8793 break; 8788 8794 } 8789 8795 8790 8796 STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatEntry, x); 8791 return rc ;8797 return rcStrict; 8792 8798 } 8793 8799 … … 8796 8802 * Single steps guest code using VT-x. 8797 8803 * 8798 * @returns VBox status code.8804 * @returns Strict VBox status code. 8799 8805 * @param pVM The cross context VM structure. 8800 8806 * @param pVCpu The cross context virtual CPU structure. … … 8803 8809 * @note Mostly the same as hmR0VmxRunGuestCodeNormal(). 8804 8810 */ 8805 static inthmR0VmxRunGuestCodeStep(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)8811 static VBOXSTRICTRC hmR0VmxRunGuestCodeStep(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 8806 8812 { 8807 8813 VMXTRANSIENT VmxTransient; … … 8825 8831 8826 8832 hmR0VmxPreRunGuestCommitted(pVM, pVCpu, pCtx, &VmxTransient); 8827 rcStrict= hmR0VmxRunGuest(pVM, pVCpu, pCtx);8833 int rcRun = hmR0VmxRunGuest(pVM, pVCpu, pCtx); 8828 8834 /* The guest-CPU context is now outdated, 'pCtx' is to be treated as 'pMixedCtx' from this point on!!! */ 8829 8835 … … 8833 8839 8834 8840 /* Check for errors with running the VM (VMLAUNCH/VMRESUME). */ 8835 if (RT_UNLIKELY(rcStrict != VINF_SUCCESS)) 8841 if (RT_SUCCESS(rcRun)) 8842 { /* very likely */ } 8843 else 8836 8844 { 8837 8845 STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatExit1, x); 8838 hmR0VmxReportWorldSwitchError(pVM, pVCpu, VBOXSTRICTRC_TODO(rcStrict), pCtx, &VmxTransient);8839 return VBOXSTRICTRC_TODO(rcStrict);8846 hmR0VmxReportWorldSwitchError(pVM, pVCpu, rcRun, pCtx, &VmxTransient); 8847 return rcRun; 8840 8848 } 8841 8849 … … 8848 8856 8849 8857 VBOXVMM_R0_HMVMX_VMEXIT_NOCTX(pVCpu, pCtx, VmxTransient.uExitReason); 8850 if (RT_UNLIKELY(VBOXVMM_R0_HMVMX_VMEXIT_ENABLED())) 8858 if (!VBOXVMM_R0_HMVMX_VMEXIT_ENABLED()) 8859 { /* more likely */ } 8860 else 8851 8861 { 8852 8862 hmR0VmxReadExitQualificationVmcs(pVCpu, &VmxTransient); … … 8898 8908 8899 8909 STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatEntry, x); 8900 return VBOXSTRICTRC_TODO(rcStrict);8910 return rcStrict; 8901 8911 } 8902 8912 … … 8905 8915 * Runs the guest code using VT-x. 8906 8916 * 8907 * @returns VBox status code.8917 * @returns Strict VBox status code. 8908 8918 * @param pVM The cross context VM structure. 8909 8919 * @param pVCpu The cross context virtual CPU structure. 8910 8920 * @param pCtx Pointer to the guest-CPU context. 8911 8921 */ 8912 VMMR0DECL( int) VMXR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)8922 VMMR0DECL(VBOXSTRICTRC) VMXR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 8913 8923 { 8914 8924 Assert(VMMRZCallRing3IsEnabled(pVCpu)); … … 8918 8928 VMMRZCallRing3SetNotification(pVCpu, hmR0VmxCallRing3Callback, pCtx); 8919 8929 8920 int rc;8930 VBOXSTRICTRC rcStrict; 8921 8931 if (!pVCpu->hm.s.fSingleInstruction) 8922 rc = hmR0VmxRunGuestCodeNormal(pVM, pVCpu, pCtx);8932 rcStrict = hmR0VmxRunGuestCodeNormal(pVM, pVCpu, pCtx); 8923 8933 else 8924 rc = hmR0VmxRunGuestCodeStep(pVM, pVCpu, pCtx);8925 8926 if (rc == VERR_EM_INTERPRETER)8927 rc = VINF_EM_RAW_EMULATE_INSTR;8928 else if (rc == VINF_EM_RESET)8929 rc = VINF_EM_TRIPLE_FAULT;8930 8931 int rc2 = hmR0VmxExitToRing3(pVM, pVCpu, pCtx, rc );8934 rcStrict = hmR0VmxRunGuestCodeStep(pVM, pVCpu, pCtx); 8935 8936 if (rcStrict == VERR_EM_INTERPRETER) 8937 rcStrict = VINF_EM_RAW_EMULATE_INSTR; 8938 else if (rcStrict == VINF_EM_RESET) 8939 rcStrict = VINF_EM_TRIPLE_FAULT; 8940 8941 int rc2 = hmR0VmxExitToRing3(pVM, pVCpu, pCtx, rcStrict); 8932 8942 if (RT_FAILURE(rc2)) 8933 8943 { 8934 pVCpu->hm.s.u32HMError = rc;8935 rc = rc2;8944 pVCpu->hm.s.u32HMError = (uint32_t)VBOXSTRICTRC_VAL(rcStrict); 8945 rcStrict = rc2; 8936 8946 } 8937 8947 Assert(!VMMRZCallRing3IsNotificationSet(pVCpu)); 8938 return rc ;8948 return rcStrict; 8939 8949 } 8940 8950 -
trunk/src/VBox/VMM/VMMR0/HMVMXR0.h
r58122 r58913 40 40 VMMR0DECL(int) VMXR0SetupVM(PVM pVM); 41 41 VMMR0DECL(int) VMXR0SaveHostState(PVM pVM, PVMCPU pVCpu); 42 VMMR0DECL( int)VMXR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);42 VMMR0DECL(VBOXSTRICTRC) VMXR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); 43 43 DECLASM(int) VMXR0StartVM32(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu); 44 44 DECLASM(int) VMXR0StartVM64(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu); -
trunk/src/VBox/VMM/include/HMInternal.h
r58912 r58913 596 596 AssertCompileSizeAlignment(VMCSCACHE, 8); 597 597 598 /** VMX StartVM function. */ 598 /** 599 * VMX StartVM function. 600 * 601 * @returns VBox status code (no informational stuff). 602 * @param fResume Whether to use VMRESUME (true) or VMLAUNCH (false). 603 * @param pCtx The CPU register context. 604 * @param pCache The VMCS cache. 605 * @param pVM Pointer to the cross context VM structure. 606 * @param pVCpu Pointer to the cross context per-CPU structure. 607 */ 599 608 typedef DECLCALLBACK(int) FNHMVMXSTARTVM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu); 600 609 /** Pointer to a VMX StartVM function. */
Note:
See TracChangeset
for help on using the changeset viewer.