VirtualBox

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


Ignore:
Timestamp:
May 29, 2021 5:51:55 AM (4 years ago)
Author:
vboxsync
Message:

Intel IOMMU: bugref:9967 Address translation, WIP.

File:
1 edited

Legend:

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

    r89366 r89375  
    312312    /** @} */
    313313
    314     /** Host-address width (HAW) valid mask. */
    315     uint64_t                    fHawMask;
    316     /** Maximum guest-address width (MGAW) valid mask (remove if it turns out we
    317      *  don't need this). */
    318     uint64_t                    fMgawMask;
     314    /** Host-address width (HAW) base address mask. */
     315    uint64_t                    fHawBaseMask;
     316    /** Maximum guest-address width (MGAW) base address mask. */
     317    uint64_t                    fMgawBaseMask;
    319318    /** Maximum supported paging level (3, 4 or 5). */
    320319    uint8_t                     uMaxPagingLevel;
     
    19361935     * Unlike AMD IOMMU paging, here there is no feature for "skipping" levels.
    19371936     */
    1938     uint64_t       uPtEntity = SlpEntry;
    1939     uint64_t const uDmaAddr  = pAddrRemap->uDmaAddr;
    1940     uint64_t const fHawMask  = pThis->fHawMask;
     1937    uint64_t       uPtEntity    = SlpEntry;
     1938    uint64_t const uDmaAddr     = pAddrRemap->uDmaAddr & pThis->fMgawBaseMask;
     1939    uint64_t const fHawBaseMask = pThis->fHawBaseMask;
    19411940    for (int8_t iLevel = uPagingLevel - 1; iLevel >= 0; iLevel--)
    19421941    {
    19431942        /* Read the paging entry for the current level. */
    19441943        {
    1945             uint8_t const  cShift         = 12 + ((iLevel - 1) * 9);
    1946             uint16_t const idxPte         = (uDmaAddr >> cShift) & UINT64_C(0x1ff);
     1944            uint8_t const  cLevelShift    = 12 + ((iLevel - 1) * 9);
     1945            uint16_t const idxPte         = (uDmaAddr >> cLevelShift) & UINT64_C(0x1ff);
    19471946            uint64_t const offPte         = idxPte << 3;
    1948             RTGCPHYS const GCPhysPtEntity = (uPtEntity & fHawMask) | offPte;
     1947            /** @todo if we validate 63:HAW (since hardware treats it as reserved and we should fault if that's the case, we might not need to & fHawbaseMask here. */
     1948            RTGCPHYS const GCPhysPtEntity = (uPtEntity & fHawBaseMask) | offPte;
    19491949            int const rc = PDMDevHlpPhysReadMeta(pDevIns, GCPhysPtEntity, &uPtEntity, sizeof(uPtEntity));
    19501950            if (RT_SUCCESS(rc))
     
    19561956                 *        available in pAddrRemap->fTtm, but how cleanly we can handle this is
    19571957                 *        something to be decided later. For now we just use legacy mode error
    1958                  *        codes below. Asserted below. */
     1958                 *        codes. Asserted as such below. */
    19591959                Assert(pAddrRemap->fTtm == VTD_TTM_LEGACY_MODE);
    19601960                dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lsl_1, VTDATFAULT_LSL_1, pAddrRemap);
     
    33213321        dmarRegWriteRaw64(pThis, VTD_MMIO_OFF_CAP_REG, pThis->fCapReg);
    33223322
    3323         pThis->fHawMask        = ~(UINT64_MAX << cGstPhysAddrBits) & UINT64_C(0xfffffffffffff000);
    3324         pThis->fMgawMask       = pThis->fHawMask;
     3323        pThis->fHawBaseMask    = ~(UINT64_MAX << cGstPhysAddrBits) & X86_PAGE_4K_BASE_MASK;
     3324        pThis->fMgawBaseMask   = pThis->fHawBaseMask;
    33253325        pThis->uMaxPagingLevel = vtdCapRegGetMaxPagingLevel(fSagaw);
    33263326    }
     
    35853585    uint16_t const offFrcd   = RT_BF_GET(pThis->fCapReg, VTD_BF_CAP_REG_FRO);
    35863586    uint16_t const offIva    = RT_BF_GET(pThis->fExtCapReg, VTD_BF_ECAP_REG_IRO);
    3587     LogRel(("%s: VER=%u.%u CAP=%#RX64 ECAP=%#RX64 (MGAW=%u bits, SAGAW=%#x HAW_Mask=%#RX64 FRO=%#x, IRO=%#x) mapped at %#RGp\n",
     3587    LogRel(("%s: VER=%u.%u CAP=%#RX64 ECAP=%#RX64 (MGAW=%u bits, SAGAW=%#x HAW=%#RX64 MGAW=%#RX64 FRO=%#x IRO=%#x) mapped at %#RGp\n",
    35883588            DMAR_LOG_PFX, RT_BF_GET(uVerReg, VTD_BF_VER_REG_MAX), RT_BF_GET(uVerReg, VTD_BF_VER_REG_MIN),
    3589             pThis->fCapReg, pThis->fExtCapReg, cMgawBits, fSagaw, pThis->fHawMask, offFrcd, offIva, DMAR_MMIO_BASE_PHYSADDR));
     3589            pThis->fCapReg, pThis->fExtCapReg, cMgawBits, fSagaw, pThis->fHawBaseMask, pThis->fMgawBaseMask, offFrcd, offIva,
     3590            DMAR_MMIO_BASE_PHYSADDR));
    35903591
    35913592    return VINF_SUCCESS;
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