VirtualBox

Changeset 89600 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Jun 10, 2021 1:17:07 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145044
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.

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