VirtualBox

Changeset 84183 in vbox


Ignore:
Timestamp:
May 7, 2020 11:23:48 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137790
Message:

AMD IOMMU: bugref:9654 Bits.

File:
1 edited

Legend:

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

    r84181 r84183  
    481481/** Maximum number of host address translation levels supported. */
    482482#define IOMMU_MAX_HOST_PT_LEVEL                     6
     483/** The IOTLB entry magic. */
     484#define IOMMU_IOTLBE_MAGIC                          0x10acce55
    483485/** @} */
    484486
     
    22132215typedef struct
    22142216{
     2217    /** Magic (IOMMU_IOTLBE_MAGIC). */
     2218    uint32_t        uMagic;
     2219    /** Reserved for future (eviction hints?). */
     2220    uint16_t        uRsvd0;
    22152221    /** The I/O access permissions (IOMMU_IO_PERM_XXX). */
    22162222    uint8_t         fIoPerm;
    22172223    /** The number of offset bits in the system physical address. */
    22182224    uint8_t         cShift;
    2219     /** Reserved for future (eviction hints?). */
    2220     uint16_t        uRsvd0;
    2221     /** Alignment padding. */
    2222     uint32_t        uRsvd1;
    22232225    /** The translated system physical address of the page. */
    22242226    RTGCPHYS        GCPhysSpa;
     
    37803782static void iommuAmdInitIotlbe(RTGCPHYS GCPhysSpa, uint8_t cShift, uint8_t fIoPerm, PIOTLBE_T pIotlbe)
    37813783{
     3784    pIotlbe->uMagic    = IOMMU_IOTLBE_MAGIC;
     3785    pIotlbe->uRsvd0    = 0;
    37823786    pIotlbe->fIoPerm   = fIoPerm;
    3783     pIotlbe->uRsvd0    = 0;
    3784     pIotlbe->uRsvd1    = 0;
     3787    pIotlbe->cShift    = cShift;
     3788    pIotlbe->GCPhysSpa = GCPhysSpa;
     3789}
     3790
     3791/**
     3792 * Updates an IOTLB entry.
     3793 *
     3794 * @param   GCPhysSpa   The translated system physical address.
     3795 * @param   cShift      The number of offset bits in the system physical address.
     3796 * @param   fIoPerm     The I/O access permissions (IOMMU_IO_PERM_XXX).
     3797 * @param   pIotlbe     The IOTLB entry to update.
     3798 */
     3799static void iommuAmdUpdateIotlbe(RTGCPHYS GCPhysSpa, uint8_t cShift, uint8_t fIoPerm, PIOTLBE_T pIotlbe)
     3800{
     3801    Assert(pIotlbe->uMagic == IOMMU_IOTLBE_MAGIC);
     3802    pIotlbe->fIoPerm   = fIoPerm;
    37853803    pIotlbe->cShift    = cShift;
    37863804    pIotlbe->GCPhysSpa = GCPhysSpa;
     
    38863904        iommuAmdRaiseIoPageFaultEvent(pDevIns, uDevId, pDte->n.u16DomainId, uIova, true /* fPresentOrValid */,
    38873905                                      enmOp, kIoPageFaultType_DteTranslationDisabled);
    3888         iommuAmdInitIotlbe(NIL_RTGCPHYS, 0 /* cShift */,  IOMMU_IO_PERM_NONE, pIotlbe);
     3906        iommuAmdUpdateIotlbe(NIL_RTGCPHYS, 0 /* cShift */,  IOMMU_IO_PERM_NONE, pIotlbe);
    38893907        return VERR_IOMMU_ADDR_TRANSLATION_FAILED;
    38903908    }
     
    38993917            return VERR_IOMMU_ADDR_ACCESS_DENIED;
    39003918        }
    3901         iommuAmdInitIotlbe(uIova, 0 /* cShift */, fDtePerm, pIotlbe);
     3919        iommuAmdUpdateIotlbe(uIova, 0 /* cShift */, fDtePerm, pIotlbe);
    39023920        return VINF_SUCCESS;
    39033921    }
     
    39103928         *        I'm just going with this one... */
    39113929        /** @todo IOMMU: raise I/O page fault. */
    3912         iommuAmdInitIotlbe(NIL_RTGCPHYS, 0 /* cShift */,  IOMMU_IO_PERM_NONE, pIotlbe);
     3930        iommuAmdUpdateIotlbe(NIL_RTGCPHYS, 0 /* cShift */,  IOMMU_IO_PERM_NONE, pIotlbe);
    39133931        return VERR_IOMMU_ADDR_TRANSLATION_FAILED;
    39143932    }
     
    39373955                                      PIOTLBE_T pIotlbe)
    39383956{
     3957    Assert(pIotlbe->uMagic == IOMMU_IOTLBE_MAGIC);
    39393958    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    39403959
     
    39493968        else
    39503969        {
    3951             iommuAmdInitIotlbe(uIova, 0 /* cShift */, IOMMU_IO_PERM_READ_WRITE, pIotlbe);
     3970            iommuAmdUpdateIotlbe(uIova, 0 /* cShift */, IOMMU_IO_PERM_READ_WRITE, pIotlbe);
    39523971            return VINF_SUCCESS;
    39533972        }
     
    39733992        else
    39743993        {
    3975             iommuAmdInitIotlbe(uIova, 0 /* cShift */, IOMMU_IO_PERM_READ_WRITE, pIotlbe);
     3994            iommuAmdUpdateIotlbe(uIova, 0 /* cShift */, IOMMU_IO_PERM_READ_WRITE, pIotlbe);
    39763995            return VINF_SUCCESS;
    39773996        }
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