On 3/18/25 14:32, Richard Henderson wrote:
Poison CONFIG_USER_ONLY and CONFIG_SOFTMMU unless
the compilation unit is in specific_ss, libuser_ss,
or libsystem_ss.  This is intended to prevent files
being incorrectly added to common_ss.

Remove #ifndef CONFIG_USER_ONLY / #error / #endif blocks.
All they do is trigger the poison error.

Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
---
  include/exec/poison.h                       | 5 +++++
  include/hw/hw.h                             | 4 ----
  include/system/confidential-guest-support.h | 4 ----
  include/system/replay.h                     | 4 ----
  include/system/xen.h                        | 4 ----
  meson.build                                 | 6 ++++--
  6 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/include/exec/poison.h b/include/exec/poison.h
index 8ed04b3108..a6ffe4577f 100644
--- a/include/exec/poison.h
+++ b/include/exec/poison.h
@@ -67,4 +67,9 @@
  #pragma GCC poison CONFIG_WHPX
  #pragma GCC poison CONFIG_XEN
+#ifndef COMPILING_SYSTEM_VS_USER
+#pragma GCC poison CONFIG_USER_ONLY
+#pragma GCC poison CONFIG_SOFTMMU
+#endif
+
  #endif
diff --git a/include/hw/hw.h b/include/hw/hw.h
index 045c1c8b09..1b33d12b7f 100644
--- a/include/hw/hw.h
+++ b/include/hw/hw.h
@@ -1,10 +1,6 @@
  #ifndef QEMU_HW_H
  #define QEMU_HW_H
-#ifdef CONFIG_USER_ONLY
-#error Cannot include hw/hw.h from user emulation
-#endif
-
  G_NORETURN void hw_error(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
#endif
diff --git a/include/system/confidential-guest-support.h 
b/include/system/confidential-guest-support.h
index b68c4bebbc..ea46b50c56 100644
--- a/include/system/confidential-guest-support.h
+++ b/include/system/confidential-guest-support.h
@@ -18,10 +18,6 @@
  #ifndef QEMU_CONFIDENTIAL_GUEST_SUPPORT_H
  #define QEMU_CONFIDENTIAL_GUEST_SUPPORT_H
-#ifdef CONFIG_USER_ONLY
-#error Cannot include system/confidential-guest-support.h from user emulation
-#endif
-
  #include "qom/object.h"
#define TYPE_CONFIDENTIAL_GUEST_SUPPORT "confidential-guest-support"
diff --git a/include/system/replay.h b/include/system/replay.h
index 8926d8cf4b..1c87c97fdd 100644
--- a/include/system/replay.h
+++ b/include/system/replay.h
@@ -11,10 +11,6 @@
  #ifndef SYSTEM_REPLAY_H
  #define SYSTEM_REPLAY_H
-#ifdef CONFIG_USER_ONLY
-#error Cannot include this header from user emulation
-#endif
-
  #include "exec/replay-core.h"
  #include "qapi/qapi-types-misc.h"
  #include "qapi/qapi-types-run-state.h"
diff --git a/include/system/xen.h b/include/system/xen.h
index 5f41915732..c2f283d1c2 100644
--- a/include/system/xen.h
+++ b/include/system/xen.h
@@ -10,10 +10,6 @@
  #ifndef SYSTEM_XEN_H
  #define SYSTEM_XEN_H
-#ifdef CONFIG_USER_ONLY
-#error Cannot include system/xen.h from user emulation
-#endif
-
  #include "exec/cpu-common.h"
#ifdef COMPILING_PER_TARGET
diff --git a/meson.build b/meson.build
index 329e7f056a..b4d65a75e5 100644
--- a/meson.build
+++ b/meson.build
@@ -4054,7 +4054,8 @@ common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: 
user_ss)
  libuser_ss = libuser_ss.apply({})
  libuser = static_library('user',
                           libuser_ss.sources() + genh,
-                         c_args: '-DCONFIG_USER_ONLY',
+                         c_args: ['-DCONFIG_USER_ONLY',
+                                  '-DCOMPILING_SYSTEM_VS_USER'],
                           dependencies: libuser_ss.dependencies(),
                           build_by_default: false)
  libuser = declare_dependency(objects: libuser.extract_all_objects(recursive: 
false),
@@ -4064,7 +4065,8 @@ common_ss.add(when: 'CONFIG_USER_ONLY', if_true: libuser)
  libsystem_ss = libsystem_ss.apply({})
  libsystem = static_library('system',
                             libsystem_ss.sources() + genh,
-                           c_args: '-DCONFIG_SOFTMMU',
+                           c_args: ['-DCONFIG_SOFTMMU',
+                                    '-DCOMPILING_SYSTEM_VS_USER'],
                             dependencies: libsystem_ss.dependencies(),
                             build_by_default: false)
  libsystem = declare_dependency(objects: 
libsystem.extract_all_objects(recursive: false),

That's a nice addition.
I'll benefit from that for hw/arm, where I have a few blocks to cleanup as well.

Reviewed-by: Pierrick Bouvier <pierrick.bouv...@linaro.org>


Reply via email to