VirtualBox

Changeset 88894 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 6, 2021 9:46:39 AM (4 years ago)
Author:
vboxsync
Message:

Intel IOMMU: bugref:9967 Interrupt remapping, work-in-progress.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Bus/DevIommuIntel.cpp

    r88893 r88894  
    278278    STAMCOUNTER                 StatMmioWriteRZ;        /**< Number of MMIO writes in RZ. */
    279279
    280     STAMCOUNTER                 StatMsiRemapR3;         /**< Number of MSI remap requests in R3. */
    281     STAMCOUNTER                 StatMsiRemapRZ;         /**< Number of MSI remap requests in RZ. */
     280    STAMCOUNTER                 StatMsiRemapCfiR3;      /**< Number of compatibility-format interrupts remap requests in R3. */
     281    STAMCOUNTER                 StatMsiRemapCfiRZ;      /**< Number of compatibility-format interrupts remap requests in RZ. */
     282    STAMCOUNTER                 StatMsiRemapRfiR3;      /**< Number of remappable-format interrupts remap requests in R3. */
     283    STAMCOUNTER                 StatMsiRemapRfiRZ;      /**< Number of remappable-format interrupts remap requests in RZ. */
    282284
    283285    STAMCOUNTER                 StatMemReadR3;          /**< Number of memory read translation requests in R3. */
     
    12951297    uint64_t const fExtCapReg = pThis->fExtCapReg;
    12961298
    1297     /*
    1298      * Queued-invalidation.
    1299      */
     1299    /* Queued-invalidation. */
    13001300    if (   (fExtCapReg & VTD_BF_ECAP_REG_QI_MASK)
    13011301        && (fChanged & VTD_BF_GCMD_REG_QIE_MASK))
     
    13031303        if (uGcmdReg & VTD_BF_GCMD_REG_QIE_MASK)
    13041304        {
    1305             /* Enable the invalidation-queue. */
    13061305            dmarRegChangeRaw32(pThis, VTD_MMIO_OFF_GSTS_REG, UINT32_MAX, VTD_BF_GSTS_REG_QIES_MASK);
    13071306            dmarInvQueueThreadWakeUpIfNeeded(pDevIns);
     
    13091308        else
    13101309        {
    1311             /* Disable the invalidation-queue. */
    13121310            dmarRegChangeRaw32(pThis, VTD_MMIO_OFF_GSTS_REG, ~VTD_BF_GSTS_REG_QIES_MASK, 0 /* fOrMask */);
    13131311            dmarRegWriteRaw32(pThis, VTD_MMIO_OFF_IQH_REG, 0);
     
    13171315    if (fExtCapReg & VTD_BF_ECAP_REG_IR_MASK)
    13181316    {
    1319         /*
    1320          * Set Interrupt Remapping Table Pointer (SIRTP).
    1321          */
     1317        /* Set Interrupt Remapping Table Pointer (SIRTP). */
    13221318        if (uGcmdReg & VTD_BF_GCMD_REG_SIRTP_MASK)
    13231319        {
     
    13281324        }
    13291325
    1330         /*
    1331          * Interrupt remapping.
    1332          */
     1326        /* Interrupt remapping. */
    13331327        if (fChanged & VTD_BF_GCMD_REG_IRE_MASK)
    13341328        {
     
    13381332                dmarRegChangeRaw32(pThis, VTD_MMIO_OFF_GSTS_REG, ~VTD_BF_GSTS_REG_IRES_MASK, 0 /* fOrMask */);
    13391333        }
    1340     }
    1341 
    1342     /*
    1343      * Set Root Table Pointer (SRTP).
    1344      */
     1334
     1335        /* Compatibility format interrupts. */
     1336        if (fChanged & VTD_BF_GCMD_REG_CFI_MASK)
     1337        {
     1338            if (uGcmdReg & VTD_BF_GCMD_REG_CFI_MASK)
     1339                dmarRegChangeRaw32(pThis, VTD_MMIO_OFF_GSTS_REG, UINT32_MAX, VTD_BF_GSTS_REG_CFIS_MASK);
     1340            else
     1341                dmarRegChangeRaw32(pThis, VTD_MMIO_OFF_GSTS_REG, ~VTD_BF_GSTS_REG_CFIS_MASK, 0 /* fOrMask */);
     1342        }
     1343    }
     1344
     1345    /* Set Root Table Pointer (SRTP). */
    13451346    if (uGcmdReg & VTD_BF_GCMD_REG_SRTP_MASK)
    13461347    {
     
    15261527static int dmarIrReadIrte(PPDMDEVINS pDevIns, uint64_t uIrtaReg, uint16_t idxIntr, PVTD_IRTE_T pIrte)
    15271528{
    1528     Assert(idxIntr < VTD_IRTA_REG_GET_ENTRIES(uIrtaReg));
     1529    Assert(idxIntr < VTD_IRTA_REG_GET_ENTRY_COUNT(uIrtaReg));
    15291530
    15301531    size_t const   cbIrte     = sizeof(*pIrte);
     
    16011602        uint16_t const uHandle         = uHandleLo | (uHandleHi << 15);
    16021603        bool const     fSubHandleValid = RT_BF_GET(pMsiIn->Addr.au32[0], VTD_BF_REMAPPABLE_MSI_ADDR_SHV);
    1603         uint32_t const idxIntr         = fSubHandleValid
     1604        uint16_t const idxIntr         = fSubHandleValid
    16041605                                       ? uHandle + RT_BF_GET(pMsiIn->Data.u32, VTD_BF_REMAPPABLE_MSI_DATA_SUBHANDLE)
    16051606                                       : uHandle;
    16061607
    16071608        /* Validate the index. */
    1608         uint32_t const cEntries = VTD_IRTA_REG_GET_ENTRIES(uIrtaReg);
     1609        uint32_t const cEntries = VTD_IRTA_REG_GET_ENTRY_COUNT(uIrtaReg);
    16091610        if (idxIntr < cEntries)
    16101611        {
     
    17331734    if (uGstsReg & VTD_BF_GSTS_REG_IRES_MASK)
    17341735    {
    1735         STAM_COUNTER_INC(&pThis->CTX_SUFF_Z(StatMsiRemap));
    1736 
    17371736        /* Handle compatibility format interrupts. */
    1738         uint8_t const fIntrFormat = VTD_MSI_ADDR_GET_INTR_FORMAT(pMsiIn->Addr.u64);
    1739         if (fIntrFormat == VTD_INTR_FORMAT_COMPAT)
     1737        bool const fIsRemapFormat = RT_BF_GET(pMsiIn->Addr.au32[0], VTD_BF_REMAPPABLE_MSI_ADDR_INTR_FMT);
     1738        if (!fIsRemapFormat)
    17401739        {
    1741             /* If in Extended Interrupt Mode (EIM) or compatibility format interrupts are  disabled, block the interrupt. */
     1740            STAM_COUNTER_INC(&pThis->CTX_SUFF_Z(StatMsiRemapCfi));
     1741
     1742            /* If EIME is enabled or CFIs are  disabled, block the interrupt. */
    17421743            if (    (uIrtaReg & VTD_BF_IRTA_REG_EIME_MASK)
    17431744                || !(uGstsReg & VTD_BF_GSTS_REG_CFIS_MASK))
     
    17531754
    17541755        /* Handle remappable format interrupts. */
     1756        STAM_COUNTER_INC(&pThis->CTX_SUFF_Z(StatMsiRemapRfi));
    17551757        return dmarIrRemapIntr(pDevIns, uIrtaReg, idDevice, pMsiIn, pMsiOut);
    17561758    }
     
    23582360    {
    23592361        uint8_t const fCfi = RT_BF_GET(uGcmdReg, VTD_BF_GCMD_REG_CFI);
    2360         pHlp->pfnPrintf(pHlp, "   CFI          = %u (%s)\n", fCfi, fCfi ? "Bypass interrupt remapping"
    2361                                                                         : "Block compatible format interrupts");
     2362        pHlp->pfnPrintf(pHlp, "   CFI          = %u (%s)\n", fCfi, fCfi ? "Bypass" : "Block");
    23622363        pHlp->pfnPrintf(pHlp, "   SIRTP        = %u\n", RT_BF_GET(uGcmdReg, VTD_BF_GCMD_REG_SIRTP));
    23632364        pHlp->pfnPrintf(pHlp, "   IRE          = %u\n", RT_BF_GET(uGcmdReg, VTD_BF_GCMD_REG_IRE));
     
    23722373    {
    23732374        uint8_t const fCfis = RT_BF_GET(uGstsReg, VTD_BF_GSTS_REG_CFIS);
    2374         pHlp->pfnPrintf(pHlp, "   CFIS         = %u (%s)\n", fCfis, fCfis ? "Bypass interrupt remapping"
    2375                                                                           : "Block compatible format interrupts");
     2375        pHlp->pfnPrintf(pHlp, "   CFIS         = %u (%s)\n", fCfis, fCfis ? "Bypass" : "Block");
    23762376        pHlp->pfnPrintf(pHlp, "   IRTPS        = %u\n", RT_BF_GET(uGstsReg, VTD_BF_GSTS_REG_IRTPS));
    23772377        pHlp->pfnPrintf(pHlp, "   IRES         = %u\n", RT_BF_GET(uGstsReg, VTD_BF_GSTS_REG_IRES));
     
    24442444    }
    24452445    pHlp->pfnPrintf(pHlp, " IRTA_REG     = %#RX64\n", uIrtaReg);
     2446    {
     2447        uint32_t const cIrtEntries = VTD_IRTA_REG_GET_ENTRY_COUNT(uIrtaReg);
     2448        uint32_t const cbIrt       = sizeof(VTD_IRTE_T) * cIrtEntries;
     2449        pHlp->pfnPrintf(pHlp, "   IRTA         = %#RX64\n",   RT_BF_GET(uIrtaReg, VTD_BF_IRTA_REG_IRTA));
     2450        pHlp->pfnPrintf(pHlp, "   EIME         = %RTbool\n",  RT_BF_GET(uIrtaReg, VTD_BF_IRTA_REG_EIME));
     2451        pHlp->pfnPrintf(pHlp, "   S            = %u entries (%u bytes)\n", cIrtEntries, cbIrt);
     2452    }
    24462453    pHlp->pfnPrintf(pHlp, " PQH_REG      = %#RX64\n", uPqhReg);
    24472454    pHlp->pfnPrintf(pHlp, " PQT_REG      = %#RX64\n", uPqtReg);
     
    27392746    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMmioWriteRZ, STAMTYPE_COUNTER, "RZ/MmioWrite", STAMUNIT_OCCURENCES, "Number of MMIO writes in RZ.");
    27402747
    2741     PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMsiRemapR3, STAMTYPE_COUNTER, "R3/MsiRemap", STAMUNIT_OCCURENCES, "Number of interrupt remap requests in R3.");
    2742     PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMsiRemapRZ, STAMTYPE_COUNTER, "RZ/MsiRemap", STAMUNIT_OCCURENCES, "Number of interrupt remap requests in RZ.");
     2748    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMsiRemapCfiR3, STAMTYPE_COUNTER, "R3/MsiRemapCfi", STAMUNIT_OCCURENCES, "Number of compatibility-format interrupt remap requests in R3.");
     2749    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMsiRemapCfiRZ, STAMTYPE_COUNTER, "RZ/MsiRemapCfi", STAMUNIT_OCCURENCES, "Number of compatibility-format interrupt remap requests in RZ.");
     2750    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMsiRemapRfiR3, STAMTYPE_COUNTER, "R3/MsiRemapRfi", STAMUNIT_OCCURENCES, "Number of remappable-format interrupt remap requests in R3.");
     2751    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMsiRemapRfiRZ, STAMTYPE_COUNTER, "RZ/MsiRemapRfi", STAMUNIT_OCCURENCES, "Number of remappable-format interrupt remap requests in RZ.");
    27432752
    27442753    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMemReadR3,  STAMTYPE_COUNTER, "R3/MemRead",  STAMUNIT_OCCURENCES, "Number of memory read translation requests in 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