diff options
| author | Alexey Kardashevskiy | 2016-06-21 03:14:01 +0200 |
|---|---|---|
| committer | David Gibson | 2016-06-22 03:13:09 +0200 |
| commit | f682e9c244af7166225f4a50cc18ff296bb9d43e (patch) | |
| tree | b7bd72279e877749a13819072e5380147e3cb66d /memory.c | |
| parent | ppc: Improve emulation of THRM registers (diff) | |
| download | qemu-f682e9c244af7166225f4a50cc18ff296bb9d43e.tar.gz qemu-f682e9c244af7166225f4a50cc18ff296bb9d43e.tar.xz qemu-f682e9c244af7166225f4a50cc18ff296bb9d43e.zip | |
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 'memory.c')
| -rw-r--r-- | memory.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -1502,12 +1502,22 @@ void memory_region_register_iommu_notifier(MemoryRegion *mr, Notifier *n) notifier_list_add(&mr->iommu_notify, n); } -void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n, - hwaddr granularity, bool is_write) +uint64_t memory_region_iommu_get_min_page_size(MemoryRegion *mr) { - hwaddr addr; + assert(memory_region_is_iommu(mr)); + if (mr->iommu_ops && mr->iommu_ops->get_min_page_size) { + return mr->iommu_ops->get_min_page_size(mr); + } + return TARGET_PAGE_SIZE; +} + +void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n, bool is_write) +{ + hwaddr addr, granularity; IOMMUTLBEntry iotlb; + granularity = memory_region_iommu_get_min_page_size(mr); + for (addr = 0; addr < memory_region_size(mr); addr += granularity) { iotlb = mr->iommu_ops->translate(mr, addr, is_write); if (iotlb.perm != IOMMU_NONE) { |
