From nobody Sun Apr 28 01:01:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500535571673988.5432392800265; Thu, 20 Jul 2017 00:26:11 -0700 (PDT) Received: from localhost ([::1]:36420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY5qa-0000UE-DG for importer@patchew.org; Thu, 20 Jul 2017 03:26:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY5nH-0006Fe-1C for qemu-devel@nongnu.org; Thu, 20 Jul 2017 03:22:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY5nC-0002zf-My for qemu-devel@nongnu.org; Thu, 20 Jul 2017 03:22:43 -0400 Received: from ozlabs.ru ([107.173.13.209]:59518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY5nC-0002xl-GT; Thu, 20 Jul 2017 03:22:38 -0400 Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 98B4B3A6006C; Thu, 20 Jul 2017 03:23:27 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 17:22:29 +1000 Message-Id: <20170720072231.35054-2-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170720072231.35054-1-aik@ozlabs.ru> References: <20170720072231.35054-1-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu v4 1/3] spapr_iommu: Realloc guest visible TCE table when hot(un)plugging vfio-pci X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Alex Williamson , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This replaces g_malloc() with spapr_tce_alloc_table() as this is the standard way of allocating tables and this allows moving the table back to KVM when unplugging a VFIO PCI device and VFIO TCE acceleration support is not present in the KVM. Although spapr_tce_alloc_table() is expected to fail with EBUSY if called when previous fd is not closed yet, in practice we will not see it because cap_spapr_vfio is false at the moment. Signed-off-by: Alexey Kardashevskiy --- hw/ppc/spapr_iommu.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index e614621a83..307dc3021e 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -275,33 +275,26 @@ static int spapr_tce_table_realize(DeviceState *dev) void spapr_tce_set_need_vfio(sPAPRTCETable *tcet, bool need_vfio) { size_t table_size =3D tcet->nb_table * sizeof(uint64_t); - void *newtable; + uint64_t *oldtable; + int newfd =3D -1; =20 - if (need_vfio =3D=3D tcet->need_vfio) { - /* Nothing to do */ - return; - } + g_assert(need_vfio !=3D tcet->need_vfio); =20 - if (!need_vfio) { - /* FIXME: We don't support transition back to KVM accelerated - * TCEs yet */ - return; - } + tcet->need_vfio =3D need_vfio; =20 - tcet->need_vfio =3D true; + oldtable =3D tcet->table; =20 - if (tcet->fd < 0) { - /* Table is already in userspace, nothing to be do */ - return; - } + tcet->table =3D spapr_tce_alloc_table(tcet->liobn, + tcet->page_shift, + tcet->bus_offset, + tcet->nb_table, + &newfd, + need_vfio); + memcpy(tcet->table, oldtable, table_size); =20 - newtable =3D g_malloc(table_size); - memcpy(newtable, tcet->table, table_size); + spapr_tce_free_table(oldtable, tcet->fd, tcet->nb_table); =20 - kvmppc_remove_spapr_tce(tcet->table, tcet->fd, tcet->nb_table); - - tcet->fd =3D -1; - tcet->table =3D newtable; + tcet->fd =3D newfd; } =20 sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn) --=20 2.11.0 From nobody Sun Apr 28 01:01:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500535590675965.7740121576536; Thu, 20 Jul 2017 00:26:30 -0700 (PDT) Received: from localhost ([::1]:36422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY5qv-0000i2-Bl for importer@patchew.org; Thu, 20 Jul 2017 03:26:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY5nl-0006bu-DN for qemu-devel@nongnu.org; Thu, 20 Jul 2017 03:23:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY5nh-0003OR-1U for qemu-devel@nongnu.org; Thu, 20 Jul 2017 03:23:13 -0400 Received: from ozlabs.ru ([107.173.13.209]:60376) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY5ng-0003Ny-KS; Thu, 20 Jul 2017 03:23:08 -0400 Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 5C7E73A6006D; Thu, 20 Jul 2017 03:23:29 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 17:22:30 +1000 Message-Id: <20170720072231.35054-3-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170720072231.35054-1-aik@ozlabs.ru> References: <20170720072231.35054-1-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu v4 2/3] vfio/spapr: Add a notifier for PPC64 HV/PR KVM about new group attached to LIOBN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Alex Williamson , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This implements a notification for a new IOMMU group attached to sPAPR's logical IO bus (LIOBN) to enable in-kernel TCE acceleration. This extends the TYPE_SPAPR_IOMMU_MEMORY_REGION class with a get_fd() callback which returns KVM fd associated with LIOBN, the notifier uses it to establish link between LIOBN and IOMMU group in the KVM. Signed-off-by: Alexey Kardashevskiy --- The practical reason for adding get_fd() as a callback is avoiding static linking to spapt_tce_get_fd(): hw/vfio/spapr.c compiles when CONFIG_SOFTMMU=3Dy to avoid multiple "ifdef PSERIES"'s in the rest of VFIO code but hw/ppc/spapr_iommu.c (where spapt_tce_get_fd() besides) compiles only when CONFIG_PSERIES=3Dy. --- include/hw/ppc/spapr.h | 15 +++++++++++++++ include/hw/vfio/vfio-common.h | 2 ++ hw/ppc/spapr_iommu.c | 10 ++++++++++ hw/vfio/common.c | 10 ++++++++++ hw/vfio/spapr.c | 39 +++++++++++++++++++++++++++++++++++++++ hw/vfio/trace-events | 1 + 6 files changed, 77 insertions(+) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 2a303a705c..c1d37e6356 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -591,6 +591,7 @@ void spapr_load_rtas(sPAPRMachineState *spapr, void *fd= t, hwaddr addr); #define RTAS_EVENT_SCAN_RATE 1 =20 typedef struct sPAPRTCETable sPAPRTCETable; +typedef struct sPAPRIOMMUMemoryRegionClass sPAPRIOMMUMemoryRegionClass; =20 #define TYPE_SPAPR_TCE_TABLE "spapr-tce-table" #define SPAPR_TCE_TABLE(obj) \ @@ -599,6 +600,12 @@ typedef struct sPAPRTCETable sPAPRTCETable; #define TYPE_SPAPR_IOMMU_MEMORY_REGION "spapr-iommu-memory-region" #define SPAPR_IOMMU_MEMORY_REGION(obj) \ OBJECT_CHECK(IOMMUMemoryRegion, (obj), TYPE_SPAPR_IOMMU_MEMORY_REG= ION) +#define SPAPR_IOMMU_MEMORY_REGION_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRIOMMUMemoryRegionClass, obj, \ + TYPE_SPAPR_IOMMU_MEMORY_REGION) +#define SPAPR_IOMMU_MEMORY_REGION_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRIOMMUMemoryRegionClass, klass, \ + TYPE_SPAPR_IOMMU_MEMORY_REGION) =20 struct sPAPRTCETable { DeviceState parent; @@ -618,6 +625,14 @@ struct sPAPRTCETable { QLIST_ENTRY(sPAPRTCETable) list; }; =20 +struct sPAPRIOMMUMemoryRegionClass { + /* private */ + IOMMUMemoryRegionClass parent_class; + + /* public */ + int (*get_fd)(IOMMUMemoryRegion *iommu_mr); +}; + sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn); =20 struct sPAPREventLogEntry { diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index f3a2ac9fee..d245d3cecc 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -177,6 +177,8 @@ extern const MemoryListener vfio_prereg_listener; int vfio_spapr_create_window(VFIOContainer *container, MemoryRegionSection *section, hwaddr *pgsize); +int vfio_spapr_notify_kvm(int vfio_kvm_device_fd, int groupfd, + IOMMUMemoryRegion *iommumr); int vfio_spapr_remove_window(VFIOContainer *container, hwaddr offset_within_address_space); =20 diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index 307dc3021e..82fca61a75 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -171,6 +171,13 @@ static void spapr_tce_notify_flag_changed(IOMMUMemoryR= egion *iommu, } } =20 +static int spapr_tce_get_fd(IOMMUMemoryRegion *iommu_mr) +{ + sPAPRTCETable *tcet =3D container_of(iommu_mr, sPAPRTCETable, iommu); + + return tcet->fd; +} + static int spapr_tce_table_post_load(void *opaque, int version_id) { sPAPRTCETable *tcet =3D SPAPR_TCE_TABLE(opaque); @@ -631,16 +638,19 @@ static TypeInfo spapr_tce_table_info =3D { static void spapr_iommu_memory_region_class_init(ObjectClass *klass, void = *data) { IOMMUMemoryRegionClass *imrc =3D IOMMU_MEMORY_REGION_CLASS(klass); + sPAPRIOMMUMemoryRegionClass *simrc =3D SPAPR_IOMMU_MEMORY_REGION_CLASS= (klass); =20 imrc->translate =3D spapr_tce_translate_iommu; imrc->get_min_page_size =3D spapr_tce_get_min_page_size; imrc->notify_flag_changed =3D spapr_tce_notify_flag_changed; + simrc->get_fd =3D spapr_tce_get_fd; } =20 static const TypeInfo spapr_iommu_memory_region_info =3D { .parent =3D TYPE_IOMMU_MEMORY_REGION, .name =3D TYPE_SPAPR_IOMMU_MEMORY_REGION, .class_init =3D spapr_iommu_memory_region_class_init, + .class_size =3D sizeof(sPAPRIOMMUMemoryRegionClass), }; =20 static void register_types(void) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 7b2924c0ef..92f1f88ae8 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -454,6 +454,16 @@ static void vfio_listener_region_add(MemoryListener *l= istener, goto fail; } =20 +#ifdef CONFIG_KVM + if (kvm_enabled()) { + VFIOGroup *group; + + QLIST_FOREACH(group, &container->group_list, container_next) { + vfio_spapr_notify_kvm(vfio_kvm_device_fd, group->fd, + IOMMU_MEMORY_REGION(section->mr)); + } + } +#endif vfio_host_win_add(container, section->offset_within_address_space, section->offset_within_address_space + int128_get64(section->size) - 1, pgsize); diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index 32fd6a9b54..2b9af75c03 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -15,8 +15,12 @@ =20 #include "hw/vfio/vfio-common.h" #include "hw/hw.h" +#include "hw/ppc/spapr.h" #include "qemu/error-report.h" #include "trace.h" +#ifdef CONFIG_KVM +#include "linux/kvm.h" +#endif =20 static bool vfio_prereg_listener_skipped_section(MemoryRegionSection *sect= ion) { @@ -188,6 +192,41 @@ int vfio_spapr_create_window(VFIOContainer *container, return 0; } =20 +int vfio_spapr_notify_kvm(int vfio_kvm_device_fd, int groupfd, + IOMMUMemoryRegion *iommu_mr) +{ +#ifdef CONFIG_KVM + struct kvm_vfio_spapr_tce param =3D { + .groupfd =3D groupfd, + }; + struct kvm_device_attr attr =3D { + .group =3D KVM_DEV_VFIO_GROUP, + .attr =3D KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE, + .addr =3D (uint64_t)(unsigned long)¶m, + }; + IOMMUMemoryRegion *spapr_iommu_mr =3D SPAPR_IOMMU_MEMORY_REGION(iommu_= mr); + sPAPRIOMMUMemoryRegionClass *simrc =3D + SPAPR_IOMMU_MEMORY_REGION_GET_CLASS(spapr_iommu_mr); + + if (!simrc->get_fd) { + error_report("vfio: No get_fd defined for IOMMU MR"); + return -EFAULT; + } + + param.tablefd =3D simrc->get_fd(spapr_iommu_mr); + + if (param.tablefd !=3D -1) { + if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) { + error_report("vfio: failed to setup fd %d for a group with fd = %d: %s", + param.tablefd, param.groupfd, strerror(errno)); + return -errno; + } + } + trace_vfio_spapr_notify_kvm(groupfd, param.tablefd); +#endif + return 0; +} + int vfio_spapr_remove_window(VFIOContainer *container, hwaddr offset_within_address_space) { diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 2561c6d31a..084a92f7c2 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -123,3 +123,4 @@ vfio_prereg_register(uint64_t va, uint64_t size, int re= t) "va=3D%"PRIx64" size=3D%"P vfio_prereg_unregister(uint64_t va, uint64_t size, int ret) "va=3D%"PRIx64= " size=3D%"PRIx64" ret=3D%d" vfio_spapr_create_window(int ps, uint64_t ws, uint64_t off) "pageshift=3D0= x%x winsize=3D0x%"PRIx64" offset=3D0x%"PRIx64 vfio_spapr_remove_window(uint64_t off) "offset=3D%"PRIx64 +vfio_spapr_notify_kvm(int groupfd, int tablefd) "Attached groupfd %d to li= obn fd %d" --=20 2.11.0 From nobody Sun Apr 28 01:01:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500535451959967.5490720629325; Thu, 20 Jul 2017 00:24:11 -0700 (PDT) Received: from localhost ([::1]:36406 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY5of-00075D-Qf for importer@patchew.org; Thu, 20 Jul 2017 03:24:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY5nH-0006Fd-19 for qemu-devel@nongnu.org; Thu, 20 Jul 2017 03:22:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY5nE-00030q-9R for qemu-devel@nongnu.org; Thu, 20 Jul 2017 03:22:43 -0400 Received: from ozlabs.ru ([107.173.13.209]:59566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY5nE-00030X-2y; Thu, 20 Jul 2017 03:22:40 -0400 Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 080683A6006E; Thu, 20 Jul 2017 03:23:30 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 17:22:31 +1000 Message-Id: <20170720072231.35054-4-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170720072231.35054-1-aik@ozlabs.ru> References: <20170720072231.35054-1-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu v4 3/3] spapr/iommu: Enable in-kernel TCE acceleration via VFIO KVM device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Alex Williamson , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This uses new kernel KVM_CAP_SPAPR_TCE_VFIO capability to enable in-kernel acceleration of TCE update requests which will go via the VFIO KVM device. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- target/ppc/kvm_ppc.h | 6 ++++++ hw/ppc/spapr_iommu.c | 4 ++++ target/ppc/kvm.c | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 6bc6fb3e2d..96936ec50f 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -46,6 +46,7 @@ void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t pa= ge_shift, int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size); int kvmppc_reset_htab(int shift_hint); uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift); +bool kvmppc_has_cap_spapr_vfio(void); #endif /* !CONFIG_USER_ONLY */ bool kvmppc_has_cap_epr(void); int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function); @@ -220,6 +221,11 @@ static inline bool kvmppc_is_mem_backend_page_size_ok(= const char *obj_path) return true; } =20 +static inline bool kvmppc_has_cap_spapr_vfio(void) +{ + return false; +} + #endif /* !CONFIG_USER_ONLY */ =20 static inline bool kvmppc_has_cap_epr(void) diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index 82fca61a75..3b4c1f50f4 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -289,6 +289,10 @@ void spapr_tce_set_need_vfio(sPAPRTCETable *tcet, bool= need_vfio) =20 tcet->need_vfio =3D need_vfio; =20 + if (!need_vfio || (tcet->fd !=3D -1 && kvmppc_has_cap_spapr_vfio())) { + return; + } + oldtable =3D tcet->table; =20 tcet->table =3D spapr_tce_alloc_table(tcet->liobn, diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 85713795de..413ce84509 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -134,7 +134,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_spapr_tce =3D kvm_check_extension(s, KVM_CAP_SPAPR_TCE); cap_spapr_tce_64 =3D kvm_check_extension(s, KVM_CAP_SPAPR_TCE_64); cap_spapr_multitce =3D kvm_check_extension(s, KVM_CAP_SPAPR_MULTITCE); - cap_spapr_vfio =3D false; + cap_spapr_vfio =3D kvm_check_extension(s, KVM_CAP_SPAPR_TCE_VFIO); cap_one_reg =3D kvm_check_extension(s, KVM_CAP_ONE_REG); cap_hior =3D kvm_check_extension(s, KVM_CAP_PPC_HIOR); cap_epr =3D kvm_check_extension(s, KVM_CAP_PPC_EPR); @@ -2428,6 +2428,11 @@ bool kvmppc_has_cap_mmu_hash_v3(void) return cap_mmu_hash_v3; } =20 +bool kvmppc_has_cap_spapr_vfio(void) +{ + return cap_spapr_vfio; +} + PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) { uint32_t host_pvr =3D mfpvr(); --=20 2.11.0