Changeset 79637 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Jul 9, 2019 9:08:37 AM (6 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/HMVMXAll.cpp
r79572 r79637 1185 1185 * @param uIntInfo The VMX event. 1186 1186 */ 1187 VMM_INT_DECL(TRPMEVENT) HMVmxEventToTrpmEventType(uint32_t uIntInfo) 1188 { 1187 VMM_INT_DECL(TRPMEVENT) HMVmxEventTypeToTrpmEventType(uint32_t uIntInfo) 1188 { 1189 Assert(VMX_IDT_VECTORING_INFO_IS_VALID(uIntInfo)); 1190 1189 1191 TRPMEVENT enmTrapType; 1190 uint8_t const uType = VMX_ ENTRY_INT_INFO_TYPE(uIntInfo);1191 uint8_t const uVector = VMX_ ENTRY_INT_INFO_VECTOR(uIntInfo);1192 uint8_t const uType = VMX_IDT_VECTORING_INFO_TYPE(uIntInfo); 1193 uint8_t const uVector = VMX_IDT_VECTORING_INFO_VECTOR(uIntInfo); 1192 1194 1193 1195 switch (uType) 1194 1196 { 1195 case VMX_ ENTRY_INT_INFO_TYPE_EXT_INT:1197 case VMX_IDT_VECTORING_INFO_TYPE_EXT_INT: 1196 1198 enmTrapType = TRPM_HARDWARE_INT; 1197 1199 break; 1198 1200 1199 case VMX_ ENTRY_INT_INFO_TYPE_NMI:1200 case VMX_ ENTRY_INT_INFO_TYPE_HW_XCPT:1201 case VMX_IDT_VECTORING_INFO_TYPE_NMI: 1202 case VMX_IDT_VECTORING_INFO_TYPE_HW_XCPT: 1201 1203 enmTrapType = TRPM_TRAP; 1202 1204 break; 1203 1205 1204 case VMX_ ENTRY_INT_INFO_TYPE_PRIV_SW_XCPT: /* INT1 (ICEBP). */1206 case VMX_IDT_VECTORING_INFO_TYPE_PRIV_SW_XCPT: /* INT1 (ICEBP). */ 1205 1207 Assert(uVector == X86_XCPT_DB); NOREF(uVector); 1206 1208 enmTrapType = TRPM_SOFTWARE_INT; 1207 1209 break; 1208 1210 1209 case VMX_ ENTRY_INT_INFO_TYPE_SW_XCPT: /* INT3 (#BP) and INTO (#OF) */1211 case VMX_IDT_VECTORING_INFO_TYPE_SW_XCPT: /* INT3 (#BP) and INTO (#OF) */ 1210 1212 Assert(uVector == X86_XCPT_BP || uVector == X86_XCPT_OF); NOREF(uVector); 1211 1213 enmTrapType = TRPM_SOFTWARE_INT; 1212 1214 break; 1213 1215 1214 case VMX_ ENTRY_INT_INFO_TYPE_SW_INT:1216 case VMX_IDT_VECTORING_INFO_TYPE_SW_INT: 1215 1217 enmTrapType = TRPM_SOFTWARE_INT; 1216 1218 break; 1217 1219 1218 case VMX_ENTRY_INT_INFO_TYPE_OTHER_EVENT: /* Shouldn't really happen. */1219 1220 default: 1220 1221 AssertMsgFailed(("Invalid trap type %#x\n", uType)); … … 1224 1225 1225 1226 return enmTrapType; 1227 } 1228 1229 1230 /** 1231 * Converts a TRPM event type into an appropriate VMX event type. 1232 * 1233 * @returns VMX event type mask. 1234 * @param uVector The event vector. 1235 * @param enmTrpmEvent The TRPM event. 1236 */ 1237 VMM_INT_DECL(uint32_t) HMTrpmEventTypeToVmxEventType(uint8_t uVector, TRPMEVENT enmTrpmEvent) 1238 { 1239 uint32_t uIntInfoType = 0; 1240 if (enmTrpmEvent == TRPM_TRAP) 1241 { 1242 /** @todo r=ramshankar: TRPM currently offers no way to determine a \#DB that was 1243 * generated using INT1 (ICEBP). */ 1244 switch (uVector) 1245 { 1246 case X86_XCPT_NMI: 1247 uIntInfoType |= (VMX_IDT_VECTORING_INFO_TYPE_NMI << VMX_IDT_VECTORING_INFO_TYPE_SHIFT); 1248 break; 1249 1250 case X86_XCPT_BP: 1251 case X86_XCPT_OF: 1252 uIntInfoType |= (VMX_IDT_VECTORING_INFO_TYPE_SW_XCPT << VMX_IDT_VECTORING_INFO_TYPE_SHIFT); 1253 break; 1254 1255 case X86_XCPT_PF: 1256 case X86_XCPT_DF: 1257 case X86_XCPT_TS: 1258 case X86_XCPT_NP: 1259 case X86_XCPT_SS: 1260 case X86_XCPT_GP: 1261 case X86_XCPT_AC: 1262 uIntInfoType |= VMX_IDT_VECTORING_INFO_ERROR_CODE_VALID; 1263 RT_FALL_THRU(); 1264 default: 1265 uIntInfoType |= (VMX_IDT_VECTORING_INFO_TYPE_HW_XCPT << VMX_IDT_VECTORING_INFO_TYPE_SHIFT); 1266 break; 1267 } 1268 } 1269 else if (enmTrpmEvent == TRPM_HARDWARE_INT) 1270 uIntInfoType |= (VMX_IDT_VECTORING_INFO_TYPE_EXT_INT << VMX_IDT_VECTORING_INFO_TYPE_SHIFT); 1271 else if (enmTrpmEvent == TRPM_SOFTWARE_INT) 1272 { 1273 switch (uVector) 1274 { 1275 case X86_XCPT_BP: 1276 case X86_XCPT_OF: 1277 uIntInfoType |= (VMX_IDT_VECTORING_INFO_TYPE_SW_XCPT << VMX_IDT_VECTORING_INFO_TYPE_SHIFT); 1278 break; 1279 1280 default: 1281 Assert(uVector == X86_XCPT_DB); 1282 uIntInfoType |= (VMX_IDT_VECTORING_INFO_TYPE_SW_INT << VMX_IDT_VECTORING_INFO_TYPE_SHIFT); 1283 break; 1284 } 1285 } 1286 else 1287 AssertMsgFailed(("Invalid TRPM event type %d\n", enmTrpmEvent)); 1288 return uIntInfoType; 1226 1289 } 1227 1290 -
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r79628 r79637 8609 8609 AssertRC(rc); 8610 8610 8611 /* Refer Intel spec. 24.8.3 "VM-entry Controls for Event Injection" for the format of u32IntInfo. */ 8612 uint32_t u32IntInfo = uVector | VMX_EXIT_INT_INFO_VALID; 8613 if (enmTrpmEvent == TRPM_TRAP) 8614 { 8615 /** @todo r=ramshankar: TRPM currently offers no way to determine a \#DB that was 8616 * generated using INT1 (ICEBP). */ 8617 switch (uVector) 8618 { 8619 case X86_XCPT_NMI: 8620 u32IntInfo |= (VMX_EXIT_INT_INFO_TYPE_NMI << VMX_EXIT_INT_INFO_TYPE_SHIFT); 8621 break; 8622 8623 case X86_XCPT_BP: 8624 case X86_XCPT_OF: 8625 u32IntInfo |= (VMX_EXIT_INT_INFO_TYPE_SW_XCPT << VMX_EXIT_INT_INFO_TYPE_SHIFT); 8626 break; 8627 8628 case X86_XCPT_PF: 8629 case X86_XCPT_DF: 8630 case X86_XCPT_TS: 8631 case X86_XCPT_NP: 8632 case X86_XCPT_SS: 8633 case X86_XCPT_GP: 8634 case X86_XCPT_AC: 8635 u32IntInfo |= VMX_EXIT_INT_INFO_ERROR_CODE_VALID; 8636 RT_FALL_THRU(); 8637 default: 8638 u32IntInfo |= (VMX_EXIT_INT_INFO_TYPE_HW_XCPT << VMX_EXIT_INT_INFO_TYPE_SHIFT); 8639 break; 8640 } 8641 } 8642 else if (enmTrpmEvent == TRPM_HARDWARE_INT) 8643 u32IntInfo |= (VMX_EXIT_INT_INFO_TYPE_EXT_INT << VMX_EXIT_INT_INFO_TYPE_SHIFT); 8644 else if (enmTrpmEvent == TRPM_SOFTWARE_INT) 8645 { 8646 switch (uVector) 8647 { 8648 case X86_XCPT_BP: 8649 case X86_XCPT_OF: 8650 u32IntInfo |= (VMX_EXIT_INT_INFO_TYPE_SW_XCPT << VMX_EXIT_INT_INFO_TYPE_SHIFT); 8651 break; 8652 8653 default: 8654 Assert(uVector == X86_XCPT_DB); 8655 u32IntInfo |= (VMX_EXIT_INT_INFO_TYPE_SW_INT << VMX_EXIT_INT_INFO_TYPE_SHIFT); 8656 break; 8657 } 8658 } 8659 else 8660 AssertMsgFailed(("Invalid TRPM event type %d\n", enmTrpmEvent)); 8611 uint32_t u32IntInfo; 8612 u32IntInfo = uVector | VMX_IDT_VECTORING_INFO_VALID; 8613 u32IntInfo |= HMTrpmEventTypeToVmxEventType(uVector, enmTrpmEvent); 8661 8614 8662 8615 rc = TRPMResetTrap(pVCpu); … … 8678 8631 Assert(pVCpu->hm.s.Event.fPending); 8679 8632 8680 uint32_t uVectorType = VMX_IDT_VECTORING_INFO_TYPE(pVCpu->hm.s.Event.u64IntInfo);8681 uint32_t uVector = VMX_IDT_VECTORING_INFO_VECTOR(pVCpu->hm.s.Event.u64IntInfo);8682 bool fErrorCodeValid = VMX_IDT_VECTORING_INFO_IS_ERROR_CODE_VALID(pVCpu->hm.s.Event.u64IntInfo);8683 uint32_t uErrorCode = pVCpu->hm.s.Event.u32ErrCode;8684 8685 8633 /* If a trap was already pending, we did something wrong! */ 8686 8634 Assert(TRPMQueryTrap(pVCpu, NULL /* pu8TrapNo */, NULL /* pEnmType */) == VERR_TRPM_NO_ACTIVE_TRAP); 8687 8635 8688 /** @todo Use HMVmxEventToTrpmEventType() later. */ 8689 TRPMEVENT enmTrapType; 8690 switch (uVectorType) 8691 { 8692 case VMX_IDT_VECTORING_INFO_TYPE_EXT_INT: 8693 enmTrapType = TRPM_HARDWARE_INT; 8694 break; 8695 8696 case VMX_IDT_VECTORING_INFO_TYPE_NMI: 8697 case VMX_IDT_VECTORING_INFO_TYPE_HW_XCPT: 8698 enmTrapType = TRPM_TRAP; 8699 break; 8700 8701 case VMX_IDT_VECTORING_INFO_TYPE_PRIV_SW_XCPT: /* #DB (INT1/ICEBP). */ 8702 Assert(uVector == X86_XCPT_DB); 8703 enmTrapType = TRPM_SOFTWARE_INT; 8704 break; 8705 8706 case VMX_IDT_VECTORING_INFO_TYPE_SW_XCPT: /* #BP (INT3) and #OF (INTO) */ 8707 Assert(uVector == X86_XCPT_BP || uVector == X86_XCPT_OF); 8708 enmTrapType = TRPM_SOFTWARE_INT; 8709 break; 8710 8711 case VMX_IDT_VECTORING_INFO_TYPE_SW_INT: 8712 enmTrapType = TRPM_SOFTWARE_INT; 8713 break; 8714 8715 default: 8716 AssertMsgFailed(("Invalid trap type %#x\n", uVectorType)); 8717 enmTrapType = TRPM_32BIT_HACK; 8718 break; 8719 } 8636 uint32_t const u32IntInfo = pVCpu->hm.s.Event.u64IntInfo; 8637 uint32_t const uVector = VMX_IDT_VECTORING_INFO_VECTOR(u32IntInfo); 8638 TRPMEVENT const enmTrapType = HMVmxEventTypeToTrpmEventType(u32IntInfo); 8720 8639 8721 8640 Log4(("HM event->TRPM: uVector=%#x enmTrapType=%d\n", uVector, enmTrapType)); … … 8724 8643 AssertRC(rc); 8725 8644 8726 if (fErrorCodeValid) 8727 TRPMSetErrorCode(pVCpu, uErrorCode); 8728 8729 if ( uVectorType == VMX_IDT_VECTORING_INFO_TYPE_HW_XCPT 8730 && uVector == X86_XCPT_PF) 8645 if (VMX_IDT_VECTORING_INFO_IS_ERROR_CODE_VALID(u32IntInfo)) 8646 TRPMSetErrorCode(pVCpu, pVCpu->hm.s.Event.u32ErrCode); 8647 8648 if (VMX_IDT_VECTORING_INFO_IS_XCPT_PF(u32IntInfo)) 8731 8649 TRPMSetFaultAddress(pVCpu, pVCpu->hm.s.Event.GCPtrFaultAddress); 8732 else if ( enmTrapType == TRPM_SOFTWARE_INT)8650 else if (VMX_IDT_VECTORING_INFO_TYPE(u32IntInfo) == VMX_IDT_VECTORING_INFO_TYPE_SW_INT) 8733 8651 TRPMSetInstrLength(pVCpu, pVCpu->hm.s.Event.cbInstr); 8734 8652
Note:
See TracChangeset
for help on using the changeset viewer.