From 096ca207af3a5eea9b0d954fb58e2e3e435918bf Mon Sep 17 00:00:00 2001 From: Alexey Kardashevskiy Date: Sat, 24 Feb 2018 19:23:19 -0500 Subject: [PATCH] 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. Backports the relevant parts of commit f682e9c244af7166225f4a50cc18ff296bb9d43e from qemu --- qemu/include/exec/memory.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qemu/include/exec/memory.h b/qemu/include/exec/memory.h index 1c84761a..8231aa8f 100644 --- a/qemu/include/exec/memory.h +++ b/qemu/include/exec/memory.h @@ -145,6 +145,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); }; struct MemoryRegion {