hw/iommu: Avoid including CONFIG_DEVICES in hw/ header
cover hw/iommu: Avoid including CONFIG_DEVICES in hw/ header
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.
Philippe Mathieu-Daudé (3):
hw/arm/smmuv3: Avoid including CONFIG_DEVICES in hw/ header hw/i386/intel_iommu: Avoid including CONFIG_DEVICES in hw/ header hw/s390x/s390-pci-vfio: Avoid including CONFIG_DEVICES in hw/ header
hw/arm/smmuv3-accel.h | 35 ------------------------ hw/i386/intel_iommu_accel.h | 35 ++---------------------- include/hw/s390x/s390-pci-vfio.h | 20 -------------- hw/arm/smmuv3-accel-stubs.c | 44 +++++++++++++++++++++++++++++++ hw/i386/intel_iommu_accel-stubs.c | 37 ++++++++++++++++++++++++++ hw/s390x/s390-pci-vfio-stubs.c | 32 ++++++++++++++++++++++ hw/arm/meson.build | 5 ++-- hw/i386/meson.build | 1 + hw/s390x/meson.build | 1 + 9 files changed, 120 insertions(+), 90 deletions(-) create mode 100644 hw/arm/smmuv3-accel-stubs.c create mode 100644 hw/i386/intel_iommu_accel-stubs.c create mode 100644 hw/s390x/s390-pci-vfio-stubs.c
Signature · 1 line
2.52.0
PATCH 1/3 hw/arm/smmuv3: Avoid including CONFIG_DEVICES in hw/ header
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.
--- hw/arm/smmuv3-accel.h | 35 ----------------------------- hw/arm/smmuv3-accel-stubs.c | 44 +++++++++++++++++++++++++++++++++++++ hw/arm/meson.build | 5 +++-- 3 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 hw/arm/smmuv3-accel-stubs.c
hw/arm/smmuv3-accel.h +0 -35
@@ -14,7 +14,6 @@#ifdef CONFIG_LINUX #include <linux/iommufd.h> #endif -#include CONFIG_DEVICES /* * Represents an accelerated SMMU instance backed by an iommufd vIOMMU object.
@@ -40,7 +39,6 @@ typedef struct SMMUv3AccelDevice {SMMUv3AccelState *s_accel; } SMMUv3AccelDevice; -#ifdef CONFIG_ARM_SMMUV3_ACCEL void smmuv3_accel_init (SMMUv3State *s);bool smmuv3_accel_install_ste (SMMUv3State *s,SMMUDevice *sdev,int sid,Error **errp);
@@ -51,38 +49,5 @@ bool smmuv3_accel_issue_inv_cmd(SMMUv3State *s, void *cmd, SMMUDevice *sdev, Error **errp);void smmuv3_accel_idr_override (SMMUv3State *s);void smmuv3_accel_reset (SMMUv3State *s); -#else -static inline void smmuv3_accel_init (SMMUv3State *s) -{ -} -static inline bool -smmuv3_accel_install_ste (SMMUv3State *s,SMMUDevice *sdev,int sid, -Error **errp) -{ -return true; -} -static inline bool -smmuv3_accel_install_ste_range (SMMUv3State *s,SMMUSIDRange *range, -Error **errp) -{ -return true; -} -static inline bool smmuv3_accel_attach_gbpa_hwpt (SMMUv3State *s,Error **errp) -{ -return true; -} -static inline bool -smmuv3_accel_issue_inv_cmd (SMMUv3State *s,void *cmd,SMMUDevice *sdev, -Error **errp) -{ -return true; -} -static inline void smmuv3_accel_idr_override (SMMUv3State *s) -{ -} -static inline void smmuv3_accel_reset (SMMUv3State *s) -{ -} -#endif #endif /* HW_ARM_SMMUV3_ACCEL_H */
hw/arm/smmuv3-accel-stubs.c new file +44 -0
44 lines not on this page · raw message
hw/arm/meson.build +3 -2
@@ -85,8 +85,9 @@ arm_common_ss.add(when: 'CONFIG_ARMSSE', if_true: files('armsse.c')) arm_common_ss.add(when: 'CONFIG_FSL_IMX7', if_true: files('fsl-imx7.c', 'mcimx7d-sabre.c')) arm_common_ss.add(when: 'CONFIG_FSL_IMX8MP', if_true: files('fsl-imx8mp.c')) arm_common_ss.add(when: 'CONFIG_FSL_IMX8MP_EVK', if_true: files('imx8mp-evk.c')) -arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmuv3.c')) -arm_ss.add(when: 'CONFIG_ARM_SMMUV3_ACCEL', if_true: files('smmuv3-accel.c')) +arm_common_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmuv3.c')) +arm_common_ss.add(when: 'CONFIG_ARM_SMMUV3_ACCEL', if_true: files('smmuv3-accel.c')) +stub_ss.add(files('smmuv3-accel-stubs.c')) arm_common_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcimx6ul-evk.c')) arm_common_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c')) arm_common_ss.add(when: 'CONFIG_XEN', if_true: files(
Signature · 1 line
2.52.0
Re: [PATCH 1/3] hw/arm/smmuv3: Avoid including CONFIG_DEVICES in hw/ header
Quoted 1 line · Philippe Mathieu-Daudé
By inlinining the stubs we can avoid the use of target-specific
s/By inlining the stubs/By turning the inline functions into stubs/ ?
Apart from that:
Quoted 136 lines
CONFIG_DEVICESinclude in a hw/ header, allowing to build the source files including it as common objects.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/arm/smmuv3-accel.h | 35 ----------------------------- hw/arm/smmuv3-accel-stubs.c | 44 +++++++++++++++++++++++++++++++++++++ hw/arm/meson.build | 5 +++-- 3 files changed, 47 insertions(+), 37 deletions(-)create mode 100644
hw/arm/smmuv3-accel-stubs.chw/arm/smmuv3-accel.h +0
-35@@ -14,7 +14,6 @@#ifdef CONFIG_LINUX #include <linux/iommufd.h> #endif -#include CONFIG_DEVICES /* * Represents an accelerated SMMU instance backed by an iommufd vIOMMU object. @@ -40,7 +39,6 @@ typedef struct SMMUv3AccelDevice {SMMUv3AccelState *s_accel; } SMMUv3AccelDevice; -#ifdef CONFIG_ARM_SMMUV3_ACCEL void smmuv3_accel_init (SMMUv3State *s);bool smmuv3_accel_install_ste (SMMUv3State *s,SMMUDevice *sdev,int sid,Error **errp);@@ -51,38 +49,5 @@ bool smmuv3_accel_issue_inv_cmd(SMMUv3State *s, void *cmd, SMMUDevice *sdev, Error **errp);void smmuv3_accel_idr_override (SMMUv3State *s);void smmuv3_accel_reset (SMMUv3State *s); -#else -static inline void smmuv3_accel_init (SMMUv3State *s) -{ -} -static inline bool -smmuv3_accel_install_ste (SMMUv3State *s,SMMUDevice *sdev,int sid, -Error **errp) -{ -return true; -} -static inline bool -smmuv3_accel_install_ste_range (SMMUv3State *s,SMMUSIDRange *range, -Error **errp) -{ -return true; -} -static inline bool smmuv3_accel_attach_gbpa_hwpt (SMMUv3State *s,Error **errp) -{ -return true; -} -static inline bool -smmuv3_accel_issue_inv_cmd (SMMUv3State *s,void *cmd,SMMUDevice *sdev, -Error **errp) -{ -return true; -} -static inline void smmuv3_accel_idr_override (SMMUv3State *s) -{ -} -static inline void smmuv3_accel_reset (SMMUv3State *s) -{ -} -#endif #endif /* HW_ARM_SMMUV3_ACCEL_H */ hw/arm/smmuv3-accel-stubs.c new file +44
-0@@ -0,0 +1,44 @@ +/* +* Stubs for accelerated SMMU instance backed by an iommufd vIOMMU object. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hw/arm/smmuv3.h" +#include "hw/arm/smmuv3-accel.h" + +void smmuv3_accel_init (SMMUv3State *s) +{ +} + +bool smmuv3_accel_install_ste (SMMUv3State *s,SMMUDevice *sdev,int sid, +Error **errp) +{ +return true; +} + +bool smmuv3_accel_install_ste_range (SMMUv3State *s,SMMUSIDRange *range, +Error **errp) +{ +return true; +} + +bool smmuv3_accel_attach_gbpa_hwpt (SMMUv3State *s,Error **errp) +{ +return true; +} + +bool smmuv3_accel_issue_inv_cmd (SMMUv3State *s,void *cmd,SMMUDevice *sdev, +Error **errp) +{ +return true; +} + +void smmuv3_accel_idr_override (SMMUv3State *s) +{ +} + +void smmuv3_accel_reset (SMMUv3State *s) +{ +}hw/arm/meson.build +3
-2@@ -85,8 +85,9 @@ arm_common_ss.add(when: 'CONFIG_ARMSSE', if_true: files('armsse.c')) arm_common_ss.add(when: 'CONFIG_FSL_IMX7', if_true: files('fsl-imx7.c', 'mcimx7d-sabre.c')) arm_common_ss.add(when: 'CONFIG_FSL_IMX8MP', if_true: files('fsl-imx8mp.c')) arm_common_ss.add(when: 'CONFIG_FSL_IMX8MP_EVK', if_true: files('imx8mp-evk.c')) -arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmuv3.c')) -arm_ss.add(when: 'CONFIG_ARM_SMMUV3_ACCEL', if_true: files('smmuv3-accel.c')) +arm_common_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmuv3.c')) +arm_common_ss.add(when: 'CONFIG_ARM_SMMUV3_ACCEL', if_true: files('smmuv3-accel.c')) +stub_ss.add(files('smmuv3-accel-stubs.c')) arm_common_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcimx6ul-evk.c')) arm_common_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c')) arm_common_ss.add(when: 'CONFIG_XEN', if_true: files(
RE: [PATCH 1/3] hw/arm/smmuv3: Avoid including CONFIG_DEVICES in hw/ header
In reply to Philippe Mathieu-DaudéQuoted 15 lines
-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: 25 February 2026 03:17
To: [email protected]
Cc: Paolo Bonzini <[email protected]>; Thomas Huth <[email protected]>; [email protected]; Pierrick Bouvier <[email protected]>; Shameer Kolothum Thodi <[email protected]>; [email protected]; Philippe Mathieu- Daudé <[email protected]>; Peter Maydell <[email protected]>; Eric Auger <[email protected]>
Subject: [PATCH 1/3] hw/arm/smmuv3: Avoid includingCONFIG_DEVICESin hw/ header
Quoted 6 lines
External email: Use caution opening links or attachments
By inlinining the stubs we can avoid the use of target-specific
CONFIG_DEVICESinclude in a hw/ header, allowing to build the source files including it as common objects.
Thanks.
However, smmuv3.c currently has a:
#ifndef CONFIG_ARM_SMMUV3_ACCEL
in smmu_validate_property().
which leads to the build failure below:
[30/195] Compiling C object libsystem_arm.a.p/hw_arm_smmuv3.c.o
FAILED: libsystem_arm.a.p/hw_arm_smmuv3.c.o
...
../hw/arm/smmuv3.c: In function ‘smmu_validate_property’:../hw/arm/smmuv3.c:1939:9: error: attempt to use poisoned "CONFIG_ARM_SMMUV3_ACCEL"
1939 | #ifndef CONFIG_ARM_SMMUV3_ACCEL
| ^
One way to fix this is to remove the CONFIG_ check from smmuv3.c and rely on the stub implementation for smmuv3_accel_init () instead:
hw/arm/smmuv3-accel.h +1 -1
@@ -39,7 +39,7 @@ typedef struct SMMUv3AccelDevice {SMMUv3AccelState *s_accel; } SMMUv3AccelDevice; -void smmuv3_accel_init (SMMUv3State *s); +bool smmuv3_accel_init (SMMUv3State *s,Error **errp);bool smmuv3_accel_install_ste (SMMUv3State *s,SMMUDevice *sdev,int sid,Error **errp); bool smmuv3_accel_install_ste_range(SMMUv3State *s, SMMUSIDRange *range,
hw/arm/smmuv3-accel-stubs.c +3 -1
@@ -8,8 +8,10 @@#include "hw/arm/smmuv3.h" #include "hw/arm/smmuv3-accel.h" -void smmuv3_accel_init (SMMUv3State *s) +bool smmuv3_accel_init (SMMUv3State *s,Error **errp) { +error_setg (errp,"accel=on support not compiled in" ); +return false; } bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevice *sdev, int sid,
hw/arm/smmuv3-accel.c +2 -1
@@ -758,11 +758,12 @@ static void smmuv3_accel_as_init(SMMUv3State *s)address_space_init (shared_as_sysmem, &root,"smmuv3-accel-as-sysmem" ); } -void smmuv3_accel_init (SMMUv3State *s) +bool smmuv3_accel_init (SMMUv3State *s,Error **errp) {SMMUState *bs =ARM_SMMU (s); s->s_accel =g_new0 (SMMUv3AccelState,1 ); bs->iommu_ops = &smmuv3_accel_ops;smmuv3_accel_as_init (s); +return true; }
hw/arm/smmuv3.c +3 -8
@@ -1936,13 +1936,6 @@ static void smmu_reset_exit(Object *obj, ResetType type)static bool smmu_validate_property (SMMUv3State *s,Error **errp) { -#ifndef CONFIG_ARM_SMMUV3_ACCEL -if (s->accel) { -error_setg (errp,"accel=on support not compiled in" ); -return false; - } -#endif -if (!s->accel) {if (!s->ril) {error_setg (errp,"ril can only be disabled if accel=on" );
@@ -1996,7 +1989,9 @@ static void smmu_realize(DeviceState *d, Error **errp) }if (s->accel) { -smmuv3_accel_init (s); +if (!smmuv3_accel_init (s, errp)) { +return ; + }error_setg (&s->migration_blocker,"Migration not supported with SMMUv3 " "accelerator mode enabled" );if (migrate_add_blocker (&s->migration_blocker, errp) <0 ) {
Thanks,
Shameer
Re: [PATCH 1/3] hw/arm/smmuv3: Avoid including CONFIG_DEVICES in hw/ header
Quoted 108 lines · Shameer Kolothum Thodi
Quoted 15 lines
-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: 25 February 2026 03:17
To: [email protected]
Cc: Paolo Bonzini <[email protected]>; Thomas Huth <[email protected]>; [email protected]; Pierrick Bouvier <[email protected]>; Shameer Kolothum Thodi <[email protected]>; [email protected]; Philippe Mathieu- Daudé <[email protected]>; Peter Maydell <[email protected]>; Eric Auger <[email protected]>
Subject: [PATCH 1/3] hw/arm/smmuv3: Avoid includingCONFIG_DEVICESin hw/ headerQuoted 6 lines
External email: Use caution opening links or attachments
By inlinining the stubs we can avoid the use of target-specific
CONFIG_DEVICESinclude in a hw/ header, allowing to build the source files including it as common objects.Thanks.
However,
smmuv3.ccurrently has a:
#ifndefCONFIG_ARM_SMMUV3_ACCEL
insmmu_validate_property().which leads to the build failure below:
[30/195] Compiling C object
libsystem_arm.a.p/hw_arm_smmuv3.c.o
FAILED:libsystem_arm.a.p/hw_arm_smmuv3.c.o
...
../hw/arm/smmuv3.c: In function ‘smmu_validate_property’:../hw/arm/smmuv3.c:1939:9: error: attempt to use poisoned "CONFIG_ARM_SMMUV3_ACCEL"
1939 | #ifndefCONFIG_ARM_SMMUV3_ACCEL
| ^One way to fix this is to remove the
CONFIG_check fromsmmuv3.cand rely on the stub implementation forsmmuv3_accel_init() instead:hw/arm/smmuv3-accel.h +1
-1@@ -39,7 +39,7 @@ typedef struct SMMUv3AccelDevice {SMMUv3AccelState *s_accel; } SMMUv3AccelDevice; -void smmuv3_accel_init (SMMUv3State *s); +bool smmuv3_accel_init (SMMUv3State *s,Error **errp);bool smmuv3_accel_install_ste (SMMUv3State *s,SMMUDevice *sdev,int sid,Error **errp); bool smmuv3_accel_install_ste_range(SMMUv3State *s, SMMUSIDRange *range,hw/arm/smmuv3-accel-stubs.c +3
-1@@ -8,8 +8,10 @@#include "hw/arm/smmuv3.h" #include "hw/arm/smmuv3-accel.h" -void smmuv3_accel_init (SMMUv3State *s) +bool smmuv3_accel_init (SMMUv3State *s,Error **errp) { +error_setg (errp,"accel=on support not compiled in" ); +return false; } bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevice *sdev, int sid,hw/arm/smmuv3-accel.c +2
-1@@ -758,11 +758,12 @@ static void smmuv3_accel_as_init(SMMUv3State *s)address_space_init (shared_as_sysmem, &root,"smmuv3-accel-as-sysmem" ); } -void smmuv3_accel_init (SMMUv3State *s) +bool smmuv3_accel_init (SMMUv3State *s,Error **errp) {SMMUState *bs =ARM_SMMU (s); s->s_accel =g_new0 (SMMUv3AccelState,1 ); bs->iommu_ops = &smmuv3_accel_ops;smmuv3_accel_as_init (s); +return true; }hw/arm/smmuv3.c +0
-7@@ -1936,13 +1936,6 @@ static void smmu_reset_exit(Object *obj, ResetType type)static bool smmu_validate_property (SMMUv3State *s,Error **errp) { -#ifndef CONFIG_ARM_SMMUV3_ACCEL -if (s->accel) { -error_setg (errp,"accel=on support not compiled in" ); -return false; - } -#endif -if (!s->accel) {if (!s->ril) {error_setg (errp,"ril can only be disabled if accel=on" );
hw/arm/smmuv3.c static void smmu_realize(DeviceState *d, Error **errp) · line 1997
Quoted 10 lines
hw/arm/smmuv3.c +3
-1@@ -1996,7 +1989,9 @@ static void smmu_realize(DeviceState *d, Error **errp) }if (s->accel) { -smmuv3_accel_init (s); +if (!smmuv3_accel_init (s, errp)) { +return ; + }error_setg (&s->migration_blocker,"Migration not supported with SMMUv3 " "accelerator mode enabled" );if (migrate_add_blocker (&s->migration_blocker, errp) <0 ) {
Great, thanks Shameer! I'll respin including that.
PATCH 2/3 hw/i386/intel_iommu: Avoid including CONFIG_DEVICES in hw/ header
In reply to Philippe Mathieu-Daudé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.
--- 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
hw/i386/intel_iommu_accel.h +2 -33
@@ -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
hw/i386/intel_iommu_accel-stubs.c new file +37 -0
@@ -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) +{ +}
hw/i386/meson.build +1 -0
@@ -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'))
Signature · 1 line
2.52.0
Re: [PATCH 2/3] hw/i386/intel_iommu: Avoid including CONFIG_DEVICES in hw/ header
Hi Phil,
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.
--- 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
hw/i386/intel_iommu_accel.h +2 -33
@@ -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
hw/i386/intel_iommu_accel-stubs.c new file +37 -0
@@ -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) +{ +}
hw/i386/meson.build +1 -0
@@ -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
Re: [PATCH 2/3] hw/i386/intel_iommu: Avoid including CONFIG_DEVICES in hw/ header
In reply to Philippe Mathieu-DaudéQuoted 1 line · Philippe Mathieu-Daudé
By inlinining the stubs we can avoid the use of target-specific
s/By inlining the stubs/By turning the inline functions into stubs/ ?
Quoted 16 lines
CONFIG_DEVICESinclude 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.chw/i386/intel_iommu_accel.h +0
-0
hw/i386/intel_iommu_accel.h line 14
Quoted 7 lines
hw/i386/intel_iommu_accel.h +1
-2@@ -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
PATCH 3/3 hw/s390x/s390-pci-vfio: Avoid including CONFIG_DEVICES in hw/ header
In reply to Philippe Mathieu-Daudé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.
--- include/hw/s390x/s390-pci-vfio.h | 20 -------------------- hw/s390x/s390-pci-vfio-stubs.c | 32 ++++++++++++++++++++++++++++++++ hw/s390x/meson.build | 1 + 3 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 hw/s390x/s390-pci-vfio-stubs.c
include/hw/s390x/s390-pci-vfio.h +0 -20
@@ -13,32 +13,12 @@#define HW_S390_PCI_VFIO_H #include "hw/s390x/s390-pci-bus.h" -#include CONFIG_DEVICES -#ifdef CONFIG_VFIO bool s390_pci_update_dma_avail (int fd,unsigned int *avail);S390PCIDMACount *s390_pci_start_dma_count (S390pciState *s,S390PCIBusDevice *pbdev);void s390_pci_end_dma_count (S390pciState *s,S390PCIDMACount *cnt);bool s390_pci_get_host_fh (S390PCIBusDevice *pbdev,uint32_t *fh);void s390_pci_get_clp_info (S390PCIBusDevice *pbdev); -#else -static inline bool s390_pci_update_dma_avail (int fd,unsigned int *avail) -{ -return false; -} -static inline S390PCIDMACount *s390_pci_start_dma_count (S390pciState *s, -S390PCIBusDevice *pbdev) -{ -return NULL ; -} -static inline void s390_pci_end_dma_count (S390pciState *s, -S390PCIDMACount *cnt) { } -static inline bool s390_pci_get_host_fh (S390PCIBusDevice *pbdev,uint32_t *fh) -{ -return false; -} -static inline void s390_pci_get_clp_info (S390PCIBusDevice *pbdev) { } -#endif #endif
hw/s390x/s390-pci-vfio-stubs.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* s390 vfio-pci stubs +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hw/s390x/s390-pci-vfio.h" + +bool s390_pci_update_dma_avail (int fd,unsigned int *avail) +{ +return false; +} + +S390PCIDMACount *s390_pci_start_dma_count (S390pciState *s, +S390PCIBusDevice *pbdev) +{ +return NULL ; +} + +void s390_pci_end_dma_count (S390pciState *s,S390PCIDMACount *cnt) +{ +} + +bool s390_pci_get_host_fh (S390PCIBusDevice *pbdev,uint32_t *fh) +{ +return false; +} + +void s390_pci_get_clp_info (S390PCIBusDevice *pbdev) +{ +}
hw/s390x/meson.build +1 -0
@@ -34,6 +34,7 @@ s390x_ss.add(when: 'CONFIG_S390_CCW_VIRTIO', if_true: files( )) s390x_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('3270-ccw.c')) s390x_ss.add(when: 'CONFIG_VFIO', if_true: files('s390-pci-vfio.c')) +stub_ss.add(files('s390-pci-vfio-stubs.c')) s390x_ss.add(when: 'CONFIG_VFIO_AP', if_false: files('ap-stub.c')) virtio_ss = ss.source_set()
Signature · 1 line
2.52.0
Re: [PATCH 3/3] hw/s390x/s390-pci-vfio: Avoid including CONFIG_DEVICES in hw/ header
Quoted 1 line · Philippe Mathieu-Daudé
By inlinining the stubs we can avoid the use of target-specific
Please fix at least the "inlinining" typo!
With that fixed:
Re: [PATCH 3/3] hw/s390x/s390-pci-vfio: Avoid including CONFIG_DEVICES in hw/ header
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
By inlinining the stubs we can avoid the use of target-specific
CONFIG_DEVICESinclude in a hw/ header, allowing to build the source files including it as common objects.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/hw/s390x/s390-pci-vfio.h | 20 -------------------- hw/s390x/s390-pci-vfio-stubs.c | 32 ++++++++++++++++++++++++++++++++ hw/s390x/meson.build | 1 + 3 files changed, 33 insertions(+), 20 deletions(-)create mode 100644
hw/s390x/s390-pci-vfio-stubs.c
This doesn't seem to break anything on s390x :) apart from the typo for "inlinining" looks good to me
Quoted 8 lines · Philippe Mathieu-Daudé
By inlinining the stubs we can avoid the use of target-specific
CONFIG_DEVICESinclude in a hw/ header, allowing to build the source files including it as common objects.Philippe Mathieu-Daudé (3):
hw/arm/smmuv3: Avoid includingCONFIG_DEVICESin hw/ header hw/i386/intel_iommu: Avoid includingCONFIG_DEVICESin hw/ header hw/s390x/s390-pci-vfio: Avoid includingCONFIG_DEVICESin hw/ header
r~