* [PATCH v2 00/21] hw/vfio: Build various objects once
@ 2025-03-08 23:08 Philippe Mathieu-Daudé
2025-03-08 23:08 ` [PATCH v2 01/21] hw/vfio/common: Include missing 'system/tcg.h' header Philippe Mathieu-Daudé
` (22 more replies)
0 siblings, 23 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:08 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
By doing the following changes:
- Clean some headers up
- Replace compile-time CONFIG_KVM check by kvm_enabled()
- Replace compile-time CONFIG_IOMMUFD check by iommufd_builtin()
we can build less vfio objects.
Since v1:
- Added R-b tags
- Introduce type_is_registered()
- Split builtin check VS meson changes (rth)
- Consider IGD
Philippe Mathieu-Daudé (21):
hw/vfio/common: Include missing 'system/tcg.h' header
hw/vfio/spapr: Do not include <linux/kvm.h>
hw/vfio: Compile some common objects once
hw/vfio: Compile more objects once
hw/vfio: Compile iommufd.c once
system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h'
hw/vfio: Compile display.c once
system/kvm: Expose kvm_irqchip_[add,remove]_change_notifier()
hw/vfio/pci: Convert CONFIG_KVM check to runtime one
qom: Introduce type_is_registered()
hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE
hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin()
hw/vfio/igd: Compile once
system/iommufd: Introduce iommufd_builtin() helper
hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
hw/vfio/pci: Compile once
hw/vfio/ap: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
hw/vfio/ccw: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
hw/vfio/s390x: Compile AP and CCW once
hw/vfio/platform: Check CONFIG_IOMMUFD at runtime using
iommufd_builtin
hw/vfio/platform: Compile once
docs/devel/vfio-iommufd.rst | 2 +-
hw/vfio/pci-quirks.h | 8 +++++
include/exec/ram_addr.h | 3 --
include/qom/object.h | 8 +++++
include/system/hostmem.h | 3 ++
include/system/iommufd.h | 6 ++++
include/system/kvm.h | 8 ++---
target/s390x/kvm/kvm_s390x.h | 2 +-
hw/ppc/spapr_caps.c | 1 +
hw/s390x/s390-virtio-ccw.c | 1 +
hw/vfio/ap.c | 27 ++++++++---------
hw/vfio/ccw.c | 27 ++++++++---------
hw/vfio/common.c | 1 +
hw/vfio/igd-stubs.c | 20 +++++++++++++
hw/vfio/igd.c | 4 +--
hw/vfio/iommufd.c | 1 -
hw/vfio/migration.c | 1 -
hw/vfio/pci-quirks.c | 9 +++---
hw/vfio/pci.c | 57 +++++++++++++++++-------------------
hw/vfio/platform.c | 25 ++++++++--------
hw/vfio/spapr.c | 4 +--
qom/object.c | 5 ++++
hw/vfio/meson.build | 35 +++++++++++++---------
23 files changed, 152 insertions(+), 106 deletions(-)
create mode 100644 hw/vfio/igd-stubs.c
--
2.47.1
^ permalink raw reply [flat|nested] 54+ messages in thread
* [PATCH v2 01/21] hw/vfio/common: Include missing 'system/tcg.h' header
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
@ 2025-03-08 23:08 ` Philippe Mathieu-Daudé
2025-03-10 8:08 ` Eric Auger
2025-03-08 23:08 ` [PATCH v2 02/21] hw/vfio/spapr: Do not include <linux/kvm.h> Philippe Mathieu-Daudé
` (21 subsequent siblings)
22 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:08 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Always include necessary headers explicitly, to avoid
when refactoring unrelated ones:
hw/vfio/common.c:1176:45: error: implicit declaration of function ‘tcg_enabled’;
1176 | tcg_enabled() ? DIRTY_CLIENTS_ALL :
| ^~~~~~~~~~~
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/common.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 7a4010ef4ee..b1596b6bf64 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -42,6 +42,7 @@
#include "migration/misc.h"
#include "migration/blocker.h"
#include "migration/qemu-file.h"
+#include "system/tcg.h"
#include "system/tpm.h"
VFIODeviceList vfio_device_list =
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 02/21] hw/vfio/spapr: Do not include <linux/kvm.h>
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
2025-03-08 23:08 ` [PATCH v2 01/21] hw/vfio/common: Include missing 'system/tcg.h' header Philippe Mathieu-Daudé
@ 2025-03-08 23:08 ` Philippe Mathieu-Daudé
2025-03-10 8:08 ` Eric Auger
2025-03-08 23:08 ` [PATCH v2 03/21] hw/vfio: Compile some common objects once Philippe Mathieu-Daudé
` (20 subsequent siblings)
22 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:08 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
<linux/kvm.h> is already include by "system/kvm.h" in the next line.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/spapr.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
index ad4c499eafe..9b5ad05bb1c 100644
--- a/hw/vfio/spapr.c
+++ b/hw/vfio/spapr.c
@@ -11,9 +11,6 @@
#include "qemu/osdep.h"
#include <sys/ioctl.h>
#include <linux/vfio.h>
-#ifdef CONFIG_KVM
-#include <linux/kvm.h>
-#endif
#include "system/kvm.h"
#include "exec/address-spaces.h"
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 03/21] hw/vfio: Compile some common objects once
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
2025-03-08 23:08 ` [PATCH v2 01/21] hw/vfio/common: Include missing 'system/tcg.h' header Philippe Mathieu-Daudé
2025-03-08 23:08 ` [PATCH v2 02/21] hw/vfio/spapr: Do not include <linux/kvm.h> Philippe Mathieu-Daudé
@ 2025-03-08 23:08 ` Philippe Mathieu-Daudé
2025-03-10 8:19 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 04/21] hw/vfio: Compile more " Philippe Mathieu-Daudé
` (19 subsequent siblings)
22 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:08 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Some files don't rely on any target-specific knowledge
and can be compiled once:
- helpers.c
- container-base.c
- migration.c (removing unnecessary "exec/ram_addr.h")
- migration-multifd.c
- cpr.c
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/migration.c | 1 -
hw/vfio/meson.build | 13 ++++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 416643ddd69..fbff46cfc35 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -27,7 +27,6 @@
#include "qapi/error.h"
#include "qapi/qapi-events-vfio.h"
#include "exec/ramlist.h"
-#include "exec/ram_addr.h"
#include "pci.h"
#include "trace.h"
#include "hw/hw.h"
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 260d65febd6..8e376cfcbf8 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -1,12 +1,7 @@
vfio_ss = ss.source_set()
vfio_ss.add(files(
- 'helpers.c',
'common.c',
- 'container-base.c',
'container.c',
- 'migration.c',
- 'migration-multifd.c',
- 'cpr.c',
))
vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
vfio_ss.add(when: 'CONFIG_IOMMUFD', if_true: files(
@@ -25,3 +20,11 @@ vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
+
+system_ss.add(when: 'CONFIG_VFIO', if_true: files(
+ 'helpers.c',
+ 'container-base.c',
+ 'migration.c',
+ 'migration-multifd.c',
+ 'cpr.c',
+))
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 04/21] hw/vfio: Compile more objects once
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-03-08 23:08 ` [PATCH v2 03/21] hw/vfio: Compile some common objects once Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-10 8:20 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 05/21] hw/vfio: Compile iommufd.c once Philippe Mathieu-Daudé
` (18 subsequent siblings)
22 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
These files depend on the VFIO symbol in their Kconfig
definition. They don't rely on target specific definitions,
move them to system_ss[] to build them once.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/meson.build | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 8e376cfcbf8..784eae4b559 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -14,13 +14,13 @@ vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
))
vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
-vfio_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c'))
-vfio_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c'))
vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
+system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c'))
+system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c'))
system_ss.add(when: 'CONFIG_VFIO', if_true: files(
'helpers.c',
'container-base.c',
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 05/21] hw/vfio: Compile iommufd.c once
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 04/21] hw/vfio: Compile more " Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-10 8:23 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 06/21] system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h' Philippe Mathieu-Daudé
` (17 subsequent siblings)
22 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Removing unused "exec/ram_addr.h" header allow to compile
iommufd.c once for all targets.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/iommufd.c | 1 -
hw/vfio/meson.build | 6 +++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index df61edffc08..42c8412bbf5 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -25,7 +25,6 @@
#include "qemu/cutils.h"
#include "qemu/chardev_open.h"
#include "pci.h"
-#include "exec/ram_addr.h"
static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova,
ram_addr_t size, void *vaddr, bool readonly)
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 784eae4b559..5c9ec7e8971 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -4,9 +4,6 @@ vfio_ss.add(files(
'container.c',
))
vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
-vfio_ss.add(when: 'CONFIG_IOMMUFD', if_true: files(
- 'iommufd.c',
-))
vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
'display.c',
'pci-quirks.c',
@@ -28,3 +25,6 @@ system_ss.add(when: 'CONFIG_VFIO', if_true: files(
'migration-multifd.c',
'cpr.c',
))
+system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files(
+ 'iommufd.c',
+))
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 06/21] system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h'
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 05/21] hw/vfio: Compile iommufd.c once Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-10 8:28 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 07/21] hw/vfio: Compile display.c once Philippe Mathieu-Daudé
` (16 subsequent siblings)
22 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Both qemu_minrampagesize() and qemu_maxrampagesize() are
related to host memory backends, having the following call
stack:
qemu_minrampagesize()
-> find_min_backend_pagesize()
-> object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)
qemu_maxrampagesize()
-> find_max_backend_pagesize()
-> object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)
Having TYPE_MEMORY_BACKEND defined in "system/hostmem.h":
include/system/hostmem.h:23:#define TYPE_MEMORY_BACKEND "memory-backend"
Move their prototype declaration to "system/hostmem.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
include/exec/ram_addr.h | 3 ---
include/system/hostmem.h | 3 +++
hw/ppc/spapr_caps.c | 1 +
hw/s390x/s390-virtio-ccw.c | 1 +
hw/vfio/spapr.c | 1 +
5 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 94bb3ccbe42..ccc8df561af 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -101,9 +101,6 @@ static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,
bool ramblock_is_pmem(RAMBlock *rb);
-long qemu_minrampagesize(void);
-long qemu_maxrampagesize(void);
-
/**
* qemu_ram_alloc_from_file,
* qemu_ram_alloc_from_fd: Allocate a ram block from the specified backing
diff --git a/include/system/hostmem.h b/include/system/hostmem.h
index 5c21ca55c01..62642e602ca 100644
--- a/include/system/hostmem.h
+++ b/include/system/hostmem.h
@@ -93,4 +93,7 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
size_t host_memory_backend_pagesize(HostMemoryBackend *memdev);
char *host_memory_backend_get_name(HostMemoryBackend *backend);
+long qemu_minrampagesize(void);
+long qemu_maxrampagesize(void);
+
#endif
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index 904bff87ce1..9e53d0c1fd1 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -34,6 +34,7 @@
#include "kvm_ppc.h"
#include "migration/vmstate.h"
#include "system/tcg.h"
+#include "system/hostmem.h"
#include "hw/ppc/spapr.h"
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 51ae0c133d8..1261d93b7ce 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -41,6 +41,7 @@
#include "hw/s390x/tod.h"
#include "system/system.h"
#include "system/cpus.h"
+#include "system/hostmem.h"
#include "target/s390x/kvm/pv.h"
#include "migration/blocker.h"
#include "qapi/visitor.h"
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
index 9b5ad05bb1c..1a5d1611f2c 100644
--- a/hw/vfio/spapr.c
+++ b/hw/vfio/spapr.c
@@ -12,6 +12,7 @@
#include <sys/ioctl.h>
#include <linux/vfio.h>
#include "system/kvm.h"
+#include "system/hostmem.h"
#include "exec/address-spaces.h"
#include "hw/vfio/vfio-common.h"
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 07/21] hw/vfio: Compile display.c once
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 06/21] system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h' Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-10 8:29 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add, remove]_change_notifier() Philippe Mathieu-Daudé
` (15 subsequent siblings)
22 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
display.c doesn't rely on target specific definitions,
move it to system_ss[] to build it once.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/meson.build | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 5c9ec7e8971..a8939c83865 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -5,7 +5,6 @@ vfio_ss.add(files(
))
vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
- 'display.c',
'pci-quirks.c',
'pci.c',
))
@@ -28,3 +27,6 @@ system_ss.add(when: 'CONFIG_VFIO', if_true: files(
system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files(
'iommufd.c',
))
+system_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
+ 'display.c',
+))
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add, remove]_change_notifier()
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 07/21] hw/vfio: Compile display.c once Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-09 18:54 ` [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add,remove]_change_notifier() Richard Henderson
2025-03-10 8:35 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 09/21] hw/vfio/pci: Convert CONFIG_KVM check to runtime one Philippe Mathieu-Daudé
` (14 subsequent siblings)
22 siblings, 2 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Currently kvm_irqchip_add_irqfd_notifier() and
kvm_irqchip_remove_irqfd_notifier() are only declared on
target specific code. There is not particular reason to,
as their prototypes don't use anything target related.
Move their declaration with common prototypes, otherwise
the next commit would trigger:
hw/vfio/pci.c: In function ‘vfio_realize’:
hw/vfio/pci.c:3178:9: error: implicit declaration of function ‘kvm_irqchip_add_change_notifier’
3178 | kvm_irqchip_add_change_notifier(&vdev->irqchip_change_notifier);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| kvm_irqchip_add_irqfd_notifier
hw/vfio/pci.c:3236:9: error: implicit declaration of function ‘kvm_irqchip_remove_change_notifier’
3236 | kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| kvm_irqchip_remove_irqfd_notifier
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/kvm.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/system/kvm.h b/include/system/kvm.h
index ab17c09a551..75673fb794e 100644
--- a/include/system/kvm.h
+++ b/include/system/kvm.h
@@ -412,10 +412,6 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg);
void kvm_irqchip_add_irq_route(KVMState *s, int gsi, int irqchip, int pin);
-void kvm_irqchip_add_change_notifier(Notifier *n);
-void kvm_irqchip_remove_change_notifier(Notifier *n);
-void kvm_irqchip_change_notify(void);
-
struct kvm_guest_debug;
struct kvm_debug_exit_arch;
@@ -517,6 +513,10 @@ void kvm_irqchip_release_virq(KVMState *s, int virq);
void kvm_add_routing_entry(KVMState *s,
struct kvm_irq_routing_entry *entry);
+void kvm_irqchip_add_change_notifier(Notifier *n);
+void kvm_irqchip_remove_change_notifier(Notifier *n);
+void kvm_irqchip_change_notify(void);
+
int kvm_irqchip_add_irqfd_notifier_gsi(KVMState *s, EventNotifier *n,
EventNotifier *rn, int virq);
int kvm_irqchip_remove_irqfd_notifier_gsi(KVMState *s, EventNotifier *n,
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 09/21] hw/vfio/pci: Convert CONFIG_KVM check to runtime one
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add, remove]_change_notifier() Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-10 9:54 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 10/21] qom: Introduce type_is_registered() Philippe Mathieu-Daudé
` (13 subsequent siblings)
22 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Use the runtime kvm_enabled() helper to check whether
KVM is available or not.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/pci.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index fdbc15885d4..9872884ff8a 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -118,8 +118,13 @@ static void vfio_intx_eoi(VFIODevice *vbasedev)
static bool vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
{
-#ifdef CONFIG_KVM
- int irq_fd = event_notifier_get_fd(&vdev->intx.interrupt);
+ int irq_fd;
+
+ if (!kvm_enabled()) {
+ return true;
+ }
+
+ irq_fd = event_notifier_get_fd(&vdev->intx.interrupt);
if (vdev->no_kvm_intx || !kvm_irqfds_enabled() ||
vdev->intx.route.mode != PCI_INTX_ENABLED ||
@@ -171,16 +176,13 @@ fail_irqfd:
fail:
qemu_set_fd_handler(irq_fd, vfio_intx_interrupt, NULL, vdev);
vfio_unmask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
+
return false;
-#else
- return true;
-#endif
}
static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev)
{
-#ifdef CONFIG_KVM
- if (!vdev->intx.kvm_accel) {
+ if (!kvm_enabled() || !vdev->intx.kvm_accel) {
return;
}
@@ -211,7 +213,6 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev)
vfio_unmask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
trace_vfio_intx_disable_kvm(vdev->vbasedev.name);
-#endif
}
static void vfio_intx_update(VFIOPCIDevice *vdev, PCIINTxRoute *route)
@@ -278,7 +279,6 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
vdev->intx.pin = pin - 1; /* Pin A (1) -> irq[0] */
pci_config_set_interrupt_pin(vdev->pdev.config, pin);
-#ifdef CONFIG_KVM
/*
* Only conditional to avoid generating error messages on platforms
* where we won't actually use the result anyway.
@@ -287,7 +287,6 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
vdev->intx.route = pci_device_route_intx_to_irq(&vdev->pdev,
vdev->intx.pin);
}
-#endif
ret = event_notifier_init(&vdev->intx.interrupt, 0);
if (ret) {
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 10/21] qom: Introduce type_is_registered()
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 09/21] hw/vfio/pci: Convert CONFIG_KVM check to runtime one Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-09 19:14 ` Richard Henderson
` (2 more replies)
2025-03-08 23:09 ` [PATCH v2 11/21] hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE Philippe Mathieu-Daudé
` (12 subsequent siblings)
22 siblings, 3 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
In order to be able to check whether a QOM type has been
registered, introduce the type_is_registered() helper.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qom/object.h | 8 ++++++++
qom/object.c | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index 9192265db76..5b5333017e0 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -898,6 +898,14 @@ Type type_register_static(const TypeInfo *info);
*/
void type_register_static_array(const TypeInfo *infos, int nr_infos);
+/**
+ * type_is_registered:
+ * @typename: The @typename to check.
+ *
+ * Returns: %true if @typename has been registered, %false otherwise.
+ */
+bool type_is_registered(const char *typename);
+
/**
* DEFINE_TYPES:
* @type_array: The array containing #TypeInfo structures to register
diff --git a/qom/object.c b/qom/object.c
index 01618d06bd8..be442980049 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -100,6 +100,11 @@ static TypeImpl *type_table_lookup(const char *name)
return g_hash_table_lookup(type_table_get(), name);
}
+bool type_is_registered(const char *typename)
+{
+ return !!type_table_lookup(typename);
+}
+
static TypeImpl *type_new(const TypeInfo *info)
{
TypeImpl *ti = g_malloc0(sizeof(*ti));
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 11/21] hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 10/21] qom: Introduce type_is_registered() Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-10 7:38 ` Cédric Le Goater
2025-03-10 9:54 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin() Philippe Mathieu-Daudé
` (11 subsequent siblings)
22 siblings, 2 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE once to help
following where the QOM type is used in the code.
We'll use it once more in the next commit.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/pci-quirks.h | 2 ++
hw/vfio/igd.c | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/pci-quirks.h b/hw/vfio/pci-quirks.h
index d1532e379b1..fdaa81f00aa 100644
--- a/hw/vfio/pci-quirks.h
+++ b/hw/vfio/pci-quirks.h
@@ -69,4 +69,6 @@ typedef struct VFIOConfigMirrorQuirk {
extern const MemoryRegionOps vfio_generic_mirror_quirk;
+#define TYPE_VFIO_PCI_IGD_LPC_BRIDGE "vfio-pci-igd-lpc-bridge"
+
#endif /* HW_VFIO_VFIO_PCI_QUIRKS_H */
diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
index b1a237edd66..1fd3c4ef1d0 100644
--- a/hw/vfio/igd.c
+++ b/hw/vfio/igd.c
@@ -262,7 +262,7 @@ static void vfio_pci_igd_lpc_bridge_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo vfio_pci_igd_lpc_bridge_info = {
- .name = "vfio-pci-igd-lpc-bridge",
+ .name = TYPE_VFIO_PCI_IGD_LPC_BRIDGE,
.parent = TYPE_PCI_DEVICE,
.class_init = vfio_pci_igd_lpc_bridge_class_init,
.interfaces = (InterfaceInfo[]) {
@@ -524,7 +524,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
lpc_bridge = pci_find_device(pci_device_root_bus(&vdev->pdev),
0, PCI_DEVFN(0x1f, 0));
if (lpc_bridge && !object_dynamic_cast(OBJECT(lpc_bridge),
- "vfio-pci-igd-lpc-bridge")) {
+ TYPE_VFIO_PCI_IGD_LPC_BRIDGE)) {
error_report("IGD device %s cannot support legacy mode due to existing "
"devices at address 1f.0", vdev->vbasedev.name);
return;
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin()
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 11/21] hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-10 7:37 ` Cédric Le Goater
2025-03-08 23:09 ` [PATCH v2 13/21] hw/vfio/igd: Compile once Philippe Mathieu-Daudé
` (10 subsequent siblings)
22 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Convert the compile time check on the CONFIG_VFIO_IGD definition
by a runtime one by calling vfio_igd_builtin(), which check
whether VFIO_IGD is built in a qemu-system binary.
Add stubs to avoid when VFIO_IGD is not built in:
/usr/bin/ld: libqemu-x86_64-softmmu.a.p/hw_vfio_pci-quirks.c.o: in function `vfio_bar_quirk_setup':
/usr/bin/ld: ../hw/vfio/pci-quirks.c:1216: undefined reference to `vfio_probe_igd_bar0_quirk'
/usr/bin/ld: ../hw/vfio/pci-quirks.c:1217: undefined reference to `vfio_probe_igd_bar4_quirk'
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/pci-quirks.h | 6 ++++++
hw/vfio/igd-stubs.c | 20 ++++++++++++++++++++
hw/vfio/pci-quirks.c | 9 ++++-----
hw/vfio/meson.build | 3 +++
4 files changed, 33 insertions(+), 5 deletions(-)
create mode 100644 hw/vfio/igd-stubs.c
diff --git a/hw/vfio/pci-quirks.h b/hw/vfio/pci-quirks.h
index fdaa81f00aa..dcdb1962600 100644
--- a/hw/vfio/pci-quirks.h
+++ b/hw/vfio/pci-quirks.h
@@ -13,6 +13,7 @@
#define HW_VFIO_VFIO_PCI_QUIRKS_H
#include "qemu/osdep.h"
+#include "qom/object.h"
#include "exec/memop.h"
/*
@@ -71,4 +72,9 @@ extern const MemoryRegionOps vfio_generic_mirror_quirk;
#define TYPE_VFIO_PCI_IGD_LPC_BRIDGE "vfio-pci-igd-lpc-bridge"
+static inline bool vfio_igd_builtin(void)
+{
+ return type_is_registered(TYPE_VFIO_PCI_IGD_LPC_BRIDGE);
+}
+
#endif /* HW_VFIO_VFIO_PCI_QUIRKS_H */
diff --git a/hw/vfio/igd-stubs.c b/hw/vfio/igd-stubs.c
new file mode 100644
index 00000000000..5d4e88aeb1b
--- /dev/null
+++ b/hw/vfio/igd-stubs.c
@@ -0,0 +1,20 @@
+/*
+ * IGD device quirk stubs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Copyright (C) Linaro, Ltd.
+ */
+
+#include "qemu/osdep.h"
+#include "pci.h"
+
+void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr)
+{
+ g_assert_not_reached();
+}
+
+void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
+{
+ g_assert_not_reached();
+}
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index c53591fe2ba..22cb35af8cc 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -11,7 +11,6 @@
*/
#include "qemu/osdep.h"
-#include CONFIG_DEVICES
#include "exec/memop.h"
#include "qemu/units.h"
#include "qemu/log.h"
@@ -1213,10 +1212,10 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr)
vfio_probe_nvidia_bar5_quirk(vdev, nr);
vfio_probe_nvidia_bar0_quirk(vdev, nr);
vfio_probe_rtl8168_bar2_quirk(vdev, nr);
-#ifdef CONFIG_VFIO_IGD
- vfio_probe_igd_bar0_quirk(vdev, nr);
- vfio_probe_igd_bar4_quirk(vdev, nr);
-#endif
+ if (vfio_igd_builtin()) {
+ vfio_probe_igd_bar0_quirk(vdev, nr);
+ vfio_probe_igd_bar4_quirk(vdev, nr);
+ }
}
void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr)
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index a8939c83865..6ab711d0539 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -17,6 +17,9 @@ specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c'))
system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c'))
+system_ss.add(when: 'CONFIG_VFIO_IGD', if_false: files(
+ 'igd-stubs.c',
+))
system_ss.add(when: 'CONFIG_VFIO', if_true: files(
'helpers.c',
'container-base.c',
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 13/21] hw/vfio/igd: Compile once
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin() Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-10 7:39 ` Cédric Le Goater
2025-03-10 7:52 ` Cédric Le Goater
2025-03-08 23:09 ` [PATCH v2 14/21] system/iommufd: Introduce iommufd_builtin() helper Philippe Mathieu-Daudé
` (9 subsequent siblings)
22 siblings, 2 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
The file doesn't use any target-specific knowledge anymore,
move it to system_ss[] to build it once.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/meson.build | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 6ab711d0539..21c9cd6d2eb 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -11,13 +11,14 @@ vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
-vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c'))
system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c'))
-system_ss.add(when: 'CONFIG_VFIO_IGD', if_false: files(
+system_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files(
+ 'igd.c',
+), if_false: files(
'igd-stubs.c',
))
system_ss.add(when: 'CONFIG_VFIO', if_true: files(
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 14/21] system/iommufd: Introduce iommufd_builtin() helper
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 13/21] hw/vfio/igd: Compile once Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin() Philippe Mathieu-Daudé
` (8 subsequent siblings)
22 siblings, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
iommufd_builtin() can be used to check at runtime whether
the IOMMUFD feature is built in a qemu-system binary.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
docs/devel/vfio-iommufd.rst | 2 +-
include/system/iommufd.h | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/docs/devel/vfio-iommufd.rst b/docs/devel/vfio-iommufd.rst
index 3d1c11f175e..08882094eee 100644
--- a/docs/devel/vfio-iommufd.rst
+++ b/docs/devel/vfio-iommufd.rst
@@ -88,7 +88,7 @@ Step 2: configure QEMU
----------------------
Interactions with the ``/dev/iommu`` are abstracted by a new iommufd
-object (compiled in with the ``CONFIG_IOMMUFD`` option).
+object (which availability can be checked at runtime using ``iommufd_builtin()``).
Any QEMU device (e.g. VFIO device) wishing to use ``/dev/iommu`` must
be linked with an iommufd object. It gets a new optional property
diff --git a/include/system/iommufd.h b/include/system/iommufd.h
index cbab75bfbf6..3fedf8cfb63 100644
--- a/include/system/iommufd.h
+++ b/include/system/iommufd.h
@@ -63,4 +63,10 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be, uint32_t hwpt_id,
Error **errp);
#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd"
+
+static inline bool iommufd_builtin(void)
+{
+ return type_is_registered(TYPE_IOMMUFD_BACKEND);
+}
+
#endif
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 14/21] system/iommufd: Introduce iommufd_builtin() helper Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-10 4:11 ` Duan, Zhenzhong
2025-03-08 23:09 ` [PATCH v2 16/21] hw/vfio/pci: Compile once Philippe Mathieu-Daudé
` (7 subsequent siblings)
22 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Convert the compile time check on the CONFIG_IOMMUFD definition
by a runtime one by calling iommufd_builtin().
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/pci.c | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 9872884ff8a..e83252766d1 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -19,7 +19,6 @@
*/
#include "qemu/osdep.h"
-#include CONFIG_DEVICES /* CONFIG_IOMMUFD */
#include <linux/vfio.h>
#include <sys/ioctl.h>
@@ -2973,11 +2972,10 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
if (!(~vdev->host.domain || ~vdev->host.bus ||
~vdev->host.slot || ~vdev->host.function)) {
error_setg(errp, "No provided host device");
- error_append_hint(errp, "Use -device vfio-pci,host=DDDD:BB:DD.F "
-#ifdef CONFIG_IOMMUFD
- "or -device vfio-pci,fd=DEVICE_FD "
-#endif
- "or -device vfio-pci,sysfsdev=PATH_TO_DEVICE\n");
+ error_append_hint(errp, "Use -device vfio-pci,host=DDDD:BB:DD.F %s"
+ "or -device vfio-pci,sysfsdev=PATH_TO_DEVICE\n",
+ iommufd_builtin()
+ ? "or -device vfio-pci,fd=DEVICE_FD " : "");
return;
}
vbasedev->sysfsdev =
@@ -3412,19 +3410,18 @@ static const Property vfio_pci_dev_properties[] = {
qdev_prop_nv_gpudirect_clique, uint8_t),
DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_relo,
OFF_AUTO_PCIBAR_OFF),
-#ifdef CONFIG_IOMMUFD
- DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
- TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-#endif
DEFINE_PROP_BOOL("skip-vsc-check", VFIOPCIDevice, skip_vsc_check, true),
};
-#ifdef CONFIG_IOMMUFD
+static const Property vfio_pci_dev_iommufd_properties[] = {
+ DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
+ TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
+};
+
static void vfio_pci_set_fd(Object *obj, const char *str, Error **errp)
{
vfio_device_set_fd(&VFIO_PCI(obj)->vbasedev, str, errp);
}
-#endif
static void vfio_pci_dev_class_init(ObjectClass *klass, void *data)
{
@@ -3433,9 +3430,10 @@ static void vfio_pci_dev_class_init(ObjectClass *klass, void *data)
device_class_set_legacy_reset(dc, vfio_pci_reset);
device_class_set_props(dc, vfio_pci_dev_properties);
-#ifdef CONFIG_IOMMUFD
- object_class_property_add_str(klass, "fd", NULL, vfio_pci_set_fd);
-#endif
+ if (iommufd_builtin()) {
+ device_class_set_props(dc, vfio_pci_dev_iommufd_properties);
+ object_class_property_add_str(klass, "fd", NULL, vfio_pci_set_fd);
+ }
dc->desc = "VFIO-based PCI device assignment";
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
pdc->realize = vfio_realize;
@@ -3540,11 +3538,11 @@ static void vfio_pci_dev_class_init(ObjectClass *klass, void *data)
"vf-token",
"Specify UUID VF token. Required for VF when PF is owned "
"by another VFIO driver");
-#ifdef CONFIG_IOMMUFD
- object_class_property_set_description(klass, /* 9.0 */
- "iommufd",
- "Set host IOMMUFD backend device");
-#endif
+ if (iommufd_builtin()) {
+ object_class_property_set_description(klass, /* 9.0 */
+ "iommufd",
+ "Set host IOMMUFD backend device");
+ }
object_class_property_set_description(klass, /* 9.1 */
"x-device-dirty-page-tracking",
"Disable device dirty page tracking and use "
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 16/21] hw/vfio/pci: Compile once
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin() Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 17/21] hw/vfio/ap: Check CONFIG_IOMMUFD at runtime using iommufd_builtin() Philippe Mathieu-Daudé
` (6 subsequent siblings)
22 siblings, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Since the files don't use any target-specific knowledge anymore,
move them to system_ss[] to build them once.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/meson.build | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 21c9cd6d2eb..ff9bd4f2e35 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -4,10 +4,6 @@ vfio_ss.add(files(
'container.c',
))
vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
-vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
- 'pci-quirks.c',
- 'pci.c',
-))
vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
@@ -33,4 +29,6 @@ system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files(
))
system_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
'display.c',
+ 'pci.c',
+ 'pci-quirks.c',
))
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 17/21] hw/vfio/ap: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 16/21] hw/vfio/pci: Compile once Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 18/21] hw/vfio/ccw: " Philippe Mathieu-Daudé
` (5 subsequent siblings)
22 siblings, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Convert the compile time check on the CONFIG_IOMMUFD definition
by a runtime one by calling iommufd_builtin().
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/ap.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index c7ab4ff57ad..a4ec2b5f9ac 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -11,7 +11,6 @@
*/
#include "qemu/osdep.h"
-#include CONFIG_DEVICES /* CONFIG_IOMMUFD */
#include <linux/vfio.h>
#include <sys/ioctl.h>
#include "qapi/error.h"
@@ -193,10 +192,11 @@ static void vfio_ap_unrealize(DeviceState *dev)
static const Property vfio_ap_properties[] = {
DEFINE_PROP_STRING("sysfsdev", VFIOAPDevice, vdev.sysfsdev),
-#ifdef CONFIG_IOMMUFD
+};
+
+static const Property vfio_ap_iommufd_properties[] = {
DEFINE_PROP_LINK("iommufd", VFIOAPDevice, vdev.iommufd,
TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-#endif
};
static void vfio_ap_reset(DeviceState *dev)
@@ -234,21 +234,20 @@ static void vfio_ap_instance_init(Object *obj)
vbasedev->mdev = true;
}
-#ifdef CONFIG_IOMMUFD
static void vfio_ap_set_fd(Object *obj, const char *str, Error **errp)
{
vfio_device_set_fd(&VFIO_AP_DEVICE(obj)->vdev, str, errp);
}
-#endif
static void vfio_ap_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
device_class_set_props(dc, vfio_ap_properties);
-#ifdef CONFIG_IOMMUFD
- object_class_property_add_str(klass, "fd", NULL, vfio_ap_set_fd);
-#endif
+ if (iommufd_builtin()) {
+ device_class_set_props(dc, vfio_ap_iommufd_properties);
+ object_class_property_add_str(klass, "fd", NULL, vfio_ap_set_fd);
+ }
dc->vmsd = &vfio_ap_vmstate;
dc->desc = "VFIO-based AP device assignment";
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
@@ -261,11 +260,11 @@ static void vfio_ap_class_init(ObjectClass *klass, void *data)
object_class_property_set_description(klass, /* 3.1 */
"sysfsdev",
"Host sysfs path of assigned device");
-#ifdef CONFIG_IOMMUFD
- object_class_property_set_description(klass, /* 9.0 */
- "iommufd",
- "Set host IOMMUFD backend device");
-#endif
+ if (iommufd_builtin()) {
+ object_class_property_set_description(klass, /* 9.0 */
+ "iommufd",
+ "Set host IOMMUFD backend device");
+ }
}
static const TypeInfo vfio_ap_info = {
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 18/21] hw/vfio/ccw: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 17/21] hw/vfio/ap: Check CONFIG_IOMMUFD at runtime using iommufd_builtin() Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 19/21] hw/vfio/s390x: Compile AP and CCW once Philippe Mathieu-Daudé
` (4 subsequent siblings)
22 siblings, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Convert the compile time check on the CONFIG_IOMMUFD definition
by a runtime one by calling iommufd_builtin().
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/ccw.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index e5e0d9e3e7e..84d1437a568 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -15,7 +15,6 @@
*/
#include "qemu/osdep.h"
-#include CONFIG_DEVICES /* CONFIG_IOMMUFD */
#include <linux/vfio.h>
#include <linux/vfio_ccw.h>
#include <sys/ioctl.h>
@@ -650,11 +649,12 @@ static void vfio_ccw_unrealize(DeviceState *dev)
static const Property vfio_ccw_properties[] = {
DEFINE_PROP_STRING("sysfsdev", VFIOCCWDevice, vdev.sysfsdev),
DEFINE_PROP_BOOL("force-orb-pfch", VFIOCCWDevice, force_orb_pfch, false),
-#ifdef CONFIG_IOMMUFD
+ DEFINE_PROP_CCW_LOADPARM("loadparm", CcwDevice, loadparm),
+};
+
+static const Property vfio_ccw_iommufd_properties[] = {
DEFINE_PROP_LINK("iommufd", VFIOCCWDevice, vdev.iommufd,
TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-#endif
- DEFINE_PROP_CCW_LOADPARM("loadparm", CcwDevice, loadparm),
};
static const VMStateDescription vfio_ccw_vmstate = {
@@ -682,12 +682,10 @@ static void vfio_ccw_instance_init(Object *obj)
DEVICE(vcdev), true);
}
-#ifdef CONFIG_IOMMUFD
static void vfio_ccw_set_fd(Object *obj, const char *str, Error **errp)
{
vfio_device_set_fd(&VFIO_CCW(obj)->vdev, str, errp);
}
-#endif
static void vfio_ccw_class_init(ObjectClass *klass, void *data)
{
@@ -695,9 +693,10 @@ static void vfio_ccw_class_init(ObjectClass *klass, void *data)
S390CCWDeviceClass *cdc = S390_CCW_DEVICE_CLASS(klass);
device_class_set_props(dc, vfio_ccw_properties);
-#ifdef CONFIG_IOMMUFD
- object_class_property_add_str(klass, "fd", NULL, vfio_ccw_set_fd);
-#endif
+ if (iommufd_builtin()) {
+ device_class_set_props(dc, vfio_ccw_iommufd_properties);
+ object_class_property_add_str(klass, "fd", NULL, vfio_ccw_set_fd);
+ }
dc->vmsd = &vfio_ccw_vmstate;
dc->desc = "VFIO-based subchannel assignment";
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
@@ -716,11 +715,11 @@ static void vfio_ccw_class_init(ObjectClass *klass, void *data)
object_class_property_set_description(klass, /* 3.0 */
"force-orb-pfch",
"Force unlimited prefetch");
-#ifdef CONFIG_IOMMUFD
- object_class_property_set_description(klass, /* 9.0 */
- "iommufd",
- "Set host IOMMUFD backend device");
-#endif
+ if (iommufd_builtin()) {
+ object_class_property_set_description(klass, /* 9.0 */
+ "iommufd",
+ "Set host IOMMUFD backend device");
+ }
object_class_property_set_description(klass, /* 9.2 */
"loadparm",
"Define which devices that can be used for booting");
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 19/21] hw/vfio/s390x: Compile AP and CCW once
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 18/21] hw/vfio/ccw: " Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 20/21] hw/vfio/platform: Check CONFIG_IOMMUFD at runtime using iommufd_builtin Philippe Mathieu-Daudé
` (3 subsequent siblings)
22 siblings, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Since the files don't use any target-specific knowledge anymore,
move them to system_ss[] to build them once, even if they are
only used for one unique binary (qemu-system-s390x).
Because files in system_ss[] don't get the target/foo/ path in
their CPPFLAGS, use header paths relative to the root directory.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/s390x/kvm/kvm_s390x.h | 2 +-
hw/vfio/ap.c | 2 +-
hw/vfio/meson.build | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/target/s390x/kvm/kvm_s390x.h b/target/s390x/kvm/kvm_s390x.h
index 649dae5948a..7b1cce3e60d 100644
--- a/target/s390x/kvm/kvm_s390x.h
+++ b/target/s390x/kvm/kvm_s390x.h
@@ -10,7 +10,7 @@
#ifndef KVM_S390X_H
#define KVM_S390X_H
-#include "cpu-qom.h"
+#include "target/s390x/cpu-qom.h"
struct kvm_s390_irq;
diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index a4ec2b5f9ac..832b98532ea 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -23,7 +23,7 @@
#include "qemu/module.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
-#include "kvm/kvm_s390x.h"
+#include "target/s390x/kvm/kvm_s390x.h"
#include "migration/vmstate.h"
#include "hw/qdev-properties.h"
#include "hw/s390x/ap-bridge.h"
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index ff9bd4f2e35..3119c841ed9 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -4,9 +4,7 @@ vfio_ss.add(files(
'container.c',
))
vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
-vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
-vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
@@ -27,6 +25,8 @@ system_ss.add(when: 'CONFIG_VFIO', if_true: files(
system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files(
'iommufd.c',
))
+system_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
+system_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
system_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
'display.c',
'pci.c',
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 20/21] hw/vfio/platform: Check CONFIG_IOMMUFD at runtime using iommufd_builtin
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 19/21] hw/vfio/s390x: Compile AP and CCW once Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 21/21] hw/vfio/platform: Compile once Philippe Mathieu-Daudé
` (2 subsequent siblings)
22 siblings, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Convert the compile time check on the CONFIG_IOMMUFD definition
by a runtime one by calling iommufd_builtin().
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/platform.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index 67bc57409c1..265c550b747 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -15,7 +15,6 @@
*/
#include "qemu/osdep.h"
-#include CONFIG_DEVICES /* CONFIG_IOMMUFD */
#include "qapi/error.h"
#include <sys/ioctl.h>
#include <linux/vfio.h>
@@ -637,10 +636,11 @@ static const Property vfio_platform_dev_properties[] = {
DEFINE_PROP_UINT32("mmap-timeout-ms", VFIOPlatformDevice,
mmap_timeout, 1100),
DEFINE_PROP_BOOL("x-irqfd", VFIOPlatformDevice, irqfd_allowed, true),
-#ifdef CONFIG_IOMMUFD
+};
+
+static const Property vfio_platform_dev_iommufd_properties[] = {
DEFINE_PROP_LINK("iommufd", VFIOPlatformDevice, vbasedev.iommufd,
TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-#endif
};
static void vfio_platform_instance_init(Object *obj)
@@ -652,12 +652,10 @@ static void vfio_platform_instance_init(Object *obj)
DEVICE(vdev), false);
}
-#ifdef CONFIG_IOMMUFD
static void vfio_platform_set_fd(Object *obj, const char *str, Error **errp)
{
vfio_device_set_fd(&VFIO_PLATFORM_DEVICE(obj)->vbasedev, str, errp);
}
-#endif
static void vfio_platform_class_init(ObjectClass *klass, void *data)
{
@@ -666,9 +664,10 @@ static void vfio_platform_class_init(ObjectClass *klass, void *data)
dc->realize = vfio_platform_realize;
device_class_set_props(dc, vfio_platform_dev_properties);
-#ifdef CONFIG_IOMMUFD
- object_class_property_add_str(klass, "fd", NULL, vfio_platform_set_fd);
-#endif
+ if (iommufd_builtin()) {
+ device_class_set_props(dc, vfio_platform_dev_iommufd_properties);
+ object_class_property_add_str(klass, "fd", NULL, vfio_platform_set_fd);
+ }
dc->vmsd = &vfio_platform_vmstate;
dc->desc = "VFIO-based platform device assignment";
sbc->connect_irq_notifier = vfio_start_irqfd_injection;
@@ -692,11 +691,11 @@ static void vfio_platform_class_init(ObjectClass *klass, void *data)
object_class_property_set_description(klass, /* 2.6 */
"sysfsdev",
"Host sysfs path of assigned device");
-#ifdef CONFIG_IOMMUFD
- object_class_property_set_description(klass, /* 9.0 */
- "iommufd",
- "Set host IOMMUFD backend device");
-#endif
+ if (iommufd_builtin()) {
+ object_class_property_set_description(klass, /* 9.0 */
+ "iommufd",
+ "Set host IOMMUFD backend device");
+ }
}
static const TypeInfo vfio_platform_dev_info = {
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* [PATCH v2 21/21] hw/vfio/platform: Compile once
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 20/21] hw/vfio/platform: Check CONFIG_IOMMUFD at runtime using iommufd_builtin Philippe Mathieu-Daudé
@ 2025-03-08 23:09 ` Philippe Mathieu-Daudé
2025-03-10 8:03 ` [PATCH v2 00/21] hw/vfio: Build various objects once Cédric Le Goater
2025-03-11 8:08 ` Cédric Le Goater
22 siblings, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08 23:09 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora,
Cédric Le Goater, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson,
Philippe Mathieu-Daudé
Since the file doesn't use any target-specific knowledge anymore,
move it to system_ss[] to build it once.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 3119c841ed9..2bcbd052950 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -4,7 +4,6 @@ vfio_ss.add(files(
'container.c',
))
vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
-vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
@@ -27,6 +26,7 @@ system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files(
))
system_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
system_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
+system_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
system_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
'display.c',
'pci.c',
--
2.47.1
^ permalink raw reply related [flat|nested] 54+ messages in thread
* Re: [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add,remove]_change_notifier()
2025-03-08 23:09 ` [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add, remove]_change_notifier() Philippe Mathieu-Daudé
@ 2025-03-09 18:54 ` Richard Henderson
2025-03-10 8:35 ` Eric Auger
1 sibling, 0 replies; 54+ messages in thread
From: Richard Henderson @ 2025-03-09 18:54 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
On 3/8/25 15:09, Philippe Mathieu-Daudé wrote:
> Currently kvm_irqchip_add_irqfd_notifier() and
> kvm_irqchip_remove_irqfd_notifier() are only declared on
> target specific code. There is not particular reason to,
> as their prototypes don't use anything target related.
>
> Move their declaration with common prototypes, otherwise
> the next commit would trigger:
>
> hw/vfio/pci.c: In function ‘vfio_realize’:
> hw/vfio/pci.c:3178:9: error: implicit declaration of function ‘kvm_irqchip_add_change_notifier’
> 3178 | kvm_irqchip_add_change_notifier(&vdev->irqchip_change_notifier);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> | kvm_irqchip_add_irqfd_notifier
> hw/vfio/pci.c:3236:9: error: implicit declaration of function ‘kvm_irqchip_remove_change_notifier’
> 3236 | kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> | kvm_irqchip_remove_irqfd_notifier
>
> Reviewed-by: Pierrick Bouvier<pierrick.bouvier@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> include/system/kvm.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 10/21] qom: Introduce type_is_registered()
2025-03-08 23:09 ` [PATCH v2 10/21] qom: Introduce type_is_registered() Philippe Mathieu-Daudé
@ 2025-03-09 19:14 ` Richard Henderson
2025-03-10 7:38 ` Cédric Le Goater
2025-03-10 9:54 ` Eric Auger
2 siblings, 0 replies; 54+ messages in thread
From: Richard Henderson @ 2025-03-09 19:14 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
On 3/8/25 15:09, Philippe Mathieu-Daudé wrote:
> In order to be able to check whether a QOM type has been
> registered, introduce the type_is_registered() helper.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> include/qom/object.h | 8 ++++++++
> qom/object.c | 5 +++++
> 2 files changed, 13 insertions(+)
Does the non-initialization of the type matter for your usage?
In other words, would object_class_by_name() do the job just as well?
But seems reasonable, anyway.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 54+ messages in thread
* RE: [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
2025-03-08 23:09 ` [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin() Philippe Mathieu-Daudé
@ 2025-03-10 4:11 ` Duan, Zhenzhong
2025-03-10 13:37 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 54+ messages in thread
From: Duan, Zhenzhong @ 2025-03-10 4:11 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel@nongnu.org
Cc: Liu, Yi L, Pierrick Bouvier, Alex Williamson,
Christian Borntraeger, Alex Bennée, Tony Krowiak,
Nicholas Piggin, Halil Pasic, Thomas Huth, David Hildenbrand,
Igor Mammedov, Matthew Rosato, Tomita Moeko, qemu-ppc@nongnu.org,
Daniel Henrique Barboza, Eric Farman, Eduardo Habkost, Peter Xu,
kvm@vger.kernel.org, qemu-s390x@nongnu.org, Eric Auger,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
Hi Philippe,
>-----Original Message-----
>From: Philippe Mathieu-Daudé <philmd@linaro.org>
>Subject: [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime
>using iommufd_builtin()
>
>Convert the compile time check on the CONFIG_IOMMUFD definition
>by a runtime one by calling iommufd_builtin().
>
>Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>---
> hw/vfio/pci.c | 38 ++++++++++++++++++--------------------
> 1 file changed, 18 insertions(+), 20 deletions(-)
>
>diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
>index 9872884ff8a..e83252766d1 100644
>--- a/hw/vfio/pci.c
>+++ b/hw/vfio/pci.c
>@@ -19,7 +19,6 @@
> */
>
> #include "qemu/osdep.h"
>-#include CONFIG_DEVICES /* CONFIG_IOMMUFD */
> #include <linux/vfio.h>
> #include <sys/ioctl.h>
>
>@@ -2973,11 +2972,10 @@ static void vfio_realize(PCIDevice *pdev, Error
>**errp)
> if (!(~vdev->host.domain || ~vdev->host.bus ||
> ~vdev->host.slot || ~vdev->host.function)) {
> error_setg(errp, "No provided host device");
>- error_append_hint(errp, "Use -device vfio-pci,host=DDDD:BB:DD.F "
>-#ifdef CONFIG_IOMMUFD
>- "or -device vfio-pci,fd=DEVICE_FD "
>-#endif
>- "or -device vfio-pci,sysfsdev=PATH_TO_DEVICE\n");
>+ error_append_hint(errp, "Use -device vfio-pci,host=DDDD:BB:DD.F %s"
>+ "or -device vfio-pci,sysfsdev=PATH_TO_DEVICE\n",
>+ iommufd_builtin()
>+ ? "or -device vfio-pci,fd=DEVICE_FD " : "");
> return;
> }
> vbasedev->sysfsdev =
>@@ -3412,19 +3410,18 @@ static const Property vfio_pci_dev_properties[] = {
> qdev_prop_nv_gpudirect_clique, uint8_t),
> DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice,
>msix_relo,
> OFF_AUTO_PCIBAR_OFF),
>-#ifdef CONFIG_IOMMUFD
>- DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
>- TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
>-#endif
> DEFINE_PROP_BOOL("skip-vsc-check", VFIOPCIDevice, skip_vsc_check, true),
> };
>
>-#ifdef CONFIG_IOMMUFD
>+static const Property vfio_pci_dev_iommufd_properties[] = {
>+ DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
>+ TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
>+};
>+
> static void vfio_pci_set_fd(Object *obj, const char *str, Error **errp)
> {
> vfio_device_set_fd(&VFIO_PCI(obj)->vbasedev, str, errp);
> }
>-#endif
>
> static void vfio_pci_dev_class_init(ObjectClass *klass, void *data)
> {
>@@ -3433,9 +3430,10 @@ static void vfio_pci_dev_class_init(ObjectClass *klass,
>void *data)
>
> device_class_set_legacy_reset(dc, vfio_pci_reset);
> device_class_set_props(dc, vfio_pci_dev_properties);
>-#ifdef CONFIG_IOMMUFD
>- object_class_property_add_str(klass, "fd", NULL, vfio_pci_set_fd);
>-#endif
>+ if (iommufd_builtin()) {
>+ device_class_set_props(dc, vfio_pci_dev_iommufd_properties);
device_class_set_props() is called twice. Won't it break qdev_print_props() and qdev_prop_walk()?
Thanks
Zhenzhong
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin()
2025-03-08 23:09 ` [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin() Philippe Mathieu-Daudé
@ 2025-03-10 7:37 ` Cédric Le Goater
2025-03-10 13:43 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 54+ messages in thread
From: Cédric Le Goater @ 2025-03-10 7:37 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 3/9/25 00:09, Philippe Mathieu-Daudé wrote:
> Convert the compile time check on the CONFIG_VFIO_IGD definition
> by a runtime one by calling vfio_igd_builtin(), which check
> whether VFIO_IGD is built in a qemu-system binary.
>
> Add stubs to avoid when VFIO_IGD is not built in:
I thought we were trying to avoid stubs in QEMU build. Did that change ?
Thanks,
C.
>
> /usr/bin/ld: libqemu-x86_64-softmmu.a.p/hw_vfio_pci-quirks.c.o: in function `vfio_bar_quirk_setup':
> /usr/bin/ld: ../hw/vfio/pci-quirks.c:1216: undefined reference to `vfio_probe_igd_bar0_quirk'
> /usr/bin/ld: ../hw/vfio/pci-quirks.c:1217: undefined reference to `vfio_probe_igd_bar4_quirk'
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/vfio/pci-quirks.h | 6 ++++++
> hw/vfio/igd-stubs.c | 20 ++++++++++++++++++++
> hw/vfio/pci-quirks.c | 9 ++++-----
> hw/vfio/meson.build | 3 +++
> 4 files changed, 33 insertions(+), 5 deletions(-)
> create mode 100644 hw/vfio/igd-stubs.c
>
> diff --git a/hw/vfio/pci-quirks.h b/hw/vfio/pci-quirks.h
> index fdaa81f00aa..dcdb1962600 100644
> --- a/hw/vfio/pci-quirks.h
> +++ b/hw/vfio/pci-quirks.h
> @@ -13,6 +13,7 @@
> #define HW_VFIO_VFIO_PCI_QUIRKS_H
>
> #include "qemu/osdep.h"
> +#include "qom/object.h"
> #include "exec/memop.h"
>
> /*
> @@ -71,4 +72,9 @@ extern const MemoryRegionOps vfio_generic_mirror_quirk;
>
> #define TYPE_VFIO_PCI_IGD_LPC_BRIDGE "vfio-pci-igd-lpc-bridge"
>
> +static inline bool vfio_igd_builtin(void)
> +{
> + return type_is_registered(TYPE_VFIO_PCI_IGD_LPC_BRIDGE);
> +}
> +
> #endif /* HW_VFIO_VFIO_PCI_QUIRKS_H */
> diff --git a/hw/vfio/igd-stubs.c b/hw/vfio/igd-stubs.c
> new file mode 100644
> index 00000000000..5d4e88aeb1b
> --- /dev/null
> +++ b/hw/vfio/igd-stubs.c
> @@ -0,0 +1,20 @@
> +/*
> + * IGD device quirk stubs
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + * Copyright (C) Linaro, Ltd.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "pci.h"
> +
> +void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr)
> +{
> + g_assert_not_reached();
> +}
> +
> +void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
> +{
> + g_assert_not_reached();
> +}
> diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
> index c53591fe2ba..22cb35af8cc 100644
> --- a/hw/vfio/pci-quirks.c
> +++ b/hw/vfio/pci-quirks.c
> @@ -11,7 +11,6 @@
> */
>
> #include "qemu/osdep.h"
> -#include CONFIG_DEVICES
> #include "exec/memop.h"
> #include "qemu/units.h"
> #include "qemu/log.h"
> @@ -1213,10 +1212,10 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr)
> vfio_probe_nvidia_bar5_quirk(vdev, nr);
> vfio_probe_nvidia_bar0_quirk(vdev, nr);
> vfio_probe_rtl8168_bar2_quirk(vdev, nr);
> -#ifdef CONFIG_VFIO_IGD
> - vfio_probe_igd_bar0_quirk(vdev, nr);
> - vfio_probe_igd_bar4_quirk(vdev, nr);
> -#endif
> + if (vfio_igd_builtin()) {
> + vfio_probe_igd_bar0_quirk(vdev, nr);
> + vfio_probe_igd_bar4_quirk(vdev, nr);
> + }
> }
>
> void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr)
> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
> index a8939c83865..6ab711d0539 100644
> --- a/hw/vfio/meson.build
> +++ b/hw/vfio/meson.build
> @@ -17,6 +17,9 @@ specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
>
> system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c'))
> system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c'))
> +system_ss.add(when: 'CONFIG_VFIO_IGD', if_false: files(
> + 'igd-stubs.c',
> +))
> system_ss.add(when: 'CONFIG_VFIO', if_true: files(
> 'helpers.c',
> 'container-base.c',
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 10/21] qom: Introduce type_is_registered()
2025-03-08 23:09 ` [PATCH v2 10/21] qom: Introduce type_is_registered() Philippe Mathieu-Daudé
2025-03-09 19:14 ` Richard Henderson
@ 2025-03-10 7:38 ` Cédric Le Goater
2025-03-10 9:54 ` Eric Auger
2 siblings, 0 replies; 54+ messages in thread
From: Cédric Le Goater @ 2025-03-10 7:38 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 3/9/25 00:09, Philippe Mathieu-Daudé wrote:
> In order to be able to check whether a QOM type has been
> registered, introduce the type_is_registered() helper.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
FWIW,
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
> ---
> include/qom/object.h | 8 ++++++++
> qom/object.c | 5 +++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 9192265db76..5b5333017e0 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -898,6 +898,14 @@ Type type_register_static(const TypeInfo *info);
> */
> void type_register_static_array(const TypeInfo *infos, int nr_infos);
>
> +/**
> + * type_is_registered:
> + * @typename: The @typename to check.
> + *
> + * Returns: %true if @typename has been registered, %false otherwise.
> + */
> +bool type_is_registered(const char *typename);
> +
> /**
> * DEFINE_TYPES:
> * @type_array: The array containing #TypeInfo structures to register
> diff --git a/qom/object.c b/qom/object.c
> index 01618d06bd8..be442980049 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -100,6 +100,11 @@ static TypeImpl *type_table_lookup(const char *name)
> return g_hash_table_lookup(type_table_get(), name);
> }
>
> +bool type_is_registered(const char *typename)
> +{
> + return !!type_table_lookup(typename);
> +}
> +
> static TypeImpl *type_new(const TypeInfo *info)
> {
> TypeImpl *ti = g_malloc0(sizeof(*ti));
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 11/21] hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE
2025-03-08 23:09 ` [PATCH v2 11/21] hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE Philippe Mathieu-Daudé
@ 2025-03-10 7:38 ` Cédric Le Goater
2025-03-10 9:54 ` Eric Auger
1 sibling, 0 replies; 54+ messages in thread
From: Cédric Le Goater @ 2025-03-10 7:38 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 3/9/25 00:09, Philippe Mathieu-Daudé wrote:
> Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE once to help
> following where the QOM type is used in the code.
> We'll use it once more in the next commit.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
> ---
> hw/vfio/pci-quirks.h | 2 ++
> hw/vfio/igd.c | 4 ++--
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/vfio/pci-quirks.h b/hw/vfio/pci-quirks.h
> index d1532e379b1..fdaa81f00aa 100644
> --- a/hw/vfio/pci-quirks.h
> +++ b/hw/vfio/pci-quirks.h
> @@ -69,4 +69,6 @@ typedef struct VFIOConfigMirrorQuirk {
>
> extern const MemoryRegionOps vfio_generic_mirror_quirk;
>
> +#define TYPE_VFIO_PCI_IGD_LPC_BRIDGE "vfio-pci-igd-lpc-bridge"
> +
> #endif /* HW_VFIO_VFIO_PCI_QUIRKS_H */
> diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
> index b1a237edd66..1fd3c4ef1d0 100644
> --- a/hw/vfio/igd.c
> +++ b/hw/vfio/igd.c
> @@ -262,7 +262,7 @@ static void vfio_pci_igd_lpc_bridge_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo vfio_pci_igd_lpc_bridge_info = {
> - .name = "vfio-pci-igd-lpc-bridge",
> + .name = TYPE_VFIO_PCI_IGD_LPC_BRIDGE,
> .parent = TYPE_PCI_DEVICE,
> .class_init = vfio_pci_igd_lpc_bridge_class_init,
> .interfaces = (InterfaceInfo[]) {
> @@ -524,7 +524,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
> lpc_bridge = pci_find_device(pci_device_root_bus(&vdev->pdev),
> 0, PCI_DEVFN(0x1f, 0));
> if (lpc_bridge && !object_dynamic_cast(OBJECT(lpc_bridge),
> - "vfio-pci-igd-lpc-bridge")) {
> + TYPE_VFIO_PCI_IGD_LPC_BRIDGE)) {
> error_report("IGD device %s cannot support legacy mode due to existing "
> "devices at address 1f.0", vdev->vbasedev.name);
> return;
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 13/21] hw/vfio/igd: Compile once
2025-03-08 23:09 ` [PATCH v2 13/21] hw/vfio/igd: Compile once Philippe Mathieu-Daudé
@ 2025-03-10 7:39 ` Cédric Le Goater
2025-03-10 7:52 ` Cédric Le Goater
1 sibling, 0 replies; 54+ messages in thread
From: Cédric Le Goater @ 2025-03-10 7:39 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 3/9/25 00:09, Philippe Mathieu-Daudé wrote:
> The file doesn't use any target-specific knowledge anymore,
> move it to system_ss[] to build it once.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
> ---
> hw/vfio/meson.build | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
> index 6ab711d0539..21c9cd6d2eb 100644
> --- a/hw/vfio/meson.build
> +++ b/hw/vfio/meson.build
> @@ -11,13 +11,14 @@ vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
> vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
> vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
> vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
> -vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
>
> specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
>
> system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c'))
> system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c'))
> -system_ss.add(when: 'CONFIG_VFIO_IGD', if_false: files(
> +system_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files(
> + 'igd.c',
> +), if_false: files(
> 'igd-stubs.c',
> ))
> system_ss.add(when: 'CONFIG_VFIO', if_true: files(
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 13/21] hw/vfio/igd: Compile once
2025-03-08 23:09 ` [PATCH v2 13/21] hw/vfio/igd: Compile once Philippe Mathieu-Daudé
2025-03-10 7:39 ` Cédric Le Goater
@ 2025-03-10 7:52 ` Cédric Le Goater
1 sibling, 0 replies; 54+ messages in thread
From: Cédric Le Goater @ 2025-03-10 7:52 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 3/9/25 00:09, Philippe Mathieu-Daudé wrote:
> The file doesn't use any target-specific knowledge anymore,
> move it to system_ss[] to build it once.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
There are conflicts with series [1] modifying igd. I think it would
be better to wait after it's merged, unless you have time to rebase
on top of [1]
Thanks,
C.
[1] https://lore.kernel.org/qemu-devel/20250306180131.32970-1-tomitamoeko@gmail.com/
> ---
> hw/vfio/meson.build | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
> index 6ab711d0539..21c9cd6d2eb 100644
> --- a/hw/vfio/meson.build
> +++ b/hw/vfio/meson.build
> @@ -11,13 +11,14 @@ vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
> vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
> vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
> vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
> -vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
>
> specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
>
> system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c'))
> system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c'))
> -system_ss.add(when: 'CONFIG_VFIO_IGD', if_false: files(
> +system_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files(
> + 'igd.c',
> +), if_false: files(
> 'igd-stubs.c',
> ))
> system_ss.add(when: 'CONFIG_VFIO', if_true: files(
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 00/21] hw/vfio: Build various objects once
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2025-03-08 23:09 ` [PATCH v2 21/21] hw/vfio/platform: Compile once Philippe Mathieu-Daudé
@ 2025-03-10 8:03 ` Cédric Le Goater
2025-03-10 13:38 ` Philippe Mathieu-Daudé
2025-03-11 8:08 ` Cédric Le Goater
22 siblings, 1 reply; 54+ messages in thread
From: Cédric Le Goater @ 2025-03-10 8:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 3/9/25 00:08, Philippe Mathieu-Daudé wrote:
> By doing the following changes:
> - Clean some headers up
> - Replace compile-time CONFIG_KVM check by kvm_enabled()
> - Replace compile-time CONFIG_IOMMUFD check by iommufd_builtin()
> we can build less vfio objects.
>
> Since v1:
> - Added R-b tags
> - Introduce type_is_registered()
> - Split builtin check VS meson changes (rth)
> - Consider IGD
>
> Philippe Mathieu-Daudé (21):
> hw/vfio/common: Include missing 'system/tcg.h' header
> hw/vfio/spapr: Do not include <linux/kvm.h>
> hw/vfio: Compile some common objects once
> hw/vfio: Compile more objects once
> hw/vfio: Compile iommufd.c once
> system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h'
> hw/vfio: Compile display.c once
> system/kvm: Expose kvm_irqchip_[add,remove]_change_notifier()
> hw/vfio/pci: Convert CONFIG_KVM check to runtime one
> qom: Introduce type_is_registered()
> hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE
> hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin()
> hw/vfio/igd: Compile once
> system/iommufd: Introduce iommufd_builtin() helper
> hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
> hw/vfio/pci: Compile once
> hw/vfio/ap: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
> hw/vfio/ccw: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
> hw/vfio/s390x: Compile AP and CCW once
> hw/vfio/platform: Check CONFIG_IOMMUFD at runtime using
> iommufd_builtin
> hw/vfio/platform: Compile once
>
> docs/devel/vfio-iommufd.rst | 2 +-
> hw/vfio/pci-quirks.h | 8 +++++
> include/exec/ram_addr.h | 3 --
> include/qom/object.h | 8 +++++
> include/system/hostmem.h | 3 ++
> include/system/iommufd.h | 6 ++++
> include/system/kvm.h | 8 ++---
> target/s390x/kvm/kvm_s390x.h | 2 +-
> hw/ppc/spapr_caps.c | 1 +
> hw/s390x/s390-virtio-ccw.c | 1 +
> hw/vfio/ap.c | 27 ++++++++---------
> hw/vfio/ccw.c | 27 ++++++++---------
> hw/vfio/common.c | 1 +
> hw/vfio/igd-stubs.c | 20 +++++++++++++
> hw/vfio/igd.c | 4 +--
> hw/vfio/iommufd.c | 1 -
> hw/vfio/migration.c | 1 -
> hw/vfio/pci-quirks.c | 9 +++---
> hw/vfio/pci.c | 57 +++++++++++++++++-------------------
> hw/vfio/platform.c | 25 ++++++++--------
> hw/vfio/spapr.c | 4 +--
> qom/object.c | 5 ++++
> hw/vfio/meson.build | 35 +++++++++++++---------
> 23 files changed, 152 insertions(+), 106 deletions(-)
> create mode 100644 hw/vfio/igd-stubs.c
>
Patches 1-9 still look ok and could be merged through the vfio tree
if maintainers ack patch 6 and 8.
The rest, depending on type_is_registered(), would be nice to have,
but since there are conflicts and soft freeze is scheduled for
tomorrow, we would probably have to wait QEMU 10.1.
Thanks,
C.
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 01/21] hw/vfio/common: Include missing 'system/tcg.h' header
2025-03-08 23:08 ` [PATCH v2 01/21] hw/vfio/common: Include missing 'system/tcg.h' header Philippe Mathieu-Daudé
@ 2025-03-10 8:08 ` Eric Auger
0 siblings, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 8:08 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 3/9/25 12:08 AM, Philippe Mathieu-Daudé wrote:
> Always include necessary headers explicitly, to avoid
> when refactoring unrelated ones:
>
> hw/vfio/common.c:1176:45: error: implicit declaration of function ‘tcg_enabled’;
> 1176 | tcg_enabled() ? DIRTY_CLIENTS_ALL :
> | ^~~~~~~~~~~
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> hw/vfio/common.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 7a4010ef4ee..b1596b6bf64 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -42,6 +42,7 @@
> #include "migration/misc.h"
> #include "migration/blocker.h"
> #include "migration/qemu-file.h"
> +#include "system/tcg.h"
> #include "system/tpm.h"
>
> VFIODeviceList vfio_device_list =
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 02/21] hw/vfio/spapr: Do not include <linux/kvm.h>
2025-03-08 23:08 ` [PATCH v2 02/21] hw/vfio/spapr: Do not include <linux/kvm.h> Philippe Mathieu-Daudé
@ 2025-03-10 8:08 ` Eric Auger
0 siblings, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 8:08 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 3/9/25 12:08 AM, Philippe Mathieu-Daudé wrote:
> <linux/kvm.h> is already include by "system/kvm.h" in the next line.
included
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
> ---
> hw/vfio/spapr.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
> index ad4c499eafe..9b5ad05bb1c 100644
> --- a/hw/vfio/spapr.c
> +++ b/hw/vfio/spapr.c
> @@ -11,9 +11,6 @@
> #include "qemu/osdep.h"
> #include <sys/ioctl.h>
> #include <linux/vfio.h>
> -#ifdef CONFIG_KVM
> -#include <linux/kvm.h>
> -#endif
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> #include "system/kvm.h"
> #include "exec/address-spaces.h"
>
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 03/21] hw/vfio: Compile some common objects once
2025-03-08 23:08 ` [PATCH v2 03/21] hw/vfio: Compile some common objects once Philippe Mathieu-Daudé
@ 2025-03-10 8:19 ` Eric Auger
0 siblings, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 8:19 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 3/9/25 12:08 AM, Philippe Mathieu-Daudé wrote:
> Some files don't rely on any target-specific knowledge
> and can be compiled once:
>
> - helpers.c
> - container-base.c
> - migration.c (removing unnecessary "exec/ram_addr.h")
> - migration-multifd.c
> - cpr.c
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> hw/vfio/migration.c | 1 -
> hw/vfio/meson.build | 13 ++++++++-----
> 2 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
> index 416643ddd69..fbff46cfc35 100644
> --- a/hw/vfio/migration.c
> +++ b/hw/vfio/migration.c
> @@ -27,7 +27,6 @@
> #include "qapi/error.h"
> #include "qapi/qapi-events-vfio.h"
> #include "exec/ramlist.h"
> -#include "exec/ram_addr.h"
> #include "pci.h"
> #include "trace.h"
> #include "hw/hw.h"
> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
> index 260d65febd6..8e376cfcbf8 100644
> --- a/hw/vfio/meson.build
> +++ b/hw/vfio/meson.build
> @@ -1,12 +1,7 @@
> vfio_ss = ss.source_set()
> vfio_ss.add(files(
> - 'helpers.c',
> 'common.c',
> - 'container-base.c',
> 'container.c',
> - 'migration.c',
> - 'migration-multifd.c',
> - 'cpr.c',
> ))
> vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
> vfio_ss.add(when: 'CONFIG_IOMMUFD', if_true: files(
> @@ -25,3 +20,11 @@ vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
> vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
>
> specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
> +
> +system_ss.add(when: 'CONFIG_VFIO', if_true: files(
> + 'helpers.c',
> + 'container-base.c',
> + 'migration.c',
> + 'migration-multifd.c',
> + 'cpr.c',
> +))
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 04/21] hw/vfio: Compile more objects once
2025-03-08 23:09 ` [PATCH v2 04/21] hw/vfio: Compile more " Philippe Mathieu-Daudé
@ 2025-03-10 8:20 ` Eric Auger
0 siblings, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 8:20 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
> These files depend on the VFIO symbol in their Kconfig
> definition. They don't rely on target specific definitions,
> move them to system_ss[] to build them once.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> hw/vfio/meson.build | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
> index 8e376cfcbf8..784eae4b559 100644
> --- a/hw/vfio/meson.build
> +++ b/hw/vfio/meson.build
> @@ -14,13 +14,13 @@ vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
> ))
> vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
> vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
> -vfio_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c'))
> -vfio_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c'))
> vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
> vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
>
> specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
>
> +system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c'))
> +system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c'))
> system_ss.add(when: 'CONFIG_VFIO', if_true: files(
> 'helpers.c',
> 'container-base.c',
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 05/21] hw/vfio: Compile iommufd.c once
2025-03-08 23:09 ` [PATCH v2 05/21] hw/vfio: Compile iommufd.c once Philippe Mathieu-Daudé
@ 2025-03-10 8:23 ` Eric Auger
0 siblings, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 8:23 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
> Removing unused "exec/ram_addr.h" header allow to compile
> iommufd.c once for all targets.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> hw/vfio/iommufd.c | 1 -
> hw/vfio/meson.build | 6 +++---
> 2 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
> index df61edffc08..42c8412bbf5 100644
> --- a/hw/vfio/iommufd.c
> +++ b/hw/vfio/iommufd.c
> @@ -25,7 +25,6 @@
> #include "qemu/cutils.h"
> #include "qemu/chardev_open.h"
> #include "pci.h"
> -#include "exec/ram_addr.h"
>
> static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova,
> ram_addr_t size, void *vaddr, bool readonly)
> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
> index 784eae4b559..5c9ec7e8971 100644
> --- a/hw/vfio/meson.build
> +++ b/hw/vfio/meson.build
> @@ -4,9 +4,6 @@ vfio_ss.add(files(
> 'container.c',
> ))
> vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
> -vfio_ss.add(when: 'CONFIG_IOMMUFD', if_true: files(
> - 'iommufd.c',
> -))
> vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
> 'display.c',
> 'pci-quirks.c',
> @@ -28,3 +25,6 @@ system_ss.add(when: 'CONFIG_VFIO', if_true: files(
> 'migration-multifd.c',
> 'cpr.c',
> ))
> +system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files(
> + 'iommufd.c',
> +))
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 06/21] system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h'
2025-03-08 23:09 ` [PATCH v2 06/21] system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h' Philippe Mathieu-Daudé
@ 2025-03-10 8:28 ` Eric Auger
0 siblings, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 8:28 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
> Both qemu_minrampagesize() and qemu_maxrampagesize() are
> related to host memory backends, having the following call
> stack:
>
> qemu_minrampagesize()
> -> find_min_backend_pagesize()
> -> object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)
>
> qemu_maxrampagesize()
> -> find_max_backend_pagesize()
> -> object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)
>
> Having TYPE_MEMORY_BACKEND defined in "system/hostmem.h":
>
> include/system/hostmem.h:23:#define TYPE_MEMORY_BACKEND "memory-backend"
>
> Move their prototype declaration to "system/hostmem.h".
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> include/exec/ram_addr.h | 3 ---
> include/system/hostmem.h | 3 +++
> hw/ppc/spapr_caps.c | 1 +
> hw/s390x/s390-virtio-ccw.c | 1 +
> hw/vfio/spapr.c | 1 +
> 5 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
> index 94bb3ccbe42..ccc8df561af 100644
> --- a/include/exec/ram_addr.h
> +++ b/include/exec/ram_addr.h
> @@ -101,9 +101,6 @@ static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,
>
> bool ramblock_is_pmem(RAMBlock *rb);
>
> -long qemu_minrampagesize(void);
> -long qemu_maxrampagesize(void);
> -
> /**
> * qemu_ram_alloc_from_file,
> * qemu_ram_alloc_from_fd: Allocate a ram block from the specified backing
> diff --git a/include/system/hostmem.h b/include/system/hostmem.h
> index 5c21ca55c01..62642e602ca 100644
> --- a/include/system/hostmem.h
> +++ b/include/system/hostmem.h
> @@ -93,4 +93,7 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
> size_t host_memory_backend_pagesize(HostMemoryBackend *memdev);
> char *host_memory_backend_get_name(HostMemoryBackend *backend);
>
> +long qemu_minrampagesize(void);
> +long qemu_maxrampagesize(void);
> +
> #endif
> diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
> index 904bff87ce1..9e53d0c1fd1 100644
> --- a/hw/ppc/spapr_caps.c
> +++ b/hw/ppc/spapr_caps.c
> @@ -34,6 +34,7 @@
> #include "kvm_ppc.h"
> #include "migration/vmstate.h"
> #include "system/tcg.h"
> +#include "system/hostmem.h"
>
> #include "hw/ppc/spapr.h"
>
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index 51ae0c133d8..1261d93b7ce 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -41,6 +41,7 @@
> #include "hw/s390x/tod.h"
> #include "system/system.h"
> #include "system/cpus.h"
> +#include "system/hostmem.h"
> #include "target/s390x/kvm/pv.h"
> #include "migration/blocker.h"
> #include "qapi/visitor.h"
> diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
> index 9b5ad05bb1c..1a5d1611f2c 100644
> --- a/hw/vfio/spapr.c
> +++ b/hw/vfio/spapr.c
> @@ -12,6 +12,7 @@
> #include <sys/ioctl.h>
> #include <linux/vfio.h>
> #include "system/kvm.h"
> +#include "system/hostmem.h"
> #include "exec/address-spaces.h"
>
> #include "hw/vfio/vfio-common.h"
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 07/21] hw/vfio: Compile display.c once
2025-03-08 23:09 ` [PATCH v2 07/21] hw/vfio: Compile display.c once Philippe Mathieu-Daudé
@ 2025-03-10 8:29 ` Eric Auger
0 siblings, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 8:29 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
> display.c doesn't rely on target specific definitions,
> move it to system_ss[] to build it once.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> hw/vfio/meson.build | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
> index 5c9ec7e8971..a8939c83865 100644
> --- a/hw/vfio/meson.build
> +++ b/hw/vfio/meson.build
> @@ -5,7 +5,6 @@ vfio_ss.add(files(
> ))
> vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
> vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
> - 'display.c',
> 'pci-quirks.c',
> 'pci.c',
> ))
> @@ -28,3 +27,6 @@ system_ss.add(when: 'CONFIG_VFIO', if_true: files(
> system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files(
> 'iommufd.c',
> ))
> +system_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
> + 'display.c',
> +))
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add,remove]_change_notifier()
2025-03-08 23:09 ` [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add, remove]_change_notifier() Philippe Mathieu-Daudé
2025-03-09 18:54 ` [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add,remove]_change_notifier() Richard Henderson
@ 2025-03-10 8:35 ` Eric Auger
1 sibling, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 8:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
> Currently kvm_irqchip_add_irqfd_notifier() and
> kvm_irqchip_remove_irqfd_notifier() are only declared on
> target specific code. There is not particular reason to,
> as their prototypes don't use anything target related.
>
> Move their declaration with common prototypes, otherwise
> the next commit would trigger:
>
> hw/vfio/pci.c: In function ‘vfio_realize’:
> hw/vfio/pci.c:3178:9: error: implicit declaration of function ‘kvm_irqchip_add_change_notifier’
> 3178 | kvm_irqchip_add_change_notifier(&vdev->irqchip_change_notifier);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> | kvm_irqchip_add_irqfd_notifier
> hw/vfio/pci.c:3236:9: error: implicit declaration of function ‘kvm_irqchip_remove_change_notifier’
> 3236 | kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> | kvm_irqchip_remove_irqfd_notifier
>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> include/system/kvm.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/system/kvm.h b/include/system/kvm.h
> index ab17c09a551..75673fb794e 100644
> --- a/include/system/kvm.h
> +++ b/include/system/kvm.h
> @@ -412,10 +412,6 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg);
>
> void kvm_irqchip_add_irq_route(KVMState *s, int gsi, int irqchip, int pin);
>
> -void kvm_irqchip_add_change_notifier(Notifier *n);
> -void kvm_irqchip_remove_change_notifier(Notifier *n);
> -void kvm_irqchip_change_notify(void);
> -
> struct kvm_guest_debug;
> struct kvm_debug_exit_arch;
>
> @@ -517,6 +513,10 @@ void kvm_irqchip_release_virq(KVMState *s, int virq);
> void kvm_add_routing_entry(KVMState *s,
> struct kvm_irq_routing_entry *entry);
>
> +void kvm_irqchip_add_change_notifier(Notifier *n);
> +void kvm_irqchip_remove_change_notifier(Notifier *n);
> +void kvm_irqchip_change_notify(void);
> +
> int kvm_irqchip_add_irqfd_notifier_gsi(KVMState *s, EventNotifier *n,
> EventNotifier *rn, int virq);
> int kvm_irqchip_remove_irqfd_notifier_gsi(KVMState *s, EventNotifier *n,
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 09/21] hw/vfio/pci: Convert CONFIG_KVM check to runtime one
2025-03-08 23:09 ` [PATCH v2 09/21] hw/vfio/pci: Convert CONFIG_KVM check to runtime one Philippe Mathieu-Daudé
@ 2025-03-10 9:54 ` Eric Auger
2025-03-10 12:54 ` BALATON Zoltan
0 siblings, 1 reply; 54+ messages in thread
From: Eric Auger @ 2025-03-10 9:54 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
Hi Philippe,
On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
> Use the runtime kvm_enabled() helper to check whether
> KVM is available or not.
Miss the "why" of this patch.
By the way I fail to remember/see where kvm_allowed is set.
I am also confused because we still have some code, like in
vfio/common.c which does both checks:
#ifdef CONFIG_KVM
if (kvm_enabled()) {
max_memslots = kvm_get_max_memslots();
}
#endif
Thanks
Eric
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
> ---
> hw/vfio/pci.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index fdbc15885d4..9872884ff8a 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -118,8 +118,13 @@ static void vfio_intx_eoi(VFIODevice *vbasedev)
>
> static bool vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
> {
> -#ifdef CONFIG_KVM
> - int irq_fd = event_notifier_get_fd(&vdev->intx.interrupt);
> + int irq_fd;
> +
> + if (!kvm_enabled()) {
> + return true;
> + }
> +
> + irq_fd = event_notifier_get_fd(&vdev->intx.interrupt);
>
> if (vdev->no_kvm_intx || !kvm_irqfds_enabled() ||
> vdev->intx.route.mode != PCI_INTX_ENABLED ||
> @@ -171,16 +176,13 @@ fail_irqfd:
> fail:
> qemu_set_fd_handler(irq_fd, vfio_intx_interrupt, NULL, vdev);
> vfio_unmask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
> +
> return false;
> -#else
> - return true;
> -#endif
> }
>
> static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev)
> {
> -#ifdef CONFIG_KVM
> - if (!vdev->intx.kvm_accel) {
> + if (!kvm_enabled() || !vdev->intx.kvm_accel) {
> return;
> }
>
> @@ -211,7 +213,6 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev)
> vfio_unmask_single_irqindex(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
>
> trace_vfio_intx_disable_kvm(vdev->vbasedev.name);
> -#endif
> }
>
> static void vfio_intx_update(VFIOPCIDevice *vdev, PCIINTxRoute *route)
> @@ -278,7 +279,6 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
> vdev->intx.pin = pin - 1; /* Pin A (1) -> irq[0] */
> pci_config_set_interrupt_pin(vdev->pdev.config, pin);
>
> -#ifdef CONFIG_KVM
> /*
> * Only conditional to avoid generating error messages on platforms
> * where we won't actually use the result anyway.
> @@ -287,7 +287,6 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
> vdev->intx.route = pci_device_route_intx_to_irq(&vdev->pdev,
> vdev->intx.pin);
> }
> -#endif
>
> ret = event_notifier_init(&vdev->intx.interrupt, 0);
> if (ret) {
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 10/21] qom: Introduce type_is_registered()
2025-03-08 23:09 ` [PATCH v2 10/21] qom: Introduce type_is_registered() Philippe Mathieu-Daudé
2025-03-09 19:14 ` Richard Henderson
2025-03-10 7:38 ` Cédric Le Goater
@ 2025-03-10 9:54 ` Eric Auger
2 siblings, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 9:54 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
> In order to be able to check whether a QOM type has been
> registered, introduce the type_is_registered() helper.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> include/qom/object.h | 8 ++++++++
> qom/object.c | 5 +++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 9192265db76..5b5333017e0 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -898,6 +898,14 @@ Type type_register_static(const TypeInfo *info);
> */
> void type_register_static_array(const TypeInfo *infos, int nr_infos);
>
> +/**
> + * type_is_registered:
> + * @typename: The @typename to check.
> + *
> + * Returns: %true if @typename has been registered, %false otherwise.
> + */
> +bool type_is_registered(const char *typename);
> +
> /**
> * DEFINE_TYPES:
> * @type_array: The array containing #TypeInfo structures to register
> diff --git a/qom/object.c b/qom/object.c
> index 01618d06bd8..be442980049 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -100,6 +100,11 @@ static TypeImpl *type_table_lookup(const char *name)
> return g_hash_table_lookup(type_table_get(), name);
> }
>
> +bool type_is_registered(const char *typename)
> +{
> + return !!type_table_lookup(typename);
> +}
> +
> static TypeImpl *type_new(const TypeInfo *info)
> {
> TypeImpl *ti = g_malloc0(sizeof(*ti));
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 11/21] hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE
2025-03-08 23:09 ` [PATCH v2 11/21] hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE Philippe Mathieu-Daudé
2025-03-10 7:38 ` Cédric Le Goater
@ 2025-03-10 9:54 ` Eric Auger
1 sibling, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 9:54 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
> Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE once to help
> following where the QOM type is used in the code.
> We'll use it once more in the next commit.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> hw/vfio/pci-quirks.h | 2 ++
> hw/vfio/igd.c | 4 ++--
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/vfio/pci-quirks.h b/hw/vfio/pci-quirks.h
> index d1532e379b1..fdaa81f00aa 100644
> --- a/hw/vfio/pci-quirks.h
> +++ b/hw/vfio/pci-quirks.h
> @@ -69,4 +69,6 @@ typedef struct VFIOConfigMirrorQuirk {
>
> extern const MemoryRegionOps vfio_generic_mirror_quirk;
>
> +#define TYPE_VFIO_PCI_IGD_LPC_BRIDGE "vfio-pci-igd-lpc-bridge"
> +
> #endif /* HW_VFIO_VFIO_PCI_QUIRKS_H */
> diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
> index b1a237edd66..1fd3c4ef1d0 100644
> --- a/hw/vfio/igd.c
> +++ b/hw/vfio/igd.c
> @@ -262,7 +262,7 @@ static void vfio_pci_igd_lpc_bridge_class_init(ObjectClass *klass, void *data)
> }
>
> static const TypeInfo vfio_pci_igd_lpc_bridge_info = {
> - .name = "vfio-pci-igd-lpc-bridge",
> + .name = TYPE_VFIO_PCI_IGD_LPC_BRIDGE,
> .parent = TYPE_PCI_DEVICE,
> .class_init = vfio_pci_igd_lpc_bridge_class_init,
> .interfaces = (InterfaceInfo[]) {
> @@ -524,7 +524,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
> lpc_bridge = pci_find_device(pci_device_root_bus(&vdev->pdev),
> 0, PCI_DEVFN(0x1f, 0));
> if (lpc_bridge && !object_dynamic_cast(OBJECT(lpc_bridge),
> - "vfio-pci-igd-lpc-bridge")) {
> + TYPE_VFIO_PCI_IGD_LPC_BRIDGE)) {
> error_report("IGD device %s cannot support legacy mode due to existing "
> "devices at address 1f.0", vdev->vbasedev.name);
> return;
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 09/21] hw/vfio/pci: Convert CONFIG_KVM check to runtime one
2025-03-10 9:54 ` Eric Auger
@ 2025-03-10 12:54 ` BALATON Zoltan
2025-03-10 14:53 ` Eric Auger
2025-03-11 8:54 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 54+ messages in thread
From: BALATON Zoltan @ 2025-03-10 12:54 UTC (permalink / raw)
To: Eric Auger
Cc: Philippe Mathieu-Daudé, qemu-devel, Yi Liu, Pierrick Bouvier,
Alex Williamson, Christian Borntraeger, Alex Bennée,
Tony Krowiak, Nicholas Piggin, Halil Pasic, Thomas Huth,
David Hildenbrand, Igor Mammedov, Matthew Rosato, Tomita Moeko,
qemu-ppc, Daniel Henrique Barboza, Eric Farman, Eduardo Habkost,
Peter Xu, kvm, Zhenzhong Duan, qemu-s390x, Paolo Bonzini,
Harsh Prateek Bora, Cédric Le Goater, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
[-- Attachment #1: Type: text/plain, Size: 836 bytes --]
On Mon, 10 Mar 2025, Eric Auger wrote:
> Hi Philippe,
>
> On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
>> Use the runtime kvm_enabled() helper to check whether
>> KVM is available or not.
>
> Miss the "why" of this patch.
>
> By the way I fail to remember/see where kvm_allowed is set.
It's in include/system/kvm.h
> I am also confused because we still have some code, like in
> vfio/common.c which does both checks:
> #ifdef CONFIG_KVM
> if (kvm_enabled()) {
> max_memslots = kvm_get_max_memslots();
> }
> #endif
I think this is because if KVM is not available the if cannot be true so
it can be left out altogether. This may make sense on platforms like
Windows and macOS where QEMU is compiled without KVM so basically
everywhere except Linux.
Regards,
BALATON Zoltan
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
2025-03-10 4:11 ` Duan, Zhenzhong
@ 2025-03-10 13:37 ` Philippe Mathieu-Daudé
2025-03-11 1:54 ` Duan, Zhenzhong
0 siblings, 1 reply; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-10 13:37 UTC (permalink / raw)
To: Duan, Zhenzhong, qemu-devel@nongnu.org
Cc: Liu, Yi L, Pierrick Bouvier, Alex Williamson,
Christian Borntraeger, Alex Bennée, Tony Krowiak,
Nicholas Piggin, Halil Pasic, Thomas Huth, David Hildenbrand,
Igor Mammedov, Matthew Rosato, Tomita Moeko, qemu-ppc@nongnu.org,
Daniel Henrique Barboza, Eric Farman, Eduardo Habkost, Peter Xu,
kvm@vger.kernel.org, qemu-s390x@nongnu.org, Eric Auger,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 10/3/25 05:11, Duan, Zhenzhong wrote:
> Hi Philippe,
>
>> -----Original Message-----
>> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Subject: [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime
>> using iommufd_builtin()
>>
>> Convert the compile time check on the CONFIG_IOMMUFD definition
>> by a runtime one by calling iommufd_builtin().
>>
>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> hw/vfio/pci.c | 38 ++++++++++++++++++--------------------
>> 1 file changed, 18 insertions(+), 20 deletions(-)
>> static void vfio_pci_dev_class_init(ObjectClass *klass, void *data)
>> {
>> @@ -3433,9 +3430,10 @@ static void vfio_pci_dev_class_init(ObjectClass *klass,
>> void *data)
>>
>> device_class_set_legacy_reset(dc, vfio_pci_reset);
>> device_class_set_props(dc, vfio_pci_dev_properties);
>> -#ifdef CONFIG_IOMMUFD
>> - object_class_property_add_str(klass, "fd", NULL, vfio_pci_set_fd);
>> -#endif
>> + if (iommufd_builtin()) {
>> + device_class_set_props(dc, vfio_pci_dev_iommufd_properties);
>
> device_class_set_props() is called twice. Won't it break qdev_print_props() and qdev_prop_walk()?
device_class_set_props() is misnamed, as it doesn't SET an array of
properties, but ADD them (or 'register') to the class.
See device_class_set_props_n() in hw/core/qdev-properties.c.
I'll see to rename the QDev methods for clarity.
Regards,
Phil.
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 00/21] hw/vfio: Build various objects once
2025-03-10 8:03 ` [PATCH v2 00/21] hw/vfio: Build various objects once Cédric Le Goater
@ 2025-03-10 13:38 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-10 13:38 UTC (permalink / raw)
To: Cédric Le Goater, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 10/3/25 09:03, Cédric Le Goater wrote:
> On 3/9/25 00:08, Philippe Mathieu-Daudé wrote:
>> By doing the following changes:
>> - Clean some headers up
>> - Replace compile-time CONFIG_KVM check by kvm_enabled()
>> - Replace compile-time CONFIG_IOMMUFD check by iommufd_builtin()
>> we can build less vfio objects.
>>
>> Since v1:
>> - Added R-b tags
>> - Introduce type_is_registered()
>> - Split builtin check VS meson changes (rth)
>> - Consider IGD
>>
>> Philippe Mathieu-Daudé (21):
>> hw/vfio/common: Include missing 'system/tcg.h' header
>> hw/vfio/spapr: Do not include <linux/kvm.h>
>> hw/vfio: Compile some common objects once
>> hw/vfio: Compile more objects once
>> hw/vfio: Compile iommufd.c once
>> system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h'
>> hw/vfio: Compile display.c once
>> system/kvm: Expose kvm_irqchip_[add,remove]_change_notifier()
>> hw/vfio/pci: Convert CONFIG_KVM check to runtime one
>> qom: Introduce type_is_registered()
>> hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE
>> hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin()
>> hw/vfio/igd: Compile once
>> system/iommufd: Introduce iommufd_builtin() helper
>> hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
>> hw/vfio/pci: Compile once
>> hw/vfio/ap: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
>> hw/vfio/ccw: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
>> hw/vfio/s390x: Compile AP and CCW once
>> hw/vfio/platform: Check CONFIG_IOMMUFD at runtime using
>> iommufd_builtin
>> hw/vfio/platform: Compile once
>>
>> docs/devel/vfio-iommufd.rst | 2 +-
>> hw/vfio/pci-quirks.h | 8 +++++
>> include/exec/ram_addr.h | 3 --
>> include/qom/object.h | 8 +++++
>> include/system/hostmem.h | 3 ++
>> include/system/iommufd.h | 6 ++++
>> include/system/kvm.h | 8 ++---
>> target/s390x/kvm/kvm_s390x.h | 2 +-
>> hw/ppc/spapr_caps.c | 1 +
>> hw/s390x/s390-virtio-ccw.c | 1 +
>> hw/vfio/ap.c | 27 ++++++++---------
>> hw/vfio/ccw.c | 27 ++++++++---------
>> hw/vfio/common.c | 1 +
>> hw/vfio/igd-stubs.c | 20 +++++++++++++
>> hw/vfio/igd.c | 4 +--
>> hw/vfio/iommufd.c | 1 -
>> hw/vfio/migration.c | 1 -
>> hw/vfio/pci-quirks.c | 9 +++---
>> hw/vfio/pci.c | 57 +++++++++++++++++-------------------
>> hw/vfio/platform.c | 25 ++++++++--------
>> hw/vfio/spapr.c | 4 +--
>> qom/object.c | 5 ++++
>> hw/vfio/meson.build | 35 +++++++++++++---------
>> 23 files changed, 152 insertions(+), 106 deletions(-)
>> create mode 100644 hw/vfio/igd-stubs.c
>>
>
> Patches 1-9 still look ok and could be merged through the vfio tree
> if maintainers ack patch 6 and 8.
>
> The rest, depending on type_is_registered(), would be nice to have,
> but since there are conflicts and soft freeze is scheduled for
> tomorrow, we would probably have to wait QEMU 10.1.
No particular rush for the 10.0 release.
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin()
2025-03-10 7:37 ` Cédric Le Goater
@ 2025-03-10 13:43 ` Philippe Mathieu-Daudé
2025-03-10 13:51 ` Cédric Le Goater
2025-03-10 15:16 ` Tomita Moeko
0 siblings, 2 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-10 13:43 UTC (permalink / raw)
To: Cédric Le Goater, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 10/3/25 08:37, Cédric Le Goater wrote:
> On 3/9/25 00:09, Philippe Mathieu-Daudé wrote:
>> Convert the compile time check on the CONFIG_VFIO_IGD definition
>> by a runtime one by calling vfio_igd_builtin(), which check
>> whether VFIO_IGD is built in a qemu-system binary.
>>
>> Add stubs to avoid when VFIO_IGD is not built in:
>
> I thought we were trying to avoid stubs in QEMU build. Did that change ?
Hmm so you want remove the VFIO_IGD Kconfig symbol and have it always
builtin with VFIO. It might make sense for quirks, since vfio_realize()
already checks for the VFIO_FEATURE_ENABLE_IGD_OPREGION feature.
I'll see if there aren't other implications I missed.
Thanks,
Phil.
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin()
2025-03-10 13:43 ` Philippe Mathieu-Daudé
@ 2025-03-10 13:51 ` Cédric Le Goater
2025-03-10 15:23 ` Philippe Mathieu-Daudé
2025-03-10 15:16 ` Tomita Moeko
1 sibling, 1 reply; 54+ messages in thread
From: Cédric Le Goater @ 2025-03-10 13:51 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 3/10/25 14:43, Philippe Mathieu-Daudé wrote:
> On 10/3/25 08:37, Cédric Le Goater wrote:
>> On 3/9/25 00:09, Philippe Mathieu-Daudé wrote:
>>> Convert the compile time check on the CONFIG_VFIO_IGD definition
>>> by a runtime one by calling vfio_igd_builtin(), which check
>>> whether VFIO_IGD is built in a qemu-system binary.
>>>
>>> Add stubs to avoid when VFIO_IGD is not built in:
>>
>> I thought we were trying to avoid stubs in QEMU build. Did that change ?
>
> Hmm so you want remove the VFIO_IGD Kconfig symbol and have it always
> builtin with VFIO. It might make sense for quirks, since vfio_realize()
> already checks for the VFIO_FEATURE_ENABLE_IGD_OPREGION feature.
I have explored this option in the past and it's much more work.
Stubs are fine IMO, if we can have them, but I remember someone
telling me (you ?) that we were trying to remove them.
Thanks,
C.
> I'll see if there aren't other implications I missed.
>
> Thanks,
>
> Phil.
>
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 09/21] hw/vfio/pci: Convert CONFIG_KVM check to runtime one
2025-03-10 12:54 ` BALATON Zoltan
@ 2025-03-10 14:53 ` Eric Auger
2025-03-11 8:54 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 54+ messages in thread
From: Eric Auger @ 2025-03-10 14:53 UTC (permalink / raw)
To: BALATON Zoltan
Cc: Philippe Mathieu-Daudé, qemu-devel, Yi Liu, Pierrick Bouvier,
Alex Williamson, Christian Borntraeger, Alex Bennée,
Tony Krowiak, Nicholas Piggin, Halil Pasic, Thomas Huth,
David Hildenbrand, Igor Mammedov, Matthew Rosato, Tomita Moeko,
qemu-ppc, Daniel Henrique Barboza, Eric Farman, Eduardo Habkost,
Peter Xu, kvm, Zhenzhong Duan, qemu-s390x, Paolo Bonzini,
Harsh Prateek Bora, Cédric Le Goater, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
Hi,
On 3/10/25 1:54 PM, BALATON Zoltan wrote:
> On Mon, 10 Mar 2025, Eric Auger wrote:
>> Hi Philippe,
>>
>> On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
>>> Use the runtime kvm_enabled() helper to check whether
>>> KVM is available or not.
>>
>> Miss the "why" of this patch.
>>
>> By the way I fail to remember/see where kvm_allowed is set.
>
> It's in include/system/kvm.h
There you can only find the kvm_enabled() macro definition.
I was eventually able to locate it:
accel/accel-system.c: *(acc->allowed) = true;
in accel_init_machine()
>
>> I am also confused because we still have some code, like in
>> vfio/common.c which does both checks:
>> #ifdef CONFIG_KVM
>> if (kvm_enabled()) {
>> max_memslots = kvm_get_max_memslots();
>> }
>> #endif
>
> I think this is because if KVM is not available the if cannot be true
> so it can be left out altogether. This may make sense on platforms
> like Windows and macOS where QEMU is compiled without KVM so basically
> everywhere except Linux.
But in practice we have a stub for kvm_get_max_memslots in
accel/stubs/kvm-stub.c.
Eric
>
> Regards,
> BALATON Zoltan
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin()
2025-03-10 13:43 ` Philippe Mathieu-Daudé
2025-03-10 13:51 ` Cédric Le Goater
@ 2025-03-10 15:16 ` Tomita Moeko
1 sibling, 0 replies; 54+ messages in thread
From: Tomita Moeko @ 2025-03-10 15:16 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Cédric Le Goater, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
qemu-ppc, Daniel Henrique Barboza, Eric Farman, Eduardo Habkost,
Peter Xu, kvm, Zhenzhong Duan, qemu-s390x, Eric Auger,
Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich, Jason Herne,
Daniel P. Berrangé, Richard Henderson
On 3/10/25 21:43, Philippe Mathieu-Daudé wrote:
> On 10/3/25 08:37, Cédric Le Goater wrote:
>> On 3/9/25 00:09, Philippe Mathieu-Daudé wrote:
>>> Convert the compile time check on the CONFIG_VFIO_IGD definition
>>> by a runtime one by calling vfio_igd_builtin(), which check
>>> whether VFIO_IGD is built in a qemu-system binary.
>>>
>>> Add stubs to avoid when VFIO_IGD is not built in:
>>
>> I thought we were trying to avoid stubs in QEMU build. Did that change ?
>
> Hmm so you want remove the VFIO_IGD Kconfig symbol and have it always
> builtin with VFIO. It might make sense for quirks, since vfio_realize()
> already checks for the VFIO_FEATURE_ENABLE_IGD_OPREGION feature.
>
> I'll see if there aren't other implications I missed.
>
> Thanks,
>
> Phil.
I personally suggest keeping the VFIO_IGD Kconfig symbol to prevent
building IGD-specific code into non x86 target. The change Cedric
mentioned in another reply [1] moves VFIO_FEATURE_ENABLE_IGD_OPREGION
from vfio_realize() to igd.c.
[1] https://lore.kernel.org/qemu-devel/20250306180131.32970-1-tomitamoeko@gmail.com/
Thanks,
Moeko
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin()
2025-03-10 13:51 ` Cédric Le Goater
@ 2025-03-10 15:23 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-10 15:23 UTC (permalink / raw)
To: Cédric Le Goater, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 10/3/25 14:51, Cédric Le Goater wrote:
> On 3/10/25 14:43, Philippe Mathieu-Daudé wrote:
>> On 10/3/25 08:37, Cédric Le Goater wrote:
>>> On 3/9/25 00:09, Philippe Mathieu-Daudé wrote:
>>>> Convert the compile time check on the CONFIG_VFIO_IGD definition
>>>> by a runtime one by calling vfio_igd_builtin(), which check
>>>> whether VFIO_IGD is built in a qemu-system binary.
>>>>
>>>> Add stubs to avoid when VFIO_IGD is not built in:
>>>
>>> I thought we were trying to avoid stubs in QEMU build. Did that change ?
>>
>> Hmm so you want remove the VFIO_IGD Kconfig symbol and have it always
>> builtin with VFIO. It might make sense for quirks, since vfio_realize()
>> already checks for the VFIO_FEATURE_ENABLE_IGD_OPREGION feature.
>
> I have explored this option in the past and it's much more work.
> Stubs are fine IMO, if we can have them, but I remember someone
> telling me (you ?) that we were trying to remove them.
We shouldn't have target-specific stubs.
(currently CONFIG_DEVICES::VFIO_IGD is target specific).
I don't think we can avoid host-specific stubs.
In unified binary, CONFIG_DEVICES disappears, VFIO_IGD
will be handled like host configuration. Although if possible I'd
rather remove VFIO_IGD, unconditionally including all quirks.
^ permalink raw reply [flat|nested] 54+ messages in thread
* RE: [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
2025-03-10 13:37 ` Philippe Mathieu-Daudé
@ 2025-03-11 1:54 ` Duan, Zhenzhong
2025-03-11 7:20 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 54+ messages in thread
From: Duan, Zhenzhong @ 2025-03-11 1:54 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel@nongnu.org
Cc: Liu, Yi L, Pierrick Bouvier, Alex Williamson,
Christian Borntraeger, Alex Bennée, Tony Krowiak,
Nicholas Piggin, Halil Pasic, Thomas Huth, David Hildenbrand,
Igor Mammedov, Matthew Rosato, Tomita Moeko, qemu-ppc@nongnu.org,
Daniel Henrique Barboza, Eric Farman, Eduardo Habkost, Peter Xu,
kvm@vger.kernel.org, qemu-s390x@nongnu.org, Eric Auger,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
>-----Original Message-----
>From: Philippe Mathieu-Daudé <philmd@linaro.org>
>Subject: Re: [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime
>using iommufd_builtin()
>
>On 10/3/25 05:11, Duan, Zhenzhong wrote:
>> Hi Philippe,
>>
>>> -----Original Message-----
>>> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> Subject: [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime
>>> using iommufd_builtin()
>>>
>>> Convert the compile time check on the CONFIG_IOMMUFD definition
>>> by a runtime one by calling iommufd_builtin().
>>>
>>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>> hw/vfio/pci.c | 38 ++++++++++++++++++--------------------
>>> 1 file changed, 18 insertions(+), 20 deletions(-)
>
>
>>> static void vfio_pci_dev_class_init(ObjectClass *klass, void *data)
>>> {
>>> @@ -3433,9 +3430,10 @@ static void vfio_pci_dev_class_init(ObjectClass
>*klass,
>>> void *data)
>>>
>>> device_class_set_legacy_reset(dc, vfio_pci_reset);
>>> device_class_set_props(dc, vfio_pci_dev_properties);
>>> -#ifdef CONFIG_IOMMUFD
>>> - object_class_property_add_str(klass, "fd", NULL, vfio_pci_set_fd);
>>> -#endif
>>> + if (iommufd_builtin()) {
>>> + device_class_set_props(dc, vfio_pci_dev_iommufd_properties);
>>
>> device_class_set_props() is called twice. Won't it break qdev_print_props() and
>qdev_prop_walk()?
>
>device_class_set_props() is misnamed, as it doesn't SET an array of
>properties, but ADD them (or 'register') to the class.
>
>See device_class_set_props_n() in hw/core/qdev-properties.c.
But it set dc->props_ and dc->props_count_, first to vfio_pci_dev_properties
and then vfio_pci_dev_iommufd_properties, this will make qdev_prop_walk()
find only iommufd property and miss others. Do I misunderstand?
Thanks
Zhenzhong
>
>I'll see to rename the QDev methods for clarity.
>
>Regards,
>
>Phil.
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
2025-03-11 1:54 ` Duan, Zhenzhong
@ 2025-03-11 7:20 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-11 7:20 UTC (permalink / raw)
To: Duan, Zhenzhong, qemu-devel@nongnu.org
Cc: Liu, Yi L, Pierrick Bouvier, Alex Williamson,
Christian Borntraeger, Alex Bennée, Tony Krowiak,
Nicholas Piggin, Halil Pasic, Thomas Huth, David Hildenbrand,
Igor Mammedov, Matthew Rosato, Tomita Moeko, qemu-ppc@nongnu.org,
Daniel Henrique Barboza, Eric Farman, Eduardo Habkost, Peter Xu,
kvm@vger.kernel.org, qemu-s390x@nongnu.org, Eric Auger,
Paolo Bonzini, Harsh Prateek Bora, Cédric Le Goater,
Ilya Leoshkevich, Jason Herne, Daniel P. Berrangé,
Richard Henderson
On 11/3/25 02:54, Duan, Zhenzhong wrote:
>
>
>> -----Original Message-----
>> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Subject: Re: [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime
>> using iommufd_builtin()
>>
>> On 10/3/25 05:11, Duan, Zhenzhong wrote:
>>> Hi Philippe,
>>>
>>>> -----Original Message-----
>>>> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>> Subject: [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime
>>>> using iommufd_builtin()
>>>>
>>>> Convert the compile time check on the CONFIG_IOMMUFD definition
>>>> by a runtime one by calling iommufd_builtin().
>>>>
>>>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>> ---
>>>> hw/vfio/pci.c | 38 ++++++++++++++++++--------------------
>>>> 1 file changed, 18 insertions(+), 20 deletions(-)
>>
>>
>>>> static void vfio_pci_dev_class_init(ObjectClass *klass, void *data)
>>>> {
>>>> @@ -3433,9 +3430,10 @@ static void vfio_pci_dev_class_init(ObjectClass
>> *klass,
>>>> void *data)
>>>>
>>>> device_class_set_legacy_reset(dc, vfio_pci_reset);
>>>> device_class_set_props(dc, vfio_pci_dev_properties);
>>>> -#ifdef CONFIG_IOMMUFD
>>>> - object_class_property_add_str(klass, "fd", NULL, vfio_pci_set_fd);
>>>> -#endif
>>>> + if (iommufd_builtin()) {
>>>> + device_class_set_props(dc, vfio_pci_dev_iommufd_properties);
>>>
>>> device_class_set_props() is called twice. Won't it break qdev_print_props() and
>> qdev_prop_walk()?
>>
>> device_class_set_props() is misnamed, as it doesn't SET an array of
>> properties, but ADD them (or 'register') to the class.
>>
>> See device_class_set_props_n() in hw/core/qdev-properties.c.
>
> But it set dc->props_ and dc->props_count_, first to vfio_pci_dev_properties
> and then vfio_pci_dev_iommufd_properties, this will make qdev_prop_walk()
> find only iommufd property and miss others. Do I misunderstand?
You are right! And I thought I was understanding what this code does...
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 00/21] hw/vfio: Build various objects once
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2025-03-10 8:03 ` [PATCH v2 00/21] hw/vfio: Build various objects once Cédric Le Goater
@ 2025-03-11 8:08 ` Cédric Le Goater
22 siblings, 0 replies; 54+ messages in thread
From: Cédric Le Goater @ 2025-03-11 8:08 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Pierrick Bouvier, Alex Williamson, Christian Borntraeger,
Alex Bennée, Tony Krowiak, Nicholas Piggin, Halil Pasic,
Thomas Huth, David Hildenbrand, Igor Mammedov, Matthew Rosato,
Tomita Moeko, qemu-ppc, Daniel Henrique Barboza, Eric Farman,
Eduardo Habkost, Peter Xu, kvm, Zhenzhong Duan, qemu-s390x,
Eric Auger, Paolo Bonzini, Harsh Prateek Bora, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 3/9/25 00:08, Philippe Mathieu-Daudé wrote:
> By doing the following changes:
> - Clean some headers up
> - Replace compile-time CONFIG_KVM check by kvm_enabled()
> - Replace compile-time CONFIG_IOMMUFD check by iommufd_builtin()
> we can build less vfio objects.
>
> Since v1:
> - Added R-b tags
> - Introduce type_is_registered()
> - Split builtin check VS meson changes (rth)
> - Consider IGD
>
> Philippe Mathieu-Daudé (21):
> hw/vfio/common: Include missing 'system/tcg.h' header
> hw/vfio/spapr: Do not include <linux/kvm.h>
> hw/vfio: Compile some common objects once
> hw/vfio: Compile more objects once
> hw/vfio: Compile iommufd.c once
> system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h'
> hw/vfio: Compile display.c once
> system/kvm: Expose kvm_irqchip_[add,remove]_change_notifier()
> hw/vfio/pci: Convert CONFIG_KVM check to runtime one
> qom: Introduce type_is_registered()
> hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE
> hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin()
> hw/vfio/igd: Compile once
> system/iommufd: Introduce iommufd_builtin() helper
> hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
> hw/vfio/pci: Compile once
> hw/vfio/ap: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
> hw/vfio/ccw: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
> hw/vfio/s390x: Compile AP and CCW once
> hw/vfio/platform: Check CONFIG_IOMMUFD at runtime using
> iommufd_builtin
> hw/vfio/platform: Compile once
>
> docs/devel/vfio-iommufd.rst | 2 +-
> hw/vfio/pci-quirks.h | 8 +++++
> include/exec/ram_addr.h | 3 --
> include/qom/object.h | 8 +++++
> include/system/hostmem.h | 3 ++
> include/system/iommufd.h | 6 ++++
> include/system/kvm.h | 8 ++---
> target/s390x/kvm/kvm_s390x.h | 2 +-
> hw/ppc/spapr_caps.c | 1 +
> hw/s390x/s390-virtio-ccw.c | 1 +
> hw/vfio/ap.c | 27 ++++++++---------
> hw/vfio/ccw.c | 27 ++++++++---------
> hw/vfio/common.c | 1 +
> hw/vfio/igd-stubs.c | 20 +++++++++++++
> hw/vfio/igd.c | 4 +--
> hw/vfio/iommufd.c | 1 -
> hw/vfio/migration.c | 1 -
> hw/vfio/pci-quirks.c | 9 +++---
> hw/vfio/pci.c | 57 +++++++++++++++++-------------------
> hw/vfio/platform.c | 25 ++++++++--------
> hw/vfio/spapr.c | 4 +--
> qom/object.c | 5 ++++
> hw/vfio/meson.build | 35 +++++++++++++---------
> 23 files changed, 152 insertions(+), 106 deletions(-)
> create mode 100644 hw/vfio/igd-stubs.c
>
Applied 1-9 to vfio-next.
Thanks,
C.
^ permalink raw reply [flat|nested] 54+ messages in thread
* Re: [PATCH v2 09/21] hw/vfio/pci: Convert CONFIG_KVM check to runtime one
2025-03-10 12:54 ` BALATON Zoltan
2025-03-10 14:53 ` Eric Auger
@ 2025-03-11 8:54 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 54+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-11 8:54 UTC (permalink / raw)
To: BALATON Zoltan, Eric Auger
Cc: qemu-devel, Yi Liu, Pierrick Bouvier, Alex Williamson,
Christian Borntraeger, Alex Bennée, Tony Krowiak,
Nicholas Piggin, Halil Pasic, Thomas Huth, David Hildenbrand,
Igor Mammedov, Matthew Rosato, Tomita Moeko, qemu-ppc,
Daniel Henrique Barboza, Eric Farman, Eduardo Habkost, Peter Xu,
kvm, Zhenzhong Duan, qemu-s390x, Paolo Bonzini,
Harsh Prateek Bora, Cédric Le Goater, Ilya Leoshkevich,
Jason Herne, Daniel P. Berrangé, Richard Henderson
On 10/3/25 13:54, BALATON Zoltan wrote:
> On Mon, 10 Mar 2025, Eric Auger wrote:
>> Hi Philippe,
>>
>> On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
>>> Use the runtime kvm_enabled() helper to check whether
>>> KVM is available or not.
>>
>> Miss the "why" of this patch.
>>
>> By the way I fail to remember/see where kvm_allowed is set.
In accel/accel-system.c:
int accel_init_machine(AccelState *accel, MachineState *ms)
{
AccelClass *acc = ACCEL_GET_CLASS(accel);
int ret;
ms->accelerator = accel;
*(acc->allowed) = true;
ret = acc->init_machine(ms);
if (ret < 0) {
ms->accelerator = NULL;
*(acc->allowed) = false;
object_unref(OBJECT(accel));
} else {
object_set_accelerator_compat_props(acc->compat_props);
}
return ret;
}
>
> It's in include/system/kvm.h
>
>> I am also confused because we still have some code, like in
>> vfio/common.c which does both checks:
>> #ifdef CONFIG_KVM
>> if (kvm_enabled()) {
>> max_memslots = kvm_get_max_memslots();
>> }
>> #endif
We should prefer kvm_enabled() over CONFIG_KVM, but for kvm_enabled()
we need the prototypes declared, which sometimes aren't.
^ permalink raw reply [flat|nested] 54+ messages in thread
end of thread, other threads:[~2025-03-11 8:55 UTC | newest]
Thread overview: 54+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-08 23:08 [PATCH v2 00/21] hw/vfio: Build various objects once Philippe Mathieu-Daudé
2025-03-08 23:08 ` [PATCH v2 01/21] hw/vfio/common: Include missing 'system/tcg.h' header Philippe Mathieu-Daudé
2025-03-10 8:08 ` Eric Auger
2025-03-08 23:08 ` [PATCH v2 02/21] hw/vfio/spapr: Do not include <linux/kvm.h> Philippe Mathieu-Daudé
2025-03-10 8:08 ` Eric Auger
2025-03-08 23:08 ` [PATCH v2 03/21] hw/vfio: Compile some common objects once Philippe Mathieu-Daudé
2025-03-10 8:19 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 04/21] hw/vfio: Compile more " Philippe Mathieu-Daudé
2025-03-10 8:20 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 05/21] hw/vfio: Compile iommufd.c once Philippe Mathieu-Daudé
2025-03-10 8:23 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 06/21] system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h' Philippe Mathieu-Daudé
2025-03-10 8:28 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 07/21] hw/vfio: Compile display.c once Philippe Mathieu-Daudé
2025-03-10 8:29 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add, remove]_change_notifier() Philippe Mathieu-Daudé
2025-03-09 18:54 ` [PATCH v2 08/21] system/kvm: Expose kvm_irqchip_[add,remove]_change_notifier() Richard Henderson
2025-03-10 8:35 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 09/21] hw/vfio/pci: Convert CONFIG_KVM check to runtime one Philippe Mathieu-Daudé
2025-03-10 9:54 ` Eric Auger
2025-03-10 12:54 ` BALATON Zoltan
2025-03-10 14:53 ` Eric Auger
2025-03-11 8:54 ` Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 10/21] qom: Introduce type_is_registered() Philippe Mathieu-Daudé
2025-03-09 19:14 ` Richard Henderson
2025-03-10 7:38 ` Cédric Le Goater
2025-03-10 9:54 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 11/21] hw/vfio/igd: Define TYPE_VFIO_PCI_IGD_LPC_BRIDGE Philippe Mathieu-Daudé
2025-03-10 7:38 ` Cédric Le Goater
2025-03-10 9:54 ` Eric Auger
2025-03-08 23:09 ` [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin() Philippe Mathieu-Daudé
2025-03-10 7:37 ` Cédric Le Goater
2025-03-10 13:43 ` Philippe Mathieu-Daudé
2025-03-10 13:51 ` Cédric Le Goater
2025-03-10 15:23 ` Philippe Mathieu-Daudé
2025-03-10 15:16 ` Tomita Moeko
2025-03-08 23:09 ` [PATCH v2 13/21] hw/vfio/igd: Compile once Philippe Mathieu-Daudé
2025-03-10 7:39 ` Cédric Le Goater
2025-03-10 7:52 ` Cédric Le Goater
2025-03-08 23:09 ` [PATCH v2 14/21] system/iommufd: Introduce iommufd_builtin() helper Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 15/21] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin() Philippe Mathieu-Daudé
2025-03-10 4:11 ` Duan, Zhenzhong
2025-03-10 13:37 ` Philippe Mathieu-Daudé
2025-03-11 1:54 ` Duan, Zhenzhong
2025-03-11 7:20 ` Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 16/21] hw/vfio/pci: Compile once Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 17/21] hw/vfio/ap: Check CONFIG_IOMMUFD at runtime using iommufd_builtin() Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 18/21] hw/vfio/ccw: " Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 19/21] hw/vfio/s390x: Compile AP and CCW once Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 20/21] hw/vfio/platform: Check CONFIG_IOMMUFD at runtime using iommufd_builtin Philippe Mathieu-Daudé
2025-03-08 23:09 ` [PATCH v2 21/21] hw/vfio/platform: Compile once Philippe Mathieu-Daudé
2025-03-10 8:03 ` [PATCH v2 00/21] hw/vfio: Build various objects once Cédric Le Goater
2025-03-10 13:38 ` Philippe Mathieu-Daudé
2025-03-11 8:08 ` Cédric Le Goater
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).