By inlinining the stubs we can avoid the use of target-specific
CONFIG_DEVICES include in a hw/ header, allowing to build the
source files including it as common objects.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/i386/intel_iommu_accel.h | 35 ++---------------------------
hw/i386/intel_iommu_accel-stubs.c | 37 +++++++++++++++++++++++++++++++
hw/i386/meson.build | 1 +
3 files changed, 40 insertions(+), 33 deletions(-)
create mode 100644 hw/i386/intel_iommu_accel-stubs.c
diff --git a/hw/i386/intel_iommu_accel.h b/hw/i386/intel_iommu_accel.h
index e5f0b077b4b..d75d232c6d4 100644
--- a/hw/i386/intel_iommu_accel.h
+++ b/hw/i386/intel_iommu_accel.h
@@ -10,9 +10,9 @@
#ifndef HW_I386_INTEL_IOMMU_ACCEL_H
#define HW_I386_INTEL_IOMMU_ACCEL_H
-#include CONFIG_DEVICES
-#ifdef CONFIG_VTD_ACCEL
+#include "hw/i386/intel_iommu_internal.h"
+
bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOMMUDevice *vtd_hiod,
Error **errp);
VTDHostIOMMUDevice *vtd_find_hiod_iommufd(VTDAddressSpace *as);
@@ -21,36 +21,5 @@ void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s, uint16_t domain_id,
uint32_t pasid, hwaddr addr,
uint64_t npages, bool ih);
void vtd_iommu_ops_update_accel(PCIIOMMUOps *ops);
-#else
-static inline bool vtd_check_hiod_accel(IntelIOMMUState *s,
- VTDHostIOMMUDevice *vtd_hiod,
- Error **errp)
-{
- error_setg(errp, "host IOMMU cannot be checked!");
- error_append_hint(errp, "CONFIG_VTD_ACCEL is not enabled");
- return false;
-}
-static inline VTDHostIOMMUDevice *vtd_find_hiod_iommufd(VTDAddressSpace *as)
-{
- return NULL;
-}
-
-static inline bool vtd_propagate_guest_pasid(VTDAddressSpace *vtd_as,
- Error **errp)
-{
- return true;
-}
-
-static inline void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s,
- uint16_t domain_id,
- uint32_t pasid, hwaddr addr,
- uint64_t npages, bool ih)
-{
-}
-
-static inline void vtd_iommu_ops_update_accel(PCIIOMMUOps *ops)
-{
-}
-#endif
#endif
diff --git a/hw/i386/intel_iommu_accel-stubs.c b/hw/i386/intel_iommu_accel-stubs.c
new file mode 100644
index 00000000000..6015e0df2a1
--- /dev/null
+++ b/hw/i386/intel_iommu_accel-stubs.c
@@ -0,0 +1,37 @@
+/*
+ * Intel IOMMU acceleration with nested translation (stubs)
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "hw/i386/intel_iommu_accel.h"
+
+bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOMMUDevice *vtd_hiod,
+ Error **errp)
+{
+ error_setg(errp, "host IOMMU cannot be checked!");
+ error_append_hint(errp, "CONFIG_VTD_ACCEL is not enabled");
+ return false;
+}
+
+VTDHostIOMMUDevice *vtd_find_hiod_iommufd(VTDAddressSpace *as)
+{
+ return NULL;
+}
+
+bool vtd_propagate_guest_pasid(VTDAddressSpace *vtd_as, Error **errp)
+{
+ return true;
+}
+
+void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s, uint16_t domain_id,
+ uint32_t pasid, hwaddr addr,
+ uint64_t npages, bool ih)
+{
+}
+
+void vtd_iommu_ops_update_accel(PCIIOMMUOps *ops)
+{
+}
diff --git a/hw/i386/meson.build b/hw/i386/meson.build
index 63ae57baa51..0f058761b66 100644
--- a/hw/i386/meson.build
+++ b/hw/i386/meson.build
@@ -22,6 +22,7 @@ i386_ss.add(when: 'CONFIG_VMMOUSE', if_true: files('vmmouse.c'))
i386_ss.add(when: 'CONFIG_VMPORT', if_true: files('vmport.c'))
i386_ss.add(when: 'CONFIG_VTD', if_true: files('intel_iommu.c'))
i386_ss.add(when: 'CONFIG_VTD_ACCEL', if_true: files('intel_iommu_accel.c'))
+stub_ss.add(files('intel_iommu_accel-stubs.c'))
i386_ss.add(when: 'CONFIG_SGX', if_true: files('sgx-epc.c','sgx.c'),
if_false: files('sgx-stub.c'))
--
2.52.0
On 25/02/2026 04.16, Philippe Mathieu-Daudé wrote: > By inlinining the stubs we can avoid the use of target-specific s/By inlining the stubs/By turning the inline functions into stubs/ ? > CONFIG_DEVICES include in a hw/ header, allowing to build the > source files including it as common objects. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > hw/i386/intel_iommu_accel.h | 35 ++--------------------------- > hw/i386/intel_iommu_accel-stubs.c | 37 +++++++++++++++++++++++++++++++ > hw/i386/meson.build | 1 + > 3 files changed, 40 insertions(+), 33 deletions(-) > create mode 100644 hw/i386/intel_iommu_accel-stubs.c > > diff --git a/hw/i386/intel_iommu_accel.h b/hw/i386/intel_iommu_accel.h > index e5f0b077b4b..d75d232c6d4 100644 > --- a/hw/i386/intel_iommu_accel.h > +++ b/hw/i386/intel_iommu_accel.h > @@ -10,9 +10,9 @@ > > #ifndef HW_I386_INTEL_IOMMU_ACCEL_H > #define HW_I386_INTEL_IOMMU_ACCEL_H > -#include CONFIG_DEVICES > > -#ifdef CONFIG_VTD_ACCEL > +#include "hw/i386/intel_iommu_internal.h" Why is this #include suddenly required? ... please add a comment about this to the patch description! Thanks, Thomas
Hi Phil,
Reviewed-by: Clement Mathieu--Drif <clement.mathieu--drif@eviden.com>
cmd
________________________________
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Sent: 25 February 2026 04:16
To: qemu-devel@nongnu.org <qemu-devel@nongnu.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>; Thomas Huth <thuth@redhat.com>; qemu-s390x@nongnu.org <qemu-s390x@nongnu.org>; Pierrick Bouvier <pierrick.bouvier@linaro.org>; Shameer Kolothum <skolothumtho@nvidia.com>; qemu-arm@nongnu.org <qemu-arm@nongnu.org>; Philippe Mathieu-Daudé <philmd@linaro.org>; Richard Henderson <richard.henderson@linaro.org>; Eduardo Habkost <eduardo@habkost.net>; Michael S. Tsirkin <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>; Jason Wang <jasowang@redhat.com>; Yi Liu <yi.l.liu@intel.com>; CLEMENT MATHIEU--DRIF <clement.mathieu--drif@eviden.com>
Subject: [PATCH 2/3] hw/i386/intel_iommu: Avoid including CONFIG_DEVICES in hw/ header
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
By inlinining the stubs we can avoid the use of target-specific
CONFIG_DEVICES include in a hw/ header, allowing to build the
source files including it as common objects.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/i386/intel_iommu_accel.h | 35 ++---------------------------
hw/i386/intel_iommu_accel-stubs.c | 37 +++++++++++++++++++++++++++++++
hw/i386/meson.build | 1 +
3 files changed, 40 insertions(+), 33 deletions(-)
create mode 100644 hw/i386/intel_iommu_accel-stubs.c
diff --git a/hw/i386/intel_iommu_accel.h b/hw/i386/intel_iommu_accel.h
index e5f0b077b4b..d75d232c6d4 100644
--- a/hw/i386/intel_iommu_accel.h
+++ b/hw/i386/intel_iommu_accel.h
@@ -10,9 +10,9 @@
#ifndef HW_I386_INTEL_IOMMU_ACCEL_H
#define HW_I386_INTEL_IOMMU_ACCEL_H
-#include CONFIG_DEVICES
-#ifdef CONFIG_VTD_ACCEL
+#include "hw/i386/intel_iommu_internal.h"
+
bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOMMUDevice *vtd_hiod,
Error **errp);
VTDHostIOMMUDevice *vtd_find_hiod_iommufd(VTDAddressSpace *as);
@@ -21,36 +21,5 @@ void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s, uint16_t domain_id,
uint32_t pasid, hwaddr addr,
uint64_t npages, bool ih);
void vtd_iommu_ops_update_accel(PCIIOMMUOps *ops);
-#else
-static inline bool vtd_check_hiod_accel(IntelIOMMUState *s,
- VTDHostIOMMUDevice *vtd_hiod,
- Error **errp)
-{
- error_setg(errp, "host IOMMU cannot be checked!");
- error_append_hint(errp, "CONFIG_VTD_ACCEL is not enabled");
- return false;
-}
-static inline VTDHostIOMMUDevice *vtd_find_hiod_iommufd(VTDAddressSpace *as)
-{
- return NULL;
-}
-
-static inline bool vtd_propagate_guest_pasid(VTDAddressSpace *vtd_as,
- Error **errp)
-{
- return true;
-}
-
-static inline void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s,
- uint16_t domain_id,
- uint32_t pasid, hwaddr addr,
- uint64_t npages, bool ih)
-{
-}
-
-static inline void vtd_iommu_ops_update_accel(PCIIOMMUOps *ops)
-{
-}
-#endif
#endif
diff --git a/hw/i386/intel_iommu_accel-stubs.c b/hw/i386/intel_iommu_accel-stubs.c
new file mode 100644
index 00000000000..6015e0df2a1
--- /dev/null
+++ b/hw/i386/intel_iommu_accel-stubs.c
@@ -0,0 +1,37 @@
+/*
+ * Intel IOMMU acceleration with nested translation (stubs)
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "hw/i386/intel_iommu_accel.h"
+
+bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOMMUDevice *vtd_hiod,
+ Error **errp)
+{
+ error_setg(errp, "host IOMMU cannot be checked!");
+ error_append_hint(errp, "CONFIG_VTD_ACCEL is not enabled");
+ return false;
+}
+
+VTDHostIOMMUDevice *vtd_find_hiod_iommufd(VTDAddressSpace *as)
+{
+ return NULL;
+}
+
+bool vtd_propagate_guest_pasid(VTDAddressSpace *vtd_as, Error **errp)
+{
+ return true;
+}
+
+void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s, uint16_t domain_id,
+ uint32_t pasid, hwaddr addr,
+ uint64_t npages, bool ih)
+{
+}
+
+void vtd_iommu_ops_update_accel(PCIIOMMUOps *ops)
+{
+}
diff --git a/hw/i386/meson.build b/hw/i386/meson.build
index 63ae57baa51..0f058761b66 100644
--- a/hw/i386/meson.build
+++ b/hw/i386/meson.build
@@ -22,6 +22,7 @@ i386_ss.add(when: 'CONFIG_VMMOUSE', if_true: files('vmmouse.c'))
i386_ss.add(when: 'CONFIG_VMPORT', if_true: files('vmport.c'))
i386_ss.add(when: 'CONFIG_VTD', if_true: files('intel_iommu.c'))
i386_ss.add(when: 'CONFIG_VTD_ACCEL', if_true: files('intel_iommu_accel.c'))
+stub_ss.add(files('intel_iommu_accel-stubs.c'))
i386_ss.add(when: 'CONFIG_SGX', if_true: files('sgx-epc.c','sgx.c'),
if_false: files('sgx-stub.c'))
--
2.52.0
© 2016 - 2026 Red Hat, Inc.