VirtualBox

Changeset 89600 in vbox


Ignore:
Timestamp:
Jun 10, 2021 1:17:07 PM (4 years ago)
Author:
vboxsync
Message:

Intel IOMMU: bugref:9967 Centralize PDM interfaces sending MSIs so it does what it should from whichever context it's called from.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmapi.h

    r85121 r89600  
    5555VMM_INT_DECL(int)       PDMIoApicSetIrq(PVM pVM, PCIBDF uBusDevFn, uint8_t u8Irq, uint8_t u8Level, uint32_t uTagSrc);
    5656VMM_INT_DECL(VBOXSTRICTRC) PDMIoApicBroadcastEoi(PVM pVM, uint8_t uVector);
    57 VMM_INT_DECL(int)       PDMIoApicSendMsi(PVM pVM, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uTagSrc);
     57VMM_INT_DECL(void)      PDMIoApicSendMsi(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uTagSrc);
    5858VMM_INT_DECL(int)       PDMVmmDevHeapR3ToGCPhys(PVM pVM, RTR3PTR pv, RTGCPHYS *pGCPhys);
    5959VMM_INT_DECL(bool)      PDMVmmDevHeapIsEnabled(PVM pVM);
  • trunk/src/VBox/VMM/VMMAll/PDMAll.cpp

    r89547 r89600  
    218218 * Send a MSI to an I/O APIC.
    219219 *
    220  * @returns VBox status code.
    221  * @param   pVM         The cross context VM structure.
     220 * @param   pDevIns     The PCI device instance.
    222221 * @param   uBusDevFn   The bus:device:function of the device initiating the MSI.
    223222 *                      Cannot be NIL_PCIBDF.
     
    228227 *          instead.
    229228 */
    230 VMM_INT_DECL(int) PDMIoApicSendMsi(PVM pVM, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uTagSrc)
    231 {
    232     /** @todo We should somehow move/make this to ring-3 only, as in ring-0, the helper
    233      *        code handles queuing the MSI to be sent from ring-3 when I/O APIC isn't
    234      *        available in R0. When this TODO is done, remove the remark in the doxygen
    235      *        above. */
    236     if (pVM->pdm.s.IoApic.CTX_SUFF(pDevIns))
    237     {
    238         Assert(pVM->pdm.s.IoApic.CTX_SUFF(pfnSendMsi));
    239         pVM->pdm.s.IoApic.CTX_SUFF(pfnSendMsi)(pVM->pdm.s.IoApic.CTX_SUFF(pDevIns), uBusDevFn, pMsi, uTagSrc);
    240         return VINF_SUCCESS;
    241     }
    242     return VERR_PDM_NO_PIC_INSTANCE;
     229VMM_INT_DECL(void) PDMIoApicSendMsi(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uTagSrc)
     230{
     231#ifdef IN_RING0
     232    PGVM pGVM = pDevIns->Internal.s.pGVM;
     233    PCPDMIOAPIC pIoApic = &pGVM->pdm.s.IoApic;
     234    if (pIoApic->pDevInsR0)
     235        pIoApic->pfnSendMsiR0(pIoApic->pDevInsR0, uBusDevFn, pMsi, uTagSrc);
     236    else if (pIoApic->pDevInsR3)
     237    {
     238        /* Queue for ring-3 execution. */
     239        PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pGVM->pdm.s.pDevHlpQueueR0);
     240        if (pTask)
     241        {
     242            pTask->enmOp = PDMDEVHLPTASKOP_IOAPIC_SEND_MSI;
     243            pTask->pDevInsR3 = NIL_RTR3PTR; /* not required */
     244            pTask->u.IoApicSendMsi.uBusDevFn = uBusDevFn;
     245            pTask->u.IoApicSendMsi.Msi       = *pMsi;
     246            pTask->u.IoApicSendMsi.uTagSrc   = uTagSrc;
     247
     248            PDMQueueInsertEx(pGVM->pdm.s.pDevHlpQueueR0, &pTask->Core, 0);
     249        }
     250        else
     251            AssertMsgFailed(("We're out of devhlp queue items!!!\n"));
     252    }
     253#else
     254    PVM pVM = pDevIns->Internal.s.pVMR3;
     255    PCPDMIOAPIC pIoApic = &pVM->pdm.s.IoApic;
     256    if (pIoApic->pDevInsR3)
     257    {
     258        Assert(pIoApic->pfnSendMsiR3);
     259        pIoApic->pfnSendMsiR3(pIoApic->pDevInsR3, uBusDevFn, pMsi, uTagSrc);
     260    }
     261#endif
    243262}
    244263
  • trunk/src/VBox/VMM/VMMR0/PDMR0DevHlp.cpp

    r89200 r89600  
    16261626
    16271627
    1628 /**
    1629  * Helper for sending an MSI via the I/O APIC.
    1630  *
    1631  * @param   pDevIns     PCI device instance.
    1632  * @param   uBusDevFn   The bus:device:function of the device initiating the MSI.
    1633  * @param   pMsi        The MSI to send.
    1634  * @param   uTagSrc     The IRQ tag and source (for tracing).
    1635  */
    1636 static void pdmR0IoApicSendMsi(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uTagSrc)
    1637 {
    1638     PGVM pGVM = pDevIns->Internal.s.pGVM;
    1639     if (pGVM->pdm.s.IoApic.pDevInsR0)
    1640         pGVM->pdm.s.IoApic.pfnSendMsiR0(pGVM->pdm.s.IoApic.pDevInsR0, uBusDevFn, pMsi, uTagSrc);
    1641     else if (pGVM->pdm.s.IoApic.pDevInsR3)
    1642     {
    1643         /* queue for ring-3 execution. */
    1644         PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pGVM->pdm.s.pDevHlpQueueR0);
    1645         if (pTask)
    1646         {
    1647             pTask->enmOp = PDMDEVHLPTASKOP_IOAPIC_SEND_MSI;
    1648             pTask->pDevInsR3 = NIL_RTR3PTR; /* not required */
    1649             pTask->u.IoApicSendMsi.uBusDevFn = uBusDevFn;
    1650             pTask->u.IoApicSendMsi.Msi       = *pMsi;
    1651             pTask->u.IoApicSendMsi.uTagSrc   = uTagSrc;
    1652 
    1653             PDMQueueInsertEx(pGVM->pdm.s.pDevHlpQueueR0, &pTask->Core, 0);
    1654         }
    1655         else
    1656             AssertMsgFailed(("We're out of devhlp queue items!!!\n"));
    1657     }
    1658 }
    1659 
    1660 
    16611628/** @interface_method_impl{PDMPCIHLPR0,pfnIoApicSendMsi} */
    16621629static DECLCALLBACK(void) pdmR0PciHlp_IoApicSendMsi(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, PCMSIMSG pMsi, uint32_t uTagSrc)
     
    16661633    Log4(("pdmR0PciHlp_IoApicSendMsi: uBusDevFn=%#x Msi=(Addr:%#RX64 Data:%#RX32) uTagSrc=%#x\n", uBusDevFn, pMsi->Addr.u64,
    16671634          pMsi->Data.u32, uTagSrc));
    1668     pdmR0IoApicSendMsi(pDevIns, uBusDevFn, pMsi, uTagSrc);
     1635    PDMIoApicSendMsi(pDevIns, uBusDevFn, pMsi, uTagSrc);
    16691636}
    16701637
     
    17481715{
    17491716    PDMDEV_ASSERT_DEVINS(pDevIns);
    1750     pdmR0IoApicSendMsi(pDevIns, NIL_PCIBDF, pMsi, uTagSrc);
     1717    PDMIoApicSendMsi(pDevIns, NIL_PCIBDF, pMsi, uTagSrc);
    17511718}
    17521719
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r88641 r89600  
    53945394        case PDMDEVHLPTASKOP_IOAPIC_SEND_MSI:
    53955395        {
    5396             PDMIoApicSendMsi(pVM, pTask->u.IoApicSendMsi.uBusDevFn, &pTask->u.IoApicSendMsi.Msi, pTask->u.IoApicSendMsi.uTagSrc);
     5396            PDMIoApicSendMsi(pTask->pDevInsR3, pTask->u.IoApicSendMsi.uBusDevFn, &pTask->u.IoApicSendMsi.Msi,
     5397                             pTask->u.IoApicSendMsi.uTagSrc);
    53975398            break;
    53985399        }
  • trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp

    r89200 r89600  
    215215    Log4(("pdmR3PciHlp_IoApicSendMsi: uBusDevFn=%#x Msi (Addr=%#RX64 Data=%#x) uTagSrc=%#x\n", uBusDevFn,
    216216          pMsi->Addr.u64, pMsi->Data.u32, uTagSrc));
    217     PDMIoApicSendMsi(pDevIns->Internal.s.pVMR3, uBusDevFn, pMsi, uTagSrc);
     217    PDMIoApicSendMsi(pDevIns, uBusDevFn, pMsi, uTagSrc);
    218218}
    219219
     
    303303    PDMDEV_ASSERT_DEVINS(pDevIns);
    304304    LogFlowFunc(("caller='%s'/%d:\n", pDevIns->pReg->szName, pDevIns->iInstance));
    305     PDMIoApicSendMsi(pDevIns->Internal.s.pVMR3, NIL_PCIBDF, pMsi, uTagSrc);
     305    PDMIoApicSendMsi(pDevIns, NIL_PCIBDF, pMsi, uTagSrc);
    306306}
    307307
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r88641 r89600  
    819819    DECLRCCALLBACKMEMBER(VBOXSTRICTRC, pfnSetEoiRC,(PPDMDEVINS pDevIns, uint8_t u8Vector));
    820820} PDMIOAPIC;
     821/** Pointer to a PDM IOAPIC instance. */
     822typedef PDMIOAPIC *PPDMIOAPIC;
     823/** Pointer to a const PDM IOAPIC instance. */
     824typedef PDMIOAPIC const *PCPDMIOAPIC;
    821825
    822826/** Maximum number of PCI busses for a VM. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette