Changeset 97289 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Oct 25, 2022 7:56:51 AM (2 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAll.cpp
r97221 r97289 9929 9929 * See if there is an interrupt pending in TRPM, inject it if we can. 9930 9930 */ 9931 /** @todo Can we centralize this under CPUMCanInjectInterrupt()? */9932 #if defined(VBOX_WITH_NESTED_HWVIRT_SVM) || defined(VBOX_WITH_NESTED_HWVIRT_VMX)9933 bool fIntrEnabled = CPUMGetGuestGif(&pVCpu->cpum.GstCtx);9934 if (fIntrEnabled)9935 {9936 if (!CPUMIsGuestInNestedHwvirtMode(IEM_GET_CTX(pVCpu)))9937 fIntrEnabled = pVCpu->cpum.GstCtx.eflags.Bits.u1IF;9938 else if (CPUMIsGuestInVmxNonRootMode(IEM_GET_CTX(pVCpu)))9939 fIntrEnabled = CPUMIsGuestVmxPhysIntrEnabled(IEM_GET_CTX(pVCpu));9940 else9941 {9942 Assert(CPUMIsGuestInSvmNestedHwVirtMode(IEM_GET_CTX(pVCpu)));9943 fIntrEnabled = CPUMIsGuestSvmPhysIntrEnabled(pVCpu, IEM_GET_CTX(pVCpu));9944 }9945 }9946 #else9947 bool fIntrEnabled = pVCpu->cpum.GstCtx.eflags.Bits.u1IF;9948 #endif9949 9950 9931 /** @todo What if we are injecting an exception and not an interrupt? Is that 9951 9932 * possible here? For now we assert it is indeed only an interrupt. */ 9952 if ( fIntrEnabled 9953 && TRPMHasTrap(pVCpu) 9954 && !CPUMIsInInterruptShadow(&pVCpu->cpum.GstCtx)) 9955 { 9956 uint8_t u8TrapNo; 9957 TRPMEVENT enmType; 9958 uint32_t uErrCode; 9959 RTGCPTR uCr2; 9960 int rc2 = TRPMQueryTrapAll(pVCpu, &u8TrapNo, &enmType, &uErrCode, &uCr2, NULL /* pu8InstLen */, NULL /* fIcebp */); 9961 AssertRC(rc2); 9962 Assert(enmType == TRPM_HARDWARE_INT); 9963 VBOXSTRICTRC rcStrict = IEMInjectTrap(pVCpu, u8TrapNo, enmType, (uint16_t)uErrCode, uCr2, 0 /* cbInstr */); 9964 TRPMResetTrap(pVCpu); 9933 if (!TRPMHasTrap(pVCpu)) 9934 { /* likely */ } 9935 else 9936 { 9937 if ( !CPUMIsInInterruptShadow(&pVCpu->cpum.GstCtx) 9938 && !CPUMAreInterruptsInhibitedByNmi(&pVCpu->cpum.GstCtx)) 9939 { 9940 /** @todo Can we centralize this under CPUMCanInjectInterrupt()? */ 9965 9941 #if defined(VBOX_WITH_NESTED_HWVIRT_SVM) || defined(VBOX_WITH_NESTED_HWVIRT_VMX) 9966 /* Injecting an event may cause a VM-exit. */ 9967 if ( rcStrict != VINF_SUCCESS 9968 && rcStrict != VINF_IEM_RAISED_XCPT) 9969 return iemExecStatusCodeFiddling(pVCpu, rcStrict); 9942 bool fIntrEnabled = CPUMGetGuestGif(&pVCpu->cpum.GstCtx); 9943 if (fIntrEnabled) 9944 { 9945 if (!CPUMIsGuestInNestedHwvirtMode(IEM_GET_CTX(pVCpu))) 9946 fIntrEnabled = pVCpu->cpum.GstCtx.eflags.Bits.u1IF; 9947 else if (CPUMIsGuestInVmxNonRootMode(IEM_GET_CTX(pVCpu))) 9948 fIntrEnabled = CPUMIsGuestVmxPhysIntrEnabled(IEM_GET_CTX(pVCpu)); 9949 else 9950 { 9951 Assert(CPUMIsGuestInSvmNestedHwVirtMode(IEM_GET_CTX(pVCpu))); 9952 fIntrEnabled = CPUMIsGuestSvmPhysIntrEnabled(pVCpu, IEM_GET_CTX(pVCpu)); 9953 } 9954 } 9970 9955 #else 9971 NOREF(rcStrict);9956 bool fIntrEnabled = pVCpu->cpum.GstCtx.eflags.Bits.u1IF; 9972 9957 #endif 9958 if (fIntrEnabled) 9959 { 9960 uint8_t u8TrapNo; 9961 TRPMEVENT enmType; 9962 uint32_t uErrCode; 9963 RTGCPTR uCr2; 9964 int rc2 = TRPMQueryTrapAll(pVCpu, &u8TrapNo, &enmType, &uErrCode, &uCr2, NULL /*pu8InstLen*/, NULL /*fIcebp*/); 9965 AssertRC(rc2); 9966 Assert(enmType == TRPM_HARDWARE_INT); 9967 VBOXSTRICTRC rcStrict = IEMInjectTrap(pVCpu, u8TrapNo, enmType, (uint16_t)uErrCode, uCr2, 0 /*cbInstr*/); 9968 9969 TRPMResetTrap(pVCpu); 9970 9971 #if defined(VBOX_WITH_NESTED_HWVIRT_SVM) || defined(VBOX_WITH_NESTED_HWVIRT_VMX) 9972 /* Injecting an event may cause a VM-exit. */ 9973 if ( rcStrict != VINF_SUCCESS 9974 && rcStrict != VINF_IEM_RAISED_XCPT) 9975 return iemExecStatusCodeFiddling(pVCpu, rcStrict); 9976 #else 9977 NOREF(rcStrict); 9978 #endif 9979 } 9980 } 9973 9981 } 9974 9982 -
trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp
r97231 r97289 4702 4702 IEM_CIMPL_DEF_2(iemCImpl_load_SReg, uint8_t, iSegReg, uint16_t, uSel) 4703 4703 { 4704 if (iSegReg != X86_SREG_SS) 4705 return IEM_CIMPL_CALL_2(iemCImpl_LoadSReg, iSegReg, uSel); 4706 /** @todo only set it the shadow flag if it was clear before? */ 4704 4707 VBOXSTRICTRC rcStrict = IEM_CIMPL_CALL_2(iemCImpl_LoadSReg, iSegReg, uSel); 4705 if ( iSegReg == X86_SREG_SS &&rcStrict == VINF_SUCCESS)4708 if (rcStrict == VINF_SUCCESS) 4706 4709 CPUMSetInInterruptShadowSs(&pVCpu->cpum.GstCtx); 4707 4710 return rcStrict; … … 4756 4759 4757 4760 /* 4758 * Commit the stack on success. 4761 * Commit the stack on success and set interrupt shadow flag if appropriate 4762 * (the latter must be done after updating RIP). 4759 4763 */ 4760 4764 if (rcStrict == VINF_SUCCESS) … … 4762 4766 pVCpu->cpum.GstCtx.rsp = TmpRsp.u; 4763 4767 if (iSegReg == X86_SREG_SS) 4768 { 4769 /** @todo only set it the shadow flag if it was clear before? */ 4764 4770 CPUMSetInInterruptShadowSs(&pVCpu->cpum.GstCtx); 4771 } 4765 4772 } 4766 4773 return rcStrict; … … 7508 7515 fEfl |= X86_EFL_IF; 7509 7516 7510 /* Commit. */ 7517 /* 7518 * Commit. 7519 * 7520 * Note! Setting the shadow interrupt flag must be done after RIP updating. 7521 */ 7511 7522 IEMMISC_SET_EFL(pVCpu, fEfl); 7512 7523 iemRegAddToRipAndClearRF(pVCpu, cbInstr); 7513 7524 if (!(fEflOld & X86_EFL_IF) && (fEfl & X86_EFL_IF)) 7525 { 7526 /** @todo only set it the shadow flag if it was clear before? */ 7514 7527 CPUMSetInInterruptShadowSti(&pVCpu->cpum.GstCtx); 7528 } 7515 7529 Log2(("STI: %#x -> %#x\n", fEflOld, fEfl)); 7516 7530 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.