From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
qemu-ppc@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Tony Krowiak" <akrowiak@linux.ibm.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
kvm@vger.kernel.org, "Yi Liu" <yi.l.liu@intel.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Zhenzhong Duan" <zhenzhong.duan@intel.com>,
"Matthew Rosato" <mjrosato@linux.ibm.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Peter Xu" <peterx@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Eric Auger" <eric.auger@redhat.com>,
qemu-s390x@nongnu.org, "Jason Herne" <jjherne@linux.ibm.com>,
"Cédric Le Goater" <clg@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: [PATCH 11/14] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()
Date: Fri, 7 Mar 2025 19:03:34 +0100 [thread overview]
Message-ID: <20250307180337.14811-12-philmd@linaro.org> (raw)
In-Reply-To: <20250307180337.14811-1-philmd@linaro.org>
Convert the compile time check on the CONFIG_IOMMUFD definition
by a runtime one by calling iommufd_builtin().
Since 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/pci.c | 38 ++++++++++++++++++--------------------
hw/vfio/meson.build | 2 +-
2 files changed, 19 insertions(+), 21 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 "
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 96e342aa8cb..9a004992c11 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -6,7 +6,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(
'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'))
@@ -29,4 +28,5 @@ 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',
))
--
2.47.1
next prev parent reply other threads:[~2025-03-07 18:04 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 18:03 [PATCH 00/14] hw/vfio: Build various objects once Philippe Mathieu-Daudé
2025-03-07 18:03 ` [PATCH 01/14] hw/vfio/common: Include missing 'system/tcg.h' header Philippe Mathieu-Daudé
2025-03-07 19:14 ` Pierrick Bouvier
2025-03-08 17:39 ` Cédric Le Goater
2025-03-07 18:03 ` [PATCH 02/14] hw/vfio/spapr: Do not include <linux/kvm.h> Philippe Mathieu-Daudé
2025-03-07 19:14 ` Pierrick Bouvier
2025-03-08 17:39 ` Cédric Le Goater
2025-03-07 18:03 ` [PATCH 03/14] hw/vfio: Compile some common objects once Philippe Mathieu-Daudé
2025-03-07 19:15 ` Pierrick Bouvier
2025-03-08 17:39 ` Cédric Le Goater
2025-03-07 18:03 ` [PATCH 04/14] hw/vfio: Compile more " Philippe Mathieu-Daudé
2025-03-07 19:15 ` Pierrick Bouvier
2025-03-08 17:45 ` Cédric Le Goater
2025-03-07 18:03 ` [PATCH 05/14] hw/vfio: Compile iommufd.c once Philippe Mathieu-Daudé
2025-03-07 19:16 ` Pierrick Bouvier
2025-03-08 17:45 ` Cédric Le Goater
2025-03-07 18:03 ` [PATCH 06/14] system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h' Philippe Mathieu-Daudé
2025-03-07 19:16 ` Pierrick Bouvier
2025-03-07 21:12 ` Philippe Mathieu-Daudé
2025-03-07 18:03 ` [PATCH 07/14] hw/vfio: Compile display.c once Philippe Mathieu-Daudé
2025-03-07 19:17 ` Pierrick Bouvier
2025-03-08 17:46 ` Cédric Le Goater
2025-03-07 18:03 ` [PATCH 08/14] system/kvm: Expose kvm_irqchip_[add,remove]_change_notifier() Philippe Mathieu-Daudé
2025-03-07 19:17 ` Pierrick Bouvier
2025-03-07 18:03 ` [PATCH 09/14] hw/vfio/pci: Convert CONFIG_KVM check to runtime one Philippe Mathieu-Daudé
2025-03-07 19:18 ` Pierrick Bouvier
2025-03-08 17:46 ` Cédric Le Goater
2025-03-07 18:03 ` [PATCH 10/14] system/iommufd: Introduce iommufd_builtin() helper Philippe Mathieu-Daudé
2025-03-07 19:18 ` Pierrick Bouvier
2025-03-07 18:03 ` Philippe Mathieu-Daudé [this message]
2025-03-07 19:19 ` [PATCH 11/14] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin() Pierrick Bouvier
2025-03-07 18:03 ` [PATCH 12/14] hw/vfio/ap: " Philippe Mathieu-Daudé
2025-03-07 19:19 ` Pierrick Bouvier
2025-03-07 18:03 ` [PATCH 13/14] hw/vfio/ccw: " Philippe Mathieu-Daudé
2025-03-07 19:19 ` Pierrick Bouvier
2025-03-07 18:03 ` [PATCH 14/14] hw/vfio/platform: Check CONFIG_IOMMUFD at runtime using iommufd_builtin Philippe Mathieu-Daudé
2025-03-07 19:20 ` Pierrick Bouvier
2025-03-08 17:48 ` [PATCH 00/14] hw/vfio: Build various objects once Cédric Le Goater
2025-03-08 20:37 ` BALATON Zoltan
2025-03-08 22:31 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250307180337.14811-12-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=akrowiak@linux.ibm.com \
--cc=alex.bennee@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=clg@redhat.com \
--cc=danielhb413@gmail.com \
--cc=david@redhat.com \
--cc=eric.auger@redhat.com \
--cc=farman@linux.ibm.com \
--cc=harshpb@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=imammedo@redhat.com \
--cc=jjherne@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=yi.l.liu@intel.com \
--cc=zhenzhong.duan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox