From: Zhenzhong Duan Date: Tue, 6 Jan 2026 06:12:48 +0000 (-0500) Subject: intel_iommu: Implement get_viommu_flags() callback X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecacfc145fa26c18173175a0fadfea564f2b9852;p=thirdparty%2Fqemu.git intel_iommu: Implement get_viommu_flags() callback Implement get_viommu_flags() callback and expose a request for nesting parent HWPT for now. VFIO uses it to create nesting parent HWPT which is further used to create nested HWPT in vIOMMU. All these will be implemented in following patches. Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan Reviewed-by: Eric Auger Reviewed-by: Nicolin Chen Reviewed-by: Yi Liu Reviewed-by: Michael S. Tsirkin Link: https://lore.kernel.org/qemu-devel/20260106061304.314546-7-zhenzhong.duan@intel.com Signed-off-by: Cédric Le Goater --- diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 7bec53a587..9ce1bab93c 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -24,6 +24,7 @@ #include "qemu/main-loop.h" #include "qapi/error.h" #include "hw/core/sysbus.h" +#include "hw/core/iommu.h" #include "intel_iommu_internal.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" @@ -4659,6 +4660,16 @@ static void vtd_dev_unset_iommu_device(PCIBus *bus, void *opaque, int devfn) vtd_iommu_unlock(s); } +static uint64_t vtd_get_viommu_flags(void *opaque) +{ + IntelIOMMUState *s = opaque; + uint64_t flags; + + flags = s->fsts ? VIOMMU_FLAG_WANT_NESTING_PARENT : 0; + + return flags; +} + /* Unmap the whole range in the notifier's scope. */ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) { @@ -5312,6 +5323,7 @@ static PCIIOMMUOps vtd_iommu_ops = { .pri_register_notifier = vtd_pri_register_notifier, .pri_unregister_notifier = vtd_pri_unregister_notifier, .pri_request_page = vtd_pri_request_page, + .get_viommu_flags = vtd_get_viommu_flags, }; static bool vtd_decide_config(IntelIOMMUState *s, Error **errp)