Hi Phil,

Reviewed-by: Clement Mathieu--Drif <[email protected]>

cmd

________________________________
From: Philippe Mathieu-Daudé <[email protected]>
Sent: 25 February 2026 04:16
To: [email protected] <[email protected]>
Cc: Paolo Bonzini <[email protected]>; Thomas Huth <[email protected]>; 
[email protected] <[email protected]>; Pierrick Bouvier 
<[email protected]>; Shameer Kolothum <[email protected]>; 
[email protected] <[email protected]>; Philippe Mathieu-Daudé 
<[email protected]>; Richard Henderson <[email protected]>; Eduardo 
Habkost <[email protected]>; Michael S. Tsirkin <[email protected]>; Marcel 
Apfelbaum <[email protected]>; Jason Wang <[email protected]>; Yi 
Liu <[email protected]>; CLEMENT MATHIEU--DRIF 
<[email protected]>
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é <[email protected]>
---
 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

Reply via email to