VirtualBox

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


Ignore:
Timestamp:
Apr 25, 2021 7:08:49 AM (4 years ago)
Author:
vboxsync
Message:

Intel IOMMU: bugref:9967 Register-based invalidation WIP, Queued-invalidation nits.

File:
1 edited

Legend:

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

    r88694 r88695  
    144144    kDmarDiag_IqtReg_Qt_NotAligned,
    145145    kDmarDiag_IqaReg_Dw_Invalid,
     146    kDmarDiag_CcmdReg_Ttm_Invalid,
     147    kDmarDiag_CcmdReg_Qi_Enabled,
     148    kDmarDiag_CcmdReg_NotSupported,
    146149    /* Last member for determining array index limit. */
    147150    kDmarDiag_End
     
    157160    DMARDIAG_DESC(kNone                         ,   "None"                ),
    158161    DMARDIAG_DESC(kDmarDiag_IqtReg_Qt_NotAligned,   "IqtReg_Qt_NotAligned"),
    159     DMARDIAG_DESC(kDmarDiag_IqaReg_Dw_Invalid   ,   "IqaReg_Dw_Invalid"   )
     162    DMARDIAG_DESC(kDmarDiag_IqaReg_Dw_Invalid   ,   "IqaReg_Dw_Invalid"   ),
     163    DMARDIAG_DESC(kDmarDiag_CcmdReg_Ttm_Invalid ,   "CcmdReg_Ttm_Invalid" ),
     164    DMARDIAG_DESC(kDmarDiag_CcmdReg_Qi_Enabled  ,   "CcmdReg_Qi_Enabled"  ),
     165    DMARDIAG_DESC(kDmarDiag_CcmdReg_NotSupported,   "CcmdReg_NotSupported")
    160166    /* kDmarDiag_End */
    161167};
     
    172178    /** DMAR magic. */
    173179    uint32_t                    u32Magic;
    174 
    175     /** The MMIO handle. */
    176     IOMMMIOHANDLE               hMmio;
    177     /** The event semaphore the invalidation-queue thread waits on. */
    178     SUPSEMEVENT                 hEvtInvQueue;
    179     /** Whether the invalidation-queue thread has been signaled. */
    180     bool volatile               fInvQueueThreadSignaled;
    181     /** Padding. */
    182     bool                        afPadding0[3];
    183     /** Error diagnostic. */
    184     DMARDIAG                    enmDiag;
    185180
    186181    /** Registers (group 0). */
     
    200195    uint64_t                    fExtCap;
    201196    /** @} */
     197
     198    /** The event semaphore the invalidation-queue thread waits on. */
     199    SUPSEMEVENT                 hEvtInvQueue;
     200    /** Whether the invalidation-queue thread has been signaled. */
     201    bool volatile               fInvQueueThreadSignaled;
     202    /** Padding. */
     203    bool                        afPadding0[3];
     204    /** Error diagnostic. */
     205    DMARDIAG                    enmDiag;
     206    /** The MMIO handle. */
     207    IOMMMIOHANDLE               hMmio;
    202208
    203209#ifdef VBOX_WITH_STATISTICS
     
    864870    uint64_t const uIqtReg = dmarRegReadRaw64(pThis, VTD_MMIO_OFF_IQT_REG);
    865871    uint64_t const uIqhReg = dmarRegReadRaw64(pThis, VTD_MMIO_OFF_IQH_REG);
    866 
    867     uint32_t const offQt = VTD_IQT_REG_GET_QT(uIqtReg);
    868     uint32_t const offQh = VTD_IQH_REG_GET_QH(uIqhReg);
    869     return offQt == offQh;
     872    /* Don't bother masking out QT, QH out of IQT_REG, IQH_REG since all other bits are RsvdZ. */
     873    Assert(!(uIqtReg & ~VTD_BF_IQT_REG_QT_MASK));
     874    Assert(!(uIqhReg & ~VTD_BF_IQH_REG_QH_MASK));
     875    return uIqtReg == uIqhReg;
    870876}
    871877
     
    906912    DMAR_ASSERT_LOCK_IS_OWNER(pDevIns, pThisCC);
    907913
    908     if (   dmarInvQueueCanProcessRequests(pThis)
     914    if (    dmarInvQueueCanProcessRequests(pThis)
    909915        && !dmarInvQueueIsEmpty(pThis)
    910916        && !ASMAtomicXchgBool(&pThis->fInvQueueThreadSignaled, true))
     
    10851091            if (uMajorVersion < 6)
    10861092            {
    1087                 /** @todo Verify queued-invalidation is not enabled.
    1088                  *  See Intel VT-d spec. 6.5.1 "Register-based Invalidation Interface" */
    1089 
    1090                 /* Verify table translation mode is legacy. */
    1091                 uint8_t const fTtm = dmarRtAddrRegGetTtm(pThis);
    1092                 if (fTtm == VTD_TTM_LEGACY_MODE)
     1093                /* Register-based invalidation can only be used when queued-invalidations are not enabled. */
     1094                uint32_t const uGstsReg = dmarRegReadRaw32(pThis, VTD_MMIO_OFF_GSTS_REG);
     1095                if (!(uGstsReg & VTD_BF_GSTS_REG_QIES_MASK))
    10931096                {
    1094                     /** @todo Invalidate. */
    1095                     return VINF_SUCCESS;
     1097                    /* Verify table translation mode is legacy. */
     1098                    uint8_t const fTtm = dmarRtAddrRegGetTtm(pThis);
     1099                    if (fTtm == VTD_TTM_LEGACY_MODE)
     1100                    {
     1101                        /** @todo Invalidate. */
     1102                        return VINF_SUCCESS;
     1103                    }
     1104                    pThis->enmDiag = kDmarDiag_CcmdReg_Ttm_Invalid;
    10961105                }
     1106                else
     1107                    pThis->enmDiag = kDmarDiag_CcmdReg_Qi_Enabled;
    10971108            }
    1098 
    1099             /** @todo Record error. */
     1109            else
     1110                pThis->enmDiag = kDmarDiag_CcmdReg_NotSupported;
     1111            dmarRegChangeRaw64(pThis, VTD_MMIO_OFF_GSTS_REG, ~VTD_BF_CCMD_REG_CAIG_MASK /* fAndMask */, 0 /* fOrMask */);
    11001112        }
    11011113    }
     
    11181130    PDMAR pThis = PDMDEVINS_2_DATA(pDevIns, PDMAR);
    11191131
    1120     uint32_t const offQt   = VTD_IQT_REG_GET_QT(uIqtReg);
     1132    /* Paranoia. */
     1133    Assert(!(uIqtReg & ~VTD_BF_IQT_REG_QT_MASK));
     1134
     1135    uint32_t const offQt   = uIqtReg;
    11211136    uint64_t const uIqaReg = dmarRegReadRaw64(pThis, VTD_MMIO_OFF_IQA_REG);
    11221137    uint8_t const  fDw     = RT_BF_GET(uIqaReg, VTD_BF_IQA_REG_DW);
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