VirtualBox

Changeset 108716 in vbox


Ignore:
Timestamp:
Mar 24, 2025 12:43:36 PM (3 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168133
Message:

VMM/GIC: bugref:10877 ITS bits, trying guest to probe/enable the ITS. [work-in-progress]

Location:
trunk
Files:
5 edited

Legend:

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

    r108695 r108716  
    127127     *                      Cannot be NIL_PCIBDF.
    128128     * @param   pMsi        The MSI to send.
    129      * @param   uEventId    TODO
     129     * @param   uEventId    The event ID specified by the device.
    130130     * @param   uTagSrc     The IRQ tag and source (for tracing).
    131131     */
  • trunk/src/VBox/VMM/VMMAll/GICAll.cpp

    r108694 r108716  
    20122012            Assert(pGicDev->fAffRoutingEnabled);
    20132013            *puValue = GIC_DIST_REG_TYPER_NUM_ITLINES_SET(pGicDev->uMaxSpi)
    2014                      | GIC_DIST_REG_TYPER_NUM_PES_SET(0)      /* Affinity routing is always enabled, hence this MBZ. */
    2015                      /*| GIC_DIST_REG_TYPER_NMI*/             /** @todo Support non-maskable interrupts */
    2016                      /*| GIC_DIST_REG_TYPER_SECURITY_EXTN*/   /** @todo Support dual security states. */
     2014                     | GIC_DIST_REG_TYPER_NUM_PES_SET(0)             /* Affinity routing is always enabled, hence this MBZ. */
     2015                     /*| GIC_DIST_REG_TYPER_NMI*/                    /** @todo Support non-maskable interrupts */
     2016                     /*| GIC_DIST_REG_TYPER_SECURITY_EXTN*/          /** @todo Support dual security states. */
    20172017                     | (pGicDev->fMbi ? GIC_DIST_REG_TYPER_MBIS : 0)
    2018                      /*| GIC_DIST_REG_TYPER_LPIS*/            /** @todo Support LPIs */
    20192018                     | (pGicDev->fRangeSel ? GIC_DIST_REG_TYPER_RSS : 0)
    2020                      | GIC_DIST_REG_TYPER_IDBITS_SET(16)      /* We only support 16-bit interrupt IDs. */
     2019                     | GIC_DIST_REG_TYPER_IDBITS_SET(16)             /* We only support 16-bit interrupt IDs. */
    20212020                     | (pGicDev->fAff3Levels ? GIC_DIST_REG_TYPER_A3V : 0);
    20222021            if (pGicDev->fExtSpi)
    20232022                *puValue |= GIC_DIST_REG_TYPER_ESPI
    20242023                         |  GIC_DIST_REG_TYPER_ESPI_RANGE_SET(pGicDev->uMaxExtSpi);
     2024            if (pGicDev->fLpi)
     2025            {
     2026                Assert(pGicDev->uMaxLpi - 2 < 13);
     2027                Assert(GIC_INTID_RANGE_LPI_START + (UINT32_C(2) << pGicDev->uMaxLpi) <= UINT16_MAX);
     2028                *puValue |= GIC_DIST_REG_TYPER_LPIS
     2029                         |  GIC_DIST_REG_TYPER_NUM_LPIS_SET(pGicDev->uMaxLpi);
     2030            }
    20252031            break;
    20262032        }
     
    23192325                     | GIC_REDIST_REG_TYPER_CPU_NUMBER_SET(idRedist)
    23202326                     | GIC_REDIST_REG_TYPER_CMN_LPI_AFF_SET(GIC_REDIST_REG_TYPER_CMN_LPI_AFF_ALL)
    2321                      | (pGicDev->fExtPpi ? GIC_REDIST_REG_TYPER_PPI_NUM_SET(pGicDev->uMaxExtPpi) : 0);
     2327                     | (pGicDev->fExtPpi ? GIC_REDIST_REG_TYPER_PPI_NUM_SET(pGicDev->uMaxExtPpi) : 0)
     2328                     | (pGicDev->fLpi    ? GIC_REDIST_REG_TYPER_PLPIS : 0);
    23222329            Assert(!pGicDev->fExtPpi || pGicDev->uMaxExtPpi > 0);
    23232330            break;
     
    30713078{
    30723079    LogFlowFunc(("\n"));
    3073     PGICDEV pGicDev = PDMDEVINS_2_DATA(pDevIns, PGICDEV);
     3080    PGICDEV  pGicDev  = PDMDEVINS_2_DATA(pDevIns, PGICDEV);
     3081    PGITSDEV pGitsDev = &pGicDev->Gits;
     3082
    30743083    RT_ZERO(pGicDev->bmIntrGroup);
    30753084    RT_ZERO(pGicDev->bmIntrConfig);
     
    30833092    pGicDev->fIntrGroup1Enabled = false;
    30843093    pGicDev->fAffRoutingEnabled = true; /* GICv2 backwards compatibility is not implemented, so this is RA1/WI. */
     3094    RT_ZERO(pGicDev->bmLpiPending);
     3095    RT_ZERO(pGicDev->abLpiConfig);
     3096    gitsInit(pGitsDev);
    30853097}
    30863098
     
    31353147{
    31363148    LogFlowFunc(("\n"));
    3137     PGICDEV  pGicDev  = PDMDEVINS_2_DATA(pDevIns, PGICDEV);
    3138     PGITSDEV pGitsDev = &pGicDev->Gits;
    3139 
    31403149    gicInit(pDevIns);
    3141     gitsInit(pGitsDev);
    31423150}
    31433151
  • trunk/src/VBox/VMM/VMMAll/GITSAll.cpp

    r108694 r108716  
    135135{
    136136    Log4Func(("\n"));
    137 
    138137    pGitsDev->fEnabled              = false;
    139138    pGitsDev->fUnmappedMsiReporting = false;
     
    147146{
    148147    RT_NOREF(pGitsDev, pHlp, pszArgs);
     148    /** @todo Debug info dump. */
    149149}
    150150#endif /* IN_RING3 */
  • trunk/src/VBox/VMM/VMMR3/GICR3.cpp

    r108682 r108716  
    5151*********************************************************************************************************************************/
    5252/** GIC saved state version. */
    53 #define GIC_SAVED_STATE_VERSION                     6
     53#define GIC_SAVED_STATE_VERSION                     7
    5454
    5555# define GIC_SYSREGRANGE(a_uFirst, a_uLast, a_szName) \
     
    102102    pHlp->pfnPrintf(pHlp, "  fMbi             = %RTbool\n", pGicDev->fMbi);
    103103    pHlp->pfnPrintf(pHlp, "  fAff3Levels      = %RTbool\n", pGicDev->fAff3Levels);
     104    pHlp->pfnPrintf(pHlp, "  fLpi             = %RTbool\n", pGicDev->fLpi);
    104105}
    105106
     
    319320    pHlp->pfnSSMPutBool(pSSM, pGicDev->fMbi);
    320321    pHlp->pfnSSMPutBool(pSSM, pGicDev->fAff3Levels);
     322    pHlp->pfnSSMPutBool(pSSM, pGicDev->fLpi);
    321323
    322324    /* Distributor state. */
     
    333335    pHlp->pfnSSMPutMem(pSSM,  &pGicDev->bmIntrRoutingMode[0], sizeof(pGicDev->bmIntrRoutingMode));
    334336
     337    /* We store the size followed by the data because we currently do not support the full LPI range. */
     338    pHlp->pfnSSMPutU32(pSSM,  sizeof(pGicDev->abLpiConfig));
     339    pHlp->pfnSSMPutMem(pSSM,  &pGicDev->abLpiConfig[0],       sizeof(pGicDev->abLpiConfig));
     340    pHlp->pfnSSMPutU32(pSSM,  sizeof(pGicDev->bmLpiPending));
     341    pHlp->pfnSSMPutMem(pSSM,  &pGicDev->bmLpiPending[0],      sizeof(pGicDev->bmLpiPending));
     342
     343    /** @todo GITS data. */
     344
    335345    /*
    336346     * Save per-VCPU data.
     
    403413    pHlp->pfnSSMGetBool(pSSM, &pGicDev->fMbi);
    404414    pHlp->pfnSSMGetBool(pSSM, &pGicDev->fAff3Levels);
     415    pHlp->pfnSSMGetBool(pSSM, &pGicDev->fLpi);
    405416
    406417    /* Distributor state. */
     
    417428    pHlp->pfnSSMGetMem(pSSM,  &pGicDev->bmIntrRoutingMode[0], sizeof(pGicDev->bmIntrRoutingMode));
    418429
     430    /* LPI config. */
     431    {
     432        uint32_t cbData = 0;
     433        int const rc = pHlp->pfnSSMGetU32(pSSM, &cbData);
     434        AssertRCReturn(rc, rc);
     435        if (cbData <= sizeof(pGicDev->abLpiConfig))
     436            pHlp->pfnSSMGetMem(pSSM, &pGicDev->abLpiConfig[0], cbData);
     437        else
     438            return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch: LPI config table size: got=%u expected=%u"),
     439                                           cbData, sizeof(pGicDev->abLpiConfig));
     440    }
     441    /* LPI pending. */
     442    {
     443        uint32_t cbData = 0;
     444        int const rc = pHlp->pfnSSMGetU32(pSSM, &cbData);
     445        AssertRCReturn(rc, rc);
     446        if (cbData <= sizeof(pGicDev->bmLpiPending))
     447            pHlp->pfnSSMGetMem(pSSM, &pGicDev->bmLpiPending[0], cbData);
     448        else
     449            return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch: LPI pending bitmap size: got=%u expected=%u"),
     450                                           cbData, sizeof(pGicDev->bmLpiPending));
     451    }
     452
     453    /** @todo GITS data. */
     454
    419455    /*
    420456     * Load per-VCPU data.
     
    481517    else
    482518        return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Invalid MaxExtPpi, got %u expected range [1,2]"), pGicDev->uMaxExtPpi);
     519    bool const fIsGitsEnabled = RT_BOOL(pGicDev->hMmioGits != NIL_IOMMMIOHANDLE);
     520    if (fIsGitsEnabled == pGicDev->fLpi)
     521    { /* likely */ }
     522    else
     523        return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch: LPIs are %s when ITS is %s"),
     524                                       fIsGitsEnabled ? "enabled" : "disabled", pGicDev->fLpi ? "enabled" : "disabled");
    483525    return rc;
    484526}
     
    587629     * most guests would assume support for SPIs. */
    588630    AssertCompile(GIC_DIST_REG_TYPER_NUM_ITLINES == 31);
     631    /** @todo This currently isn't implemented and the full range is always
     632     *        supported. */
    589633    rc = pHlp->pfnCFGMQueryU8Def(pCfg, "MaxSpi", &pGicDev->uMaxSpi, 31 /* Upto and incl. IntId 1023 */);
    590634    AssertLogRelRCReturn(rc, rc);
     
    609653     * disabled. */
    610654    AssertCompile(GIC_DIST_REG_TYPER_ESPI_RANGE >> GIC_DIST_REG_TYPER_ESPI_RANGE_BIT == 31);
     655    /** @todo This currently isn't implemented and the full range is always
     656     *        supported. */
    611657    rc = pHlp->pfnCFGMQueryU8Def(pCfg, "MaxExtSpi", &pGicDev->uMaxExtSpi, 31);
    612658    AssertLogRelRCReturn(rc, rc);
     
    628674     * supported. Valid values are [1,2] which equates to extended PPI IntIds
    629675     * [1087,1119]. This is unused when extended PPIs are disabled. */
     676    /** @todo This currently isn't implemented and the full range is always
     677     *        supported. */
    630678    rc = pHlp->pfnCFGMQueryU8Def(pCfg, "MaxExtPpi", &pGicDev->uMaxExtPpi, 2);
    631679    AssertLogRelRCReturn(rc, rc);
     
    657705    /** @devcfgm{gic, Aff3Levels, bool, true}
    658706     * Configures whether non-zero affinity 3 levels (A3V) are supported
    659      * (GICD_TYPER.A3V) and (ICC_CTLR.A3V). */
     707     * (GICD_TYPER.A3V and ICC_CTLR.A3V). */
    660708    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "Aff3Levels", &pGicDev->fAff3Levels, true);
    661709    AssertLogRelRCReturn(rc, rc);
     710
     711    /** @devcfgm{gic, Lpi, bool, true}
     712     * Configures whether physical LPIs are supported (GICD_TYPER.LPIS and
     713     * GICR_TYPER.PLPIS). */
     714    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "Lpi", &pGicDev->fLpi, true);
     715    AssertLogRelRCReturn(rc, rc);
     716
     717    /** @devcfgm{gic, MaxLpi, uint8_t, 14}
     718     * Configures GICD_TYPER.num_LPIs.
     719     *
     720     * For the physical LPI range [8192,65535], configures the number of physical LPI
     721     * supported. Valid values are [3,14] which equates to LPI IntIds 8192 to
     722     * [8207,40959]. A value of 15 or higher would exceed the maximum INTID size of
     723     * 16-bits since 8192 + 2^(NumLpi+1) is >= 73727. A value of 2 or lower support
     724     * fewer than 15 LPIs which seem pointless and is hence disallowed. This value is
     725     * ignored (set to 0 in the register) when LPIs are disabled. */
     726    rc = pHlp->pfnCFGMQueryU8Def(pCfg, "MaxLpi", &pGicDev->uMaxLpi, 10);
     727    AssertLogRelRCReturn(rc, rc);
     728
     729    /* We currently support 2048 LPIs until we need to support more. */
     730    if (pGicDev->uMaxLpi == 10)
     731    { /* likely */ }
     732    else
     733        return PDMDevHlpVMSetError(pDevIns, VERR_INVALID_PARAMETER, RT_SRC_POS,
     734                                   N_("Configuration error: \"MaxLpi\" must be in the range [3,14]"));
     735    AssertRelease(UINT32_C(2) << pGicDev->uMaxLpi <= RT_ELEMENTS(pGicDev->abLpiConfig));
    662736
    663737    /*
     
    723797                                           &pGicDev->hMmioGits);
    724798            AssertRCReturn(rc, rc);
     799
     800            /* When the ITS is enabled we must support LPIs. */
     801            if (!pGicDev->fLpi)
     802                return PDMDevHlpVMSetError(pDevIns, VERR_INVALID_PARAMETER, RT_SRC_POS,
     803                                           N_("Configuration error: \"Lpi\" must be enabled when ITS is enabled\n"));
    725804        }
    726805        else
     
    794873    bool const fMbi            = pGicDev->fMbi;
    795874    bool const fAff3Levels     = pGicDev->fAff3Levels;
     875    bool const fLpi            = pGicDev->fLpi;
    796876    uint16_t const uExtPpiLast = uMaxExtPpi == GIC_REDIST_REG_TYPER_PPI_NUM_MAX_1087 ? 1087 : GIC_INTID_RANGE_EXT_PPI_LAST;
    797     LogRel(("GIC: ArchRev=%u RangeSel=%RTbool Nmi=%RTbool Mbi=%RTbool Aff3Levels=%RTbool\n",
    798             uArchRev, fRangeSel, fNmi, fMbi, fAff3Levels));
     877    LogRel(("GIC: ArchRev=%u RangeSel=%RTbool Nmi=%RTbool Mbi=%RTbool Aff3Levels=%RTbool Lpi=%RTbool\n",
     878            uArchRev, fRangeSel, fNmi, fMbi, fAff3Levels, fLpi));
    799879    LogRel(("GIC: SPIs=true (%u:32..%u) ExtSPIs=%RTbool (%u:4095..%u) ExtPPIs=%RTbool (%u:1056..%u)\n",
    800880            uMaxSpi, 32 * (uMaxSpi + 1),
  • trunk/src/VBox/VMM/include/GICInternal.h

    r108682 r108716  
    127127     *  (ICC_CTLR.A3V). */
    128128    bool                        fAff3Levels;
    129     /** Alignment. */
    130     bool                        afPadding[2];
     129    /** Whether LPIs are supported (GICD_TYPER.PLPIS). */
     130    bool                        fLpi;
     131    /** The maximum LPI supported (GICD_TYPER.num_LPI). */
     132    uint8_t                     uMaxLpi;
     133    /** Padding. */
     134    bool                        afPadding[4];
    131135    /** @} */
    132136
    133137    /** @name GITS device data and LPIs.
    134138     * @{ */
     139    /** ITS device state. */
    135140    GITSDEV                     Gits;
    136     uint8_t                     abLpiPriority[8192];
     141    /** LPI configuration table (priority + enabled bit). */
     142    uint8_t                     abLpiConfig[2048];
     143    /** LPI pending bitmap. */
     144    uint32_t                    bmLpiPending[64];
    137145    /** @} */
    138146
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