VirtualBox

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


Ignore:
Timestamp:
May 26, 2021 6:52:15 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144630
Message:

Intel IOMMU: bugref:9967 Address translation, WIP. Scaffolding for PASID (if and when we implement PASID in future).

File:
1 edited

Legend:

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

    r89275 r89284  
    143143/** The current saved state version. */
    144144#define DMAR_SAVED_STATE_VERSION                    1
    145 
    146 /** @name DMAR_IO_PERM_XXX: DMAR I/O permissions.
    147  * These are not according to the spec. other than the value of the READ and WRITE
    148  * permissions. */
    149 #define DMAR_IO_PERM_READ                           RT_BIT(0)
    150 #define DMAR_IO_PERM_WRITE                          RT_BIT(1)
    151 #define DMAR_IO_PERM_EXECUTE                        RT_BIT(2)
    152 #define DMAR_IO_PERM_SUPERVISOR                     RT_BIT(3)
    153 /** @} */
    154145
    155146
     
    434425{
    435426    /** The device ID (bus, device, function). */
    436     uint16_t        idDevice;
    437     uint16_t        uPadding0;
    438     /** The DMA remapping operation request type. */
    439     VTDREQTYPE      enmReqType;
     427    uint16_t                idDevice;
     428    uint16_t                uPadding0;
     429    /** The PASID if present, can be NIL_PCIPASID. */
     430    PCIPASID                Pasid;
     431    /* The address type of the memory request. */
     432    PCIADDRTYPE             enmAddrType;
     433    /** The type of the translation request. */
     434    VTDREQTYPE              enmReqType;
    440435    /** The DMA address being accessed. */
    441     uint64_t        uDmaAddr;
     436    uint64_t                uDmaAddr;
    442437    /** The size of the DMA access (in bytes). */
    443     size_t          cbDma;
     438    size_t                  cbDma;
    444439
    445440    /** The translated system-physical address (HPA). */
    446     RTGCPHYS        GCPhysSpa;
     441    RTGCPHYS                GCPhysSpa;
    447442    /** The size of the contiguous translated region (in bytes). */
    448     size_t          cbContiguous;
     443    size_t                  cbContiguous;
    449444} DMARADDRMAP;
    450445/** Pointer to a DMA address map. */
     
    14161411 */
    14171412static void dmarAtFaultRecordEx(PPDMDEVINS pDevIns, DMARDIAG enmDiag, VTDATFAULT enmAtFault, uint16_t idDevice,
    1418                                 uint64_t uFaultAddr, VTDREQTYPE enmReqType, uint8_t uAddrType, bool fHasPasid, uint32_t uPasid,
    1419                                 uint8_t fReqAttr)
     1413                                uint64_t uFaultAddr, VTDREQTYPE enmReqType, uint8_t uAddrType, bool fHasPasid,
     1414                                uint32_t uPasid, uint8_t fReqAttr)
    14201415{
    14211416    uint8_t const fType1 = enmReqType & RT_BIT(1);
     
    14551450{
    14561451    dmarAtFaultRecordEx(pDevIns, enmDiag, enmAtFault, idDevice, uFaultAddr, enmReqType, 0 /* uAddrType */,
    1457                           false /* fHasPasid */, 0 /* uPasid */, 0 /* fReqAttr */);
     1452                        false /* fHasPasid */, 0 /* uPasid */, 0 /* fReqAttr */);
    14581453}
    14591454
     
    18991894 * @param   pDevIns         The IOMMU device instance.
    19001895 * @param   uRtaddrReg      The current RTADDR_REG value.
    1901  * @param   enmAddrType     The PCI memory request address type.
    19021896 * @param   pAddrRemap      The DMA address remap info.
    19031897 */
    1904 static int dmarDrLegacyModeRemapAddr(PPDMDEVINS pDevIns, uint64_t uRtaddrReg, PCIADDRTYPE enmAddrType, PDMARADDRMAP pAddrRemap)
     1898static int dmarDrLegacyModeRemapAddr(PPDMDEVINS pDevIns, uint64_t uRtaddrReg, PDMARADDRMAP pAddrRemap)
    19051899{
    19061900    uint8_t const idxRootEntry = RT_HI_U8(pAddrRemap->idDevice);
     
    19371931                                case 0:
    19381932                                {
    1939                                     if (enmAddrType == PCIADDRTYPE_UNTRANSLATED)
     1933                                    if (pAddrRemap->enmAddrType == PCIADDRTYPE_UNTRANSLATED)
    19401934                                    {
    19411935                                        /** @todo perform second-level translation. */
     
    19661960                                {
    19671961                                    dmarAtFaultQualifiedRecord(pDevIns, kDmarDiag_Atf_Lct_4_2, VTDATFAULT_LCT_4_2,
    1968                                                                pAddrRemap->idDevice, pAddrRemap->uDmaAddr, pAddrRemap->enmReqType,
    1969                                                                uCtxEntryQword0);
     1962                                                               pAddrRemap->idDevice, pAddrRemap->uDmaAddr,
     1963                                                               pAddrRemap->enmReqType, uCtxEntryQword0);
    19701964                                    break;
    19711965                                }
     
    20051999 * @param   pDevIns         The IOMMU device instance.
    20062000 * @param   uRtaddrReg      The current RTADDR_REG value.
    2007  * @param   enmAddrType     The PCI memory request address type.
    20082001 * @param   pAddrRemap      The DMA address remap info.
    20092002 */
    2010 static int dmarDrScalableModeRemapAddr(PPDMDEVINS pDevIns, uint64_t uRtaddrReg, PCIADDRTYPE enmAddrType, PDMARADDRMAP pAddrRemap)
    2011 {
    2012     RT_NOREF(enmAddrType);
     2003static int dmarDrScalableModeRemapAddr(PPDMDEVINS pDevIns, uint64_t uRtaddrReg, PDMARADDRMAP pAddrRemap)
     2004{
    20132005    PCDMAR pThis = PDMDEVINS_2_DATA(pDevIns, PDMAR);
    20142006    if (pThis->fExtCapReg & VTD_BF_ECAP_REG_SMTS_MASK)
     
    20932085
    20942086        DMARADDRMAP AddrRemap;
    2095         AddrRemap.idDevice     = idDevice;
    2096         AddrRemap.enmReqType   = enmReqType;
    2097         AddrRemap.uDmaAddr     = uIova;
    2098         AddrRemap.cbDma        = cbIova;
    2099         AddrRemap.GCPhysSpa    = NIL_RTGCPHYS;
    2100         AddrRemap.cbContiguous = 0;
     2087        AddrRemap.idDevice       = idDevice;
     2088        AddrRemap.Pasid          = NIL_PCIPASID;
     2089        AddrRemap.enmAddrType    = PCIADDRTYPE_UNTRANSLATED;
     2090        AddrRemap.enmReqType     = enmReqType;
     2091        AddrRemap.uDmaAddr       = uIova;
     2092        AddrRemap.cbDma          = cbIova;
     2093        AddrRemap.GCPhysSpa      = NIL_RTGCPHYS;
     2094        AddrRemap.cbContiguous   = 0;
    21012095
    21022096        int rc;
     
    21062100            case VTD_TTM_LEGACY_MODE:
    21072101            {
    2108                 rc = dmarDrLegacyModeRemapAddr(pDevIns, uRtaddrReg, PCIADDRTYPE_UNTRANSLATED, &AddrRemap);
     2102                rc = dmarDrLegacyModeRemapAddr(pDevIns, uRtaddrReg, &AddrRemap);
    21092103                break;
    21102104            }
     
    21122106            case VTD_TTM_SCALABLE_MODE:
    21132107            {
    2114                 rc = dmarDrScalableModeRemapAddr(pDevIns, uRtaddrReg, PCIADDRTYPE_UNTRANSLATED, &AddrRemap);
     2108                rc = dmarDrScalableModeRemapAddr(pDevIns, uRtaddrReg, &AddrRemap);
    21152109                break;
    21162110            }
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