VirtualBox

Changeset 108496 in vbox for trunk/src


Ignore:
Timestamp:
Mar 10, 2025 1:02:16 PM (2 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167884
Message:

VMM/GIC: bugref:10404 Minor improvements to code getting the highest pending interrupt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/GICAll.cpp

    r108494 r108496  
    18321832                                                 uint16_t *pidxIntr, uint8_t *pbPriority)
    18331833{
    1834 #define GIC_DIST_INTR_COUNT     RT_ELEMENTS(pGicDev->bmIntrPending)
    1835 #define GIC_REDIST_INTR_COUNT   RT_ELEMENTS(pGicCpu->bmIntrPending)
    1836 
    18371834    /*
    18381835     * Collect interrupts that are pending, enabled and inactive.
    18391836     * Discard interrupts if the group they belong to is disabled.
    1840      * While collected the interrupts, pick the one with the highest, non-idle priority.
     1837     * While collecting the interrupts, pick the one with the highest, non-idle priority.
    18411838     */
    18421839    uint16_t uIntId    = GIC_INTID_RANGE_SPECIAL_NO_INTERRUPT;
     
    18471844    {
    18481845        uint16_t idxHighest = UINT16_MAX;
    1849         uint32_t bmIntrPending[GIC_REDIST_INTR_COUNT];
    1850         for (uint16_t i = 0; i < GIC_REDIST_INTR_COUNT; i++)
    1851         {
    1852             bmIntrPending[i] = (pGicCpu->bmIntrPending[i] & pGicCpu->bmIntrEnabled[i]) & ~pGicCpu->bmIntrActive[i];
     1846        for (uint16_t i = 0; i < RT_ELEMENTS(pGicCpu->bmIntrPending); i++)
     1847        {
     1848            uint32_t uIntrPending = (pGicCpu->bmIntrPending[i] & pGicCpu->bmIntrEnabled[i]) & ~pGicCpu->bmIntrActive[i];
    18531849            if (!fGroup1)
    1854                 bmIntrPending[i] &= ~pGicCpu->bmIntrGroup[i];
     1850                uIntrPending &= ~pGicCpu->bmIntrGroup[i];
    18551851            if (!fGroup0)
    1856                 bmIntrPending[i] &= pGicCpu->bmIntrGroup[i];
    1857 
    1858             uint16_t const idxPending = ASMBitFirstSetU32(bmIntrPending[i]);
     1852                uIntrPending &= pGicCpu->bmIntrGroup[i];
     1853
     1854            uint16_t const idxPending = ASMBitFirstSetU32(uIntrPending);
    18591855            if (idxPending > 0)
    18601856            {
    1861                 uint32_t const idxPriority = (32 * i) + idxPending - 1;
     1857                uint32_t const idxPriority = 32 * i + idxPending - 1;
    18621858                Assert(idxPriority < RT_ELEMENTS(pGicCpu->abIntrPriority));
    18631859                if (pGicCpu->abIntrPriority[idxPriority] < uPriority)
     
    18811877    {
    18821878        uint16_t idxHighest = UINT16_MAX;
    1883         uint32_t bmIntrPending[GIC_DIST_INTR_COUNT];
    1884         for (uint16_t i = 0; i < GIC_DIST_INTR_COUNT; i++)
    1885         {
    1886             bmIntrPending[i] = (pGicDev->bmIntrPending[i] & pGicDev->bmIntrEnabled[i]) & ~pGicDev->bmIntrActive[i];
     1879        for (uint16_t i = 0; i < RT_ELEMENTS(pGicDev->bmIntrPending) / 2; i++)
     1880        {
     1881            uint32_t uLo = (pGicDev->bmIntrPending[i]     & pGicDev->bmIntrEnabled[i])     & ~pGicDev->bmIntrActive[i];
     1882            uint32_t uHi = (pGicDev->bmIntrPending[i + 1] & pGicDev->bmIntrEnabled[i + 1]) & ~pGicDev->bmIntrActive[i + 1];
    18871883            if (!fGroup1)
    1888                 bmIntrPending[i] &= ~pGicDev->bmIntrGroup[i];
     1884            {
     1885                uLo &= ~pGicDev->bmIntrGroup[i];
     1886                uHi &= ~pGicDev->bmIntrGroup[i + 1];
     1887            }
    18891888            if (!fGroup0)
    1890                 bmIntrPending[i] &= pGicDev->bmIntrGroup[i];
    1891 
    1892             uint16_t const idxPending = ASMBitFirstSetU32(bmIntrPending[i]);
     1889            {
     1890                uLo &= pGicDev->bmIntrGroup[i];
     1891                uHi &= pGicDev->bmIntrGroup[i + 1];
     1892            }
     1893
     1894            uint64_t const uIntrPending = RT_MAKE_U64(uLo, uHi);
     1895            uint16_t const idxPending   = ASMBitFirstSetU64(uIntrPending);
    18931896            if (idxPending > 0)
    18941897            {
    1895                 uint32_t const idxPriority = (32 * i) + idxPending - 1;
     1898                uint32_t const idxPriority = 64 * i + idxPending - 1;
    18961899                if (pGicDev->abIntrPriority[idxPriority] < uPriority)
    18971900                {
     
    19201923    LogFlowFunc(("uIntId=%u [idxIntr=%u uPriority=%u]\n", uIntId, idxIntr, uPriority));
    19211924    return uIntId;
    1922 
    1923 #undef GIC_DIST_INTR_COUNT
    1924 #undef GIC_REDIST_INTR_COUNT
    19251925}
    19261926#else
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