Changeset 62329 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Jul 19, 2016 3:02:51 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/TRPM.cpp
r62291 r62329 1495 1495 Assert(enmEvent == TRPM_HARDWARE_INT); 1496 1496 1497 if (!EMIsSupervisorCodeRecompiled(pVM)) 1498 { 1499 #ifdef TRPM_FORWARD_TRAPS_IN_GC 1497 #if defined(TRPM_FORWARD_TRAPS_IN_GC) && !defined(IEM_VERIFICATION_MODE) 1500 1498 1501 1499 # ifdef LOG_ENABLED 1502 1503 1500 DBGFR3_INFO_LOG(pVM, pVCpu, "cpumguest", "TRPMInject"); 1501 DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, "TRPMInject"); 1504 1502 # endif 1505 1503 1506 uint8_t u8Interrupt = 0; 1507 int rc = PDMGetInterrupt(pVCpu, &u8Interrupt); 1508 Log(("TRPMR3InjectEvent: CPU%d u8Interrupt=%d (%#x) rc=%Rrc\n", pVCpu->idCpu, u8Interrupt, u8Interrupt, rc)); 1509 if (RT_SUCCESS(rc)) 1504 uint8_t u8Interrupt = 0; 1505 int rc = PDMGetInterrupt(pVCpu, &u8Interrupt); 1506 Log(("TRPMR3InjectEvent: CPU%d u8Interrupt=%d (%#x) rc=%Rrc\n", pVCpu->idCpu, u8Interrupt, u8Interrupt, rc)); 1507 if (RT_SUCCESS(rc)) 1508 { 1509 if (HMIsEnabled(pVM) || EMIsSupervisorCodeRecompiled(pVM)) 1510 1510 { 1511 # ifndef IEM_VERIFICATION_MODE 1512 if (HMIsEnabled(pVM)) 1513 # endif 1511 rc = TRPMAssertTrap(pVCpu, u8Interrupt, enmEvent); 1512 AssertRC(rc); 1513 STAM_COUNTER_INC(&pVM->trpm.s.paStatForwardedIRQR3[u8Interrupt]); 1514 return HMR3IsActive(pVCpu) ? VINF_EM_RESCHEDULE_HM : VINF_EM_RESCHEDULE_REM; 1515 } 1516 /* If the guest gate is not patched, then we will check (again) if we can patch it. */ 1517 if (pVM->trpm.s.aGuestTrapHandler[u8Interrupt] == TRPM_INVALID_HANDLER) 1518 { 1519 CSAMR3CheckGates(pVM, u8Interrupt, 1); 1520 Log(("TRPMR3InjectEvent: recheck gate %x -> valid=%d\n", u8Interrupt, TRPMR3GetGuestTrapHandler(pVM, u8Interrupt) != TRPM_INVALID_HANDLER)); 1521 } 1522 1523 if (pVM->trpm.s.aGuestTrapHandler[u8Interrupt] != TRPM_INVALID_HANDLER) 1524 { 1525 /* Must check pending forced actions as our IDT or GDT might be out of sync */ 1526 rc = EMR3CheckRawForcedActions(pVM, pVCpu); 1527 if (rc == VINF_SUCCESS) 1514 1528 { 1515 rc = TRPMAssertTrap(pVCpu, u8Interrupt, enmEvent); 1516 AssertRC(rc); 1517 STAM_COUNTER_INC(&pVM->trpm.s.paStatForwardedIRQR3[u8Interrupt]); 1518 return HMR3IsActive(pVCpu) ? VINF_EM_RESCHEDULE_HM : VINF_EM_RESCHEDULE_REM; 1519 } 1520 /* If the guest gate is not patched, then we will check (again) if we can patch it. */ 1521 if (pVM->trpm.s.aGuestTrapHandler[u8Interrupt] == TRPM_INVALID_HANDLER) 1522 { 1523 CSAMR3CheckGates(pVM, u8Interrupt, 1); 1524 Log(("TRPMR3InjectEvent: recheck gate %x -> valid=%d\n", u8Interrupt, TRPMR3GetGuestTrapHandler(pVM, u8Interrupt) != TRPM_INVALID_HANDLER)); 1525 } 1526 1527 if (pVM->trpm.s.aGuestTrapHandler[u8Interrupt] != TRPM_INVALID_HANDLER) 1528 { 1529 /* Must check pending forced actions as our IDT or GDT might be out of sync */ 1530 rc = EMR3CheckRawForcedActions(pVM, pVCpu); 1531 if (rc == VINF_SUCCESS) 1529 /* There's a handler -> let's execute it in raw mode */ 1530 rc = TRPMForwardTrap(pVCpu, CPUMCTX2CORE(pCtx), u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, enmEvent, -1); 1531 if (rc == VINF_SUCCESS /* Don't use RT_SUCCESS */) 1532 1532 { 1533 /* There's a handler -> let's execute it in raw mode */ 1534 rc = TRPMForwardTrap(pVCpu, CPUMCTX2CORE(pCtx), u8Interrupt, 0, TRPM_TRAP_NO_ERRORCODE, enmEvent, -1); 1535 if (rc == VINF_SUCCESS /* Don't use RT_SUCCESS */) 1536 { 1537 Assert(!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_SELM_SYNC_GDT | VMCPU_FF_SELM_SYNC_LDT | VMCPU_FF_TRPM_SYNC_IDT | VMCPU_FF_SELM_SYNC_TSS)); 1538 1539 STAM_COUNTER_INC(&pVM->trpm.s.paStatForwardedIRQR3[u8Interrupt]); 1540 return VINF_EM_RESCHEDULE_RAW; 1541 } 1533 Assert(!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_SELM_SYNC_GDT | VMCPU_FF_SELM_SYNC_LDT | VMCPU_FF_TRPM_SYNC_IDT | VMCPU_FF_SELM_SYNC_TSS)); 1534 1535 STAM_COUNTER_INC(&pVM->trpm.s.paStatForwardedIRQR3[u8Interrupt]); 1536 return VINF_EM_RESCHEDULE_RAW; 1542 1537 } 1543 1538 } 1544 else1545 STAM_COUNTER_INC(&pVM->trpm.s.StatForwardFailNoHandler);1546 1547 rc = TRPMAssertTrap(pVCpu, u8Interrupt, enmEvent);1548 AssertRCReturn(rc, rc);1549 1539 } 1550 1540 else 1551 { 1552 /* Can happen if the interrupt is masked by TPR or APIC is disabled. */ 1553 AssertMsg(rc == VERR_APIC_INTR_MASKED_BY_TPR || rc == VERR_NO_DATA, ("PDMGetInterrupt failed. rc=%Rrc\n", rc)); 1554 return HMR3IsActive(pVCpu) ? VINF_EM_RESCHEDULE_HM : VINF_EM_RESCHEDULE_REM; /* (Heed the halted state if this is changed!) */ 1555 } 1556 #else /* !TRPM_FORWARD_TRAPS_IN_GC */ 1557 uint8_t u8Interrupt = 0; 1558 int rc = PDMGetInterrupt(pVCpu, &u8Interrupt); 1559 Log(("TRPMR3InjectEvent: u8Interrupt=%d (%#x) rc=%Rrc\n", u8Interrupt, u8Interrupt, rc)); 1560 if (RT_SUCCESS(rc)) 1561 { 1562 rc = TRPMAssertTrap(pVCpu, u8Interrupt, TRPM_HARDWARE_INT); 1563 AssertRC(rc); 1564 STAM_COUNTER_INC(&pVM->trpm.s.paStatForwardedIRQR3[u8Interrupt]); 1565 } 1566 else 1567 { 1568 /* Can happen if the interrupt is masked by TPR or APIC is disabled. */ 1569 AssertMsg(rc == VERR_APIC_INTR_MASKED_BY_TPR || rc == VERR_NO_DATA, ("PDMGetInterrupt failed. rc=%Rrc\n", rc)); 1570 } 1541 STAM_COUNTER_INC(&pVM->trpm.s.StatForwardFailNoHandler); 1542 1543 rc = TRPMAssertTrap(pVCpu, u8Interrupt, enmEvent); 1544 AssertRCReturn(rc, rc); 1545 } 1546 else 1547 { 1548 /* Can happen if the interrupt is masked by TPR or APIC is disabled. */ 1549 AssertMsg(rc == VERR_APIC_INTR_MASKED_BY_TPR || rc == VERR_NO_DATA, ("PDMGetInterrupt failed. rc=%Rrc\n", rc)); 1571 1550 return HMR3IsActive(pVCpu) ? VINF_EM_RESCHEDULE_HM : VINF_EM_RESCHEDULE_REM; /* (Heed the halted state if this is changed!) */ 1572 #endif /* !TRPM_FORWARD_TRAPS_IN_GC */ 1573 } 1551 } 1552 1574 1553 /** @todo check if it's safe to translate the patch address to the original guest address. 1575 1554 * this implies a safe state in translated instructions and should take sti successors into account (instruction fusing) 1576 1555 */ 1577 /* Note: if it's a PATM address, then we'll go back to raw mode regardless of the return code below. */1556 /* Note: if it's a PATM address, then we'll go back to raw mode regardless of the return codes below. */ 1578 1557 1579 1558 /* Fall back to the recompiler */ 1580 1559 return VINF_EM_RESCHEDULE_REM; /* (Heed the halted state if this is changed!) */ 1560 1561 #else /* !TRPM_FORWARD_TRAPS_IN_GC || IEM_VERIFICATION_MODE */ 1562 uint8_t u8Interrupt = 0; 1563 int rc = PDMGetInterrupt(pVCpu, &u8Interrupt); 1564 Log(("TRPMR3InjectEvent: u8Interrupt=%d (%#x) rc=%Rrc\n", u8Interrupt, u8Interrupt, rc)); 1565 if (RT_SUCCESS(rc)) 1566 { 1567 rc = TRPMAssertTrap(pVCpu, u8Interrupt, TRPM_HARDWARE_INT); 1568 AssertRC(rc); 1569 STAM_COUNTER_INC(&pVM->trpm.s.paStatForwardedIRQR3[u8Interrupt]); 1570 } 1571 else 1572 { 1573 /* Can happen if the interrupt is masked by TPR or APIC is disabled. */ 1574 AssertMsg(rc == VERR_APIC_INTR_MASKED_BY_TPR || rc == VERR_NO_DATA, ("PDMGetInterrupt failed. rc=%Rrc\n", rc)); 1575 } 1576 return HMR3IsActive(pVCpu) ? VINF_EM_RESCHEDULE_HM : VINF_EM_RESCHEDULE_REM; /* (Heed the halted state if this is changed!) */ 1577 #endif /* !TRPM_FORWARD_TRAPS_IN_GC || IEM_VERIFICATION_MODE */ 1578 1581 1579 } 1582 1580
Note:
See TracChangeset
for help on using the changeset viewer.