VirtualBox

Changeset 88631 in vbox


Ignore:
Timestamp:
Apr 21, 2021 11:54:19 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143934
Message:

AMD IOMMU: bugref:9654 Slightly more efficient when a VM does not have an IOMMU configured.

Location:
trunk
Files:
6 edited

Legend:

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

    r88580 r88631  
    19411941     * @param   idDevice    The device identifier (bus, device, function).
    19421942     * @param   pMsiIn      The source MSI.
    1943      * @param   pMsiOut     Where to store the remapped MSI.
     1943     * @param   pMsiOut     Where to store the remapped MSI (only updated when
     1944     *                      VINF_SUCCESS is returned).
    19441945     */
    19451946    DECLCALLBACKMEMBER(int, pfnIommuMsiRemap,(PPDMDEVINS pDevIns, uint16_t idDevice, PCMSIMSG pMsiIn, PMSIMSG pMsiOut));
  • trunk/src/VBox/Devices/PC/DevIoApic.cpp

    r88612 r88631  
    536536        RT_ZERO(MsiIn);
    537537        ioapicGetMsiFromApicIntr(&ApicIntr, &MsiIn);
    538         int rcRemap = pThisCC->pIoApicHlp->pfnIommuMsiRemap(pDevIns, VBOX_PCI_BDF_SB_IOAPIC, &MsiIn, &MsiOut);
     538        int const rcRemap = pThisCC->pIoApicHlp->pfnIommuMsiRemap(pDevIns, VBOX_PCI_BDF_SB_IOAPIC, &MsiIn, &MsiOut);
     539        if (RT_SUCCESS(rcRemap))
     540            STAM_COUNTER_INC(&pThis->StatIommuRemappedIntr);
     541        else if (rcRemap == VERR_IOMMU_NOT_PRESENT)
     542            MsiOut = MsiIn;
     543        else
     544        {
     545            STAM_COUNTER_INC(&pThis->StatIommuDiscardedIntr);
     546            return;
     547        }
     548
     549        ioapicGetApicIntrFromMsi(&MsiOut, &ApicIntr);
     550
     551# ifdef RT_STRICT
    539552        if (RT_SUCCESS(rcRemap))
    540553        {
    541             STAM_COUNTER_INC(&pThis->StatIommuRemappedIntr);
    542             LogFlow(("IOAPIC: IOMMU remapped interrupt %#x to %#x\n", MsiIn.Data.n.u8Vector, MsiOut.Data.n.u8Vector));
    543             ioapicGetApicIntrFromMsi(&MsiOut, &ApicIntr);
    544554            Assert(ApicIntr.u8Polarity == IOAPIC_RTE_GET_POLARITY(u64Rte)); /* Ensure polarity hasn't changed. */
    545555            Assert(ApicIntr.u8TriggerMode == u8TriggerMode);                /* Ensure trigger mode hasn't changed. */
    546556        }
    547         else
    548         {
    549             STAM_COUNTER_INC(&pThis->StatIommuDiscardedIntr);
    550             Log(("IOAPIC: IOMMU discarded interrupt %#x. rc=%Rrc\n", ApicIntr.u8Vector, rcRemap));
    551             return;
    552         }
     557# endif
    553558#endif
    554559
     
    925930        MSIMSG MsiOut;
    926931        RT_ZERO(MsiOut);
    927         int rcRemap = pThisCC->pIoApicHlp->pfnIommuMsiRemap(pDevIns, uBusDevFn, pMsi, &MsiOut);
     932        int const rcRemap = pThisCC->pIoApicHlp->pfnIommuMsiRemap(pDevIns, uBusDevFn, pMsi, &MsiOut);
    928933        if (RT_SUCCESS(rcRemap))
    929         {
    930934            STAM_COUNTER_INC(&pThis->StatIommuRemappedMsi);
    931             ioapicGetApicIntrFromMsi(&MsiOut, &ApicIntr);
    932         }
     935        else if (rcRemap == VERR_IOMMU_NOT_PRESENT)
     936            MsiOut = *pMsi;
    933937        else
    934938        {
    935939            STAM_COUNTER_INC(&pThis->StatIommuDiscardedMsi);
    936             Log(("IOAPIC: MSI (Addr=%#RX64 Data=%#RX32) remapping failed. rc=%Rrc", pMsi->Addr.u64, pMsi->Data.u32, rcRemap));
    937940            return;
    938941        }
     942        ioapicGetApicIntrFromMsi(&MsiOut, &ApicIntr);
    939943    }
    940944    else
  • trunk/src/VBox/VMM/VMMAll/PDMAllIommu.cpp

    r88078 r88631  
    6464#endif
    6565    return PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn);
     66}
     67
     68
     69/**
     70 * Returns whether an IOMMU instance is present.
     71 *
     72 * @returns @c true if an IOMMU is present, @c false otherwise.
     73 * @param   pDevIns     The device instance.
     74 */
     75bool pdmIommuIsPresent(PPDMDEVINS pDevIns)
     76{
     77    PPDMIOMMU pIommu = PDMDEVINS_TO_IOMMU(pDevIns);
     78    return pIommu != 0;
    6679}
    6780
  • trunk/src/VBox/VMM/VMMR0/PDMR0DevHlp.cpp

    r88593 r88631  
    15311531
    15321532#ifdef VBOX_WITH_IOMMU_AMD
    1533     int rc = pdmIommuMsiRemap(pDevIns, idDevice, pMsiIn, pMsiOut);
    1534     if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT)
    1535         return rc;
     1533    if (pdmIommuIsPresent(pDevIns))
     1534        return pdmIommuMsiRemap(pDevIns, idDevice, pMsiIn, pMsiOut);
    15361535#else
    15371536    RT_NOREF(pDevIns, idDevice);
    15381537#endif
    1539 
    1540     *pMsiOut = *pMsiIn;
    1541     return VINF_SUCCESS;
     1538    return VERR_IOMMU_NOT_PRESENT;
    15421539}
    15431540
  • trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp

    r88580 r88631  
    149149
    150150#ifdef VBOX_WITH_IOMMU_AMD
    151     int rc = pdmIommuMsiRemap(pDevIns, idDevice, pMsiIn, pMsiOut);
    152     if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT)
    153         return rc;
     151    if (pdmIommuIsPresent(pDevIns))
     152        return pdmIommuMsiRemap(pDevIns, idDevice, pMsiIn, pMsiOut);
    154153#else
    155154    RT_NOREF(pDevIns, idDevice);
    156155#endif
    157 
    158     *pMsiOut = *pMsiIn;
    159     return VINF_SUCCESS;
     156    return VERR_IOMMU_NOT_PRESENT;
    160157}
    161158
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r88582 r88631  
    16731673
    16741674#if defined(VBOX_WITH_IOMMU_AMD) || defined(VBOX_WITH_IOMMU_INTEL)
     1675bool        pdmIommuIsPresent(PPDMDEVINS pDevIns);
    16751676int         pdmIommuMsiRemap(PPDMDEVINS pDevIns, uint16_t idDevice, PCMSIMSG pMsiIn, PMSIMSG pMsiOut);
    16761677int         pdmIommuMemAccessRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, uint32_t fFlags);
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