VirtualBox

Changeset 84867 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jun 18, 2020 8:17:47 AM (5 years ago)
Author:
vboxsync
Message:

AMD IOMMU: bugref:9654 DevIoApic: Remap interrupts via the IOMMU.

File:
1 edited

Legend:

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

    r84860 r84867  
    444444}
    445445
    446 #if 0
     446
    447447/**
    448448 * Convert an APIC interrupt to an MSI message.
     
    466466     *        possible in theory? Maybe document this more explicitly... */
    467467}
    468 #endif
     468
    469469
    470470/**
     
    488488#endif
    489489
    490     /* Ensure the RTE isn't masked. */
     490    /*
     491     * Ensure the interrupt isn't masked.
     492     */
    491493    uint64_t const u64Rte = pThis->au64RedirTable[idxRte];
    492494    if (!IOAPIC_RTE_IS_MASKED(u64Rte))
     
    504506        }
    505507
    506         /** @todo IOMMU: Call into the IOMMU on how to remap this interrupt. uBusDevFn
    507          *        will be needed then. */
     508        XAPICINTR ApicIntr;
     509        ApicIntr.u8Vector       = IOAPIC_RTE_GET_VECTOR(u64Rte);
     510        ApicIntr.u8Dest         = IOAPIC_RTE_GET_DEST(u64Rte);
     511        ApicIntr.u8DestMode     = IOAPIC_RTE_GET_DEST_MODE(u64Rte);
     512        ApicIntr.u8DeliveryMode = IOAPIC_RTE_GET_DELIVERY_MODE(u64Rte);
     513        ApicIntr.u8Polarity     = IOAPIC_RTE_GET_POLARITY(u64Rte);
     514        ApicIntr.u8TriggerMode  = u8TriggerMode;
     515        ApicIntr.u8RedirHint    = 0;
     516
     517#ifdef VBOX_WITH_IOMMU_AMD
     518        /*
     519         * The interrupt may need to be remapped (or discarded) if an IOMMU is present.
     520         */
     521        MSIMSG MsiOut;
     522        MSIMSG MsiIn;
     523        ioapicGetMsiFromApicIntr(&ApicIntr, &MsiIn);
     524        Assert(PCIBDF_IS_VALID(uBusDevFn));
     525        int rcRemap = pThisCC->pIoApicHlp->pfnIommuMsiRemap(pDevIns, uBusDevFn, &MsiIn, &MsiOut);
     526        if (RT_SUCCESS(rcRemap))
     527            ioapicGetApicIntrFromMsi(&MsiOut, &ApicIntr);
     528        else
     529        {
     530            if (rcRemap == VERR_IOMMU_INTR_REMAP_DENIED)
     531                Log3(("IOAPIC: Interrupt (u8Vector=%#x) remapping denied. rc=%Rrc", ApicIntr.u8Vector, rcRemap));
     532            else
     533                Log(("IOAPIC: Interrupt (u8Vector=%#x) remapping failed. rc=%Rrc", ApicIntr.u8Vector, rcRemap));
     534            return;
     535        }
     536#else
    508537        NOREF(uBusDevFn);
    509 
    510         uint8_t const  u8Vector       = IOAPIC_RTE_GET_VECTOR(u64Rte);
    511         uint8_t const  u8DeliveryMode = IOAPIC_RTE_GET_DELIVERY_MODE(u64Rte);
    512         uint8_t const  u8DestMode     = IOAPIC_RTE_GET_DEST_MODE(u64Rte);
    513         uint8_t const  u8Polarity     = IOAPIC_RTE_GET_POLARITY(u64Rte);
    514         uint8_t const  u8Dest         = IOAPIC_RTE_GET_DEST(u64Rte);
    515         uint32_t const u32TagSrc      = pThis->au32TagSrc[idxRte];
    516 
     538#endif
     539
     540        uint32_t const u32TagSrc = pThis->au32TagSrc[idxRte];
    517541        Log2(("IOAPIC: Signaling %s-triggered interrupt. Dest=%#x DestMode=%s Vector=%#x (%u)\n",
    518               u8TriggerMode == IOAPIC_RTE_TRIGGER_MODE_EDGE ? "edge" : "level", u8Dest,
    519               u8DestMode == IOAPIC_RTE_DEST_MODE_PHYSICAL ? "physical" : "logical", u8Vector, u8Vector));
     542              ApicIntr.u8TriggerMode == IOAPIC_RTE_TRIGGER_MODE_EDGE ? "edge" : "level", ApicIntr.u8Dest,
     543              ApicIntr.u8DestMode == IOAPIC_RTE_DEST_MODE_PHYSICAL ? "physical" : "logical",
     544              ApicIntr.u8Vector, ApicIntr.u8Vector));
    520545
    521546        /*
     
    523548         */
    524549        int rc = pThisCC->pIoApicHlp->pfnApicBusDeliver(pDevIns,
    525                                                         u8Dest,
    526                                                         u8DestMode,
    527                                                         u8DeliveryMode,
    528                                                         u8Vector,
    529                                                         u8Polarity,
    530                                                         u8TriggerMode,
     550                                                        ApicIntr.u8Dest,
     551                                                        ApicIntr.u8DestMode,
     552                                                        ApicIntr.u8DeliveryMode,
     553                                                        ApicIntr.u8Vector,
     554                                                        ApicIntr.u8Polarity,
     555                                                        ApicIntr.u8TriggerMode,
    531556                                                        u32TagSrc);
    532557        /* Can't reschedule to R3. */
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