VirtualBox

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


Ignore:
Timestamp:
Mar 2, 2021 6:14:39 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142992
Message:

AMD IOMMU: bugref:9654 Naming cleanup (uDeviceId -> idDevice etc.)

File:
1 edited

Legend:

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

    r87894 r87906  
    286286    uint16_t        fFlags;
    287287    /** The domain ID assigned for this device by software. */
    288     uint16_t        uDomainId;
     288    uint16_t        idDomain;
    289289} DTECACHE;
    290290/** Pointer to an I/O device struct. */
     
    646646    PIOMMUR3            pIommuR3;
    647647    /** The domain ID to flush. */
    648     uint16_t            uDomainId;
     648    uint16_t            idDomain;
    649649} IOTLBEFLUSHARG;
    650650/** Pointer to an IOTLBE flush argument. */
     
    663663    PCDBGFINFOHLP       pHlp;
    664664    /** The domain ID to dump IOTLB entry. */
    665     uint16_t            uDomainId;
     665    uint16_t            idDomain;
    666666} IOTLBEINFOARG;
    667667/** Pointer to an IOTLBE flush argument. */
     
    680680    /** The device table entry (can be NULL). */
    681681    PCDTE_T         pDte;
    682     /** The device ID. */
    683     uint16_t        uDeviceId;
     682    /** The device ID (bus, device, function). */
     683    uint16_t        idDevice;
    684684    /** The domain ID (when the DTE isn't provided). */
    685     uint16_t        uDomainId;
     685    uint16_t        idDomain;
    686686} IOMMUOPAUX;
    687687/** Pointer to an I/O address lookup struct. */
     
    882882 *
    883883 * @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   uDevId  The 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 */
     887DECLINLINE(uint16_t) iommuAmdDteCacheEntryLookup(PIOMMU pThis, uint16_t idDevice)
    888888{
    889889    uint16_t const cDeviceIds = RT_ELEMENTS(pThis->aDeviceIds);
    890890    for (uint16_t i = 0; i < cDeviceIds; i++)
    891891    {
    892         if (pThis->aDeviceIds[i] == uDevId)
     892        if (pThis->aDeviceIds[i] == idDevice)
    893893            return i;
    894894    }
     
    926926 *
    927927 * @param   pDevIns     The IOMMU instance data.
    928  * @param   uDevId      The device ID (bus, device, function).
     928 * @param   idDevice    The device ID (bus, device, function).
    929929 * @param   pDte        The device table entry.
    930930 * @param   fOrMask     The device flags (usually compound flags) to OR in with the
    931931 *                      basic flags, see IOMMU_DTE_CACHE_F_XXX.
    932932 */
    933 static int iommuAmdDteCacheAdd(PPDMDEVINS pDevIns, uint16_t uDevId, PCDTE_T pDte, uint16_t fOrMask)
     933static int iommuAmdDteCacheAdd(PPDMDEVINS pDevIns, uint16_t idDevice, PCDTE_T pDte, uint16_t fOrMask)
    934934{
    935935    Assert(pDte);
    936     Assert(uDevId);
     936    Assert(idDevice);
    937937
    938938    int rc = VINF_SUCCESS;
    939     uint16_t const fFlags    = iommuAmdGetBasicDevFlags(pDte) | IOMMU_DTE_CACHE_F_PRESENT | fOrMask;
    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;
    941941
    942942    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
     
    944944
    945945    uint16_t const cDteCache = RT_ELEMENTS(pThis->aDteCache);
    946     uint16_t idxDte = iommuAmdDteCacheEntryLookup(pThis, uDevId);
     946    uint16_t idxDte = iommuAmdDteCacheEntryLookup(pThis, idDevice);
    947947    if (idxDte < cDteCache)
    948948    {
    949         pThis->aDteCache[idxDte].fFlags    = fFlags;
    950         pThis->aDteCache[idxDte].uDomainId = uDomainId;
     949        pThis->aDteCache[idxDte].fFlags   = fFlags;
     950        pThis->aDteCache[idxDte].idDomain = idDomain;
    951951    }
    952952    else if ((idxDte = iommuAmdDteCacheEntryGetUnused(pThis)) < cDteCache)
    953953    {
    954         pThis->aDeviceIds[idxDte] = uDevId;
    955         pThis->aDteCache[idxDte].fFlags    = fFlags;
    956         pThis->aDteCache[idxDte].uDomainId = uDomainId;
     954        pThis->aDeviceIds[idxDte] = idDevice;
     955        pThis->aDteCache[idxDte].fFlags   = fFlags;
     956        pThis->aDteCache[idxDte].idDomain = idDomain;
    957957    }
    958958    else
     
    968968 *
    969969 * @param   pDevIns     The IOMMU instance data.
    970  * @param   uDevId      The device ID (bus, device, function).
     970 * @param   idDevice    The device ID (bus, device, function).
    971971 * @param   fFlags      Additional device flags to OR with existing flags, see
    972972 *                      IOMMU_DTE_CACHE_F_XXX.
    973973 */
    974 static void iommuAmdDteCacheAddFlags(PPDMDEVINS pDevIns, uint16_t uDevId, uint16_t fFlags)
     974static void iommuAmdDteCacheAddFlags(PPDMDEVINS pDevIns, uint16_t idDevice, uint16_t fFlags)
    975975{
    976976    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
     
    978978
    979979    uint16_t const cDteCache = RT_ELEMENTS(pThis->aDteCache);
    980     uint16_t const idxDte = iommuAmdDteCacheEntryLookup(pThis, uDevId);
     980    uint16_t const idxDte = iommuAmdDteCacheEntryLookup(pThis, idDevice);
    981981    if (   idxDte < cDteCache
    982982        && (pThis->aDteCache[idxDte].fFlags & IOMMU_DTE_CACHE_F_PRESENT))
     
    991991 *
    992992 * @param   pDevIns     The IOMMU instance data.
    993  * @param   uDevId      The 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 */
     995static void iommuAmdDteCacheRemove(PPDMDEVINS pDevIns, uint16_t idDevice)
    996996{
    997997    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
     
    999999
    10001000    uint16_t const cDteCache = RT_ELEMENTS(pThis->aDteCache);
    1001     uint16_t const idxDte    = iommuAmdDteCacheEntryLookup(pThis, uDevId);
     1001    uint16_t const idxDte    = iommuAmdDteCacheEntryLookup(pThis, idDevice);
    10021002    if (idxDte < cDteCache)
    10031003    {
    1004         pThis->aDteCache[idxDte].fFlags    = 0;
    1005         pThis->aDteCache[idxDte].uDomainId = 0;
     1004        pThis->aDteCache[idxDte].fFlags   = 0;
     1005        pThis->aDteCache[idxDte].idDomain = 0;
    10061006    }
    10071007
     
    10761076    //Assert(pArgs->pIommuCC->u32Magic == IOMMU_MAGIC);
    10771077
    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)
    10801080    {
    10811081        PCIOTLBE pIotlbe = (PCIOTLBE)pNode;
     
    11171117    //Assert(pArgs->pIommuR3->u32Magic == IOMMU_MAGIC);
    11181118
    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)
    11211121    {
    11221122        /* Mark this entry is as invalidated and needs to be evicted later. */
     
    11351135 * @param   pThisR3         The ring-3 IOMMU device state.
    11361136 * @param   pIotlbe         The IOTLB entry to initialize and insert.
    1137  * @param   uDomainId       The domain ID.
     1137 * @param   idDomain        The domain ID.
    11381138 * @param   uIova           The I/O virtual address.
    11391139 * @param   pPageLookup     The I/O page lookup result of the access.
    11401140 */
    1141 static void iommuAmdIotlbEntryInsert(PIOMMU pThis, PIOMMUR3 pThisR3, PIOTLBE pIotlbe, uint16_t uDomainId, uint64_t uIova,
     1141static void iommuAmdIotlbEntryInsert(PIOMMU pThis, PIOMMUR3 pThisR3, PIOTLBE pIotlbe, uint16_t idDomain, uint64_t uIova,
    11421142                                     PCIOPAGELOOKUP pPageLookup)
    11431143{
    11441144    /* 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);
    11461146    pIotlbe->PageLookup = *pPageLookup;
    11471147
     
    12131213 * @param   pThis       The shared IOMMU device state.
    12141214 * @param   pThisR3     The ring-3 IOMMU device state.
    1215  * @param   uDomainId   The domain ID.
     1215 * @param   idDomain    The domain ID.
    12161216 * @param   uIova       The I/O virtual address.
    12171217 */
    1218 static PIOTLBE iommuAmdIotlbLookup(PIOMMU pThis, PIOMMUR3 pThisR3, uint64_t uDomainId, uint64_t uIova)
     1218static PIOTLBE iommuAmdIotlbLookup(PIOMMU pThis, PIOMMUR3 pThisR3, uint64_t idDomain, uint64_t uIova)
    12191219{
    12201220    RT_NOREF(pThis);
    12211221
    1222     uint64_t const uKey = IOMMU_IOTLB_KEY_MAKE(uDomainId, uIova);
     1222    uint64_t const uKey = IOMMU_IOTLB_KEY_MAKE(idDomain, uIova);
    12231223    PIOTLBE pIotlbe = (PIOTLBE)RTAvlU64Get(&pThisR3->TreeIotlbe, uKey);
    12241224    if (    pIotlbe
     
    12401240 * @param   pThis           The shared IOMMU device state.
    12411241 * @param   pThis           The ring-3 IOMMU device state.
    1242  * @param   uDomainId       The domain ID.
     1242 * @param   idDomain        The domain ID.
    12431243 * @param   uIova           The I/O virtual address.
    12441244 * @param   pPageLookup     The I/O page lookup result of the access.
    12451245 */
    1246 static void iommuAmdIotlbAdd(PIOMMU pThis, PIOMMUR3 pThisR3, uint16_t uDomainId, uint64_t uIova, PCIOPAGELOOKUP pPageLookup)
     1246static void iommuAmdIotlbAdd(PIOMMU pThis, PIOMMUR3 pThisR3, uint16_t idDomain, uint64_t uIova, PCIOPAGELOOKUP pPageLookup)
    12471247{
    12481248    Assert(!(uIova & X86_PAGE_4K_OFFSET_MASK));
     
    12661266
    12671267        /* 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);
    12691269
    12701270        /* Move the entry to the most recently used slot. */
     
    12781278
    12791279        /* 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);
    12811281
    12821282        /* Add the entry to the most recently used slot. */
     
    13161316 *
    13171317 * @param   pDevIns         The IOMMU instance data.
    1318  * @param   uDomainId       The domain ID.
     1318 * @param   idDomain        The domain ID.
    13191319 * @param   uIova           The I/O virtual address to invalidate.
    13201320 * @param   cbInvalidate    The size of the invalidation (must be 4K aligned).
    13211321 */
    1322 static void iommuAmdIotlbRemoveRange(PPDMDEVINS pDevIns, uint16_t uDomainId, uint64_t uIova, size_t cbInvalidate)
     1322static void iommuAmdIotlbRemoveRange(PPDMDEVINS pDevIns, uint16_t idDomain, uint64_t uIova, size_t cbInvalidate)
    13231323{
    13241324    /* Validate. */
     
    13331333    do
    13341334    {
    1335         uint64_t const uKey = IOMMU_IOTLB_KEY_MAKE(uDomainId, uIova);
     1335        uint64_t const uKey = IOMMU_IOTLB_KEY_MAKE(idDomain, uIova);
    13361336        PIOTLBE pIotlbe = iommuAmdIotlbEntryRemove(pThis, pThisR3, uKey);
    13371337        if (pIotlbe)
     
    13491349 *
    13501350 * @param   pDevIns     The IOMMU instance data.
    1351  * @param   uDomainId   The domain ID.
    1352  */
    1353 static void iommuAmdIotlbRemoveDomainId(PPDMDEVINS pDevIns, uint16_t uDomainId)
     1351 * @param   idDomain    The domain ID.
     1352 */
     1353static void iommuAmdIotlbRemoveDomainId(PPDMDEVINS pDevIns, uint16_t idDomain)
    13541354{
    13551355    /*
     
    13641364
    13651365    IOTLBEFLUSHARG Args;
    1366     Args.pIommuR3  = pThisR3;
    1367     Args.uDomainId = uDomainId;
     1366    Args.pIommuR3 = pThisR3;
     1367    Args.idDomain = idDomain;
    13681368    RTAvlU64DoWithAll(&pThisR3->TreeIotlbe, true /* fFromLeft */, iommuAmdIotlbEntryRemoveDomainId, &Args);
    13691369
     
    13761376 *
    13771377 * @param   pDevIns     The IOMMU instance data.
    1378  * @param   uDomainId   The domain ID.
     1378 * @param   idDomain    The domain ID.
    13791379 * @param   uIova       The I/O virtual address.
    1380  * @param   cbAccess    The size of the access (must be 4K aligned).
     1380 * @param   cbIova      The size of the access (must be 4K aligned).
    13811381 * @param   GCPhysSpa   The translated system-physical address.
    13821382 * @param   fPerm       The I/O permissions for the access, see IOMMU_IO_PERM_XXX.
    13831383 */
    1384 static void iommuAmdIotlbAddRange(PPDMDEVINS pDevIns, uint16_t uDomainId, uint64_t uIova, size_t cbAccess, RTGCPHYS GCPhysSpa,
     1384static void iommuAmdIotlbAddRange(PPDMDEVINS pDevIns, uint16_t idDomain, uint64_t uIova, size_t cbIova, RTGCPHYS GCPhysSpa,
    13851385                                  uint8_t fPerm)
    13861386{
    13871387    Assert(!(uIova & X86_PAGE_4K_OFFSET_MASK));
    13881388    Assert(!(GCPhysSpa & X86_PAGE_4K_OFFSET_MASK));
    1389     Assert(!(cbAccess & X86_PAGE_4K_OFFSET_MASK));
    1390     Assert(cbAccess >= X86_PAGE_4K_SIZE);
     1389    Assert(!(cbIova & X86_PAGE_4K_OFFSET_MASK));
     1390    Assert(cbIova >= X86_PAGE_4K_SIZE);
    13911391
    13921392    PIOMMU   pThis   = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
     
    14001400    PageLookup.GCPhysSpa = GCPhysSpa;
    14011401
    1402     size_t cPages = cbAccess / X86_PAGE_4K_SIZE;
     1402    size_t cPages = cbIova / X86_PAGE_4K_SIZE;
    14031403    cPages = RT_MIN(cPages, IOMMU_IOTLBE_MAX);
    14041404
     
    14071407    do
    14081408    {
    1409         iommuAmdIotlbAdd(pThis, pThisR3, uDomainId, uIova, &PageLookup);
     1409        iommuAmdIotlbAdd(pThis, pThisR3, idDomain, uIova, &PageLookup);
    14101410        uIova                += X86_PAGE_4K_SIZE;
    14111411        PageLookup.GCPhysSpa += X86_PAGE_4K_SIZE;
     
    14231423 * @returns Index of the found entry, or cache capacity if not found.
    14241424 * @param   pThis       The shared IOMMU device state.
    1425  * @param   uDevId      The device ID (bus, device, function).
     1425 * @param   idDevice    The device ID (bus, device, function).
    14261426 * @param   offIrte     The offset into the interrupt remap table.
    14271427 */
    1428 static uint16_t iommuAmdIrteCacheEntryLookup(PCIOMMU pThis, uint16_t uDevId, uint16_t offIrte)
     1428static uint16_t iommuAmdIrteCacheEntryLookup(PCIOMMU pThis, uint16_t idDevice, uint16_t offIrte)
    14291429{
    14301430    /** @todo Consider sorting and binary search when the cache capacity grows.
     
    14321432     *  interrupt remapping once programmed, so hopefully sorting shouldn't happen
    14331433     *  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);
    14351435    uint16_t const cIrteCache = RT_ELEMENTS(pThis->aIrteCache);
    14361436    for (uint16_t i = 0; i < cIrteCache; i++)
     
    14651465 * @returns VBox status code.
    14661466 * @param   pDevIns     The IOMMU instance data.
    1467  * @param   uDevId      The device ID (bus, device, function).
     1467 * @param   idDevice    The device ID (bus, device, function).
    14681468 * @param   enmOp       The IOMMU operation being performed.
    14691469 * @param   pMsiIn      The source MSI.
    14701470 * @param   pMsiOut     Where to store the remapped MSI.
    14711471 */
    1472 static int iommuAmdIrteCacheLookup(PPDMDEVINS pDevIns, uint16_t uDevId, IOMMUOP enmOp, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)
     1472static int iommuAmdIrteCacheLookup(PPDMDEVINS pDevIns, uint16_t idDevice, IOMMUOP enmOp, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)
    14731473{
    14741474    RT_NOREF(enmOp); /* May need it if we have to report errors (currently we fallback to the slower path to do that). */
     
    14841484    IOMMU_LOCK_CACHE_NORET(pDevIns, pThis);
    14851485
    1486     uint16_t const idxDteCache = iommuAmdDteCacheEntryLookup(pThis, uDevId);
     1486    uint16_t const idxDteCache = iommuAmdDteCacheEntryLookup(pThis, idDevice);
    14871487    if (idxDteCache < RT_ELEMENTS(pThis->aDteCache))
    14881488    {
     
    15031503                    /* Interrupt table length has been verified prior to adding entries to the cache. */
    15041504                    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);
    15061506                    if (idxIrteCache < RT_ELEMENTS(pThis->aIrteCache))
    15071507                    {
     
    15391539 *
    15401540 * @param   pDevIns     The IOMMU instance data.
    1541  * @param   uDevId      The device ID (bus, device, function).
     1541 * @param   idDevice    The device ID (bus, device, function).
    15421542 * @param   offIrte     The offset into the interrupt remap table.
    15431543 * @param   pIrte       The IRTE to cache.
    15441544 */
    1545 static int iommuAmdIrteCacheAdd(PPDMDEVINS pDevIns, uint16_t uDevId, uint16_t offIrte, PCIRTE_T pIrte)
     1545static int iommuAmdIrteCacheAdd(PPDMDEVINS pDevIns, uint16_t idDevice, uint16_t offIrte, PCIRTE_T pIrte)
    15461546{
    15471547    Assert(offIrte != 0xffff);  /* Shouldn't be a valid IRTE table offset since sizeof(IRTE) is a multiple of 4. */
     
    15531553    /* Find an existing entry or get an unused slot. */
    15541554    uint16_t const cIrteCache = RT_ELEMENTS(pThis->aIrteCache);
    1555     uint16_t idxIrteCache     = iommuAmdIrteCacheEntryLookup(pThis, uDevId, offIrte);
     1555    uint16_t idxIrteCache     = iommuAmdIrteCacheEntryLookup(pThis, idDevice, offIrte);
    15561556    if (   idxIrteCache < cIrteCache
    15571557        || (idxIrteCache = iommuAmdIrteCacheEntryGetUnused(pThis)) < cIrteCache)
    15581558    {
    1559         pThis->aIrteCache[idxIrteCache].uKey = IOMMU_IRTE_CACHE_KEY_MAKE(uDevId, offIrte);
     1559        pThis->aIrteCache[idxIrteCache].uKey = IOMMU_IRTE_CACHE_KEY_MAKE(idDevice, offIrte);
    15601560        pThis->aIrteCache[idxIrteCache].Irte = *pIrte;
    15611561    }
     
    15721572 *
    15731573 * @param   pDevIns     The IOMMU instance data.
    1574  * @param   uDevId      The 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 */
     1576static void iommuAmdIrteCacheRemove(PPDMDEVINS pDevIns, uint16_t idDevice)
    15771577{
    15781578    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
     
    15821582    {
    15831583        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))
    15851585        {
    15861586            pIrteCache->uKey     = IOMMU_IRTE_CACHE_KEY_NIL;
     
    26722672    }
    26732673    else
    2674         return NULL;
     2674        pReg = NULL;
    26752675    return pReg;
    26762676}
     
    29862986 * Initializes a PAGE_TAB_HARDWARE_ERROR event.
    29872987 *
    2988  * @param   uDevId              The device ID (bus, device, function).
    2989  * @param   uDomainId           The domain ID.
     2988 * @param   idDevice            The device ID (bus, device, function).
     2989 * @param   idDomain            The domain ID.
    29902990 * @param   GCPhysPtEntity      The system physical address of the page table
    29912991 *                              entity.
     
    29932993 * @param   pEvtPageTabHwErr    Where to store the initialized event.
    29942994 */
    2995 static void iommuAmdPageTabHwErrorEventInit(uint16_t uDevId, uint16_t uDomainId, RTGCPHYS GCPhysPtEntity, IOMMUOP enmOp,
     2995static void iommuAmdPageTabHwErrorEventInit(uint16_t idDevice, uint16_t idDomain, RTGCPHYS GCPhysPtEntity, IOMMUOP enmOp,
    29962996                                            PEVT_PAGE_TAB_HW_ERR_T pEvtPageTabHwErr)
    29972997{
    29982998    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;
    30013001    pEvtPageTabHwErr->n.u1GuestOrNested    = 0;
    30023002    pEvtPageTabHwErr->n.u1Interrupt        = RT_BOOL(enmOp == IOMMUOP_INTR_REQ);
     
    30333033    IOMMU_UNLOCK(pDevIns, pThisCC);
    30343034
    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",
    30363036         pEvtPageTabHwErr->n.u16DevId, pEvtPageTabHwErr->n.u16DomainOrPasidLo, pEvtPageTabHwErr->n.u64Addr, enmOp,
    30373037         pEvtPageTabHwErr->n.u2Type));
     
    30863086 * Initializes a DEV_TAB_HARDWARE_ERROR event.
    30873087 *
    3088  * @param   uDevId              The device ID (bus, device, function).
     3088 * @param   idDevice            The device ID (bus, device, function).
    30893089 * @param   GCPhysDte           The system physical address of the failed device table
    30903090 *                              access.
     
    30923092 * @param   pEvtDevTabHwErr     Where to store the initialized event.
    30933093 */
    3094 static void iommuAmdDevTabHwErrorEventInit(uint16_t uDevId, RTGCPHYS GCPhysDte, IOMMUOP enmOp,
     3094static void iommuAmdDevTabHwErrorEventInit(uint16_t idDevice, RTGCPHYS GCPhysDte, IOMMUOP enmOp,
    30953095                                           PEVT_DEV_TAB_HW_ERROR_T pEvtDevTabHwErr)
    30963096{
    30973097    memset(pEvtDevTabHwErr, 0, sizeof(*pEvtDevTabHwErr));
    3098     pEvtDevTabHwErr->n.u16DevId      = uDevId;
     3098    pEvtDevTabHwErr->n.u16DevId      = idDevice;
    30993099    pEvtDevTabHwErr->n.u1Intr        = RT_BOOL(enmOp == IOMMUOP_INTR_REQ);
    31003100    /** @todo IOMMU: Any other transaction type that can set read/write bit? */
     
    31313131    IOMMU_UNLOCK(pDevIns, pThisCC);
    31323132
    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,
    31343134             pEvtDevTabHwErr->n.u64Addr, enmOp, pEvtDevTabHwErr->n.u2Type));
    31353135}
     
    31763176 * Initializes an ILLEGAL_DEV_TABLE_ENTRY event.
    31773177 *
    3178  * @param   uDevId          The device ID (bus, device, function).
     3178 * @param   idDevice        The device ID (bus, device, function).
    31793179 * @param   uIova           The I/O virtual address.
    31803180 * @param   fRsvdNotZero    Whether reserved bits are not zero. Pass @c false if the
     
    31843184 * @param   pEvtIllegalDte  Where to store the initialized event.
    31853185 */
    3186 static void iommuAmdIllegalDteEventInit(uint16_t uDevId, uint64_t uIova, bool fRsvdNotZero, IOMMUOP enmOp,
     3186static void iommuAmdIllegalDteEventInit(uint16_t idDevice, uint64_t uIova, bool fRsvdNotZero, IOMMUOP enmOp,
    31873187                                        PEVT_ILLEGAL_DTE_T pEvtIllegalDte)
    31883188{
    31893189    memset(pEvtIllegalDte, 0, sizeof(*pEvtIllegalDte));
    3190     pEvtIllegalDte->n.u16DevId      = uDevId;
     3190    pEvtIllegalDte->n.u16DevId      = idDevice;
    31913191    pEvtIllegalDte->n.u1Interrupt   = RT_BOOL(enmOp == IOMMUOP_INTR_REQ);
    31923192    pEvtIllegalDte->n.u1ReadWrite   = RT_BOOL(enmOp == IOMMUOP_MEM_WRITE);
     
    32213221        iommuAmdSetPciTargetAbort(pDevIns);
    32223222
    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,
    32243224             pEvtIllegalDte->n.u64Addr, enmOp, enmEvtType));
    32253225    NOREF(enmEvtType);
     
    32303230 * Initializes an IO_PAGE_FAULT event.
    32313231 *
    3232  * @param   uDevId              The device ID (bus, device, function).
    3233  * @param   uDomainId           The domain ID.
     3232 * @param   idDevice            The device ID (bus, device, function).
     3233 * @param   idDomain            The domain ID.
    32343234 * @param   uIova               The I/O virtual address being accessed.
    32353235 * @param   fPresent            Transaction to a page marked as present (including
     
    32433243 * @param   pEvtIoPageFault     Where to store the initialized event.
    32443244 */
    3245 static void iommuAmdIoPageFaultEventInit(uint16_t uDevId, uint16_t uDomainId, uint64_t uIova, bool fPresent, bool fRsvdNotZero,
     3245static void iommuAmdIoPageFaultEventInit(uint16_t idDevice, uint16_t idDomain, uint64_t uIova, bool fPresent, bool fRsvdNotZero,
    32463246                                         bool fPermDenied, IOMMUOP enmOp, PEVT_IO_PAGE_FAULT_T pEvtIoPageFault)
    32473247{
    32483248    Assert(!fPermDenied || fPresent);
    32493249    memset(pEvtIoPageFault, 0, sizeof(*pEvtIoPageFault));
    3250     pEvtIoPageFault->n.u16DevId            = uDevId;
     3250    pEvtIoPageFault->n.u16DevId            = idDevice;
    32513251    //pEvtIoPageFault->n.u4PasidHi         = 0;
    3252     pEvtIoPageFault->n.u16DomainOrPasidLo  = uDomainId;
     3252    pEvtIoPageFault->n.u16DomainOrPasidLo  = idDomain;
    32533253    //pEvtIoPageFault->n.u1GuestOrNested   = 0;
    32543254    //pEvtIoPageFault->n.u1NoExecute       = 0;
     
    34303430 * @returns VBox status code.
    34313431 * @param   pDevIns     The IOMMU device instance.
    3432  * @param   uDevId      The device ID (bus, device, function).
     3432 * @param   idDevice    The device ID (bus, device, function).
    34333433 * @param   enmOp       The IOMMU operation being performed.
    34343434 * @param   pDte        Where to store the device table entry.
     
    34363436 * @thread  Any.
    34373437 */
    3438 static int iommuAmdDteRead(PPDMDEVINS pDevIns, uint16_t uDevId, IOMMUOP enmOp, PDTE_T pDte)
     3438static int iommuAmdDteRead(PPDMDEVINS pDevIns, uint16_t idDevice, IOMMUOP enmOp, PDTE_T pDte)
    34393439{
    34403440    PCIOMMU  pThis   = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
     
    34473447    Assert(idxSegsEn < RT_ELEMENTS(g_auDevTabSegShifts));
    34483448
    3449     uint8_t const idxSeg = (uDevId & g_auDevTabSegMasks[idxSegsEn]) >> g_auDevTabSegShifts[idxSegsEn];
     3449    uint8_t const idxSeg = (idDevice & g_auDevTabSegMasks[idxSegsEn]) >> g_auDevTabSegShifts[idxSegsEn];
    34503450    Assert(idxSeg < RT_ELEMENTS(pThis->aDevTabBaseAddrs));
    34513451    AssertCompile(RT_ELEMENTS(g_auDevTabSegShifts) == RT_ELEMENTS(g_auDevTabSegMasks));
    34523452
    34533453    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);
    34553455    RTGCPHYS const GCPhysDte    = GCPhysDevTab + offDte;
    34563456
     
    34723472
    34733473        EVT_DEV_TAB_HW_ERROR_T EvtDevTabHwErr;
    3474         iommuAmdDevTabHwErrorEventInit(uDevId, GCPhysDte, enmOp, &EvtDevTabHwErr);
     3474        iommuAmdDevTabHwErrorEventInit(idDevice, GCPhysDte, enmOp, &EvtDevTabHwErr);
    34753475        iommuAmdDevTabHwErrorEventRaise(pDevIns, enmOp, &EvtDevTabHwErr);
    34763476        return VERR_IOMMU_DTE_READ_FAILED;
     
    34793479    /* Raise an I/O page fault for out-of-bounds acccess. */
    34803480    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 */,
    34823482                                 false /* fPermDenied */, enmOp, &EvtIoPageFault);
    34833483    iommuAmdIoPageFaultEventRaise(pDevIns, 0 /* fIoDevFlags */, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    35013501 * @param   pDevIns         The IOMMU device instance.
    35023502 * @param   uIova           The I/O virtual address to translate.
    3503  * @param   uDevId          The device ID (bus, device, function).
     3503 * @param   idDevice        The device ID (bus, device, function).
    35043504 * @param   fPerm           The I/O permissions for this access, see
    35053505 *                          IOMMU_IO_PERM_XXX.
     
    35093509 * @thread  Any.
    35103510 */
    3511 static int iommuAmdPreTranslateChecks(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, uint8_t fPerm, PCDTE_T pDte,
     3511static int iommuAmdPreTranslateChecks(PPDMDEVINS pDevIns, uint16_t idDevice, uint64_t uIova, uint8_t fPerm, PCDTE_T pDte,
    35123512                                      IOMMUOP enmOp)
    35133513{
     
    35263526        LogFunc(("Translation valid bit not set -> IOPF\n"));
    35273527        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 */,
    35293529                                     false /* fPermDenied */, enmOp, &EvtIoPageFault);
    35303530        iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    35443544        LogFunc(("Permission denied by DTE (fPerm=%#x fDtePerm=%#x) -> IOPF\n", fPerm, fDtePerm));
    35453545        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 */,
    35473547                                     true /* fPermDenied */, enmOp, &EvtIoPageFault);
    35483548        iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    35753575         *        raising an ILLEGAL_DEV_TABLE_ENTRY event or an IO_PAGE_FAULT event here.
    35763576         *        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));
    35783578        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 */,
    35803580                                     false /* fPermDenied */, enmOp, &EvtIoPageFault);
    35813581        iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    35983598 * @param   fPerm           The I/O permissions for this access, see
    35993599 *                          IOMMU_IO_PERM_XXX.
    3600  * @param   uDevId          The device ID (bus, device, function).
     3600 * @param   idDevice        The device ID (bus, device, function).
    36013601 * @param   pDte            The device table entry.
    36023602 * @param   enmOp           The IOMMU operation being performed.
     
    36063606 * @thread  Any.
    36073607 */
    3608 static int iommuAmdIoPageTableWalk(PPDMDEVINS pDevIns, uint64_t uIova, uint8_t fPerm, uint16_t uDevId, PCDTE_T pDte,
     3608static int iommuAmdIoPageTableWalk(PPDMDEVINS pDevIns, uint64_t uIova, uint8_t fPerm, uint16_t idDevice, PCDTE_T pDte,
    36093609                                   IOMMUOP enmOp, PIOPAGELOOKUP pPageLookup)
    36103610{
     
    36453645                LogFunc(("Failed to read page table entry at %#RGp. rc=%Rrc -> PageTabHwError\n", GCPhysPtEntity, rc));
    36463646                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);
    36483648                iommuAmdPageTabHwErrorEventRaise(pDevIns, enmOp, &EvtPageTabHwErr);
    36493649                return VERR_IOMMU_IPE_2;
     
    36563656        else
    36573657        {
    3658             LogFunc(("Page table entry not present (uDevId=%#x) -> IOPF\n", uDevId));
     3658            LogFunc(("Page table entry not present (idDevice=%#x) -> IOPF\n", idDevice));
    36593659            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 */,
    36613661                                         false /* fPermDenied */, enmOp, &EvtIoPageFault);
    36623662            iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    36713671        else
    36723672        {
    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));
    36743674            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 */,
    36763676                                         true /* fPermDenied */, enmOp, &EvtIoPageFault);
    36773677            iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    37113711            LogFunc(("Page size invalid cShift=%#x -> IOPF\n", cShift));
    37123712            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 */,
    37143714                                         false /* fPermDenied */, enmOp, &EvtIoPageFault);
    37153715            iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    37263726            LogFunc(("Next level of PDE invalid uNextLevel=%#x -> IOPF\n", uNextLevel));
    37273727            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 */,
    37293729                                         false /* fPermDenied */, enmOp, &EvtIoPageFault);
    37303730            iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    37433743            LogFunc(("Next level (%#x) must be less than the current level (%#x) -> IOPF\n", uNextLevel, uLevel));
    37443744            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 */,
    37463746                                         false /* fPermDenied */, enmOp, &EvtIoPageFault);
    37473747            iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    37613761            LogFunc(("IOVA of skipped levels are not zero %#RX64 (SkipMask=%#RX64) -> IOPF\n", uIova, uIovaSkipMask));
    37623762            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 */,
    37643764                                         false /* fPermDenied */, enmOp, &EvtIoPageFault);
    37653765            iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    37993799    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    38003800    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);
    38023802    STAM_PROFILE_ADV_STOP(&pThis->StatProfDteLookup, a); NOREF(pThis);
    38033803    return rc;
     
    38263826
    38273827    int            rc;
    3828     size_t const   cbAccess    = pAddrIn->cb;
     3828    size_t const   cbIova      = pAddrIn->cb;
    38293829    uint8_t const  fPerm       = pAddrIn->fPerm;
    38303830    uint64_t const uIova       = pAddrIn->uAddr;
    38313831    RTGCPHYS       GCPhysSpa   = NIL_RTGCPHYS;
    3832     size_t         cbRemaining = cbAccess;
     3832    size_t         cbRemaining = cbIova;
    38333833    uint64_t       uIovaPage   = pAddrIn->uAddr & X86_PAGE_4K_BASE_MASK;
    38343834    uint64_t       offIova     = pAddrIn->uAddr & X86_PAGE_4K_OFFSET_MASK;
     
    38463846
    38473847            /* Store the translated address before continuing to access more pages. */
    3848             if (cbRemaining == cbAccess)
     3848            if (cbRemaining == cbIova)
    38493849            {
    38503850                uint64_t const offMask = IOMMU_GET_PAGE_OFF_MASK(PageLookup.cShift);
     
    38853885
    38863886    pAddrOut->uAddr = GCPhysSpa;                /* Update the translated address. */
    3887     pAddrOut->cb    = cbAccess - cbRemaining;   /* Update the size of the contiguous memory region. */
     3887    pAddrOut->cb    = cbIova - cbRemaining;     /* Update the size of the contiguous memory region. */
    38883888    pAddrOut->fPerm = PageLookupPrev.fPerm;     /* Update the allowed permissions for this access. */
    38893889    if (pcbPages)
     
    38983898 * @returns VBox status code.
    38993899 * @param   pDevIns         The IOMMU instance data.
    3900  * @param   uDevId          The device ID (bus, device, function).
     3900 * @param   idDevice        The device ID (bus, device, function).
    39013901 * @param   uIova           The I/O virtual address to lookup.
    3902  * @param   cbAccess        The size of the access.
     3902 * @param   cbIova          The size of the access.
    39033903 * @param   fPerm           The I/O permissions for this access, see
    39043904 *                          IOMMU_IO_PERM_XXX.
     
    39103910 * @thread  Any.
    39113911 */
    3912 static int iommuAmdDteLookup(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbAccess, uint8_t fPerm, IOMMUOP enmOp,
     3912static int iommuAmdDteLookup(PPDMDEVINS pDevIns, uint16_t idDevice, uint64_t uIova, size_t cbIova, uint8_t fPerm, IOMMUOP enmOp,
    39133913                             PRTGCPHYS pGCPhysSpa, size_t *pcbContiguous)
    39143914{
     
    39193919    /* Read the device table entry from memory. */
    39203920    DTE_T Dte;
    3921     int rc = iommuAmdDteRead(pDevIns, uDevId, enmOp, &Dte);
     3921    int rc = iommuAmdDteRead(pDevIns, idDevice, enmOp, &Dte);
    39223922    if (RT_SUCCESS(rc))
    39233923    {
     
    39343934                 *       so there's no need to check the address exclusion base/limit here.
    39353935                 */
    3936                 rc = iommuAmdPreTranslateChecks(pDevIns, uDevId, uIova, fPerm, &Dte, enmOp);
     3936                rc = iommuAmdPreTranslateChecks(pDevIns, idDevice, uIova, fPerm, &Dte, enmOp);
    39373937                if (rc == VINF_SUCCESS)
    39383938                {
    39393939                    IOADDRRANGE AddrIn;
    39403940                    AddrIn.uAddr = uIova;
    3941                     AddrIn.cb    = cbAccess;
     3941                    AddrIn.cb    = cbIova;
    39423942                    AddrIn.fPerm = fPerm;
    39433943
    39443944                    IOMMUOPAUX Aux;
    3945                     Aux.enmOp     = enmOp;
    3946                     Aux.pDte      = &Dte;
    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;
    39493949
    39503950                    IOADDRRANGE AddrOut;
     
    39603960                    if (rc == VERR_OUT_OF_RANGE)
    39613961                    {
    3962                         Assert(cbContiguous > 0 && cbContiguous < cbAccess);
     3962                        Assert(cbContiguous > 0 && cbContiguous < cbIova);
    39633963                        rc = VINF_SUCCESS;
    39643964                        STAM_COUNTER_INC(&pThis->StatAccessDteNonContig); NOREF(pThis);
     
    39723972                    {
    39733973                        /* 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);
    39753975                        /* Update IOTLB for the contiguous range of I/O virtual addresses. */
    39763976                        iommuAmdIotlbAddRange(pDevIns, Dte.n.u16DomainId, uIova & X86_PAGE_4K_BASE_MASK, cbPages,
     
    39853985                     * GPA=SPA, but the permission bits are important and controls accesses.
    39863986                     */
    3987                     GCPhysSpa    =  uIova;
    3988                     cbContiguous = cbAccess;
     3987                    GCPhysSpa    = uIova;
     3988                    cbContiguous = cbIova;
    39893989                    rc = VINF_SUCCESS;
    39903990
    39913991#ifdef IOMMU_WITH_IOTLBE_CACHE
    39923992                    /* 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);
    39943994#endif
    39953995                }
     
    40084008                LogFunc(("Invalid DTE reserved bits (u64[0]=%#RX64 u64[1]=%#RX64) -> Illegal DTE\n", fRsvd0, fRsvd1));
    40094009                EVT_ILLEGAL_DTE_T Event;
    4010                 iommuAmdIllegalDteEventInit(uDevId, uIova, true /* fRsvdNotZero */, enmOp, &Event);
     4010                iommuAmdIllegalDteEventInit(idDevice, uIova, true /* fRsvdNotZero */, enmOp, &Event);
    40114011                iommuAmdIllegalDteEventRaise(pDevIns, enmOp, &Event, kIllegalDteType_RsvdNotZero);
    40124012                rc = VERR_IOMMU_ADDR_TRANSLATION_FAILED;
     
    40204020             */
    40214021            GCPhysSpa    = uIova;
    4022             cbContiguous = cbAccess;
     4022            cbContiguous = cbIova;
    40234023
    40244024#ifdef IOMMU_WITH_IOTLBE_CACHE
    40254025            /* 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 */);
    40274027#endif
    40284028        }
     
    40304030    else
    40314031    {
    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));
    40334033        rc = VERR_IOMMU_ADDR_TRANSLATION_FAILED;
    40344034    }
     
    40704070
    40714071    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);
    40734073    STAM_PROFILE_ADV_STOP(&pThis->StatProfIotlbeLookup, a);
    40744074    if (pIotlbe)
     
    40984098 *
    40994099 * @param   pDevIns         The IOMMU instance data.
    4100  * @param   uDevId          The device ID (bus, device, function).
     4100 * @param   idDevice        The device ID (bus, device, function).
    41014101 * @param   uIova           The I/O virtual address to lookup.
    4102  * @param   cbAccess        The size of the access.
     4102 * @param   cbIova          The size of the access.
    41034103 * @param   fPerm           The I/O permissions for this access, see
    41044104 *                          IOMMU_IO_PERM_XXX.
     
    41084108 *                          and permission-checked.
    41094109 */
    4110 static int iommuAmdCacheLookup(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uIova, size_t cbAccess, uint8_t fPerm, IOMMUOP enmOp,
     4110static int iommuAmdCacheLookup(PPDMDEVINS pDevIns, uint16_t idDevice, uint64_t uIova, size_t cbIova, uint8_t fPerm, IOMMUOP enmOp,
    41114111                               PRTGCPHYS pGCPhysSpa, size_t *pcbContiguous)
    41124112{
     
    41144114    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    41154115
    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);                    \
    41214121    } while (0)
    41224122
     
    41284128
    41294129    /* Lookup the DTE cache entry. */
    4130     uint16_t const idxDteCache = iommuAmdDteCacheEntryLookup(pThis, uDevId);
     4130    uint16_t const idxDteCache = iommuAmdDteCacheEntryLookup(pThis, idDevice);
    41314131    if (idxDteCache < RT_ELEMENTS(pThis->aDteCache))
    41324132    {
     
    41384138            IOADDRRANGE AddrIn;
    41394139            AddrIn.uAddr = uIova;
    4140             AddrIn.cb    = cbAccess;
     4140            AddrIn.cb    = cbIova;
    41414141            AddrIn.fPerm = fPerm;
    41424142
    41434143            IOMMUOPAUX Aux;
    4144             Aux.enmOp     = enmOp;
    4145             Aux.pDte      = NULL;
    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;
    41484148
    41494149            IOADDRRANGE AddrOut;
    41504150            rc = iommuAmdLookupIoAddrRange(pDevIns, iommuAmdCacheLookupPage, &AddrIn, &Aux, &AddrOut, NULL /* pcbPages */);
    4151             Assert(AddrOut.cb <= cbAccess);
     4151            Assert(AddrOut.cb <= cbIova);
    41524152            *pGCPhysSpa    = AddrOut.uAddr;
    41534153            *pcbContiguous = AddrOut.cb;
     
    41624162            {
    41634163                *pGCPhysSpa    = uIova;
    4164                 *pcbContiguous = cbAccess;
     4164                *pcbContiguous = cbIova;
    41654165                rc = VINF_SUCCESS;
    41664166            }
     
    41724172            /* Forward addresses untranslated, without checking permissions. */
    41734173            *pGCPhysSpa    = uIova;
    4174             *pcbContiguous = cbAccess;
     4174            *pcbContiguous = cbIova;
    41754175            rc = VINF_SUCCESS;
    41764176        }
     
    42364236 * @returns VBox status code.
    42374237 * @param   pDevIns         The IOMMU device instance.
    4238  * @param   uDevId          The device ID (bus, device, function).
     4238 * @param   idDevice        The device ID (bus, device, function).
    42394239 * @param   uIova           The I/O virtual address being accessed.
    4240  * @param   cbAccess        The number of bytes being accessed.
     4240 * @param   cbIova          The size of the access.
    42414241 * @param   fFlags          The access flags, see PDMIOMMU_MEM_F_XXX.
    42424242 * @param   pGCPhysSpa      Where to store the translated system physical address.
     
    42464246 * @thread  Any.
    42474247 */
    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)
     4248static DECLCALLBACK(int) iommuAmdMemAccess(PPDMDEVINS pDevIns, uint16_t idDevice, uint64_t uIova, size_t cbIova,
     4249                                           uint32_t fFlags, PRTGCPHYS pGCPhysSpa, size_t *pcbContiguous)
    42504250{
    42514251    /* Validate. */
    42524252    AssertPtr(pDevIns);
    42534253    AssertPtr(pGCPhysSpa);
    4254     Assert(cbAccess > 0);
     4254    Assert(cbIova > 0);
    42554255    Assert(!(fFlags & ~PDMIOMMU_MEM_F_VALID_MASK));
    42564256
     
    42624262        uint8_t fPerm;
    42634263        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));
    42654265
    42664266        int rc;
    42674267#ifdef IOMMU_WITH_IOTLBE_CACHE
    42684268        /* 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);
    42704270        if (rc == VINF_SUCCESS)
    42714271        {
    42724272            /* All pages in the access were found in the cache with sufficient permissions. */
    4273             Assert(*pcbContiguous == cbAccess);
     4273            Assert(*pcbContiguous == cbIova);
    42744274            Assert(*pGCPhysSpa != NIL_RTGCPHYS);
    42754275            STAM_COUNTER_INC(&pThis->StatAccessCacheHitFull);
     
    42814281        {
    42824282            /* Access stopped since translations resulted in non-contiguous memory, let caller resume access. */
    4283             Assert(*pcbContiguous > 0 && *pcbContiguous < cbAccess);
     4283            Assert(*pcbContiguous > 0 && *pcbContiguous < cbIova);
    42844284            STAM_COUNTER_INC(&pThis->StatAccessCacheNonContig);
    42854285            return VINF_SUCCESS;
     
    42914291         * so go through the slower path and raise the required event.
    42924292         */
    4293         AssertMsg(*pcbContiguous < cbAccess, ("Invalid size: cbContiguous=%zu cbAccess=%zu\n", *pcbContiguous, cbAccess));
    4294         uIova    += *pcbContiguous;
    4295         cbAccess -= *pcbContiguous;
     4293        AssertMsg(*pcbContiguous < cbIova, ("Invalid size: cbContiguous=%zu cbIova=%zu\n", *pcbContiguous, cbIova));
     4294        uIova  += *pcbContiguous;
     4295        cbIova -= *pcbContiguous;
    42964296        /* We currently are including any permission denied pages as cache misses too.*/
    42974297        STAM_COUNTER_INC(&pThis->StatAccessCacheMiss);
     
    42994299
    43004300        /* 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);
    43024302        if (RT_SUCCESS(rc))
    43034303        { /* likely */ }
     
    43054305        {
    43064306            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                      cbAccess, rc));
     4307            LogFunc(("DTE lookup failed! idDevice=%#x uIova=%#RX64 fPerm=%u cbIova=%zu rc=%#Rrc\n", idDevice, uIova, fPerm,
     4308                     cbIova, rc));
    43094309        }
    43104310
     
    43144314    /* Addresses are forwarded without translation when the IOMMU is disabled. */
    43154315    *pGCPhysSpa    = uIova;
    4316     *pcbContiguous = cbAccess;
     4316    *pcbContiguous = cbIova;
    43174317    return VINF_SUCCESS;
    43184318}
     
    43244324 * @returns VBox status code.
    43254325 * @param   pDevIns         The IOMMU device instance.
    4326  * @param   uDevId          The device ID (bus, device, function).
     4326 * @param   idDevice        The device ID (bus, device, function).
    43274327 * @param   cIovas          The number of addresses being accessed.
    43284328 * @param   pauIovas        The I/O virtual addresses for each page being accessed.
     
    43324332 * @thread  Any.
    43334333 */
    4334 static DECLCALLBACK(int) iommuAmdMemBulkAccess(PPDMDEVINS pDevIns, uint16_t uDevId, size_t cIovas, uint64_t const *pauIovas,
     4334static DECLCALLBACK(int) iommuAmdMemBulkAccess(PPDMDEVINS pDevIns, uint16_t idDevice, size_t cIovas, uint64_t const *pauIovas,
    43354335                                               uint32_t fFlags, PRTGCPHYS paGCPhysSpa)
    43364336{
     
    43494349        uint8_t fPerm;
    43504350        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));
    43524352
    43534353        /** @todo IOMMU: IOTLB cache lookup. */
     
    43574357        {
    43584358            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);
    43604360            if (RT_SUCCESS(rc))
    43614361            { /* likely */ }
    43624362            else
    43634363            {
    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));
    43654365                return rc;
    43664366            }
     
    43844384 * @returns VBox status code.
    43854385 * @param   pDevIns     The IOMMU device instance.
    4386  * @param   uDevId      The device ID (bus, device, function).
     4386 * @param   idDevice    The device ID (bus, device, function).
    43874387 * @param   pDte        The device table entry.
    43884388 * @param   GCPhysIn    The source MSI address (used for reporting errors).
     
    43934393 * @thread  Any.
    43944394 */
    4395 static int iommuAmdIrteRead(PPDMDEVINS pDevIns, uint16_t uDevId, PCDTE_T pDte, RTGCPHYS GCPhysIn, uint32_t uDataIn,
     4395static int iommuAmdIrteRead(PPDMDEVINS pDevIns, uint16_t idDevice, PCDTE_T pDte, RTGCPHYS GCPhysIn, uint32_t uDataIn,
    43964396                            IOMMUOP enmOp, PIRTE_T pIrte)
    43974397{
     
    44134413
    44144414        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 */,
    44164416                                     false /* fPermDenied */, enmOp, &EvtIoPageFault);
    44174417        iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, NULL /* pIrte */, enmOp, &EvtIoPageFault,
     
    44404440 * @returns VBox status code.
    44414441 * @param   pDevIns     The IOMMU instance data.
    4442  * @param   uDevId      The device ID (bus, device, function).
     4442 * @param   idDevice    The device ID (bus, device, function).
    44434443 * @param   pDte        The device table entry.
    44444444 * @param   enmOp       The IOMMU operation being performed.
     
    44484448 * @thread  Any.
    44494449 */
    4450 static int iommuAmdIntrRemap(PPDMDEVINS pDevIns, uint16_t uDevId, PCDTE_T pDte, IOMMUOP enmOp, PCMSIMSG pMsiIn,
     4450static int iommuAmdIntrRemap(PPDMDEVINS pDevIns, uint16_t idDevice, PCDTE_T pDte, IOMMUOP enmOp, PCMSIMSG pMsiIn,
    44514451                             PMSIMSG pMsiOut)
    44524452{
     
    44554455    IRTE_T Irte;
    44564456    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);
    44584458    if (RT_SUCCESS(rc))
    44594459    {
     
    44664466                    iommuAmdIrteRemapMsi(pMsiIn, pMsiOut, &Irte);
    44674467#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);
    44694469#endif
    44704470                    return VINF_SUCCESS;
     
    44734473                LogFunc(("Interrupt type (%#x) invalid -> IOPF\n", Irte.n.u3IntrType));
    44744474                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,
    44764476                                             true /* fRsvdNotZero */, false /* fPermDenied */, enmOp, &EvtIoPageFault);
    44774477                iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, &Irte, enmOp, &EvtIoPageFault,
     
    44824482            LogFunc(("Guest mode not supported -> IOPF\n"));
    44834483            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,
    44854485                                         true /* fRsvdNotZero */, false /* fPermDenied */, enmOp, &EvtIoPageFault);
    44864486            iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, &Irte, enmOp, &EvtIoPageFault, kIoPageFaultType_IrteRsvdNotZero);
     
    44904490        LogFunc(("Remapping disabled -> IOPF\n"));
    44914491        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,
    44934493                                     false /* fRsvdNotZero */, false /* fPermDenied */, enmOp, &EvtIoPageFault);
    44944494        iommuAmdIoPageFaultEventRaiseWithDte(pDevIns, pDte, &Irte, enmOp, &EvtIoPageFault, kIoPageFaultType_IrteRemapEn);
     
    45054505 * @returns VBox status code.
    45064506 * @param   pDevIns     The IOMMU instance data.
    4507  * @param   uDevId      The device ID (bus, device, function).
     4507 * @param   idDevice    The device ID (bus, device, function).
    45084508 * @param   enmOp       The IOMMU operation being performed.
    45094509 * @param   pMsiIn      The source MSI.
     
    45124512 * @thread  Any.
    45134513 */
    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));
     4514static 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));
    45194519
    45204520    /* Read the device table entry from memory. */
    45214521    DTE_T Dte;
    4522     int rc = iommuAmdDteRead(pDevIns, uDevId, enmOp, &Dte);
     4522    int rc = iommuAmdDteRead(pDevIns, idDevice, enmOp, &Dte);
    45234523    if (RT_SUCCESS(rc))
    45244524    {
    45254525#ifdef IOMMU_WITH_IRTE_CACHE
    4526         iommuAmdDteCacheAdd(pDevIns, uDevId, &Dte, 0 /* fFlags */);
     4526        iommuAmdDteCacheAdd(pDevIns, idDevice, &Dte, 0 /* fFlags */);
    45274527#endif
    45284528        /* If the DTE is not valid, all interrupts are forwarded without remapping. */
     
    45384538                LogFunc(("Invalid reserved bits in DTE (u64[2]=%#RX64 u64[3]=%#RX64) -> Illegal DTE\n", fRsvd0, fRsvd1));
    45394539                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);
    45414541                iommuAmdIllegalDteEventRaise(pDevIns, enmOp, &Event, kIllegalDteType_RsvdNotZero);
    45424542                return VERR_IOMMU_INTR_REMAP_FAILED;
     
    45914591                                NOREF(pThis);
    45924592
    4593                                 return iommuAmdIntrRemap(pDevIns, uDevId, &Dte, enmOp, pMsiIn, pMsiOut);
     4593                                return iommuAmdIntrRemap(pDevIns, idDevice, &Dte, enmOp, pMsiIn, pMsiOut);
    45944594                            }
    45954595
    45964596                            LogFunc(("Invalid interrupt table length %#x -> Illegal DTE\n", uIntrTabLen));
    45974597                            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);
    45994599                            iommuAmdIllegalDteEventRaise(pDevIns, enmOp, &Event, kIllegalDteType_RsvdIntTabLen);
    46004600                            return VERR_IOMMU_INTR_REMAP_FAILED;
     
    46184618                        LogFunc(("IntCtl mode invalid %#x -> Illegal DTE\n", uIntrCtrl));
    46194619                        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);
    46214621                        iommuAmdIllegalDteEventRaise(pDevIns, enmOp, &Event, kIllegalDteType_RsvdIntCtl);
    46224622                        return VERR_IOMMU_INTR_REMAP_FAILED;
     
    46714671    }
    46724672
    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));
    46744674    return VERR_IOMMU_INTR_REMAP_FAILED;
    46754675}
     
    46814681 * @returns VBox status code.
    46824682 * @param   pDevIns     The IOMMU device instance.
    4683  * @param   uDevId      The device ID (bus, device, function).
     4683 * @param   idDevice    The device ID (bus, device, function).
    46844684 * @param   pMsiIn      The source MSI.
    46854685 * @param   pMsiOut     Where to store the remapped MSI.
    46864686 */
    4687 static DECLCALLBACK(int) iommuAmdMsiRemap(PPDMDEVINS pDevIns, uint16_t uDevId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)
     4687static DECLCALLBACK(int) iommuAmdMsiRemap(PPDMDEVINS pDevIns, uint16_t idDevice, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)
    46884688{
    46894689    /* Validate. */
     
    47034703#ifdef IOMMU_WITH_IRTE_CACHE
    47044704        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);
    47064706        STAM_PROFILE_ADV_STOP(&pThis->StatProfIrteCacheLookup, a);
    47074707        if (RT_SUCCESS(rc))
     
    47144714
    47154715        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);
    47174717        STAM_PROFILE_ADV_STOP(&pThis->StatProfIrteLookup, a);
    47184718        return rc;
     
    48594859#ifdef IOMMU_WITH_IOTLBE_CACHE
    48604860                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;
    48624862                bool const     fFlushPde = pCmdInvPages->n.u1PageDirEntries;
    48634863                uint8_t cShift;
     
    48934893                {
    48944894                    /* Remove the range of I/O virtual addresses requesting to be invalidated. */
    4895                     size_t const cbAccess = 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);
    48974897                }
    48984898                else
     
    49024902                     * In such situations we must remove all ranges for the specified domain ID.
    49034903                     */
    4904                     iommuAmdIotlbRemoveDomainId(pDevIns, uDomainId);
     4904                    iommuAmdIotlbRemoveDomainId(pDevIns, idDomain);
    49054905                }
    49064906#endif
     
    59325932    if (pszArgs)
    59335933    {
    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);
    59365936        if (RT_SUCCESS(rc))
    59375937        {
    59385938            DTE_T Dte;
    5939             rc = iommuAmdDteRead(pDevIns, uDevId, IOMMUOP_TRANSLATE_REQ,  &Dte);
     5939            rc = iommuAmdDteRead(pDevIns, idDevice, IOMMUOP_TRANSLATE_REQ,  &Dte);
    59405940            if (RT_SUCCESS(rc))
    59415941            {
    5942                 pHlp->pfnPrintf(pHlp, "DTE for device %#x\n", uDevId);
     5942                pHlp->pfnPrintf(pHlp, "DTE for device %#x\n", idDevice);
    59435943                iommuAmdR3DbgInfoDteWorker(pHlp, &Dte, " ");
    59445944                return;
    59455945            }
    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);
    59475947        }
    59485948        else
     
    59685968    for (uint16_t i = 0; i < cDteCache; i++)
    59695969    {
    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);
    59775977
    59785978            PCDTECACHE pDteCache = &pThis->aDteCache[i];
    59795979            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);
    59815981            pHlp->pfnPrintf(pHlp, "\n");
    59825982        }
     
    59955995    if (pszArgs)
    59965996    {
    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);
    59995999        if (RT_SUCCESS(rc))
    60006000        {
    6001             pHlp->pfnPrintf(pHlp, "IOTLBEs for domain %u (%#x):\n", uDomainId, uDomainId);
     6001            pHlp->pfnPrintf(pHlp, "IOTLBEs for domain %u (%#x):\n", idDomain, idDomain);
    60026002            PIOMMU   pThis   = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    60036003            PIOMMUR3 pThisR3 = PDMDEVINS_2_DATA_CC(pDevIns, PIOMMUR3);
    60046004            IOTLBEINFOARG Args;
    6005             Args.pIommuR3  = pThisR3;
    6006             Args.pHlp      = pHlp;
    6007             Args.uDomainId = uDomainId;
     6005            Args.pIommuR3 = pThisR3;
     6006            Args.pHlp     = pHlp;
     6007            Args.idDomain = idDomain;
    60086008
    60096009            IOMMU_LOCK_CACHE_NORET(pDevIns, pThis);
     
    60566056        if (uKey != IOMMU_IRTE_CACHE_KEY_NIL)
    60576057        {
    6058             uint16_t const uDeviceId = IOMMU_IRTE_CACHE_KEY_GET_DEVICE_ID(uKey);
    6059             uint16_t const offIrte   = IOMMU_IRTE_CACHE_KEY_GET_OFF(uKey);
     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);
    60606060            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);
    60656065
    60666066            PCIRTE_T pIrte = &pIrteCache->Irte;
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