VirtualBox

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


Ignore:
Timestamp:
Jun 3, 2020 1:24:01 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138417
Message:

AMD IOMMU: bugref:9654 DevIoApic: Conversion between xAPIC interrupts and MSIs for upcoming IOMMU changes.

File:
1 edited

Legend:

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

    r84647 r84663  
    310310
    311311
     312/**
     313 * xAPIC interrupt.
     314 */
     315typedef struct XAPICINTR
     316{
     317    /** The interrupt vector. */
     318    uint8_t         u8Vector;
     319    /** The destination (mask or ID). */
     320    uint8_t         u8Dest;
     321    /** The destination mode. */
     322    uint8_t         u8DestMode;
     323    /** Delivery mode. */
     324    uint8_t         u8DeliveryMode;
     325    /** Trigger mode. */
     326    uint8_t         u8TriggerMode;
     327    /** Redirection hint. */
     328    uint8_t         u8RedirHint;
     329    /** Polarity. */
     330    uint8_t         u8Polarity;
     331    /** Padding. */
     332    uint8_t         abPadding0;
     333} XAPICINTR;
     334/** Pointer to an I/O xAPIC interrupt struct. */
     335typedef XAPICINTR *PXAPICINTR;
     336/** Pointer to a const xAPIC interrupt struct. */
     337typedef XAPICINTR const *PCXAPICINTR;
     338
     339
    312340#ifndef VBOX_DEVICE_STRUCT_TESTCASE
    313341
     
    389417}
    390418
     419
     420/**
     421 * Converts an MSI message to an APIC interrupt.
     422 *
     423 * @param   pMsi    The MSI message to convert.
     424 * @param   pIntr   Where to store the APIC interrupt.
     425 */
     426DECLINLINE(void) ioapicGetApicIntrFromMsi(PCMSIMSG pMsi, PXAPICINTR pIntr)
     427{
     428    /*
     429     * Parse the message from the physical address and data
     430     * See Intel spec. 10.11.1 "Message Address Register Format".
     431     * See Intel spec. 10.11.2 "Message Data Register Format".
     432     */
     433    memset(pIntr, 0, sizeof(*pIntr));
     434    pIntr->u8Dest         = pMsi->MsiAddr.n.u8DestId;
     435    pIntr->u8DestMode     = pMsi->MsiAddr.n.u1DestMode;
     436    pIntr->u8RedirHint    = pMsi->MsiAddr.n.u1RedirHint;
     437
     438    pIntr->u8Vector       = pMsi->MsiData.n.u8Vector;
     439    pIntr->u8TriggerMode  = pMsi->MsiData.n.u1TriggerMode;
     440    pIntr->u8DeliveryMode = pMsi->MsiData.n.u3DeliveryMode;
     441}
     442
     443#if 0
     444/**
     445 * Convert an APIC interrupt to an MSI message.
     446 *
     447 * @param   pIntr   The APIC interrupt to convert.
     448 * @param   pMsi    Where to store the MSI message.
     449 */
     450DECLINLINE(void) ioapicGetMsiFromApicIntr(PCXAPICINTR pIntr, PMSIMSG pMsi)
     451{
     452    memset(pMsi, 0, sizeof(*pMsi));
     453    pMsi->MsiAddr.n.u12Addr        = VBOX_MSI_ADDR_BASE >> VBOX_MSI_ADDR_SHIFT;
     454    pMsi->MsiAddr.n.u8DestId       = pIntr->u8Dest;
     455    pMsi->MsiAddr.n.u1RedirHint    = pIntr->u8RedirHint;
     456    pMsi->MsiAddr.n.u1DestMode     = pIntr->u8DestMode;
     457
     458    pMsi->MsiData.n.u8Vector       = pIntr->u8Vector;
     459    pMsi->MsiData.n.u3DeliveryMode = pIntr->u8DeliveryMode;
     460    pMsi->MsiData.n.u1TriggerMode  = pIntr->u8TriggerMode;
     461
     462    /* pMsi->MsiData.n.u1Level     = ??? */
     463    /** @todo r=ramshankar: Level triggered MSIs don't make much sense though
     464     *        possible in theory? Maybe document this more explicitly... */
     465}
     466#endif
    391467
    392468/**
     
    780856    LogFlow(("IOAPIC: ioapicSendMsi: GCPhys=%#RGp uValue=%#RX32\n", GCPhys, uValue));
    781857
    782     /*
    783      * Parse the message from the physical address.
    784      * See Intel spec. 10.11.1 "Message Address Register Format".
    785      */
    786     uint8_t const u8DestId   = (GCPhys & VBOX_MSI_ADDR_DEST_ID_MASK) >> VBOX_MSI_ADDR_DEST_ID_SHIFT;
    787     uint8_t const u8DestMode = (GCPhys >> VBOX_MSI_ADDR_DEST_MODE_SHIFT) & 0x1;
    788     /** @todo Check if we need to implement Redirection Hint Indicator. */
    789     /* uint8_t const uRedirectHint  = (GCPhys >> VBOX_MSI_ADDR_REDIRECTION_SHIFT) & 0x1; */
    790 
    791     /*
    792      * Parse the message data.
    793      * See Intel spec. 10.11.2 "Message Data Register Format".
    794      */
    795     uint8_t const u8Vector       = (uValue & VBOX_MSI_DATA_VECTOR_MASK)  >> VBOX_MSI_DATA_VECTOR_SHIFT;
    796     uint8_t const u8TriggerMode  = (uValue >> VBOX_MSI_DATA_TRIGGER_SHIFT) & 0x1;
    797     uint8_t const u8DeliveryMode = (uValue >> VBOX_MSI_DATA_DELIVERY_MODE_SHIFT) & 0x7;
     858    MSIMSG MsiMsg;
     859    MsiMsg.MsiAddr.u64 = GCPhys;
     860    MsiMsg.MsiData.u32 = uValue;
     861
     862    XAPICINTR ApicIntr;
     863    ioapicGetApicIntrFromMsi(&MsiMsg, &ApicIntr);
    798864
    799865    /*
     
    801867     */
    802868    int rc = pThisCC->pIoApicHlp->pfnApicBusDeliver(pDevIns,
    803                                                     u8DestId,
    804                                                     u8DestMode,
    805                                                     u8DeliveryMode,
    806                                                     u8Vector,
     869                                                    ApicIntr.u8Dest,
     870                                                    ApicIntr.u8DestMode,
     871                                                    ApicIntr.u8DeliveryMode,
     872                                                    ApicIntr.u8Vector,
    807873                                                    0 /* u8Polarity - N/A */,
    808                                                     u8TriggerMode,
     874                                                    ApicIntr.u8TriggerMode,
    809875                                                    uTagSrc);
    810876    /* Can't reschedule to R3. */
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