Changeset 89451 in vbox for trunk/src/VBox
- Timestamp:
- Jun 2, 2021 6:41:13 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuIntel.cpp
r89419 r89451 461 461 462 462 /** 463 * Type ofDMAR originated events that generate interrupts.463 * DMAR originated events that generate interrupts. 464 464 */ 465 465 typedef enum DMAREVENTTYPE … … 478 478 /** The system-physical base address of the translation. */ 479 479 RTGCPHYS GCPhysBase; 480 /** The domain ID of the translated region. */ 481 uint16_t idDomain; 482 /** The permissions granted. */ 483 uint8_t fPerm; 480 484 /** The page shift of the translation. */ 481 485 uint8_t cShift; 482 /** The permissions granted. */483 uint8_t fPerm;484 /** The domain ID of the translated region. */485 uint16_t idDomain;486 486 } DMARIOTLBE; 487 487 /** Pointer to an IOTLB entry. */ … … 489 489 /** Pointer to a const IOTLB entry. */ 490 490 typedef DMARIOTLBE const *PCDMARIOTLBE; 491 492 /** 493 * DMA Address Request. 494 */ 495 typedef struct DMARADDRREQ 491 AssertCompileSizeAlignment(DMARIOTLBE, 4); 492 493 /** 494 * DMA Memory Request. 495 */ 496 typedef struct DMARMEMREQ 496 497 { 497 498 /** The address being accessed. */ … … 509 510 /** The request type. */ 510 511 VTDREQTYPE enmReqType; 511 } DMAR ADDRREQ;512 /** Pointer to a DMA addressrequest. */513 typedef DMAR ADDRREQ *PDMARADDRREQ;514 /** Pointer to a const DMA request. */515 typedef DMAR ADDRREQ const *PCDMARADDRREQ;516 517 /** 518 * DMA Address Remap Info.519 */ 520 typedef struct DMAR ADDRREMAP521 { 522 /* The DMA addressrequest. */523 DMAR ADDRREQ AddrReq;512 } DMARMEMREQ; 513 /** Pointer to a DMA memory request. */ 514 typedef DMARMEMREQ *PDMARMEMREQ; 515 /** Pointer to a const DMA memory request. */ 516 typedef DMARMEMREQ const *PCDMARMEMREQ; 517 518 /** 519 * DMA Memory Request Remapping Information. 520 */ 521 typedef struct DMARMEMREQREMAP 522 { 523 /* The DMA memory request. */ 524 DMARMEMREQ Req; 524 525 /** The table translation mode (VTD_TTM_XXX). */ 525 526 uint8_t fTtm; … … 527 528 uint8_t fFpd; 528 529 529 /** The IOTLBE result sfor this remapping. */530 /** The IOTLBE result for this remapping. */ 530 531 DMARIOTLBE Iotlbe; 531 532 /** The size of the contiguous translated region (in bytes). */ 532 533 size_t cbContiguous; 533 } DMAR ADDRREMAP;534 } DMARMEMREQREMAP; 534 535 /** Pointer to a DMA remap info. */ 535 typedef DMAR ADDRREMAP *PDMARADDRREMAP;536 typedef DMARMEMREQREMAP *PDMARMEMREQREMAP; 536 537 /** Pointer to a const DMA remap info. */ 537 typedef DMAR ADDRREMAP const *PCDMARADDRREMAP;538 typedef DMARMEMREQREMAP const *PCDMARMEMREQREMAP; 538 539 539 540 … … 1498 1499 * Records an address translation fault. 1499 1500 * 1500 * @param pDevIns The IOMMU device instance.1501 * @param enmDiag The diagnostic reason.1502 * @param enmAtFault The address translation fault reason.1503 * @param p AddrRemap The DMA address remapinfo.1504 */ 1505 static void dmarAtFaultRecord(PPDMDEVINS pDevIns, DMARDIAG enmDiag, VTDATFAULT enmAtFault, PCDMAR ADDRREMAP pAddrRemap)1501 * @param pDevIns The IOMMU device instance. 1502 * @param enmDiag The diagnostic reason. 1503 * @param enmAtFault The address translation fault reason. 1504 * @param pMemReqRemap The DMA memory request remapping info. 1505 */ 1506 static void dmarAtFaultRecord(PPDMDEVINS pDevIns, DMARDIAG enmDiag, VTDATFAULT enmAtFault, PCDMARMEMREQREMAP pMemReqRemap) 1506 1507 { 1507 1508 /* … … 1509 1510 * in the contex entry, scalable-mode context entry etc. 1510 1511 */ 1511 if (!pAddrRemap->fFpd) 1512 { 1513 uint8_t const fType1 = pAddrRemap->AddrReq.enmReqType & RT_BIT(1); 1514 uint8_t const fType2 = pAddrRemap->AddrReq.enmReqType & RT_BIT(0); 1515 uint8_t const fExec = pAddrRemap->AddrReq.fReqPerm & DMAR_PERM_EXE; 1516 uint8_t const fPriv = pAddrRemap->AddrReq.fReqPerm & DMAR_PERM_PRIV; 1517 uint64_t const uFrcdHi = RT_BF_MAKE(VTD_BF_1_FRCD_REG_SID, pAddrRemap->AddrReq.idDevice) 1512 if (!pMemReqRemap->fFpd) 1513 { 1514 uint16_t const idDevice = pMemReqRemap->Req.idDevice; 1515 uint8_t const fType1 = pMemReqRemap->Req.enmReqType & RT_BIT(1); 1516 uint8_t const fType2 = pMemReqRemap->Req.enmReqType & RT_BIT(0); 1517 uint8_t const fExec = pMemReqRemap->Req.fReqPerm & DMAR_PERM_EXE; 1518 uint8_t const fPriv = pMemReqRemap->Req.fReqPerm & DMAR_PERM_PRIV; 1519 bool const fHasPasid = PCIPASID_IS_VALID(pMemReqRemap->Req.Pasid); 1520 uint32_t const uPasid = PCIPASID_VAL(pMemReqRemap->Req.Pasid); 1521 PCIADDRTYPE const enmAt = pMemReqRemap->Req.enmAddrType; 1522 1523 uint64_t const uFrcdHi = RT_BF_MAKE(VTD_BF_1_FRCD_REG_SID, idDevice) 1518 1524 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_T2, fType2) 1519 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_PP, PCIPASID_IS_VALID(pAddrRemap->AddrReq.Pasid))1525 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_PP, fHasPasid) 1520 1526 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_EXE, fExec) 1521 1527 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_PRIV, fPriv) 1522 1528 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_FR, enmAtFault) 1523 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_PV, PCIPASID_VAL(pAddrRemap->AddrReq.Pasid))1524 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_AT, pAddrRemap->AddrReq.enmAddrType)1529 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_PV, uPasid) 1530 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_AT, enmAt) 1525 1531 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_T1, fType1) 1526 1532 | RT_BF_MAKE(VTD_BF_1_FRCD_REG_F, 1); 1527 uint64_t const uFrcdLo = p AddrRemap->AddrReq.uDmaAddr & X86_PAGE_BASE_MASK;1533 uint64_t const uFrcdLo = pMemReqRemap->Req.uDmaAddr & X86_PAGE_BASE_MASK; 1528 1534 dmarPrimaryFaultRecord(pDevIns, enmDiag, uFrcdHi, uFrcdLo); 1529 1535 } … … 1995 2001 * @param cPagingLevel The paging level. 1996 2002 * @param idDomain The domain ID for the translation. 1997 * @param p AddrRemap The DMA address remapinfo.2003 * @param pMemReqRemap The DMA memory request remapping info. 1998 2004 */ 1999 2005 static int dmarDrSecondLevelTranslate(PPDMDEVINS pDevIns, VTD_SLP_ENTRY_T SlpEntry, uint8_t cPagingLevel, uint16_t idDomain, 2000 PDMAR ADDRREMAP pAddrRemap)2006 PDMARMEMREQREMAP pMemReqRemap) 2001 2007 { 2002 2008 PCDMAR pThis = PDMDEVINS_2_DATA(pDevIns, PCDMAR); … … 2022 2028 2023 2029 /* Second-level translations restricts input address to an implementation-specific MGAW. */ 2024 uint64_t const uDmaAddr = p AddrRemap->AddrReq.uDmaAddr;2030 uint64_t const uDmaAddr = pMemReqRemap->Req.uDmaAddr; 2025 2031 if (!(uDmaAddr & pThis->fInvMgawMask)) 2026 2032 { /* likely */ } 2027 2033 else 2028 2034 { 2029 if (p AddrRemap->fTtm == VTD_TTM_LEGACY_MODE)2030 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lgn_1_1, VTDATFAULT_LGN_1_1, p AddrRemap);2035 if (pMemReqRemap->fTtm == VTD_TTM_LEGACY_MODE) 2036 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lgn_1_1, VTDATFAULT_LGN_1_1, pMemReqRemap); 2031 2037 else 2032 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Sgn_5, VTDATFAULT_SGN_5, p AddrRemap);2038 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Sgn_5, VTDATFAULT_SGN_5, pMemReqRemap); 2033 2039 return VERR_IOMMU_ADDR_TRANSLATION_FAILED; 2034 2040 } … … 2054 2060 else 2055 2061 { 2056 if (p AddrRemap->fTtm == VTD_TTM_LEGACY_MODE)2057 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lsl_1, VTDATFAULT_LSL_1, p AddrRemap);2062 if (pMemReqRemap->fTtm == VTD_TTM_LEGACY_MODE) 2063 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lsl_1, VTDATFAULT_LSL_1, pMemReqRemap); 2058 2064 else 2059 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Ssl_1, VTDATFAULT_SSL_1, p AddrRemap);2065 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Ssl_1, VTDATFAULT_SSL_1, pMemReqRemap); 2060 2066 return VERR_IOMMU_ADDR_TRANSLATION_FAILED; 2061 2067 } … … 2068 2074 * See Intel spec. 7.1.3 "Fault conditions and Remapping hardware behavior for various request". 2069 2075 */ 2070 uint8_t const fReqPerm = p AddrRemap->AddrReq.fReqPerm & pThis->fPermValidMask;2076 uint8_t const fReqPerm = pMemReqRemap->Req.fReqPerm & pThis->fPermValidMask; 2071 2077 uint8_t const fPtPerm = uPtEntity & pThis->fPermValidMask; 2072 2078 if ((fPtPerm & fReqPerm) == fReqPerm) … … 2074 2080 else 2075 2081 { 2076 if (p AddrRemap->fTtm == VTD_TTM_LEGACY_MODE)2077 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lsl_2, VTDATFAULT_LSL_2, p AddrRemap);2082 if (pMemReqRemap->fTtm == VTD_TTM_LEGACY_MODE) 2083 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lsl_2, VTDATFAULT_LSL_2, pMemReqRemap); 2078 2084 else 2079 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Ssl_2, VTDATFAULT_SSL_2, p AddrRemap);2085 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Ssl_2, VTDATFAULT_SSL_2, pMemReqRemap); 2080 2086 return VERR_IOMMU_ADDR_TRANSLATION_FAILED; 2081 2087 } … … 2088 2094 else 2089 2095 { 2090 if (p AddrRemap->fTtm == VTD_TTM_LEGACY_MODE)2091 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lsl_2, VTDATFAULT_LSL_2, p AddrRemap);2096 if (pMemReqRemap->fTtm == VTD_TTM_LEGACY_MODE) 2097 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lsl_2, VTDATFAULT_LSL_2, pMemReqRemap); 2092 2098 else 2093 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Ssl_3, VTDATFAULT_SSL_3, p AddrRemap);2099 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Ssl_3, VTDATFAULT_SSL_3, pMemReqRemap); 2094 2100 return VERR_IOMMU_ADDR_TRANSLATION_FAILED; 2095 2101 } … … 2106 2112 if (fSllpsMask & RT_BIT(iLevel - 1)) 2107 2113 { 2108 p AddrRemap->Iotlbe.GCPhysBase = uPtEntity & ~(RT_BIT_64(cLevelShift) - 1);2109 p AddrRemap->Iotlbe.cShift = cLevelShift;2110 p AddrRemap->Iotlbe.fPerm = fPtPerm;2111 p AddrRemap->Iotlbe.idDomain = idDomain;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; 2112 2118 return VINF_SUCCESS; 2113 2119 } 2114 2120 2115 if (p AddrRemap->fTtm == VTD_TTM_LEGACY_MODE)2116 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lsl_2_LargePage, VTDATFAULT_LSL_2, p AddrRemap);2121 if (pMemReqRemap->fTtm == VTD_TTM_LEGACY_MODE) 2122 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lsl_2_LargePage, VTDATFAULT_LSL_2, pMemReqRemap); 2117 2123 else 2118 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Ssl_3_LargePage, VTDATFAULT_SSL_3, p AddrRemap);2124 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Ssl_3_LargePage, VTDATFAULT_SSL_3, pMemReqRemap); 2119 2125 return VERR_IOMMU_ADDR_TRANSLATION_FAILED; 2120 2126 } … … 2125 2131 if (iLevel == 0) 2126 2132 { 2127 p AddrRemap->Iotlbe.GCPhysBase = uPtEntity & ~(RT_BIT_64(cLevelShift) - 1);2128 p AddrRemap->Iotlbe.cShift = cLevelShift;2129 p AddrRemap->Iotlbe.fPerm = fPtPerm;2130 p AddrRemap->Iotlbe.idDomain = idDomain;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; 2131 2137 return VINF_SUCCESS; 2132 2138 } … … 2144 2150 * @param pDevIns The IOMMU device instance. 2145 2151 * @param uRtaddrReg The current RTADDR_REG value. 2146 * @param p AddrRemap The DMA address remapinfo.2147 */ 2148 static int dmarDrLegacyModeRemapAddr(PPDMDEVINS pDevIns, uint64_t uRtaddrReg, PDMAR ADDRREMAP pAddrRemap)2149 { 2150 Assert(p AddrRemap->fTtm == VTD_TTM_LEGACY_MODE); /* Paranoia. */2152 * @param pMemReqRemap The DMA memory request remapping info. 2153 */ 2154 static int dmarDrLegacyModeRemapAddr(PPDMDEVINS pDevIns, uint64_t uRtaddrReg, PDMARMEMREQREMAP pMemReqRemap) 2155 { 2156 Assert(pMemReqRemap->fTtm == VTD_TTM_LEGACY_MODE); /* Paranoia. */ 2151 2157 2152 2158 /* Read the root-entry from guest memory. */ 2153 uint8_t const idxRootEntry = RT_HI_U8(p AddrRemap->AddrReq.idDevice);2159 uint8_t const idxRootEntry = RT_HI_U8(pMemReqRemap->Req.idDevice); 2154 2160 VTD_ROOT_ENTRY_T RootEntry; 2155 2161 int rc = dmarDrReadRootEntry(pDevIns, uRtaddrReg, idxRootEntry, &RootEntry); … … 2168 2174 /* Read the context-entry from guest memory. */ 2169 2175 RTGCPHYS const GCPhysCtxTable = RT_BF_GET(uRootEntryQword0, VTD_BF_0_ROOT_ENTRY_CTP); 2170 uint8_t const idxCtxEntry = RT_LO_U8(p AddrRemap->AddrReq.idDevice);2176 uint8_t const idxCtxEntry = RT_LO_U8(pMemReqRemap->Req.idDevice); 2171 2177 VTD_CONTEXT_ENTRY_T CtxEntry; 2172 2178 rc = dmarDrReadCtxEntry(pDevIns, GCPhysCtxTable, idxCtxEntry, &CtxEntry); … … 2177 2183 2178 2184 /* Note the FPD bit which software can use to supress translation faults from here on in. */ 2179 p AddrRemap->fFpd = RT_BF_GET(uCtxEntryQword0, VTD_BF_0_CONTEXT_ENTRY_FPD);2185 pMemReqRemap->fFpd = RT_BF_GET(uCtxEntryQword0, VTD_BF_0_CONTEXT_ENTRY_FPD); 2180 2186 2181 2187 /* Check if the context-entry is present (must be done before validating reserved bits). */ … … 2201 2207 * through SLPTPTR. Translated requests and Translation Requests are blocked. 2202 2208 */ 2203 if (p AddrRemap->AddrReq.enmAddrType == PCIADDRTYPE_UNTRANSLATED)2209 if (pMemReqRemap->Req.enmAddrType == PCIADDRTYPE_UNTRANSLATED) 2204 2210 { 2205 2211 /* Validate the address width and get the paging level. */ … … 2215 2221 /* Finally... perform second-level translation. */ 2216 2222 return dmarDrSecondLevelTranslate(pDevIns, SlpEntry, cPagingLevel, idDomain, 2217 p AddrRemap);2223 pMemReqRemap); 2218 2224 } 2219 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_4_3, VTDATFAULT_LCT_4_3, p AddrRemap);2225 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_4_3, VTDATFAULT_LCT_4_3, pMemReqRemap); 2220 2226 } 2221 2227 else 2222 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_4_1, VTDATFAULT_LCT_4_1, p AddrRemap);2228 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_4_1, VTDATFAULT_LCT_4_1, pMemReqRemap); 2223 2229 } 2224 2230 else 2225 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_5, VTDATFAULT_LCT_5, p AddrRemap);2231 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_5, VTDATFAULT_LCT_5, pMemReqRemap); 2226 2232 break; 2227 2233 } … … 2236 2242 if (pThis->fExtCapReg & VTD_BF_ECAP_REG_PT_MASK) 2237 2243 { 2238 if (p AddrRemap->AddrReq.enmAddrType == PCIADDRTYPE_UNTRANSLATED)2244 if (pMemReqRemap->Req.enmAddrType == PCIADDRTYPE_UNTRANSLATED) 2239 2245 { 2240 2246 /** @todo Check AW == maximum SAGAW bit? */ 2241 p AddrRemap->Iotlbe.GCPhysBase = pAddrRemap->AddrReq.uDmaAddr & X86_PAGE_4K_BASE_MASK;2242 p AddrRemap->Iotlbe.cShift = X86_PAGE_4K_SHIFT;2243 p AddrRemap->Iotlbe.fPerm = DMAR_PERM_ALL;2244 p AddrRemap->Iotlbe.idDomain = idDomain;2245 p AddrRemap->cbContiguous = pAddrRemap->AddrReq.cbDma;2247 pMemReqRemap->Iotlbe.GCPhysBase = pMemReqRemap->Req.uDmaAddr & X86_PAGE_4K_BASE_MASK; 2248 pMemReqRemap->Iotlbe.cShift = X86_PAGE_4K_SHIFT; 2249 pMemReqRemap->Iotlbe.fPerm = DMAR_PERM_ALL; 2250 pMemReqRemap->Iotlbe.idDomain = idDomain; 2251 pMemReqRemap->cbContiguous = pMemReqRemap->Req.cbDma; 2246 2252 return VINF_SUCCESS; 2247 2253 } 2248 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_5, VTDATFAULT_LCT_5, p AddrRemap);2254 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_5, VTDATFAULT_LCT_5, pMemReqRemap); 2249 2255 break; 2250 2256 } … … 2265 2271 { 2266 2272 /* Any other TT value is reserved. */ 2267 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_4_2, VTDATFAULT_LCT_4_2, p AddrRemap);2273 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_4_2, VTDATFAULT_LCT_4_2, pMemReqRemap); 2268 2274 break; 2269 2275 } … … 2271 2277 } 2272 2278 else 2273 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_3, VTDATFAULT_LCT_3, p AddrRemap);2279 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_3, VTDATFAULT_LCT_3, pMemReqRemap); 2274 2280 } 2275 2281 else 2276 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_2, VTDATFAULT_LCT_2, p AddrRemap);2282 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_2, VTDATFAULT_LCT_2, pMemReqRemap); 2277 2283 } 2278 2284 else 2279 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_1, VTDATFAULT_LCT_1, p AddrRemap);2285 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lct_1, VTDATFAULT_LCT_1, pMemReqRemap); 2280 2286 } 2281 2287 else 2282 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lrt_3, VTDATFAULT_LRT_3, p AddrRemap);2288 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lrt_3, VTDATFAULT_LRT_3, pMemReqRemap); 2283 2289 } 2284 2290 else 2285 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lrt_2, VTDATFAULT_LRT_2, p AddrRemap);2291 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lrt_2, VTDATFAULT_LRT_2, pMemReqRemap); 2286 2292 } 2287 2293 else 2288 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lrt_1, VTDATFAULT_LRT_1, p AddrRemap);2294 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Lrt_1, VTDATFAULT_LRT_1, pMemReqRemap); 2289 2295 return VERR_IOMMU_ADDR_TRANSLATION_FAILED; 2290 2296 } … … 2297 2303 * @param pDevIns The IOMMU device instance. 2298 2304 * @param uRtaddrReg The current RTADDR_REG value. 2299 * @param p AddrRemap The DMA address remapinfo.2300 */ 2301 static int dmarDrScalableModeRemapAddr(PPDMDEVINS pDevIns, uint64_t uRtaddrReg, PDMAR ADDRREMAP pAddrRemap)2305 * @param pMemReqRemap The DMA memory request remapping info. 2306 */ 2307 static int dmarDrScalableModeRemapAddr(PPDMDEVINS pDevIns, uint64_t uRtaddrReg, PDMARMEMREQREMAP pMemReqRemap) 2302 2308 { 2303 2309 PCDMAR pThis = PDMDEVINS_2_DATA(pDevIns, PDMAR); … … 2308 2314 } 2309 2315 2310 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Rta_1_3, VTDATFAULT_RTA_1_3, p AddrRemap);2316 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Rta_1_3, VTDATFAULT_RTA_1_3, pMemReqRemap); 2311 2317 return VERR_IOMMU_ADDR_TRANSLATION_FAILED; 2312 2318 } … … 2385 2391 2386 2392 uint8_t const fTtm = RT_BF_GET(uRtaddrReg, VTD_BF_RTADDR_REG_TTM); 2387 DMAR ADDRREMAP AddrRemap;2388 RT_ZERO( AddrRemap);2389 AddrRemap.AddrReq.uDmaAddr = uIova;2390 AddrRemap.AddrReq.cbDma = cbIova;2391 AddrRemap.AddrReq.fReqPerm = fReqPerm;2392 AddrRemap.AddrReq.idDevice = idDevice;2393 AddrRemap.AddrReq.Pasid = NIL_PCIPASID;2394 AddrRemap.AddrReq.enmAddrType = PCIADDRTYPE_UNTRANSLATED;2395 AddrRemap.AddrReq.enmReqType = enmReqType;2396 AddrRemap.fTtm = fTtm;2397 AddrRemap.Iotlbe.GCPhysBase = NIL_RTGCPHYS;2393 DMARMEMREQREMAP MemReqRemap; 2394 RT_ZERO(MemReqRemap); 2395 MemReqRemap.Req.uDmaAddr = uIova; 2396 MemReqRemap.Req.cbDma = cbIova; 2397 MemReqRemap.Req.fReqPerm = fReqPerm; 2398 MemReqRemap.Req.idDevice = idDevice; 2399 MemReqRemap.Req.Pasid = NIL_PCIPASID; 2400 MemReqRemap.Req.enmAddrType = PCIADDRTYPE_UNTRANSLATED; 2401 MemReqRemap.Req.enmReqType = enmReqType; 2402 MemReqRemap.fTtm = fTtm; 2403 MemReqRemap.Iotlbe.GCPhysBase = NIL_RTGCPHYS; 2398 2404 2399 2405 int rc; … … 2402 2408 case VTD_TTM_LEGACY_MODE: 2403 2409 { 2404 rc = dmarDrLegacyModeRemapAddr(pDevIns, uRtaddrReg, & AddrRemap);2410 rc = dmarDrLegacyModeRemapAddr(pDevIns, uRtaddrReg, &MemReqRemap); 2405 2411 break; 2406 2412 } … … 2408 2414 case VTD_TTM_SCALABLE_MODE: 2409 2415 { 2410 rc = dmarDrScalableModeRemapAddr(pDevIns, uRtaddrReg, & AddrRemap);2416 rc = dmarDrScalableModeRemapAddr(pDevIns, uRtaddrReg, &MemReqRemap); 2411 2417 break; 2412 2418 } … … 2418 2424 dmarDrTargetAbort(pDevIns); 2419 2425 else 2420 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Rta_1_1, VTDATFAULT_RTA_1_1, & AddrRemap);2426 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Rta_1_1, VTDATFAULT_RTA_1_1, &MemReqRemap); 2421 2427 break; 2422 2428 } … … 2425 2431 { 2426 2432 rc = VERR_IOMMU_ADDR_TRANSLATION_FAILED; 2427 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Rta_1_2, VTDATFAULT_RTA_1_2, & AddrRemap);2433 dmarAtFaultRecord(pDevIns, kDmarDiag_Atf_Rta_1_2, VTDATFAULT_RTA_1_2, &MemReqRemap); 2428 2434 break; 2429 2435 } 2430 2436 } 2431 2437 2432 *pcbContiguous = AddrRemap.cbContiguous;2433 *pGCPhysSpa = AddrRemap.Iotlbe.GCPhysBase | DMAR_GET_PAGE_OFF_MASK(AddrRemap.Iotlbe.cShift);2438 *pcbContiguous = MemReqRemap.cbContiguous; 2439 *pGCPhysSpa = MemReqRemap.Iotlbe.GCPhysBase | DMAR_GET_PAGE_OFF_MASK(MemReqRemap.Iotlbe.cShift); 2434 2440 return rc; 2435 2441 }
Note:
See TracChangeset
for help on using the changeset viewer.