[PATCH 34/37] include/system: Remove ifndef CONFIG_USER_ONLY

Richard Henderson posted 37 patches 8 months, 1 week ago
There is a newer version of this series
[PATCH 34/37] include/system: Remove ifndef CONFIG_USER_ONLY
Posted by Richard Henderson 8 months, 1 week ago
This is include/system, so CONFIG_USER_ONLY will never be true.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/system/cpu-timers.h | 2 +-
 include/system/qtest.h      | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/system/cpu-timers.h b/include/system/cpu-timers.h
index 64ae54f6d6..f10cb5e7d4 100644
--- a/include/system/cpu-timers.h
+++ b/include/system/cpu-timers.h
@@ -30,7 +30,7 @@ typedef enum {
     ICOUNT_ADAPTATIVE,
 } ICountMode;
 
-#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
+#ifdef CONFIG_TCG
 extern ICountMode use_icount;
 #define icount_enabled() (use_icount)
 #else
diff --git a/include/system/qtest.h b/include/system/qtest.h
index 6ddddc501b..84b1f8c6ee 100644
--- a/include/system/qtest.h
+++ b/include/system/qtest.h
@@ -23,7 +23,6 @@ static inline bool qtest_enabled(void)
     return qtest_allowed;
 }
 
-#ifndef CONFIG_USER_ONLY
 void G_GNUC_PRINTF(2, 3) qtest_sendf(CharBackend *chr, const char *fmt, ...);
 void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words));
 bool qtest_driver(void);
@@ -33,6 +32,5 @@ void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error **
 void qtest_server_set_send_handler(void (*send)(void *, const char *),
                                  void *opaque);
 void qtest_server_inproc_recv(void *opaque, const char *buf);
-#endif
 
 #endif
-- 
2.43.0
Re: [PATCH 34/37] include/system: Remove ifndef CONFIG_USER_ONLY
Posted by Pierrick Bouvier 8 months, 1 week ago
On 3/12/25 20:45, Richard Henderson wrote:
> This is include/system, so CONFIG_USER_ONLY will never be true.
> 

Some build configurations have this symbol missing.
https://github.com/pbo-linaro/qemu-ci/actions/runs/13826820446

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   include/system/cpu-timers.h | 2 +-
>   include/system/qtest.h      | 2 --
>   2 files changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/include/system/cpu-timers.h b/include/system/cpu-timers.h
> index 64ae54f6d6..f10cb5e7d4 100644
> --- a/include/system/cpu-timers.h
> +++ b/include/system/cpu-timers.h
> @@ -30,7 +30,7 @@ typedef enum {
>       ICOUNT_ADAPTATIVE,
>   } ICountMode;
>   
> -#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
> +#ifdef CONFIG_TCG
>   extern ICountMode use_icount;
>   #define icount_enabled() (use_icount)
>   #else
> diff --git a/include/system/qtest.h b/include/system/qtest.h
> index 6ddddc501b..84b1f8c6ee 100644
> --- a/include/system/qtest.h
> +++ b/include/system/qtest.h
> @@ -23,7 +23,6 @@ static inline bool qtest_enabled(void)
>       return qtest_allowed;
>   }
>   
> -#ifndef CONFIG_USER_ONLY
>   void G_GNUC_PRINTF(2, 3) qtest_sendf(CharBackend *chr, const char *fmt, ...);
>   void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words));
>   bool qtest_driver(void);
> @@ -33,6 +32,5 @@ void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error **
>   void qtest_server_set_send_handler(void (*send)(void *, const char *),
>                                    void *opaque);
>   void qtest_server_inproc_recv(void *opaque, const char *buf);
> -#endif
>   
>   #endif
Re: [PATCH 34/37] include/system: Remove ifndef CONFIG_USER_ONLY
Posted by Philippe Mathieu-Daudé 8 months, 1 week ago
On 13/3/25 04:45, Richard Henderson wrote:
> This is include/system, so CONFIG_USER_ONLY will never be true.

Ideally yes. I started moving headers in include/system/ to clarify
APIs, but that doesn't mean some of these APIs aren't being
(incorrectly) used in user emulation.

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   include/system/cpu-timers.h | 2 +-
>   include/system/qtest.h      | 2 --
>   2 files changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/include/system/cpu-timers.h b/include/system/cpu-timers.h
> index 64ae54f6d6..f10cb5e7d4 100644
> --- a/include/system/cpu-timers.h
> +++ b/include/system/cpu-timers.h
> @@ -30,7 +30,7 @@ typedef enum {
>       ICOUNT_ADAPTATIVE,
>   } ICountMode;
>   
> -#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
> +#ifdef CONFIG_TCG
>   extern ICountMode use_icount;
>   #define icount_enabled() (use_icount)
>   #else
 >   #define icount_enabled() ICOUNT_DISABLED
 >   #endif

For example accel/tcg/tcg-all.c include this header in user and
gets icount_enabled() = 0.

So first we'd need preparatory changes in to form of:

-- >8 --
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index c1a30b01219..daa629e5b72 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -74,4 +74,7 @@ DECLARE_INSTANCE_CHECKER(TCGState, TCG_STATE,
  static bool default_mttcg_enabled(void)
  {
+#ifdef CONFIG_USER_ONLY
+    return false;
+#else
      if (icount_enabled()) {
          return false;
@@ -85,4 +88,5 @@ static bool default_mttcg_enabled(void)
      return false;
  #endif
+#endif
  }
---