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/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
diff --git a/hw/arm/smmuv3-accel.h b/hw/arm/smmuv3-accel.h
index a8a64802eca..7e48d1555d3 100644
--- a/hw/arm/smmuv3-accel.h
+++ b/hw/arm/smmuv3-accel.h
@@ -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 */
diff --git a/hw/arm/smmuv3-accel-stubs.c b/hw/arm/smmuv3-accel-stubs.c
new file mode 100644
index 00000000000..b64f1e4d93e
--- /dev/null
+++ b/hw/arm/smmuv3-accel-stubs.c
@@ -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)
+{
+}
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
index 47cdc51d135..8f834c32b1f 100644
--- a/hw/arm/meson.build
+++ b/hw/arm/meson.build
@@ -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(
--
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/ ?
Apart from that:
Reviewed-by: Thomas Huth <thuth@redhat.com>
> 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/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
>
> diff --git a/hw/arm/smmuv3-accel.h b/hw/arm/smmuv3-accel.h
> index a8a64802eca..7e48d1555d3 100644
> --- a/hw/arm/smmuv3-accel.h
> +++ b/hw/arm/smmuv3-accel.h
> @@ -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 */
> diff --git a/hw/arm/smmuv3-accel-stubs.c b/hw/arm/smmuv3-accel-stubs.c
> new file mode 100644
> index 00000000000..b64f1e4d93e
> --- /dev/null
> +++ b/hw/arm/smmuv3-accel-stubs.c
> @@ -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)
> +{
> +}
> diff --git a/hw/arm/meson.build b/hw/arm/meson.build
> index 47cdc51d135..8f834c32b1f 100644
> --- a/hw/arm/meson.build
> +++ b/hw/arm/meson.build
> @@ -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(
> -----Original Message-----
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Sent: 25 February 2026 03:17
> To: qemu-devel@nongnu.org
> Cc: Paolo Bonzini <pbonzini@redhat.com>; Thomas Huth
> <thuth@redhat.com>; qemu-s390x@nongnu.org; Pierrick Bouvier
> <pierrick.bouvier@linaro.org>; Shameer Kolothum Thodi
> <skolothumtho@nvidia.com>; qemu-arm@nongnu.org; Philippe Mathieu-
> Daudé <philmd@linaro.org>; Peter Maydell <peter.maydell@linaro.org>; Eric
> Auger <eric.auger@redhat.com>
> Subject: [PATCH 1/3] hw/arm/smmuv3: Avoid including CONFIG_DEVICES in
> hw/ header
>
> External email: Use caution opening links or attachments
>
>
> 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.
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:
diff --git a/hw/arm/smmuv3-accel.h b/hw/arm/smmuv3-accel.h
index 7e48d1555d..a224017c6c 100644
--- a/hw/arm/smmuv3-accel.h
+++ b/hw/arm/smmuv3-accel.h
@@ -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,
diff --git a/hw/arm/smmuv3-accel-stubs.c b/hw/arm/smmuv3-accel-stubs.c
index b64f1e4d93..c08caa6fa4 100644
--- a/hw/arm/smmuv3-accel-stubs.c
+++ b/hw/arm/smmuv3-accel-stubs.c
@@ -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,
diff --git a/hw/arm/smmuv3-accel.c b/hw/arm/smmuv3-accel.c
index f5cd4df336..ed647c45b8 100644
--- a/hw/arm/smmuv3-accel.c
+++ b/hw/arm/smmuv3-accel.c
@@ -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;
}
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index c08d58c579..8c51554c39 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -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
On 25/2/26 10:20, Shameer Kolothum Thodi wrote:
>
>
>> -----Original Message-----
>> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Sent: 25 February 2026 03:17
>> To: qemu-devel@nongnu.org
>> Cc: Paolo Bonzini <pbonzini@redhat.com>; Thomas Huth
>> <thuth@redhat.com>; qemu-s390x@nongnu.org; Pierrick Bouvier
>> <pierrick.bouvier@linaro.org>; Shameer Kolothum Thodi
>> <skolothumtho@nvidia.com>; qemu-arm@nongnu.org; Philippe Mathieu-
>> Daudé <philmd@linaro.org>; Peter Maydell <peter.maydell@linaro.org>; Eric
>> Auger <eric.auger@redhat.com>
>> Subject: [PATCH 1/3] hw/arm/smmuv3: Avoid including CONFIG_DEVICES in
>> hw/ header
>>
>> External email: Use caution opening links or attachments
>>
>>
>> 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.
>
> 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:
>
> diff --git a/hw/arm/smmuv3-accel.h b/hw/arm/smmuv3-accel.h
> index 7e48d1555d..a224017c6c 100644
> --- a/hw/arm/smmuv3-accel.h
> +++ b/hw/arm/smmuv3-accel.h
> @@ -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,
> diff --git a/hw/arm/smmuv3-accel-stubs.c b/hw/arm/smmuv3-accel-stubs.c
> index b64f1e4d93..c08caa6fa4 100644
> --- a/hw/arm/smmuv3-accel-stubs.c
> +++ b/hw/arm/smmuv3-accel-stubs.c
> @@ -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,
> diff --git a/hw/arm/smmuv3-accel.c b/hw/arm/smmuv3-accel.c
> index f5cd4df336..ed647c45b8 100644
> --- a/hw/arm/smmuv3-accel.c
> +++ b/hw/arm/smmuv3-accel.c
> @@ -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;
> }
> diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
> index c08d58c579..8c51554c39 100644
> --- a/hw/arm/smmuv3.c
> +++ b/hw/arm/smmuv3.c
> @@ -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) {
Great, thanks Shameer! I'll respin including that.
© 2016 - 2026 Red Hat, Inc.