Changeset 71908 in vbox for trunk/src/VBox
- Timestamp:
- Apr 19, 2018 5:13:28 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp
r71907 r71908 1371 1371 1372 1372 /** 1373 * Adds an exception to the intercept exception bitmap in the VMCB and updates 1374 * the corresponding VMCB Clean bit. 1373 * Sets an exception intercept in the specified VMCB. 1375 1374 * 1376 1375 * @param pVmcb Pointer to the VM control block. 1377 * @param u 32Xcpt The value of the exception (X86_XCPT_*).1378 */ 1379 DECLINLINE(void) hmR0Svm AddXcptIntercept(PSVMVMCB pVmcb, uint32_t u32Xcpt)1380 { 1381 if (!(pVmcb->ctrl.u32InterceptXcpt & RT_BIT(u 32Xcpt)))1382 { 1383 pVmcb->ctrl.u32InterceptXcpt |= RT_BIT(u 32Xcpt);1376 * @param uXcpt The exception (X86_XCPT_*). 1377 */ 1378 DECLINLINE(void) hmR0SvmSetXcptIntercept(PSVMVMCB pVmcb, uint8_t uXcpt) 1379 { 1380 if (!(pVmcb->ctrl.u32InterceptXcpt & RT_BIT(uXcpt))) 1381 { 1382 pVmcb->ctrl.u32InterceptXcpt |= RT_BIT(uXcpt); 1384 1383 pVmcb->ctrl.u32VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_INTERCEPTS; 1385 1384 } … … 1388 1387 1389 1388 /** 1390 * Removes an exception from the intercept-exception bitmap in the VMCB and 1391 * updates the corresponding VMCB Clean bit. 1389 * Clears an exception intercept in the specified VMCB. 1392 1390 * 1393 1391 * @param pVCpu The cross context virtual CPU structure. 1394 1392 * @param pCtx Pointer to the guest-CPU context. 1395 1393 * @param pVmcb Pointer to the VM control block. 1396 * @param u 32Xcpt The value of the exception (X86_XCPT_*).1394 * @param uXcpt The exception (X86_XCPT_*). 1397 1395 * 1398 1396 * @remarks This takes into account if we're executing a nested-guest and only … … 1400 1398 * are not intercepting it. 1401 1399 */ 1402 DECLINLINE(void) hmR0Svm RemoveXcptIntercept(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMVMCB pVmcb, uint32_t u32Xcpt)1403 { 1404 Assert(u 32Xcpt != X86_XCPT_DB);1405 Assert(u 32Xcpt != X86_XCPT_AC);1400 DECLINLINE(void) hmR0SvmClearXcptIntercept(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMVMCB pVmcb, uint8_t uXcpt) 1401 { 1402 Assert(uXcpt != X86_XCPT_DB); 1403 Assert(uXcpt != X86_XCPT_AC); 1406 1404 #ifndef HMSVM_ALWAYS_TRAP_ALL_XCPTS 1407 if (pVmcb->ctrl.u32InterceptXcpt & RT_BIT(u 32Xcpt))1408 { 1409 bool fRemove Xcpt= true;1405 if (pVmcb->ctrl.u32InterceptXcpt & RT_BIT(uXcpt)) 1406 { 1407 bool fRemove = true; 1410 1408 #ifdef VBOX_WITH_NESTED_HWVIRT 1411 1409 /* Only remove the intercept if the nested-guest is also not intercepting it! */ … … 1413 1411 { 1414 1412 PCSVMNESTEDVMCBCACHE pVmcbNstGstCache = hmR0SvmGetNestedVmcbCache(pVCpu, pCtx); 1415 fRemove Xcpt = !(pVmcbNstGstCache->u32InterceptXcpt & RT_BIT(u32Xcpt));1413 fRemove = !(pVmcbNstGstCache->u32InterceptXcpt & RT_BIT(uXcpt)); 1416 1414 } 1417 1415 #else 1418 1416 RT_NOREF2(pVCpu, pCtx); 1419 1417 #endif 1420 if (fRemove Xcpt)1421 { 1422 pVmcb->ctrl.u32InterceptXcpt &= ~RT_BIT(u 32Xcpt);1418 if (fRemove) 1419 { 1420 pVmcb->ctrl.u32InterceptXcpt &= ~RT_BIT(uXcpt); 1423 1421 pVmcb->ctrl.u32VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_INTERCEPTS; 1424 1422 } … … 1429 1427 } 1430 1428 1429 #if 0 1430 /** 1431 * Sets a control intercept in the specified VMCB. 1432 * 1433 * @param pVmcb Pointer to the VM control block. 1434 * @param fCtrlIntercept The control intercept (SVM_CTRL_INTERCEPT_*). 1435 */ 1436 DECLINLINE(void) hmR0SvmSetCtrlIntercept(PSVMVMCB pVmcb, uint64_t fCtrlIntercept) 1437 { 1438 if (!(pVmcb->ctrl.u64InterceptCtrl & fCtrlIntercept)) 1439 { 1440 pVmcb->ctrl.u64InterceptCtrl |= fCtrlIntercept; 1441 pVmcb->ctrl.u32VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_INTERCEPTS; 1442 } 1443 } 1444 1445 1446 /** 1447 * Clears a control intercept in the specified VMCB. 1448 * 1449 * @param pVCpu The cross context virtual CPU structure. 1450 * @param pCtx Pointer to the guest-CPU context. 1451 * @param pVmcb Pointer to the VM control block. 1452 * @param fCtrlIntercept The control intercept (SVM_CTRL_INTERCEPT_*). 1453 * 1454 * @remarks This takes into account if we're executing a nested-guest and only 1455 * removes the control intercept if both the guest -and- nested-guest 1456 * are not intercepting it. 1457 */ 1458 DECLINLINE(void) hmR0SvmClearCtrlIntercept(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMVMCB pVmcb, uint64_t fCtrlIntercept) 1459 { 1460 if (pVmcb->ctrl.u64InterceptCtrl & fCtrlIntercept) 1461 { 1462 bool fRemove = true; 1463 #ifdef VBOX_WITH_NESTED_HWVIRT 1464 /* Only remove the control intercept if the nested-guest is also not intercepting it! */ 1465 if (CPUMIsGuestInSvmNestedHwVirtMode(pCtx)) 1466 { 1467 PCSVMNESTEDVMCBCACHE pVmcbNstGstCache = hmR0SvmGetNestedVmcbCache(pVCpu, pCtx); 1468 fRemove = !(pVmcbNstGstCache->u64InterceptCtrl & fCtrlIntercept); 1469 } 1470 #else 1471 RT_NOREF2(pVCpu, pCtx); 1472 #endif 1473 if (fRemove) 1474 { 1475 pVmcb->ctrl.u64InterceptCtrl &= ~fCtrlIntercept; 1476 pVmcb->ctrl.u32VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_INTERCEPTS; 1477 } 1478 } 1479 } 1480 #endif 1431 1481 1432 1482 /** … … 1469 1519 { 1470 1520 uShadowCr0 |= X86_CR0_NE; 1471 hmR0Svm AddXcptIntercept(pVmcb, X86_XCPT_MF);1521 hmR0SvmSetXcptIntercept(pVmcb, X86_XCPT_MF); 1472 1522 } 1473 1523 else 1474 hmR0Svm RemoveXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_MF);1524 hmR0SvmClearXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_MF); 1475 1525 1476 1526 /* … … 2033 2083 /* Trap #UD for GIM provider (e.g. for hypercalls). */ 2034 2084 if (pVCpu->hm.s.fGIMTrapXcptUD) 2035 hmR0Svm AddXcptIntercept(pVmcb, X86_XCPT_UD);2085 hmR0SvmSetXcptIntercept(pVmcb, X86_XCPT_UD); 2036 2086 else 2037 hmR0Svm RemoveXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_UD);2087 hmR0SvmClearXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_UD); 2038 2088 2039 2089 /* Trap #BP for INT3 debug breakpoints set by the VM debugger. */ 2040 2090 if (pVCpu->CTX_SUFF(pVM)->dbgf.ro.cEnabledInt3Breakpoints) 2041 hmR0Svm AddXcptIntercept(pVmcb, X86_XCPT_BP);2091 hmR0SvmSetXcptIntercept(pVmcb, X86_XCPT_BP); 2042 2092 else 2043 hmR0Svm RemoveXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_BP);2093 hmR0SvmClearXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_BP); 2044 2094 2045 2095 /* The remaining intercepts are handled elsewhere, e.g. in hmR0SvmLoadSharedCR0(). */
Note:
See TracChangeset
for help on using the changeset viewer.