VirtualBox

Ignore:
Timestamp:
Nov 20, 2020 8:47:25 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141410
Message:

AMD IOMMU: bugref:9654 DevIoApic: Fix passing the correct BDF (southbridge I/O APIC's BDF) to the IOMMU for remapping line-based interrupts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevIoApic.cpp

    r86901 r86927  
    485485 * @param   pThis       The shared I/O APIC device state.
    486486 * @param   pThisCC     The I/O APIC device state for the current context.
    487  * @param   uBusDevFn   The bus:device:function of the device initiating the IRQ.
    488487 * @param   idxRte      The index of the RTE (validated).
    489488 *
     
    492491 *          function.
    493492 */
    494 static void ioapicSignalIntrForRte(PPDMDEVINS pDevIns, PIOAPIC pThis, PIOAPICCC pThisCC, PCIBDF uBusDevFn, uint8_t idxRte)
     493static void ioapicSignalIntrForRte(PPDMDEVINS pDevIns, PIOAPIC pThis, PIOAPICCC pThisCC, uint8_t idxRte)
    495494{
    496495#ifndef IOAPIC_WITH_PDM_CRITSECT
     
    529528        /*
    530529         * The interrupt may need to be remapped (or discarded) if an IOMMU is present.
     530         * For line-based interrupts we must use the southbridge I/O APIC's BDF as
     531         * the origin of the interrupt, see @bugref{9654#c74}.
    531532         */
    532533        MSIMSG MsiOut;
     
    535536        RT_ZERO(MsiIn);
    536537        ioapicGetMsiFromApicIntr(&ApicIntr, &MsiIn);
    537         if (!PCIBDF_IS_VALID(uBusDevFn))
    538             uBusDevFn = VBOX_PCI_BDF_SB_IOAPIC;
    539         int rcRemap = pThisCC->pIoApicHlp->pfnIommuMsiRemap(pDevIns, uBusDevFn, &MsiIn, &MsiOut);
    540         LogFlow(("IOAPIC: IOMMU Remap. rc=%Rrc VectorIn=%#x VectorOut=%#x\n", rcRemap, MsiIn.Data.n.u8Vector, MsiOut.Data.n.u8Vector));
     538        int rcRemap = pThisCC->pIoApicHlp->pfnIommuMsiRemap(pDevIns, VBOX_PCI_BDF_SB_IOAPIC, &MsiIn, &MsiOut);
    541539        if (RT_SUCCESS(rcRemap))
    542540        {
    543541            STAM_COUNTER_INC(&pThis->StatIommuRemappedIntr);
     542            LogFlow(("IOAPIC: IOMMU remapped interrupt %#x to %#x\n", rcRemap, MsiIn.Data.n.u8Vector, MsiOut.Data.n.u8Vector));
    544543            ioapicGetApicIntrFromMsi(&MsiOut, &ApicIntr);
    545544            Assert(ApicIntr.u8Polarity == IOAPIC_RTE_GET_POLARITY(u64Rte)); /* Ensure polarity hasn't changed. */
     
    549548        {
    550549            STAM_COUNTER_INC(&pThis->StatIommuDiscardedIntr);
    551             Log(("IOAPIC: Interrupt (%#x) discarded (rc=%Rrc)\n", ApicIntr.u8Vector, rcRemap));
     550            Log(("IOAPIC: IOMMU discarded interrupt %#x. rc=%Rrc\n", ApicIntr.u8Vector, rcRemap));
    552551            return;
    553552        }
    554 #else
    555         NOREF(uBusDevFn);
    556553#endif
    557554
     
    677674        {
    678675            LogFlow(("IOAPIC: ioapicSetRedirTableEntry: Signalling pending interrupt. idxRte=%u\n", idxRte));
    679             ioapicSignalIntrForRte(pDevIns, pThis, pThisCC, VBOX_PCI_BDF_SB_IOAPIC, idxRte);
     676            ioapicSignalIntrForRte(pDevIns, pThis, pThisCC, idxRte);
    680677        }
    681678
     
    792789                uint32_t const uPinMask = UINT32_C(1) << idxRte;
    793790                if (pThis->uIrr & uPinMask)
    794                     ioapicSignalIntrForRte(pDevIns, pThis, pThisCC, VBOX_PCI_BDF_SB_IOAPIC, idxRte);
     791                    ioapicSignalIntrForRte(pDevIns, pThis, pThisCC, idxRte);
    795792            }
    796793        }
    797794
    798795        IOAPIC_UNLOCK(pDevIns, pThis, pThisCC);
     796#ifndef VBOX_WITH_IOMMU_AMD
    799797        AssertMsg(fRemoteIrrCleared, ("Failed to clear remote IRR for vector %#x (%u)\n", u8Vector, u8Vector));
     798#endif
    800799    }
    801800    else
     
    811810static DECLCALLBACK(void) ioapicSetIrq(PPDMDEVINS pDevIns, PCIBDF uBusDevFn, int iIrq, int iLevel, uint32_t uTagSrc)
    812811{
     812    RT_NOREF(uBusDevFn);    /** @todo r=ramshankar: Remove this argument if it's also unnecessary with Intel IOMMU. */
    813813#define IOAPIC_ASSERT_IRQ(a_uBusDevFn, a_idxRte, a_PinMask) do { \
    814814        pThis->au32TagSrc[(a_idxRte)] = !pThis->au32TagSrc[(a_idxRte)] ? uTagSrc : RT_BIT_32(31); \
    815815        pThis->uIrr |= a_PinMask; \
    816         ioapicSignalIntrForRte(pDevIns, pThis, pThisCC, (a_uBusDevFn), (a_idxRte)); \
     816        ioapicSignalIntrForRte(pDevIns, pThis, pThisCC, (a_idxRte)); \
    817817    } while (0)
    818818
     
    930930    {
    931931        STAM_COUNTER_INC(&pThis->StatIommuDiscardedMsi);
    932         if (rcRemap == VERR_IOMMU_INTR_REMAP_DENIED)
    933             Log3(("IOAPIC: MSI (Addr=%#RX64 Data=%#RX32) remapping denied. rc=%Rrc", pMsi->Addr.u64, pMsi->Data.u32, rcRemap));
    934         else
    935             Log(("IOAPIC: MSI (Addr=%#RX64 Data=%#RX32) remapping failed. rc=%Rrc", pMsi->Addr.u64, pMsi->Data.u32, rcRemap));
     932        Log(("IOAPIC: MSI (Addr=%#RX64 Data=%#RX32) remapping failed. rc=%Rrc", pMsi->Addr.u64, pMsi->Data.u32, rcRemap));
    936933        return;
    937934    }
     
    13781375    PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "NumCPUs|ChipType", "");
    13791376
    1380     /* The number of CPUs is currently unused, but left in CFGM and saved-state in case an ID of 0 is
    1381        upsets some guest which we haven't yet tested. */
     1377    /* The number of CPUs is currently unused, but left in CFGM and saved-state in case an ID of 0
     1378       upsets some guest which we haven't yet been tested. */
    13821379    uint32_t cCpus;
    13831380    int rc = pHlp->pfnCFGMQueryU32Def(pCfg, "NumCPUs", &cCpus, 1);
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