VirtualBox

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


Ignore:
Timestamp:
Jun 2, 2021 7:46:32 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144806
Message:

Intel IOMMU: bugref:9967 Address translation, WIP.

File:
1 edited

Legend:

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

    r89451 r89452  
    192192    kDmarDiag_Atf_Lgn_1_2,
    193193    kDmarDiag_Atf_Lgn_1_3,
     194    kDmarDiag_Atf_Lgn_4,
    194195    kDmarDiag_Atf_Lrt_1,
    195196    kDmarDiag_Atf_Lrt_2,
     
    202203    kDmarDiag_Atf_Rta_1_3,
    203204    kDmarDiag_Atf_Sgn_5,
     205    kDmarDiag_Atf_Sgn_8,
    204206    kDmarDiag_Atf_Ssl_1,
    205207    kDmarDiag_Atf_Ssl_2,
     
    269271    DMARDIAG_DESC(Atf_Lgn_1_2               ),
    270272    DMARDIAG_DESC(Atf_Lgn_1_3               ),
     273    DMARDIAG_DESC(Atf_Lgn_4                 ),
    271274    DMARDIAG_DESC(Atf_Lrt_1                 ),
    272275    DMARDIAG_DESC(Atf_Lrt_2                 ),
     
    279282    DMARDIAG_DESC(Atf_Rta_1_3               ),
    280283    DMARDIAG_DESC(Atf_Sgn_5                 ),
     284    DMARDIAG_DESC(Atf_Sgn_8                 ),
    281285    DMARDIAG_DESC(Atf_Ssl_1                 ),
    282286    DMARDIAG_DESC(Atf_Ssl_2                 ),
     
    19941998
    19951999/**
     2000 * Validates the output address of a translation and updates the IOTLB entry for the
     2001 * given memory request remapping.
     2002 *
     2003 * @returns VBox status code.
     2004 * @param   pDevIns         The IOMMU device instance.
     2005 * @param   GCPhyseBase     The output address of the translation.
     2006 * @param   cShift          The page shift of the translation.
     2007 * @param   fPerm           The permissions granted for the translated.
     2008 * @param   idDomain        The domain ID of the translated region.
     2009 * @param   pMemReqRemap    The DMA memory request remapping info.
     2010 */
     2011static int dmarDrValidateAndUpdateIotlbe(PPDMDEVINS pDevIns, RTGCPHYS GCPhyseBase, uint8_t cShift, uint8_t fPerm,
     2012                                         uint16_t idDomain, PDMARMEMREQREMAP pMemReqRemap)
     2013{
     2014    Assert(   pMemReqRemap->fTtm == VTD_TTM_LEGACY_MODE
     2015           || pMemReqRemap->fTtm == VTD_TTM_SCALABLE_MODE);
     2016    Assert(!(GCPhyseBase & X86_PAGE_4K_OFFSET_MASK));
     2017
     2018    /* Ensure the output address is not in the interrupt address range. */
     2019    if (GCPhyseBase - VBOX_MSI_ADDR_BASE >= VBOX_MSI_ADDR_SIZE)
     2020    {
     2021        pMemReqRemap->Iotlbe.GCPhysBase = GCPhyseBase;
     2022        pMemReqRemap->Iotlbe.cShift     = cShift;
     2023        pMemReqRemap->Iotlbe.fPerm      = fPerm;
     2024        pMemReqRemap->Iotlbe.idDomain   = idDomain;
     2025        return VINF_SUCCESS;
     2026    }
     2027
     2028    if (pMemReqRemap->fTtm == VTD_TTM_LEGACY_MODE)
     2029        dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lgn_4, VTDATFAULT_LGN_4, pMemReqRemap);
     2030    else
     2031        dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Sgn_8, VTDATFAULT_SGN_8, pMemReqRemap);
     2032    return VERR_IOMMU_ADDR_TRANSLATION_FAILED;
     2033}
     2034
     2035
     2036/**
    19962037 * Performs second level translation.
    19972038 *
     
    21122153            if (fSllpsMask & RT_BIT(iLevel - 1))
    21132154            {
    2114                 pMemReqRemap->Iotlbe.GCPhysBase = uPtEntity & ~(RT_BIT_64(cLevelShift) - 1);
    2115                 pMemReqRemap->Iotlbe.cShift     = cLevelShift;
    2116                 pMemReqRemap->Iotlbe.fPerm      = fPtPerm;
    2117                 pMemReqRemap->Iotlbe.idDomain   = idDomain;
    2118                 return VINF_SUCCESS;
     2155                RTGCPHYS const GCPhysBase = uPtEntity & ~(RT_BIT_64(cLevelShift) - 1);
     2156                return dmarDrValidateAndUpdateIotlbe(pDevIns, GCPhysBase, cLevelShift, fPtPerm, idDomain, pMemReqRemap);
    21192157            }
    21202158
     
    21312169        if (iLevel == 0)
    21322170        {
    2133             pMemReqRemap->Iotlbe.GCPhysBase = uPtEntity & ~(RT_BIT_64(cLevelShift) - 1);
    2134             pMemReqRemap->Iotlbe.cShift     = cLevelShift;
    2135             pMemReqRemap->Iotlbe.fPerm      = fPtPerm;
    2136             pMemReqRemap->Iotlbe.idDomain   = idDomain;
    2137             return VINF_SUCCESS;
     2171            RTGCPHYS const GCPhysBase = uPtEntity & ~(RT_BIT_64(cLevelShift) - 1);
     2172            return dmarDrValidateAndUpdateIotlbe(pDevIns, GCPhysBase, cLevelShift, fPtPerm, idDomain, pMemReqRemap);
    21382173        }
    21392174    }
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