From: Wu Fei <[email protected]> For accelerated IOMMU, we need nested parent domain creation. Add the callback support so that VFIO can create a nested parent.
This follows the approach of the ARM SMMUv3. Signed-off-by: Wu Fei <[email protected]> Signed-off-by: Gong Shuai <[email protected]> --- hw/riscv/riscv-iommu-accel.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/riscv/riscv-iommu-accel.c b/hw/riscv/riscv-iommu-accel.c index 7bb725d957..2bafbfa5e0 100644 --- a/hw/riscv/riscv-iommu-accel.c +++ b/hw/riscv/riscv-iommu-accel.c @@ -10,6 +10,7 @@ #include "hw/pci/pci_bridge.h" #include "hw/pci-host/gpex.h" #include "hw/vfio/pci.h" +#include "hw/core/iommu.h" #include "riscv-iommu.h" #include "riscv-iommu-accel.h" @@ -134,9 +135,21 @@ static AddressSpace *riscv_iommu_accel_find_as(PCIBus *bus, void *opaque, } } +static uint64_t riscv_iommu_accel_get_viommu_flags(void *opaque) +{ + /* + * We return VIOMMU_FLAG_WANT_NESTING_PARENT to inform VFIO core to create a + * nesting parent which is required for accelerated riscv iommu support. + * The real HW nested support should be reported from host riscv iommu and if + * it doesn't, the nesting parent allocation will fail anyway in VFIO core. + */ + return VIOMMU_FLAG_WANT_NESTING_PARENT; +} + static const PCIIOMMUOps riscv_iommu_accel_ops = { .supports_address_space = riscv_iommu_accel_supports_as, .get_address_space = riscv_iommu_accel_find_as, + .get_viommu_flags = riscv_iommu_accel_get_viommu_flags, }; static void riscv_iommu_accel_as_init(RISCVIOMMUState *s) -- 2.53.0
