diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-06-21 11:14:01 +1000 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2016-06-22 11:13:09 +1000 |
commit | f682e9c244af7166225f4a50cc18ff296bb9d43e (patch) | |
tree | b7bd72279e877749a13819072e5380147e3cb66d /include/exec/memory.h | |
parent | f0278900d38b2d8d9531c484bd088d9a7d5d4ea2 (diff) |
memory: Add reporting of supported page sizes
Every IOMMU has some granularity which MemoryRegionIOMMUOps::translate
uses when translating, however this information is not available outside
the translate context for various checks.
This adds a get_min_page_size callback to MemoryRegionIOMMUOps and
a wrapper for it so IOMMU users (such as VFIO) can know the minimum
actual page size supported by an IOMMU.
As IOMMU MR represents a guest IOMMU, this uses TARGET_PAGE_SIZE
as fallback.
This removes vfio_container_granularity() and uses new helper in
memory_region_iommu_replay() when replaying IOMMU mappings on added
IOMMU memory region.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
[dwg: Removed an unnecessary calculation]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'include/exec/memory.h')
-rw-r--r-- | include/exec/memory.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/include/exec/memory.h b/include/exec/memory.h index 4ab680052f..e3829f797a 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -151,6 +151,8 @@ typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps; struct MemoryRegionIOMMUOps { /* Return a TLB entry that contains a given address. */ IOMMUTLBEntry (*translate)(MemoryRegion *iommu, hwaddr addr, bool is_write); + /* Returns minimum supported page size */ + uint64_t (*get_min_page_size)(MemoryRegion *iommu); }; typedef struct CoalescedMemoryRange CoalescedMemoryRange; @@ -573,6 +575,16 @@ static inline bool memory_region_is_iommu(MemoryRegion *mr) /** + * memory_region_iommu_get_min_page_size: get minimum supported page size + * for an iommu + * + * Returns minimum supported page size for an iommu. + * + * @mr: the memory region being queried + */ +uint64_t memory_region_iommu_get_min_page_size(MemoryRegion *mr); + +/** * memory_region_notify_iommu: notify a change in an IOMMU translation entry. * * @mr: the memory region that was changed @@ -596,16 +608,15 @@ void memory_region_register_iommu_notifier(MemoryRegion *mr, Notifier *n); /** * memory_region_iommu_replay: replay existing IOMMU translations to - * a notifier + * a notifier with the minimum page granularity returned by + * mr->iommu_ops->get_page_size(). * * @mr: the memory region to observe * @n: the notifier to which to replay iommu mappings - * @granularity: Minimum page granularity to replay notifications for * @is_write: Whether to treat the replay as a translate "write" * through the iommu */ -void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n, - hwaddr granularity, bool is_write); +void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n, bool is_write); /** * memory_region_unregister_iommu_notifier: unregister a notifier for |