Changeset 87906 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Mar 2, 2021 6:14:39 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142992
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r87894 r87906 286 286 uint16_t fFlags; 287 287 /** The domain ID assigned for this device by software. */ 288 uint16_t uDomainId;288 uint16_t idDomain; 289 289 } DTECACHE; 290 290 /** Pointer to an I/O device struct. */ … … 646 646 PIOMMUR3 pIommuR3; 647 647 /** The domain ID to flush. */ 648 uint16_t uDomainId;648 uint16_t idDomain; 649 649 } IOTLBEFLUSHARG; 650 650 /** Pointer to an IOTLBE flush argument. */ … … 663 663 PCDBGFINFOHLP pHlp; 664 664 /** The domain ID to dump IOTLB entry. */ 665 uint16_t uDomainId;665 uint16_t idDomain; 666 666 } IOTLBEINFOARG; 667 667 /** Pointer to an IOTLBE flush argument. */ … … 680 680 /** The device table entry (can be NULL). */ 681 681 PCDTE_T pDte; 682 /** The device ID . */683 uint16_t uDeviceId;682 /** The device ID (bus, device, function). */ 683 uint16_t idDevice; 684 684 /** The domain ID (when the DTE isn't provided). */ 685 uint16_t uDomainId;685 uint16_t idDomain; 686 686 } IOMMUOPAUX; 687 687 /** Pointer to an I/O address lookup struct. */ … … 882 882 * 883 883 * @returns The index of the entry, or the cache capacity if no entry was found. 884 * @param pThis The shared IOMMU device state.885 * @param uDevIdThe device ID (bus, device, function).886 */ 887 DECLINLINE(uint16_t) iommuAmdDteCacheEntryLookup(PIOMMU pThis, uint16_t uDevId)884 * @param pThis The shared IOMMU device state. 885 * @param idDevice The device ID (bus, device, function). 886 */ 887 DECLINLINE(uint16_t) iommuAmdDteCacheEntryLookup(PIOMMU pThis, uint16_t idDevice) 888 888 { 889 889 uint16_t const cDeviceIds = RT_ELEMENTS(pThis->aDeviceIds); 890 890 for (uint16_t i = 0; i < cDeviceIds; i++) 891 891 { 892 if (pThis->aDeviceIds[i] == uDevId)892 if (pThis->aDeviceIds[i] == idDevice) 893 893 return i; 894 894 } … … 926 926 * 927 927 * @param pDevIns The IOMMU instance data. 928 * @param uDevIdThe device ID (bus, device, function).928 * @param idDevice The device ID (bus, device, function). 929 929 * @param pDte The device table entry. 930 930 * @param fOrMask The device flags (usually compound flags) to OR in with the 931 931 * basic flags, see IOMMU_DTE_CACHE_F_XXX. 932 932 */ 933 static int iommuAmdDteCacheAdd(PPDMDEVINS pDevIns, uint16_t uDevId, PCDTE_T pDte, uint16_t fOrMask)933 static int iommuAmdDteCacheAdd(PPDMDEVINS pDevIns, uint16_t idDevice, PCDTE_T pDte, uint16_t fOrMask) 934 934 { 935 935 Assert(pDte); 936 Assert( uDevId);936 Assert(idDevice); 937 937 938 938 int rc = VINF_SUCCESS; 939 uint16_t const fFlags 940 uint16_t const uDomainId= pDte->n.u16DomainId;939 uint16_t const fFlags = iommuAmdGetBasicDevFlags(pDte) | IOMMU_DTE_CACHE_F_PRESENT | fOrMask; 940 uint16_t const idDomain = pDte->n.u16DomainId; 941 941 942 942 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); … … 944 944 945 945 uint16_t const cDteCache = RT_ELEMENTS(pThis->aDteCache); 946 uint16_t idxDte = iommuAmdDteCacheEntryLookup(pThis, uDevId);946 uint16_t idxDte = iommuAmdDteCacheEntryLookup(pThis, idDevice); 947 947 if (idxDte < cDteCache) 948 948 { 949 pThis->aDteCache[idxDte].fFlags 950 pThis->aDteCache[idxDte]. uDomainId = uDomainId;949 pThis->aDteCache[idxDte].fFlags = fFlags; 950 pThis->aDteCache[idxDte].idDomain = idDomain; 951 951 } 952 952 else if ((idxDte = iommuAmdDteCacheEntryGetUnused(pThis)) < cDteCache) 953 953 { 954 pThis->aDeviceIds[idxDte] = uDevId;955 pThis->aDteCache[idxDte].fFlags 956 pThis->aDteCache[idxDte]. uDomainId = uDomainId;954 pThis->aDeviceIds[idxDte] = idDevice; 955 pThis->aDteCache[idxDte].fFlags = fFlags; 956 pThis->aDteCache[idxDte].idDomain = idDomain; 957 957 } 958 958 else … … 968 968 * 969 969 * @param pDevIns The IOMMU instance data. 970 * @param uDevIdThe device ID (bus, device, function).970 * @param idDevice The device ID (bus, device, function). 971 971 * @param fFlags Additional device flags to OR with existing flags, see 972 972 * IOMMU_DTE_CACHE_F_XXX. 973 973 */ 974 static void iommuAmdDteCacheAddFlags(PPDMDEVINS pDevIns, uint16_t uDevId, uint16_t fFlags)974 static void iommuAmdDteCacheAddFlags(PPDMDEVINS pDevIns, uint16_t idDevice, uint16_t fFlags) 975 975 { 976 976 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); … … 978 978 979 979 uint16_t const cDteCache = RT_ELEMENTS(pThis->aDteCache); 980 uint16_t const idxDte = iommuAmdDteCacheEntryLookup(pThis, uDevId);980 uint16_t const idxDte = iommuAmdDteCacheEntryLookup(pThis, idDevice); 981 981 if ( idxDte < cDteCache 982 982 && (pThis->aDteCache[idxDte].fFlags & IOMMU_DTE_CACHE_F_PRESENT)) … … 991 991 * 992 992 * @param pDevIns The IOMMU instance data. 993 * @param uDevIdThe device ID to remove cache entries for.994 */ 995 static void iommuAmdDteCacheRemove(PPDMDEVINS pDevIns, uint16_t uDevId)993 * @param idDevice The device ID to remove cache entries for. 994 */ 995 static void iommuAmdDteCacheRemove(PPDMDEVINS pDevIns, uint16_t idDevice) 996 996 { 997 997 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); … … 999 999 1000 1000 uint16_t const cDteCache = RT_ELEMENTS(pThis->aDteCache); 1001 uint16_t const idxDte = iommuAmdDteCacheEntryLookup(pThis, uDevId);1001 uint16_t const idxDte = iommuAmdDteCacheEntryLookup(pThis, idDevice); 1002 1002 if (idxDte < cDteCache) 1003 1003 { 1004 pThis->aDteCache[idxDte].fFlags 1005 pThis->aDteCache[idxDte]. uDomainId= 0;1004 pThis->aDteCache[idxDte].fFlags = 0; 1005 pThis->aDteCache[idxDte].idDomain = 0; 1006 1006 } 1007 1007 … … 1076 1076 //Assert(pArgs->pIommuCC->u32Magic == IOMMU_MAGIC); 1077 1077 1078 uint16_t const uDomainId= IOMMU_IOTLB_KEY_GET_DOMAIN_ID(pNode->Key);1079 if ( uDomainId == pArgs->uDomainId)1078 uint16_t const idDomain = IOMMU_IOTLB_KEY_GET_DOMAIN_ID(pNode->Key); 1079 if (idDomain == pArgs->idDomain) 1080 1080 { 1081 1081 PCIOTLBE pIotlbe = (PCIOTLBE)pNode; … … 1117 1117 //Assert(pArgs->pIommuR3->u32Magic == IOMMU_MAGIC); 1118 1118 1119 uint16_t const uDomainId= IOMMU_IOTLB_KEY_GET_DOMAIN_ID(pNode->Key);1120 if ( uDomainId == pArgs->uDomainId)1119 uint16_t const idDomain = IOMMU_IOTLB_KEY_GET_DOMAIN_ID(pNode->Key); 1120 if (idDomain == pArgs->idDomain) 1121 1121 { 1122 1122 /* Mark this entry is as invalidated and needs to be evicted later. */ … … 1135 1135 * @param pThisR3 The ring-3 IOMMU device state. 1136 1136 * @param pIotlbe The IOTLB entry to initialize and insert. 1137 * @param uDomainIdThe domain ID.1137 * @param idDomain The domain ID. 1138 1138 * @param uIova The I/O virtual address. 1139 1139 * @param pPageLookup The I/O page lookup result of the access. 1140 1140 */ 1141 static void iommuAmdIotlbEntryInsert(PIOMMU pThis, PIOMMUR3 pThisR3, PIOTLBE pIotlbe, uint16_t uDomainId, uint64_t uIova,1141 static void iommuAmdIotlbEntryInsert(PIOMMU pThis, PIOMMUR3 pThisR3, PIOTLBE pIotlbe, uint16_t idDomain, uint64_t uIova, 1142 1142 PCIOPAGELOOKUP pPageLookup) 1143 1143 { 1144 1144 /* Initialize the IOTLB entry with results of the I/O page walk. */ 1145 pIotlbe->Core.Key = IOMMU_IOTLB_KEY_MAKE( uDomainId, uIova);1145 pIotlbe->Core.Key = IOMMU_IOTLB_KEY_MAKE(idDomain, uIova); 1146 1146 pIotlbe->PageLookup = *pPageLookup; 1147 1147 … … 1213 1213 * @param pThis The shared IOMMU device state. 1214 1214 * @param pThisR3 The ring-3 IOMMU device state. 1215 * @param uDomainIdThe domain ID.1215 * @param idDomain The domain ID. 1216 1216 * @param uIova The I/O virtual address. 1217 1217 */ 1218 static PIOTLBE iommuAmdIotlbLookup(PIOMMU pThis, PIOMMUR3 pThisR3, uint64_t uDomainId, uint64_t uIova)1218 static PIOTLBE iommuAmdIotlbLookup(PIOMMU pThis, PIOMMUR3 pThisR3, uint64_t idDomain, uint64_t uIova) 1219 1219 { 1220 1220 RT_NOREF(pThis); 1221 1221 1222 uint64_t const uKey = IOMMU_IOTLB_KEY_MAKE( uDomainId, uIova);1222 uint64_t const uKey = IOMMU_IOTLB_KEY_MAKE(idDomain, uIova); 1223 1223 PIOTLBE pIotlbe = (PIOTLBE)RTAvlU64Get(&pThisR3->TreeIotlbe, uKey); 1224 1224 if ( pIotlbe … … 1240 1240 * @param pThis The shared IOMMU device state. 1241 1241 * @param pThis The ring-3 IOMMU device state. 1242 * @param uDomainIdThe domain ID.1242 * @param idDomain The domain ID. 1243 1243 * @param uIova The I/O virtual address. 1244 1244 * @param pPageLookup The I/O page lookup result of the access. 1245 1245 */ 1246 static void iommuAmdIotlbAdd(PIOMMU pThis, PIOMMUR3 pThisR3, uint16_t uDomainId, uint64_t uIova, PCIOPAGELOOKUP pPageLookup)1246 static void iommuAmdIotlbAdd(PIOMMU pThis, PIOMMUR3 pThisR3, uint16_t idDomain, uint64_t uIova, PCIOPAGELOOKUP pPageLookup) 1247 1247 { 1248 1248 Assert(!(uIova & X86_PAGE_4K_OFFSET_MASK)); … … 1266 1266 1267 1267 /* Initialize and insert the IOTLB entry into the cache. */ 1268 iommuAmdIotlbEntryInsert(pThis, pThisR3, pIotlbe, uDomainId, uIova, pPageLookup);1268 iommuAmdIotlbEntryInsert(pThis, pThisR3, pIotlbe, idDomain, uIova, pPageLookup); 1269 1269 1270 1270 /* Move the entry to the most recently used slot. */ … … 1278 1278 1279 1279 /* Initialize and insert the IOTLB entry into the cache. */ 1280 iommuAmdIotlbEntryInsert(pThis, pThisR3, pIotlbe, uDomainId, uIova, pPageLookup);1280 iommuAmdIotlbEntryInsert(pThis, pThisR3, pIotlbe, idDomain, uIova, pPageLookup); 1281 1281 1282 1282 /* Add the entry to the most recently used slot. */ … … 1316 1316 * 1317 1317 * @param pDevIns The IOMMU instance data. 1318 * @param uDomainIdThe domain ID.1318 * @param idDomain The domain ID. 1319 1319 * @param uIova The I/O virtual address to invalidate. 1320 1320 * @param cbInvalidate The size of the invalidation (must be 4K aligned). 1321 1321 */ 1322 static void iommuAmdIotlbRemoveRange(PPDMDEVINS pDevIns, uint16_t uDomainId, uint64_t uIova, size_t cbInvalidate)1322 static void iommuAmdIotlbRemoveRange(PPDMDEVINS pDevIns, uint16_t idDomain, uint64_t uIova, size_t cbInvalidate) 1323 1323 { 1324 1324 /* Validate. */ … … 1333 1333 do 1334 1334 { 1335 uint64_t const uKey = IOMMU_IOTLB_KEY_MAKE( uDomainId, uIova);1335 uint64_t const uKey = IOMMU_IOTLB_KEY_MAKE(idDomain, uIova); 1336 1336 PIOTLBE pIotlbe = iommuAmdIotlbEntryRemove(pThis, pThisR3, uKey); 1337 1337 if (pIotlbe) … … 1349 1349 * 1350 1350 * @param pDevIns The IOMMU instance data. 1351 * @param uDomainIdThe domain ID.1352 */ 1353 static void iommuAmdIotlbRemoveDomainId(PPDMDEVINS pDevIns, uint16_t uDomainId)1351 * @param idDomain The domain ID. 1352 */ 1353 static void iommuAmdIotlbRemoveDomainId(PPDMDEVINS pDevIns, uint16_t idDomain) 1354 1354 { 1355 1355 /* … … 1364 1364 1365 1365 IOTLBEFLUSHARG Args; 1366 Args.pIommuR3 1367 Args. uDomainId = uDomainId;1366 Args.pIommuR3 = pThisR3; 1367 Args.idDomain = idDomain; 1368 1368 RTAvlU64DoWithAll(&pThisR3->TreeIotlbe, true /* fFromLeft */, iommuAmdIotlbEntryRemoveDomainId, &Args); 1369 1369 … … 1376 1376 * 1377 1377 * @param pDevIns The IOMMU instance data. 1378 * @param uDomainIdThe domain ID.1378 * @param idDomain The domain ID. 1379 1379 * @param uIova The I/O virtual address. 1380 * @param cb AccessThe size of the access (must be 4K aligned).1380 * @param cbIova The size of the access (must be 4K aligned). 1381 1381 * @param GCPhysSpa The translated system-physical address. 1382 1382 * @param fPerm The I/O permissions for the access, see IOMMU_IO_PERM_XXX. 1383 1383 */ 1384 static void iommuAmdIotlbAddRange(PPDMDEVINS pDevIns, uint16_t uDomainId, uint64_t uIova, size_t cbAccess, RTGCPHYS GCPhysSpa,1384 static void iommuAmdIotlbAddRange(PPDMDEVINS pDevIns, uint16_t idDomain, uint64_t uIova, size_t cbIova, RTGCPHYS GCPhysSpa, 1385 1385 uint8_t fPerm) 1386 1386 { 1387 1387 Assert(!(uIova & X86_PAGE_4K_OFFSET_MASK)); 1388 1388 Assert(!(GCPhysSpa & X86_PAGE_4K_OFFSET_MASK)); 1389 Assert(!(cb Access& X86_PAGE_4K_OFFSET_MASK));1390 Assert(cb Access>= X86_PAGE_4K_SIZE);1389 Assert(!(cbIova & X86_PAGE_4K_OFFSET_MASK)); 1390 Assert(cbIova >= X86_PAGE_4K_SIZE); 1391 1391 1392 1392 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); … … 1400 1400 PageLookup.GCPhysSpa = GCPhysSpa; 1401 1401 1402 size_t cPages = cb Access/ X86_PAGE_4K_SIZE;1402 size_t cPages = cbIova / X86_PAGE_4K_SIZE; 1403 1403 cPages = RT_MIN(cPages, IOMMU_IOTLBE_MAX); 1404 1404 … … 1407 1407 do 1408 1408 { 1409 iommuAmdIotlbAdd(pThis, pThisR3, uDomainId, uIova, &PageLookup);1409 iommuAmdIotlbAdd(pThis, pThisR3, idDomain, uIova, &PageLookup); 1410 1410 uIova += X86_PAGE_4K_SIZE; 1411 1411 PageLookup.GCPhysSpa += X86_PAGE_4K_SIZE; … … 1423 1423 * @returns Index of the found entry, or cache capacity if not found. 1424 1424 * @param pThis The shared IOMMU device state. 1425 * @param uDevIdThe device ID (bus, device, function).1425 * @param idDevice The device ID (bus, device, function). 1426 1426 * @param offIrte The offset into the interrupt remap table. 1427 1427 */ 1428 static uint16_t iommuAmdIrteCacheEntryLookup(PCIOMMU pThis, uint16_t uDevId, uint16_t offIrte)1428 static uint16_t iommuAmdIrteCacheEntryLookup(PCIOMMU pThis, uint16_t idDevice, uint16_t offIrte) 1429 1429 { 1430 1430 /** @todo Consider sorting and binary search when the cache capacity grows. … … 1432 1432 * interrupt remapping once programmed, so hopefully sorting shouldn't happen 1433 1433 * often. */ 1434 uint32_t const uKey = IOMMU_IRTE_CACHE_KEY_MAKE( uDevId, offIrte);1434 uint32_t const uKey = IOMMU_IRTE_CACHE_KEY_MAKE(idDevice, offIrte); 1435 1435 uint16_t const cIrteCache = RT_ELEMENTS(pThis->aIrteCache); 1436 1436 for (uint16_t i = 0; i < cIrteCache; i++) … … 1465 1465 * @returns VBox status code. 1466 1466 * @param pDevIns The IOMMU instance data. 1467 * @param uDevIdThe device ID (bus, device, function).1467 * @param idDevice The device ID (bus, device, function). 1468 1468 * @param enmOp The IOMMU operation being performed. 1469 1469 * @param pMsiIn The source MSI. 1470 1470 * @param pMsiOut Where to store the remapped MSI. 1471 1471 */ 1472 static int iommuAmdIrteCacheLookup(PPDMDEVINS pDevIns, uint16_t uDevId, IOMMUOP enmOp, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)1472 static int iommuAmdIrteCacheLookup(PPDMDEVINS pDevIns, uint16_t idDevice, IOMMUOP enmOp, PCMSIMSG pMsiIn, PMSIMSG pMsiOut) 1473 1473 { 1474 1474 RT_NOREF(enmOp); /* May need it if we have to report errors (currently we fallback to the slower path to do that). */ … … 1484 1484 IOMMU_LOCK_CACHE_NORET(pDevIns, pThis); 1485 1485 1486 uint16_t const idxDteCache = iommuAmdDteCacheEntryLookup(pThis, uDevId);1486 uint16_t const idxDteCache = iommuAmdDteCacheEntryLookup(pThis, idDevice); 1487 1487 if (idxDteCache < RT_ELEMENTS(pThis->aDteCache)) 1488 1488 { … … 1503 1503 /* Interrupt table length has been verified prior to adding entries to the cache. */ 1504 1504 uint16_t const offIrte = IOMMU_GET_IRTE_OFF(pMsiIn->Data.u32); 1505 uint16_t const idxIrteCache = iommuAmdIrteCacheEntryLookup(pThis, uDevId, offIrte);1505 uint16_t const idxIrteCache = iommuAmdIrteCacheEntryLookup(pThis, idDevice, offIrte); 1506 1506 if (idxIrteCache < RT_ELEMENTS(pThis->aIrteCache)) 1507 1507 { … … 1539 1539 * 1540 1540 * @param pDevIns The IOMMU instance data. 1541 * @param uDevIdThe device ID (bus, device, function).1541 * @param idDevice The device ID (bus, device, function). 1542 1542 * @param offIrte The offset into the interrupt remap table. 1543 1543 * @param pIrte The IRTE to cache. 1544 1544 */ 1545 static int iommuAmdIrteCacheAdd(PPDMDEVINS pDevIns, uint16_t uDevId, uint16_t offIrte, PCIRTE_T pIrte)1545 static int iommuAmdIrteCacheAdd(PPDMDEVINS pDevIns, uint16_t idDevice, uint16_t offIrte, PCIRTE_T pIrte) 1546 1546 { 1547 1547 Assert(offIrte != 0xffff); /* Shouldn't be a valid IRTE table offset since sizeof(IRTE) is a multiple of 4. */ … … 1553 1553 /* Find an existing entry or get an unused slot. */ 1554 1554 uint16_t const cIrteCache = RT_ELEMENTS(pThis->aIrteCache); 1555 uint16_t idxIrteCache = iommuAmdIrteCacheEntryLookup(pThis, uDevId, offIrte);1555 uint16_t idxIrteCache = iommuAmdIrteCacheEntryLookup(pThis, idDevice, offIrte); 1556 1556 if ( idxIrteCache < cIrteCache 1557 1557 || (idxIrteCache = iommuAmdIrteCacheEntryGetUnused(pThis)) < cIrteCache) 1558 1558 { 1559 pThis->aIrteCache[idxIrteCache].uKey = IOMMU_IRTE_CACHE_KEY_MAKE( uDevId, offIrte);1559 pThis->aIrteCache[idxIrteCache].uKey = IOMMU_IRTE_CACHE_KEY_MAKE(idDevice, offIrte); 1560 1560 pThis->aIrteCache[idxIrteCache].Irte = *pIrte; 1561 1561 } … … 1572 1572 * 1573 1573 * @param pDevIns The IOMMU instance data. 1574 * @param uDevIdThe device ID (bus, device, function).1575 */ 1576 static void iommuAmdIrteCacheRemove(PPDMDEVINS pDevIns, uint16_t uDevId)1574 * @param idDevice The device ID (bus, device, function). 1575 */ 1576 static void iommuAmdIrteCacheRemove(PPDMDEVINS pDevIns, uint16_t idDevice) 1577 1577 { 1578 1578 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); … … 1582 1582 { 1583 1583 PIRTECACHE pIrteCache = &pThis->aIrteCache[i]; 1584 if ( uDevId== IOMMU_IRTE_CACHE_KEY_GET_DEVICE_ID(pIrteCache->uKey))1584 if (idDevice == IOMMU_IRTE_CACHE_KEY_GET_DEVICE_ID(pIrteCache->uKey)) 1585 1585 { 1586 1586 pIrteCache->uKey = IOMMU_IRTE_CACHE_KEY_NIL; … … 2672 2672 } 2673 2673 else 2674 returnNULL;2674 pReg = NULL; 2675 2675 return pReg; 2676 2676 } … … 2986 2986 * Initializes a PAGE_TAB_HARDWARE_ERROR event. 2987 2987 * 2988 * @param uDevIdThe device ID (bus, device, function).2989 * @param uDomainIdThe domain ID.2988 * @param idDevice The device ID (bus, device, function). 2989 * @param idDomain The domain ID. 2990 2990 * @param GCPhysPtEntity The system physical address of the page table 2991 2991 * entity. … … 2993 2993 * @param pEvtPageTabHwErr Where to store the initialized event. 2994 2994 */ 2995 static void iommuAmdPageTabHwErrorEventInit(uint16_t uDevId, uint16_t uDomainId, RTGCPHYS GCPhysPtEntity, IOMMUOP enmOp,2995 static void iommuAmdPageTabHwErrorEventInit(uint16_t idDevice, uint16_t idDomain, RTGCPHYS GCPhysPtEntity, IOMMUOP enmOp, 2996 2996 PEVT_PAGE_TAB_HW_ERR_T pEvtPageTabHwErr) 2997 2997 { 2998 2998 memset(pEvtPageTabHwErr, 0, sizeof(*pEvtPageTabHwErr)); 2999 pEvtPageTabHwErr->n.u16DevId = uDevId;3000 pEvtPageTabHwErr->n.u16DomainOrPasidLo = uDomainId;2999 pEvtPageTabHwErr->n.u16DevId = idDevice; 3000 pEvtPageTabHwErr->n.u16DomainOrPasidLo = idDomain; 3001 3001 pEvtPageTabHwErr->n.u1GuestOrNested = 0; 3002 3002 pEvtPageTabHwErr->n.u1Interrupt = RT_BOOL(enmOp == IOMMUOP_INTR_REQ); … … 3033 3033 IOMMU_UNLOCK(pDevIns, pThisCC); 3034 3034 3035 LogFunc(("Raised PAGE_TAB_HARDWARE_ERROR. uDevId=%#x uDomainId=%#x GCPhysPtEntity=%#RGp enmOp=%u u2Type=%u\n",3035 LogFunc(("Raised PAGE_TAB_HARDWARE_ERROR. idDevice=%#x idDomain=%#x GCPhysPtEntity=%#RGp enmOp=%u u2Type=%u\n", 3036 3036 pEvtPageTabHwErr->n.u16DevId, pEvtPageTabHwErr->n.u16DomainOrPasidLo, pEvtPageTabHwErr->n.u64Addr, enmOp, 3037 3037 pEvtPageTabHwErr->n.u2Type)); … … 3086 3086 * Initializes a DEV_TAB_HARDWARE_ERROR event. 3087 3087 * 3088 * @param uDevIdThe device ID (bus, device, function).3088 * @param idDevice The device ID (bus, device, function). 3089 3089 * @param GCPhysDte The system physical address of the failed device table 3090 3090 * access. … … 3092 3092 * @param pEvtDevTabHwErr Where to store the initialized event. 3093 3093 */ 3094 static void iommuAmdDevTabHwErrorEventInit(uint16_t uDevId, RTGCPHYS GCPhysDte, IOMMUOP enmOp,3094 static void iommuAmdDevTabHwErrorEventInit(uint16_t idDevice, RTGCPHYS GCPhysDte, IOMMUOP enmOp, 3095 3095 PEVT_DEV_TAB_HW_ERROR_T pEvtDevTabHwErr) 3096 3096 { 3097 3097 memset(pEvtDevTabHwErr, 0, sizeof(*pEvtDevTabHwErr)); 3098 pEvtDevTabHwErr->n.u16DevId = uDevId;3098 pEvtDevTabHwErr->n.u16DevId = idDevice; 3099 3099 pEvtDevTabHwErr->n.u1Intr = RT_BOOL(enmOp == IOMMUOP_INTR_REQ); 3100 3100 /** @todo IOMMU: Any other transaction type that can set read/write bit? */ … … 3131 3131 IOMMU_UNLOCK(pDevIns, pThisCC); 3132 3132 3133 LogFunc(("Raised DEV_TAB_HARDWARE_ERROR. uDevId=%#x GCPhysDte=%#RGp enmOp=%u u2Type=%u\n", pEvtDevTabHwErr->n.u16DevId,3133 LogFunc(("Raised DEV_TAB_HARDWARE_ERROR. idDevice=%#x GCPhysDte=%#RGp enmOp=%u u2Type=%u\n", pEvtDevTabHwErr->n.u16DevId, 3134 3134 pEvtDevTabHwErr->n.u64Addr, enmOp, pEvtDevTabHwErr->n.u2Type)); 3135 3135 } … … 3176 3176 * Initializes an ILLEGAL_DEV_TABLE_ENTRY event. 3177 3177 * 3178 * @param uDevIdThe device ID (bus, device, function).3178 * @param idDevice The device ID (bus, device, function). 3179 3179 * @param uIova The I/O virtual address. 3180 3180 * @param fRsvdNotZero Whether reserved bits are not zero. Pass @c false if the … … 3184 3184 * @param pEvtIllegalDte Where to store the initialized event. 3185 3185 */ 3186 static void iommuAmdIllegalDteEventInit(uint16_t uDevId, uint64_t uIova, bool fRsvdNotZero, IOMMUOP enmOp,3186 static void iommuAmdIllegalDteEventInit(uint16_t idDevice, uint64_t uIova, bool fRsvdNotZero, IOMMUOP enmOp, 3187 3187 PEVT_ILLEGAL_DTE_T pEvtIllegalDte) 3188 3188 { 3189 3189 memset(pEvtIllegalDte, 0, sizeof(*pEvtIllegalDte)); 3190 pEvtIllegalDte->n.u16DevId = uDevId;3190 pEvtIllegalDte->n.u16DevId = idDevice; 3191 3191 pEvtIllegalDte->n.u1Interrupt = RT_BOOL(enmOp == IOMMUOP_INTR_REQ); 3192 3192 pEvtIllegalDte->n.u1ReadWrite = RT_BOOL(enmOp == IOMMUOP_MEM_WRITE); … … 3221 3221 iommuAmdSetPciTargetAbort(pDevIns); 3222 3222 3223 LogFunc(("Raised ILLEGAL_DTE_EVENT. uDevId=%#x uIova=%#RX64 enmOp=%u enmEvtType=%u\n", pEvtIllegalDte->n.u16DevId,3223 LogFunc(("Raised ILLEGAL_DTE_EVENT. idDevice=%#x uIova=%#RX64 enmOp=%u enmEvtType=%u\n", pEvtIllegalDte->n.u16DevId, 3224 3224 pEvtIllegalDte->n.u64Addr, enmOp, enmEvtType)); 3225 3225 NOREF(enmEvtType); … … 3230 3230 * Initializes an IO_PAGE_FAULT event. 3231 3231 * 3232 * @param uDevIdThe device ID (bus, device, function).3233 * @param uDomainIdThe domain ID.3232 * @param idDevice The device ID (bus, device, function). 3233 * @param idDomain The domain ID. 3234 3234 * @param uIova The I/O virtual address being accessed. 3235 3235 * @param fPresent Transaction to a page marked as present (including … … 3243 3243 * @param pEvtIoPageFault Where to store the initialized event. 3244 3244 */ 3245 static void iommuAmdIoPageFaultEventInit(uint16_t uDevId, uint16_t uDomainId, uint64_t uIova, bool fPresent, bool fRsvdNotZero,3245 static void iommuAmdIoPageFaultEventInit(uint16_t idDevice, uint16_t idDomain, uint64_t uIova, bool fPresent, bool fRsvdNotZero, 3246 3246 bool fPermDenied, IOMMUOP enmOp, PEVT_IO_PAGE_FAULT_T pEvtIoPageFault) 3247 3247 { 3248 3248 Assert(!fPermDenied || fPresent); 3249 3249 memset(pEvtIoPageFault, 0, sizeof(*pEvtIoPageFault)); 3250 pEvtIoPageFault->n.u16DevId = uDevId;3250 pEvtIoPageFault->n.u16DevId = idDevice; 3251 3251 //pEvtIoPageFault->n.u4PasidHi = 0; 3252 pEvtIoPageFault->n.u16DomainOrPasidLo = uDomainId;3252 pEvtIoPageFault->n.u16DomainOrPasidLo = idDomain; 3253 3253 //pEvtIoPageFault->n.u1GuestOrNested = 0; 3254 3254 //pEvtIoPageFault->n.u1NoExecute = 0; … … 3430 3430 * @returns VBox status code. 3431 3431 * @param pDevIns The IOMMU device instance. 3432 * @param uDevIdThe device ID (bus, device, function).3432 * @param idDevice The device ID (bus, device, function). 3433 3433 * @param enmOp The IOMMU operation being performed. 3434 3434 * @param pDte Where to store the device table entry. … … 3436 3436 * @thread Any. 3437 3437 */ 3438 static int iommuAmdDteRead(PPDMDEVINS pDevIns, uint16_t uDevId, IOMMUOP enmOp, PDTE_T pDte)3438 static int iommuAmdDteRead(PPDMDEVINS pDevIns, uint16_t idDevice, IOMMUOP enmOp, PDTE_T pDte) 3439 3439 { 3440 3440 PCIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); … … 3447 3447 Assert(idxSegsEn < RT_ELEMENTS(g_auDevTabSegShifts)); 3448 3448 3449 uint8_t const idxSeg = ( uDevId& g_auDevTabSegMasks[idxSegsEn]) >> g_auDevTabSegShifts[idxSegsEn];3449 uint8_t const idxSeg = (idDevice & g_auDevTabSegMasks[idxSegsEn]) >> g_auDevTabSegShifts[idxSegsEn]; 3450 3450 Assert(idxSeg < RT_ELEMENTS(pThis->aDevTabBaseAddrs)); 3451 3451 AssertCompile(RT_ELEMENTS(g_auDevTabSegShifts) == RT_ELEMENTS(g_auDevTabSegMasks)); 3452 3452 3453 3453 RTGCPHYS const GCPhysDevTab = pThis->aDevTabBaseAddrs[idxSeg].n.u40Base << X86_PAGE_4K_SHIFT; 3454 uint32_t const offDte = ( uDevId& ~g_auDevTabSegMasks[idxSegsEn]) * sizeof(DTE_T);3454 uint32_t const offDte = (idDevice & ~g_auDevTabSegMasks[idxSegsEn]) * sizeof(DTE_T); 3455 3455 RTGCPHYS const GCPhysDte = GCPhysDevTab + offDte; 3456 3456 … … 3472 3472 3473 3473 EVT_DEV_TAB_HW_ERROR_T EvtDevTabHwErr; 3474 iommuAmdDevTabHwErrorEventInit( uDevId, GCPhysDte, enmOp, &EvtDevTabHwErr);3474 iommuAmdDevTabHwErrorEventInit(idDevice, GCPhysDte, enmOp, &EvtDevTabHwErr); 3475 3475 iommuAmdDevTabHwErrorEventRaise(pDevIns, enmOp, &EvtDevTabHwErr); 3476 3476 return VERR_IOMMU_DTE_READ_FAILED; … … 3479 3479 /* Raise an I/O page fault for out-of-bounds acccess. */ 3480 3480 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 3481 iommuAmdIoPageFaultEventInit( uDevId, 0 /* uDomainId*/, 0 /* uIova */, false /* fPresent */, false /* fRsvdNotZero */,3481 iommuAmdIoPageFaultEventInit(idDevice, 0 /* idDomain */, 0 /* uIova */, false /* fPresent */, false /* fRsvdNotZero */, 3482 3482 false /* fPermDenied */, enmOp, &EvtIoPageFault); 3483 3483 iommuAmdIoPageFaultEventRaise(pDevIns, 0 /* fIoDevFlags */, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 3501 3501 * @param pDevIns The IOMMU device instance. 3502 3502 * @param uIova The I/O virtual address to translate. 3503 * @param uDevIdThe device ID (bus, device, function).3503 * @param idDevice The device ID (bus, device, function). 3504 3504 * @param fPerm The I/O permissions for this access, see 3505 3505 * IOMMU_IO_PERM_XXX. … … 3509 3509 * @thread Any. 3510 3510 */ 3511 static int iommuAmdPreTranslateChecks(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, uint8_t fPerm, PCDTE_T pDte,3511 static int iommuAmdPreTranslateChecks(PPDMDEVINS pDevIns, uint16_t idDevice, uint64_t uIova, uint8_t fPerm, PCDTE_T pDte, 3512 3512 IOMMUOP enmOp) 3513 3513 { … … 3526 3526 LogFunc(("Translation valid bit not set -> IOPF\n")); 3527 3527 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 3528 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, uIova, false /* fPresent */, false /* fRsvdNotZero */,3528 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, uIova, false /* fPresent */, false /* fRsvdNotZero */, 3529 3529 false /* fPermDenied */, enmOp, &EvtIoPageFault); 3530 3530 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 3544 3544 LogFunc(("Permission denied by DTE (fPerm=%#x fDtePerm=%#x) -> IOPF\n", fPerm, fDtePerm)); 3545 3545 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 3546 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */,3546 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */, 3547 3547 true /* fPermDenied */, enmOp, &EvtIoPageFault); 3548 3548 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 3575 3575 * raising an ILLEGAL_DEV_TABLE_ENTRY event or an IO_PAGE_FAULT event here. 3576 3576 * I'm just going with I/O page fault. */ 3577 LogFunc(("Invalid root page table level %#x ( uDevId=%#x) -> IOPF\n", uMaxLevel, uDevId));3577 LogFunc(("Invalid root page table level %#x (idDevice=%#x) -> IOPF\n", uMaxLevel, idDevice)); 3578 3578 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 3579 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */,3579 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */, 3580 3580 false /* fPermDenied */, enmOp, &EvtIoPageFault); 3581 3581 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 3598 3598 * @param fPerm The I/O permissions for this access, see 3599 3599 * IOMMU_IO_PERM_XXX. 3600 * @param uDevIdThe device ID (bus, device, function).3600 * @param idDevice The device ID (bus, device, function). 3601 3601 * @param pDte The device table entry. 3602 3602 * @param enmOp The IOMMU operation being performed. … … 3606 3606 * @thread Any. 3607 3607 */ 3608 static int iommuAmdIoPageTableWalk(PPDMDEVINS pDevIns, uint64_t uIova, uint8_t fPerm, uint16_t uDevId, PCDTE_T pDte,3608 static int iommuAmdIoPageTableWalk(PPDMDEVINS pDevIns, uint64_t uIova, uint8_t fPerm, uint16_t idDevice, PCDTE_T pDte, 3609 3609 IOMMUOP enmOp, PIOPAGELOOKUP pPageLookup) 3610 3610 { … … 3645 3645 LogFunc(("Failed to read page table entry at %#RGp. rc=%Rrc -> PageTabHwError\n", GCPhysPtEntity, rc)); 3646 3646 EVT_PAGE_TAB_HW_ERR_T EvtPageTabHwErr; 3647 iommuAmdPageTabHwErrorEventInit( uDevId, pDte->n.u16DomainId, GCPhysPtEntity, enmOp, &EvtPageTabHwErr);3647 iommuAmdPageTabHwErrorEventInit(idDevice, pDte->n.u16DomainId, GCPhysPtEntity, enmOp, &EvtPageTabHwErr); 3648 3648 iommuAmdPageTabHwErrorEventRaise(pDevIns, enmOp, &EvtPageTabHwErr); 3649 3649 return VERR_IOMMU_IPE_2; … … 3656 3656 else 3657 3657 { 3658 LogFunc(("Page table entry not present ( uDevId=%#x) -> IOPF\n", uDevId));3658 LogFunc(("Page table entry not present (idDevice=%#x) -> IOPF\n", idDevice)); 3659 3659 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 3660 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, uIova, false /* fPresent */, false /* fRsvdNotZero */,3660 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, uIova, false /* fPresent */, false /* fRsvdNotZero */, 3661 3661 false /* fPermDenied */, enmOp, &EvtIoPageFault); 3662 3662 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 3671 3671 else 3672 3672 { 3673 LogFunc(("Page table entry access denied ( uDevId=%#x fPerm=%#x fPtePerm=%#x) -> IOPF\n", uDevId, fPerm, fPtePerm));3673 LogFunc(("Page table entry access denied (idDevice=%#x fPerm=%#x fPtePerm=%#x) -> IOPF\n", idDevice, fPerm, fPtePerm)); 3674 3674 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 3675 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */,3675 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */, 3676 3676 true /* fPermDenied */, enmOp, &EvtIoPageFault); 3677 3677 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 3711 3711 LogFunc(("Page size invalid cShift=%#x -> IOPF\n", cShift)); 3712 3712 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 3713 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */,3713 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */, 3714 3714 false /* fPermDenied */, enmOp, &EvtIoPageFault); 3715 3715 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 3726 3726 LogFunc(("Next level of PDE invalid uNextLevel=%#x -> IOPF\n", uNextLevel)); 3727 3727 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 3728 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */,3728 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */, 3729 3729 false /* fPermDenied */, enmOp, &EvtIoPageFault); 3730 3730 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 3743 3743 LogFunc(("Next level (%#x) must be less than the current level (%#x) -> IOPF\n", uNextLevel, uLevel)); 3744 3744 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 3745 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */,3745 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */, 3746 3746 false /* fPermDenied */, enmOp, &EvtIoPageFault); 3747 3747 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 3761 3761 LogFunc(("IOVA of skipped levels are not zero %#RX64 (SkipMask=%#RX64) -> IOPF\n", uIova, uIovaSkipMask)); 3762 3762 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 3763 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */,3763 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, uIova, true /* fPresent */, false /* fRsvdNotZero */, 3764 3764 false /* fPermDenied */, enmOp, &EvtIoPageFault); 3765 3765 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 3799 3799 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 3800 3800 STAM_PROFILE_ADV_START(&pThis->StatProfDteLookup, a); 3801 int rc = iommuAmdIoPageTableWalk(pDevIns, uIovaPage, fPerm, pAux-> uDeviceId, pAux->pDte, pAux->enmOp, pPageLookup);3801 int rc = iommuAmdIoPageTableWalk(pDevIns, uIovaPage, fPerm, pAux->idDevice, pAux->pDte, pAux->enmOp, pPageLookup); 3802 3802 STAM_PROFILE_ADV_STOP(&pThis->StatProfDteLookup, a); NOREF(pThis); 3803 3803 return rc; … … 3826 3826 3827 3827 int rc; 3828 size_t const cb Access= pAddrIn->cb;3828 size_t const cbIova = pAddrIn->cb; 3829 3829 uint8_t const fPerm = pAddrIn->fPerm; 3830 3830 uint64_t const uIova = pAddrIn->uAddr; 3831 3831 RTGCPHYS GCPhysSpa = NIL_RTGCPHYS; 3832 size_t cbRemaining = cb Access;3832 size_t cbRemaining = cbIova; 3833 3833 uint64_t uIovaPage = pAddrIn->uAddr & X86_PAGE_4K_BASE_MASK; 3834 3834 uint64_t offIova = pAddrIn->uAddr & X86_PAGE_4K_OFFSET_MASK; … … 3846 3846 3847 3847 /* Store the translated address before continuing to access more pages. */ 3848 if (cbRemaining == cb Access)3848 if (cbRemaining == cbIova) 3849 3849 { 3850 3850 uint64_t const offMask = IOMMU_GET_PAGE_OFF_MASK(PageLookup.cShift); … … 3885 3885 3886 3886 pAddrOut->uAddr = GCPhysSpa; /* Update the translated address. */ 3887 pAddrOut->cb = cb Access - cbRemaining;/* Update the size of the contiguous memory region. */3887 pAddrOut->cb = cbIova - cbRemaining; /* Update the size of the contiguous memory region. */ 3888 3888 pAddrOut->fPerm = PageLookupPrev.fPerm; /* Update the allowed permissions for this access. */ 3889 3889 if (pcbPages) … … 3898 3898 * @returns VBox status code. 3899 3899 * @param pDevIns The IOMMU instance data. 3900 * @param uDevIdThe device ID (bus, device, function).3900 * @param idDevice The device ID (bus, device, function). 3901 3901 * @param uIova The I/O virtual address to lookup. 3902 * @param cb AccessThe size of the access.3902 * @param cbIova The size of the access. 3903 3903 * @param fPerm The I/O permissions for this access, see 3904 3904 * IOMMU_IO_PERM_XXX. … … 3910 3910 * @thread Any. 3911 3911 */ 3912 static int iommuAmdDteLookup(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbAccess, uint8_t fPerm, IOMMUOP enmOp,3912 static int iommuAmdDteLookup(PPDMDEVINS pDevIns, uint16_t idDevice, uint64_t uIova, size_t cbIova, uint8_t fPerm, IOMMUOP enmOp, 3913 3913 PRTGCPHYS pGCPhysSpa, size_t *pcbContiguous) 3914 3914 { … … 3919 3919 /* Read the device table entry from memory. */ 3920 3920 DTE_T Dte; 3921 int rc = iommuAmdDteRead(pDevIns, uDevId, enmOp, &Dte);3921 int rc = iommuAmdDteRead(pDevIns, idDevice, enmOp, &Dte); 3922 3922 if (RT_SUCCESS(rc)) 3923 3923 { … … 3934 3934 * so there's no need to check the address exclusion base/limit here. 3935 3935 */ 3936 rc = iommuAmdPreTranslateChecks(pDevIns, uDevId, uIova, fPerm, &Dte, enmOp);3936 rc = iommuAmdPreTranslateChecks(pDevIns, idDevice, uIova, fPerm, &Dte, enmOp); 3937 3937 if (rc == VINF_SUCCESS) 3938 3938 { 3939 3939 IOADDRRANGE AddrIn; 3940 3940 AddrIn.uAddr = uIova; 3941 AddrIn.cb = cb Access;3941 AddrIn.cb = cbIova; 3942 3942 AddrIn.fPerm = fPerm; 3943 3943 3944 3944 IOMMUOPAUX Aux; 3945 Aux.enmOp 3946 Aux.pDte 3947 Aux. uDeviceId = uDevId;3948 Aux. uDomainId= Dte.n.u16DomainId;3945 Aux.enmOp = enmOp; 3946 Aux.pDte = &Dte; 3947 Aux.idDevice = idDevice; 3948 Aux.idDomain = Dte.n.u16DomainId; 3949 3949 3950 3950 IOADDRRANGE AddrOut; … … 3960 3960 if (rc == VERR_OUT_OF_RANGE) 3961 3961 { 3962 Assert(cbContiguous > 0 && cbContiguous < cb Access);3962 Assert(cbContiguous > 0 && cbContiguous < cbIova); 3963 3963 rc = VINF_SUCCESS; 3964 3964 STAM_COUNTER_INC(&pThis->StatAccessDteNonContig); NOREF(pThis); … … 3972 3972 { 3973 3973 /* Update that addresses requires translation (cumulative permissions of DTE and I/O page tables). */ 3974 iommuAmdDteCacheAdd(pDevIns, uDevId, &Dte, IOMMU_DTE_CACHE_F_ADDR_TRANSLATE);3974 iommuAmdDteCacheAdd(pDevIns, idDevice, &Dte, IOMMU_DTE_CACHE_F_ADDR_TRANSLATE); 3975 3975 /* Update IOTLB for the contiguous range of I/O virtual addresses. */ 3976 3976 iommuAmdIotlbAddRange(pDevIns, Dte.n.u16DomainId, uIova & X86_PAGE_4K_BASE_MASK, cbPages, … … 3985 3985 * GPA=SPA, but the permission bits are important and controls accesses. 3986 3986 */ 3987 GCPhysSpa = 3988 cbContiguous = cb Access;3987 GCPhysSpa = uIova; 3988 cbContiguous = cbIova; 3989 3989 rc = VINF_SUCCESS; 3990 3990 3991 3991 #ifdef IOMMU_WITH_IOTLBE_CACHE 3992 3992 /* Update that addresses permissions of DTE apply (but omit address translation). */ 3993 iommuAmdDteCacheAdd(pDevIns, uDevId, &Dte, IOMMU_DTE_CACHE_F_IO_PERM);3993 iommuAmdDteCacheAdd(pDevIns, idDevice, &Dte, IOMMU_DTE_CACHE_F_IO_PERM); 3994 3994 #endif 3995 3995 } … … 4008 4008 LogFunc(("Invalid DTE reserved bits (u64[0]=%#RX64 u64[1]=%#RX64) -> Illegal DTE\n", fRsvd0, fRsvd1)); 4009 4009 EVT_ILLEGAL_DTE_T Event; 4010 iommuAmdIllegalDteEventInit( uDevId, uIova, true /* fRsvdNotZero */, enmOp, &Event);4010 iommuAmdIllegalDteEventInit(idDevice, uIova, true /* fRsvdNotZero */, enmOp, &Event); 4011 4011 iommuAmdIllegalDteEventRaise(pDevIns, enmOp, &Event, kIllegalDteType_RsvdNotZero); 4012 4012 rc = VERR_IOMMU_ADDR_TRANSLATION_FAILED; … … 4020 4020 */ 4021 4021 GCPhysSpa = uIova; 4022 cbContiguous = cb Access;4022 cbContiguous = cbIova; 4023 4023 4024 4024 #ifdef IOMMU_WITH_IOTLBE_CACHE 4025 4025 /* Update that addresses don't require translation (nor permission checks) but a DTE is present. */ 4026 iommuAmdDteCacheAdd(pDevIns, uDevId, &Dte, 0 /* fFlags */);4026 iommuAmdDteCacheAdd(pDevIns, idDevice, &Dte, 0 /* fFlags */); 4027 4027 #endif 4028 4028 } … … 4030 4030 else 4031 4031 { 4032 LogFunc(("Failed to read device table entry. uDevId=%#x rc=%Rrc\n", uDevId, rc));4032 LogFunc(("Failed to read device table entry. idDevice=%#x rc=%Rrc\n", idDevice, rc)); 4033 4033 rc = VERR_IOMMU_ADDR_TRANSLATION_FAILED; 4034 4034 } … … 4070 4070 4071 4071 STAM_PROFILE_ADV_START(&pThis->StatProfIotlbeLookup, a); 4072 PCIOTLBE pIotlbe = iommuAmdIotlbLookup(pThis, pThisR3, pAux-> uDomainId, uIovaPage);4072 PCIOTLBE pIotlbe = iommuAmdIotlbLookup(pThis, pThisR3, pAux->idDomain, uIovaPage); 4073 4073 STAM_PROFILE_ADV_STOP(&pThis->StatProfIotlbeLookup, a); 4074 4074 if (pIotlbe) … … 4098 4098 * 4099 4099 * @param pDevIns The IOMMU instance data. 4100 * @param uDevIdThe device ID (bus, device, function).4100 * @param idDevice The device ID (bus, device, function). 4101 4101 * @param uIova The I/O virtual address to lookup. 4102 * @param cb AccessThe size of the access.4102 * @param cbIova The size of the access. 4103 4103 * @param fPerm The I/O permissions for this access, see 4104 4104 * IOMMU_IO_PERM_XXX. … … 4108 4108 * and permission-checked. 4109 4109 */ 4110 static int iommuAmdCacheLookup(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbAccess, uint8_t fPerm, IOMMUOP enmOp,4110 static int iommuAmdCacheLookup(PPDMDEVINS pDevIns, uint16_t idDevice, uint64_t uIova, size_t cbIova, uint8_t fPerm, IOMMUOP enmOp, 4111 4111 PRTGCPHYS pGCPhysSpa, size_t *pcbContiguous) 4112 4112 { … … 4114 4114 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 4115 4115 4116 #define IOMMU_IOTLB_LOOKUP_FAILED(a_rc) 4117 do { 4118 *pGCPhysSpa = NIL_RTGCPHYS; 4119 *pcbContiguous = 0; 4120 rc = (a_rc); 4116 #define IOMMU_IOTLB_LOOKUP_FAILED(a_rc) \ 4117 do { \ 4118 *pGCPhysSpa = NIL_RTGCPHYS; \ 4119 *pcbContiguous = 0; \ 4120 rc = (a_rc); \ 4121 4121 } while (0) 4122 4122 … … 4128 4128 4129 4129 /* Lookup the DTE cache entry. */ 4130 uint16_t const idxDteCache = iommuAmdDteCacheEntryLookup(pThis, uDevId);4130 uint16_t const idxDteCache = iommuAmdDteCacheEntryLookup(pThis, idDevice); 4131 4131 if (idxDteCache < RT_ELEMENTS(pThis->aDteCache)) 4132 4132 { … … 4138 4138 IOADDRRANGE AddrIn; 4139 4139 AddrIn.uAddr = uIova; 4140 AddrIn.cb = cb Access;4140 AddrIn.cb = cbIova; 4141 4141 AddrIn.fPerm = fPerm; 4142 4142 4143 4143 IOMMUOPAUX Aux; 4144 Aux.enmOp 4145 Aux.pDte 4146 Aux. uDeviceId = uDevId;4147 Aux. uDomainId = pDteCache->uDomainId;4144 Aux.enmOp = enmOp; 4145 Aux.pDte = NULL; 4146 Aux.idDevice = idDevice; 4147 Aux.idDomain = pDteCache->idDomain; 4148 4148 4149 4149 IOADDRRANGE AddrOut; 4150 4150 rc = iommuAmdLookupIoAddrRange(pDevIns, iommuAmdCacheLookupPage, &AddrIn, &Aux, &AddrOut, NULL /* pcbPages */); 4151 Assert(AddrOut.cb <= cb Access);4151 Assert(AddrOut.cb <= cbIova); 4152 4152 *pGCPhysSpa = AddrOut.uAddr; 4153 4153 *pcbContiguous = AddrOut.cb; … … 4162 4162 { 4163 4163 *pGCPhysSpa = uIova; 4164 *pcbContiguous = cb Access;4164 *pcbContiguous = cbIova; 4165 4165 rc = VINF_SUCCESS; 4166 4166 } … … 4172 4172 /* Forward addresses untranslated, without checking permissions. */ 4173 4173 *pGCPhysSpa = uIova; 4174 *pcbContiguous = cb Access;4174 *pcbContiguous = cbIova; 4175 4175 rc = VINF_SUCCESS; 4176 4176 } … … 4236 4236 * @returns VBox status code. 4237 4237 * @param pDevIns The IOMMU device instance. 4238 * @param uDevIdThe device ID (bus, device, function).4238 * @param idDevice The device ID (bus, device, function). 4239 4239 * @param uIova The I/O virtual address being accessed. 4240 * @param cb Access The number of bytes being accessed.4240 * @param cbIova The size of the access. 4241 4241 * @param fFlags The access flags, see PDMIOMMU_MEM_F_XXX. 4242 4242 * @param pGCPhysSpa Where to store the translated system physical address. … … 4246 4246 * @thread Any. 4247 4247 */ 4248 static DECLCALLBACK(int) iommuAmdMemAccess(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbAccess, uint32_t fFlags,4249 PRTGCPHYS pGCPhysSpa, size_t *pcbContiguous)4248 static DECLCALLBACK(int) iommuAmdMemAccess(PPDMDEVINS pDevIns, uint16_t idDevice, uint64_t uIova, size_t cbIova, 4249 uint32_t fFlags, PRTGCPHYS pGCPhysSpa, size_t *pcbContiguous) 4250 4250 { 4251 4251 /* Validate. */ 4252 4252 AssertPtr(pDevIns); 4253 4253 AssertPtr(pGCPhysSpa); 4254 Assert(cb Access> 0);4254 Assert(cbIova > 0); 4255 4255 Assert(!(fFlags & ~PDMIOMMU_MEM_F_VALID_MASK)); 4256 4256 … … 4262 4262 uint8_t fPerm; 4263 4263 iommuAmdMemAccessGetPermAndOp(pThis, fFlags, &enmOp, &fPerm, false /* fBulk */); 4264 LogFlowFunc(("%s: uDevId=%#x uIova=%#RX64 cb=%zu\n", iommuAmdMemAccessGetPermName(fPerm), uDevId, uIova, cbAccess));4264 LogFlowFunc(("%s: idDevice=%#x uIova=%#RX64 cb=%zu\n", iommuAmdMemAccessGetPermName(fPerm), idDevice, uIova, cbIova)); 4265 4265 4266 4266 int rc; 4267 4267 #ifdef IOMMU_WITH_IOTLBE_CACHE 4268 4268 /* Lookup the IOVA from the cache. */ 4269 rc = iommuAmdCacheLookup(pDevIns, uDevId, uIova, cbAccess, fPerm, enmOp, pGCPhysSpa, pcbContiguous);4269 rc = iommuAmdCacheLookup(pDevIns, idDevice, uIova, cbIova, fPerm, enmOp, pGCPhysSpa, pcbContiguous); 4270 4270 if (rc == VINF_SUCCESS) 4271 4271 { 4272 4272 /* All pages in the access were found in the cache with sufficient permissions. */ 4273 Assert(*pcbContiguous == cb Access);4273 Assert(*pcbContiguous == cbIova); 4274 4274 Assert(*pGCPhysSpa != NIL_RTGCPHYS); 4275 4275 STAM_COUNTER_INC(&pThis->StatAccessCacheHitFull); … … 4281 4281 { 4282 4282 /* Access stopped since translations resulted in non-contiguous memory, let caller resume access. */ 4283 Assert(*pcbContiguous > 0 && *pcbContiguous < cb Access);4283 Assert(*pcbContiguous > 0 && *pcbContiguous < cbIova); 4284 4284 STAM_COUNTER_INC(&pThis->StatAccessCacheNonContig); 4285 4285 return VINF_SUCCESS; … … 4291 4291 * so go through the slower path and raise the required event. 4292 4292 */ 4293 AssertMsg(*pcbContiguous < cb Access, ("Invalid size: cbContiguous=%zu cbAccess=%zu\n", *pcbContiguous, cbAccess));4294 uIova 4295 cb Access-= *pcbContiguous;4293 AssertMsg(*pcbContiguous < cbIova, ("Invalid size: cbContiguous=%zu cbIova=%zu\n", *pcbContiguous, cbIova)); 4294 uIova += *pcbContiguous; 4295 cbIova -= *pcbContiguous; 4296 4296 /* We currently are including any permission denied pages as cache misses too.*/ 4297 4297 STAM_COUNTER_INC(&pThis->StatAccessCacheMiss); … … 4299 4299 4300 4300 /* Lookup the IOVA from the device table. */ 4301 rc = iommuAmdDteLookup(pDevIns, uDevId, uIova, cbAccess, fPerm, enmOp, pGCPhysSpa, pcbContiguous);4301 rc = iommuAmdDteLookup(pDevIns, idDevice, uIova, cbIova, fPerm, enmOp, pGCPhysSpa, pcbContiguous); 4302 4302 if (RT_SUCCESS(rc)) 4303 4303 { /* likely */ } … … 4305 4305 { 4306 4306 Assert(rc != VERR_OUT_OF_RANGE); 4307 LogFunc(("DTE lookup failed! uDevId=%#x uIova=%#RX64 fPerm=%u cbAccess=%zu rc=%#Rrc\n", uDevId, uIova, fPerm,4308 cb Access, rc));4307 LogFunc(("DTE lookup failed! idDevice=%#x uIova=%#RX64 fPerm=%u cbIova=%zu rc=%#Rrc\n", idDevice, uIova, fPerm, 4308 cbIova, rc)); 4309 4309 } 4310 4310 … … 4314 4314 /* Addresses are forwarded without translation when the IOMMU is disabled. */ 4315 4315 *pGCPhysSpa = uIova; 4316 *pcbContiguous = cb Access;4316 *pcbContiguous = cbIova; 4317 4317 return VINF_SUCCESS; 4318 4318 } … … 4324 4324 * @returns VBox status code. 4325 4325 * @param pDevIns The IOMMU device instance. 4326 * @param uDevIdThe device ID (bus, device, function).4326 * @param idDevice The device ID (bus, device, function). 4327 4327 * @param cIovas The number of addresses being accessed. 4328 4328 * @param pauIovas The I/O virtual addresses for each page being accessed. … … 4332 4332 * @thread Any. 4333 4333 */ 4334 static DECLCALLBACK(int) iommuAmdMemBulkAccess(PPDMDEVINS pDevIns, uint16_t uDevId, size_t cIovas, uint64_t const *pauIovas,4334 static DECLCALLBACK(int) iommuAmdMemBulkAccess(PPDMDEVINS pDevIns, uint16_t idDevice, size_t cIovas, uint64_t const *pauIovas, 4335 4335 uint32_t fFlags, PRTGCPHYS paGCPhysSpa) 4336 4336 { … … 4349 4349 uint8_t fPerm; 4350 4350 iommuAmdMemAccessGetPermAndOp(pThis, fFlags, &enmOp, &fPerm, true /* fBulk */); 4351 LogFlowFunc(("%s: uDevId=%#x cIovas=%zu\n", iommuAmdMemAccessGetPermName(fPerm), uDevId, cIovas));4351 LogFlowFunc(("%s: idDevice=%#x cIovas=%zu\n", iommuAmdMemAccessGetPermName(fPerm), idDevice, cIovas)); 4352 4352 4353 4353 /** @todo IOMMU: IOTLB cache lookup. */ … … 4357 4357 { 4358 4358 size_t cbContig; 4359 int rc = iommuAmdDteLookup(pDevIns, uDevId, pauIovas[i], X86_PAGE_SIZE, fPerm, enmOp, &paGCPhysSpa[i], &cbContig);4359 int rc = iommuAmdDteLookup(pDevIns, idDevice, pauIovas[i], X86_PAGE_SIZE, fPerm, enmOp, &paGCPhysSpa[i], &cbContig); 4360 4360 if (RT_SUCCESS(rc)) 4361 4361 { /* likely */ } 4362 4362 else 4363 4363 { 4364 LogFunc(("Failed! uDevId=%#x uIova=%#RX64 fPerm=%u rc=%Rrc\n", uDevId, pauIovas[i], fPerm, rc));4364 LogFunc(("Failed! idDevice=%#x uIova=%#RX64 fPerm=%u rc=%Rrc\n", idDevice, pauIovas[i], fPerm, rc)); 4365 4365 return rc; 4366 4366 } … … 4384 4384 * @returns VBox status code. 4385 4385 * @param pDevIns The IOMMU device instance. 4386 * @param uDevIdThe device ID (bus, device, function).4386 * @param idDevice The device ID (bus, device, function). 4387 4387 * @param pDte The device table entry. 4388 4388 * @param GCPhysIn The source MSI address (used for reporting errors). … … 4393 4393 * @thread Any. 4394 4394 */ 4395 static int iommuAmdIrteRead(PPDMDEVINS pDevIns, uint16_t uDevId, PCDTE_T pDte, RTGCPHYS GCPhysIn, uint32_t uDataIn,4395 static int iommuAmdIrteRead(PPDMDEVINS pDevIns, uint16_t idDevice, PCDTE_T pDte, RTGCPHYS GCPhysIn, uint32_t uDataIn, 4396 4396 IOMMUOP enmOp, PIRTE_T pIrte) 4397 4397 { … … 4413 4413 4414 4414 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 4415 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, GCPhysIn, false /* fPresent */, false /* fRsvdNotZero */,4415 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, GCPhysIn, false /* fPresent */, false /* fRsvdNotZero */, 4416 4416 false /* fPermDenied */, enmOp, &EvtIoPageFault); 4417 4417 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault, … … 4440 4440 * @returns VBox status code. 4441 4441 * @param pDevIns The IOMMU instance data. 4442 * @param uDevIdThe device ID (bus, device, function).4442 * @param idDevice The device ID (bus, device, function). 4443 4443 * @param pDte The device table entry. 4444 4444 * @param enmOp The IOMMU operation being performed. … … 4448 4448 * @thread Any. 4449 4449 */ 4450 static int iommuAmdIntrRemap(PPDMDEVINS pDevIns, uint16_t uDevId, PCDTE_T pDte, IOMMUOP enmOp, PCMSIMSG pMsiIn,4450 static int iommuAmdIntrRemap(PPDMDEVINS pDevIns, uint16_t idDevice, PCDTE_T pDte, IOMMUOP enmOp, PCMSIMSG pMsiIn, 4451 4451 PMSIMSG pMsiOut) 4452 4452 { … … 4455 4455 IRTE_T Irte; 4456 4456 uint32_t const uMsiInData = pMsiIn->Data.u32; 4457 int rc = iommuAmdIrteRead(pDevIns, uDevId, pDte, pMsiIn->Addr.u64, uMsiInData, enmOp, &Irte);4457 int rc = iommuAmdIrteRead(pDevIns, idDevice, pDte, pMsiIn->Addr.u64, uMsiInData, enmOp, &Irte); 4458 4458 if (RT_SUCCESS(rc)) 4459 4459 { … … 4466 4466 iommuAmdIrteRemapMsi(pMsiIn, pMsiOut, &Irte); 4467 4467 #ifdef IOMMU_WITH_IRTE_CACHE 4468 iommuAmdIrteCacheAdd(pDevIns, uDevId, IOMMU_GET_IRTE_OFF(uMsiInData), &Irte);4468 iommuAmdIrteCacheAdd(pDevIns, idDevice, IOMMU_GET_IRTE_OFF(uMsiInData), &Irte); 4469 4469 #endif 4470 4470 return VINF_SUCCESS; … … 4473 4473 LogFunc(("Interrupt type (%#x) invalid -> IOPF\n", Irte.n.u3IntrType)); 4474 4474 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 4475 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, pMsiIn->Addr.u64, Irte.n.u1RemapEnable,4475 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, pMsiIn->Addr.u64, Irte.n.u1RemapEnable, 4476 4476 true /* fRsvdNotZero */, false /* fPermDenied */, enmOp, &EvtIoPageFault); 4477 4477 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, &Irte, enmOp, &EvtIoPageFault, … … 4482 4482 LogFunc(("Guest mode not supported -> IOPF\n")); 4483 4483 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 4484 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, pMsiIn->Addr.u64, Irte.n.u1RemapEnable,4484 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, pMsiIn->Addr.u64, Irte.n.u1RemapEnable, 4485 4485 true /* fRsvdNotZero */, false /* fPermDenied */, enmOp, &EvtIoPageFault); 4486 4486 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, &Irte, enmOp, &EvtIoPageFault, kIoPageFaultType_IrteRsvdNotZero); … … 4490 4490 LogFunc(("Remapping disabled -> IOPF\n")); 4491 4491 EVT_IO_PAGE_FAULT_T EvtIoPageFault; 4492 iommuAmdIoPageFaultEventInit( uDevId, pDte->n.u16DomainId, pMsiIn->Addr.u64, Irte.n.u1RemapEnable,4492 iommuAmdIoPageFaultEventInit(idDevice, pDte->n.u16DomainId, pMsiIn->Addr.u64, Irte.n.u1RemapEnable, 4493 4493 false /* fRsvdNotZero */, false /* fPermDenied */, enmOp, &EvtIoPageFault); 4494 4494 iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, &Irte, enmOp, &EvtIoPageFault, kIoPageFaultType_IrteRemapEn); … … 4505 4505 * @returns VBox status code. 4506 4506 * @param pDevIns The IOMMU instance data. 4507 * @param uDevIdThe device ID (bus, device, function).4507 * @param idDevice The device ID (bus, device, function). 4508 4508 * @param enmOp The IOMMU operation being performed. 4509 4509 * @param pMsiIn The source MSI. … … 4512 4512 * @thread Any. 4513 4513 */ 4514 static int iommuAmdIntrTableLookup(PPDMDEVINS pDevIns, uint16_t uDevId, IOMMUOP enmOp, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)4515 { 4516 LogFlowFunc((" uDevId=%#x (%#x:%#x:%#x) enmOp=%u\n", uDevId,4517 (( uDevId >> VBOX_PCI_BUS_SHIFT) & VBOX_PCI_BUS_MASK),4518 ((uDevId >> VBOX_PCI_DEVFN_DEV_SHIFT) & VBOX_PCI_DEVFN_DEV_MASK), (uDevId & VBOX_PCI_DEVFN_FUN_MASK),enmOp));4514 static int iommuAmdIntrTableLookup(PPDMDEVINS pDevIns, uint16_t idDevice, IOMMUOP enmOp, PCMSIMSG pMsiIn, PMSIMSG pMsiOut) 4515 { 4516 LogFlowFunc(("idDevice=%#x (%#x:%#x:%#x) enmOp=%u\n", idDevice, ((idDevice >> VBOX_PCI_BUS_SHIFT) & VBOX_PCI_BUS_MASK), 4517 ((idDevice >> VBOX_PCI_DEVFN_DEV_SHIFT) & VBOX_PCI_DEVFN_DEV_MASK), (idDevice & VBOX_PCI_DEVFN_FUN_MASK), 4518 enmOp)); 4519 4519 4520 4520 /* Read the device table entry from memory. */ 4521 4521 DTE_T Dte; 4522 int rc = iommuAmdDteRead(pDevIns, uDevId, enmOp, &Dte);4522 int rc = iommuAmdDteRead(pDevIns, idDevice, enmOp, &Dte); 4523 4523 if (RT_SUCCESS(rc)) 4524 4524 { 4525 4525 #ifdef IOMMU_WITH_IRTE_CACHE 4526 iommuAmdDteCacheAdd(pDevIns, uDevId, &Dte, 0 /* fFlags */);4526 iommuAmdDteCacheAdd(pDevIns, idDevice, &Dte, 0 /* fFlags */); 4527 4527 #endif 4528 4528 /* If the DTE is not valid, all interrupts are forwarded without remapping. */ … … 4538 4538 LogFunc(("Invalid reserved bits in DTE (u64[2]=%#RX64 u64[3]=%#RX64) -> Illegal DTE\n", fRsvd0, fRsvd1)); 4539 4539 EVT_ILLEGAL_DTE_T Event; 4540 iommuAmdIllegalDteEventInit( uDevId, pMsiIn->Addr.u64, true /* fRsvdNotZero */, enmOp, &Event);4540 iommuAmdIllegalDteEventInit(idDevice, pMsiIn->Addr.u64, true /* fRsvdNotZero */, enmOp, &Event); 4541 4541 iommuAmdIllegalDteEventRaise(pDevIns, enmOp, &Event, kIllegalDteType_RsvdNotZero); 4542 4542 return VERR_IOMMU_INTR_REMAP_FAILED; … … 4591 4591 NOREF(pThis); 4592 4592 4593 return iommuAmdIntrRemap(pDevIns, uDevId, &Dte, enmOp, pMsiIn, pMsiOut);4593 return iommuAmdIntrRemap(pDevIns, idDevice, &Dte, enmOp, pMsiIn, pMsiOut); 4594 4594 } 4595 4595 4596 4596 LogFunc(("Invalid interrupt table length %#x -> Illegal DTE\n", uIntrTabLen)); 4597 4597 EVT_ILLEGAL_DTE_T Event; 4598 iommuAmdIllegalDteEventInit( uDevId, pMsiIn->Addr.u64, false /* fRsvdNotZero */, enmOp, &Event);4598 iommuAmdIllegalDteEventInit(idDevice, pMsiIn->Addr.u64, false /* fRsvdNotZero */, enmOp, &Event); 4599 4599 iommuAmdIllegalDteEventRaise(pDevIns, enmOp, &Event, kIllegalDteType_RsvdIntTabLen); 4600 4600 return VERR_IOMMU_INTR_REMAP_FAILED; … … 4618 4618 LogFunc(("IntCtl mode invalid %#x -> Illegal DTE\n", uIntrCtrl)); 4619 4619 EVT_ILLEGAL_DTE_T Event; 4620 iommuAmdIllegalDteEventInit( uDevId, pMsiIn->Addr.u64, true /* fRsvdNotZero */, enmOp, &Event);4620 iommuAmdIllegalDteEventInit(idDevice, pMsiIn->Addr.u64, true /* fRsvdNotZero */, enmOp, &Event); 4621 4621 iommuAmdIllegalDteEventRaise(pDevIns, enmOp, &Event, kIllegalDteType_RsvdIntCtl); 4622 4622 return VERR_IOMMU_INTR_REMAP_FAILED; … … 4671 4671 } 4672 4672 4673 LogFunc(("Failed to read device table entry. uDevId=%#x rc=%Rrc\n", uDevId, rc));4673 LogFunc(("Failed to read device table entry. idDevice=%#x rc=%Rrc\n", idDevice, rc)); 4674 4674 return VERR_IOMMU_INTR_REMAP_FAILED; 4675 4675 } … … 4681 4681 * @returns VBox status code. 4682 4682 * @param pDevIns The IOMMU device instance. 4683 * @param uDevIdThe device ID (bus, device, function).4683 * @param idDevice The device ID (bus, device, function). 4684 4684 * @param pMsiIn The source MSI. 4685 4685 * @param pMsiOut Where to store the remapped MSI. 4686 4686 */ 4687 static DECLCALLBACK(int) iommuAmdMsiRemap(PPDMDEVINS pDevIns, uint16_t uDevId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)4687 static DECLCALLBACK(int) iommuAmdMsiRemap(PPDMDEVINS pDevIns, uint16_t idDevice, PCMSIMSG pMsiIn, PMSIMSG pMsiOut) 4688 4688 { 4689 4689 /* Validate. */ … … 4703 4703 #ifdef IOMMU_WITH_IRTE_CACHE 4704 4704 STAM_PROFILE_ADV_START(&pThis->StatProfIrteCacheLookup, a); 4705 rc = iommuAmdIrteCacheLookup(pDevIns, uDevId, IOMMUOP_INTR_REQ, pMsiIn, pMsiOut);4705 rc = iommuAmdIrteCacheLookup(pDevIns, idDevice, IOMMUOP_INTR_REQ, pMsiIn, pMsiOut); 4706 4706 STAM_PROFILE_ADV_STOP(&pThis->StatProfIrteCacheLookup, a); 4707 4707 if (RT_SUCCESS(rc)) … … 4714 4714 4715 4715 STAM_PROFILE_ADV_START(&pThis->StatProfIrteLookup, a); 4716 rc = iommuAmdIntrTableLookup(pDevIns, uDevId, IOMMUOP_INTR_REQ, pMsiIn, pMsiOut);4716 rc = iommuAmdIntrTableLookup(pDevIns, idDevice, IOMMUOP_INTR_REQ, pMsiIn, pMsiOut); 4717 4717 STAM_PROFILE_ADV_STOP(&pThis->StatProfIrteLookup, a); 4718 4718 return rc; … … 4859 4859 #ifdef IOMMU_WITH_IOTLBE_CACHE 4860 4860 uint64_t const uIova = RT_MAKE_U64(pCmdInvPages->n.u20AddrLo << X86_PAGE_4K_SHIFT, pCmdInvPages->n.u32AddrHi); 4861 uint16_t const uDomainId= pCmdInvPages->n.u16DomainId;4861 uint16_t const idDomain = pCmdInvPages->n.u16DomainId; 4862 4862 bool const fFlushPde = pCmdInvPages->n.u1PageDirEntries; 4863 4863 uint8_t cShift; … … 4893 4893 { 4894 4894 /* Remove the range of I/O virtual addresses requesting to be invalidated. */ 4895 size_t const cb Access= RT_BIT_64(cShift);4896 iommuAmdIotlbRemoveRange(pDevIns, uDomainId, uIova, cbAccess);4895 size_t const cbIova = RT_BIT_64(cShift); 4896 iommuAmdIotlbRemoveRange(pDevIns, idDomain, uIova, cbIova); 4897 4897 } 4898 4898 else … … 4902 4902 * In such situations we must remove all ranges for the specified domain ID. 4903 4903 */ 4904 iommuAmdIotlbRemoveDomainId(pDevIns, uDomainId);4904 iommuAmdIotlbRemoveDomainId(pDevIns, idDomain); 4905 4905 } 4906 4906 #endif … … 5932 5932 if (pszArgs) 5933 5933 { 5934 uint16_t uDevId= 0;5935 int rc = RTStrToUInt16Full(pszArgs, 0 /* uBase */, & uDevId);5934 uint16_t idDevice = 0; 5935 int rc = RTStrToUInt16Full(pszArgs, 0 /* uBase */, &idDevice); 5936 5936 if (RT_SUCCESS(rc)) 5937 5937 { 5938 5938 DTE_T Dte; 5939 rc = iommuAmdDteRead(pDevIns, uDevId, IOMMUOP_TRANSLATE_REQ, &Dte);5939 rc = iommuAmdDteRead(pDevIns, idDevice, IOMMUOP_TRANSLATE_REQ, &Dte); 5940 5940 if (RT_SUCCESS(rc)) 5941 5941 { 5942 pHlp->pfnPrintf(pHlp, "DTE for device %#x\n", uDevId);5942 pHlp->pfnPrintf(pHlp, "DTE for device %#x\n", idDevice); 5943 5943 iommuAmdR3DbgInfoDteWorker(pHlp, &Dte, " "); 5944 5944 return; 5945 5945 } 5946 pHlp->pfnPrintf(pHlp, "Failed to read DTE for device ID %u (%#x). rc=%Rrc\n", uDevId, uDevId, rc);5946 pHlp->pfnPrintf(pHlp, "Failed to read DTE for device ID %u (%#x). rc=%Rrc\n", idDevice, idDevice, rc); 5947 5947 } 5948 5948 else … … 5968 5968 for (uint16_t i = 0; i < cDteCache; i++) 5969 5969 { 5970 uint16_t const uDeviceId= pThis->aDeviceIds[i];5971 if ( uDeviceId)5972 { 5973 pHlp->pfnPrintf(pHlp, " Entry[%u]: Device=%#x (BDF %02x:%02x.%d)\n", i, uDeviceId,5974 ( uDeviceId>> VBOX_PCI_BUS_SHIFT) & VBOX_PCI_BUS_MASK,5975 ( uDeviceId>> VBOX_PCI_DEVFN_DEV_SHIFT) & VBOX_PCI_DEVFN_DEV_MASK,5976 uDeviceId& VBOX_PCI_DEVFN_FUN_MASK);5970 uint16_t const idDevice = pThis->aDeviceIds[i]; 5971 if (idDevice) 5972 { 5973 pHlp->pfnPrintf(pHlp, " Entry[%u]: Device=%#x (BDF %02x:%02x.%d)\n", i, idDevice, 5974 (idDevice >> VBOX_PCI_BUS_SHIFT) & VBOX_PCI_BUS_MASK, 5975 (idDevice >> VBOX_PCI_DEVFN_DEV_SHIFT) & VBOX_PCI_DEVFN_DEV_MASK, 5976 idDevice & VBOX_PCI_DEVFN_FUN_MASK); 5977 5977 5978 5978 PCDTECACHE pDteCache = &pThis->aDteCache[i]; 5979 5979 pHlp->pfnPrintf(pHlp, " Flags = %#x\n", pDteCache->fFlags); 5980 pHlp->pfnPrintf(pHlp, " Domain Id = %u\n", pDteCache-> uDomainId);5980 pHlp->pfnPrintf(pHlp, " Domain Id = %u\n", pDteCache->idDomain); 5981 5981 pHlp->pfnPrintf(pHlp, "\n"); 5982 5982 } … … 5995 5995 if (pszArgs) 5996 5996 { 5997 uint16_t uDomainId= 0;5998 int rc = RTStrToUInt16Full(pszArgs, 0 /* uBase */, & uDomainId);5997 uint16_t idDomain = 0; 5998 int rc = RTStrToUInt16Full(pszArgs, 0 /* uBase */, &idDomain); 5999 5999 if (RT_SUCCESS(rc)) 6000 6000 { 6001 pHlp->pfnPrintf(pHlp, "IOTLBEs for domain %u (%#x):\n", uDomainId, uDomainId);6001 pHlp->pfnPrintf(pHlp, "IOTLBEs for domain %u (%#x):\n", idDomain, idDomain); 6002 6002 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 6003 6003 PIOMMUR3 pThisR3 = PDMDEVINS_2_DATA_CC(pDevIns, PIOMMUR3); 6004 6004 IOTLBEINFOARG Args; 6005 Args.pIommuR3 6006 Args.pHlp 6007 Args. uDomainId = uDomainId;6005 Args.pIommuR3 = pThisR3; 6006 Args.pHlp = pHlp; 6007 Args.idDomain = idDomain; 6008 6008 6009 6009 IOMMU_LOCK_CACHE_NORET(pDevIns, pThis); … … 6056 6056 if (uKey != IOMMU_IRTE_CACHE_KEY_NIL) 6057 6057 { 6058 uint16_t const uDeviceId= IOMMU_IRTE_CACHE_KEY_GET_DEVICE_ID(uKey);6059 uint16_t const offIrte 6058 uint16_t const idDevice = IOMMU_IRTE_CACHE_KEY_GET_DEVICE_ID(uKey); 6059 uint16_t const offIrte = IOMMU_IRTE_CACHE_KEY_GET_OFF(uKey); 6060 6060 pHlp->pfnPrintf(pHlp, " Entry[%u]: Offset=%#x Device=%#x (BDF %02x:%02x.%d)\n", 6061 idxIrte, offIrte, uDeviceId,6062 ( uDeviceId>> VBOX_PCI_BUS_SHIFT) & VBOX_PCI_BUS_MASK,6063 ( uDeviceId>> VBOX_PCI_DEVFN_DEV_SHIFT) & VBOX_PCI_DEVFN_DEV_MASK,6064 uDeviceId& VBOX_PCI_DEVFN_FUN_MASK);6061 idxIrte, offIrte, idDevice, 6062 (idDevice >> VBOX_PCI_BUS_SHIFT) & VBOX_PCI_BUS_MASK, 6063 (idDevice >> VBOX_PCI_DEVFN_DEV_SHIFT) & VBOX_PCI_DEVFN_DEV_MASK, 6064 idDevice & VBOX_PCI_DEVFN_FUN_MASK); 6065 6065 6066 6066 PCIRTE_T pIrte = &pIrteCache->Irte;
Note:
See TracChangeset
for help on using the changeset viewer.