qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] semihosting/uaccess: Compile once
@ 2025-05-09 11:07 Philippe Mathieu-Daudé
  2025-05-09 11:07 ` [PATCH v2 1/2] semihosting/uaccess: Remove uses of target_ulong type Philippe Mathieu-Daudé
  2025-05-09 11:07 ` [PATCH v2 2/2] semihosting/uaccess: Compile once Philippe Mathieu-Daudé
  0 siblings, 2 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-09 11:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alex Bennée, Pierrick Bouvier, Philippe Mathieu-Daudé

Replace target_ulong -> vaddr/size_t to compile once.

since v1:
- fixed build error when TCG disabled (Pierrick)

Philippe Mathieu-Daudé (2):
  semihosting/uaccess: Remove uses of target_ulong type
  semihosting/uaccess: Compile once

 include/semihosting/uaccess.h | 12 ++++++------
 semihosting/uaccess.c         | 10 +++++-----
 semihosting/meson.build       |  4 +---
 3 files changed, 12 insertions(+), 14 deletions(-)

-- 
2.47.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] semihosting/uaccess: Remove uses of target_ulong type
  2025-05-09 11:07 [PATCH v2 0/2] semihosting/uaccess: Compile once Philippe Mathieu-Daudé
@ 2025-05-09 11:07 ` Philippe Mathieu-Daudé
  2025-05-09 11:07 ` [PATCH v2 2/2] semihosting/uaccess: Compile once Philippe Mathieu-Daudé
  1 sibling, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-09 11:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alex Bennée, Pierrick Bouvier, Philippe Mathieu-Daudé

Replace target_ulong by vaddr or size_t types to match
cpu_memory_rw_debug() prototype in "exec/cpu-common.h":

  int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
                          void *ptr, size_t len,
                          bool is_write);

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 include/semihosting/uaccess.h | 12 ++++++------
 semihosting/uaccess.c         | 10 +++++-----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/semihosting/uaccess.h b/include/semihosting/uaccess.h
index 6bc90b12d6f..2093a498277 100644
--- a/include/semihosting/uaccess.h
+++ b/include/semihosting/uaccess.h
@@ -15,9 +15,9 @@
 #endif
 
 #include "exec/cpu-common.h"
-#include "exec/cpu-defs.h"
 #include "exec/tswap.h"
 #include "exec/page-protection.h"
+#include "exec/vaddr.h"
 
 /**
  * get_user_u64:
@@ -89,8 +89,8 @@
  *
  * The returned pointer should be freed using uaccess_unlock_user().
  */
-void *uaccess_lock_user(CPUArchState *env, target_ulong addr,
-                        target_ulong len, bool copy);
+void *uaccess_lock_user(CPUArchState *env, vaddr addr,
+                        size_t len, bool copy);
 /**
  * lock_user:
  *
@@ -103,7 +103,7 @@ void *uaccess_lock_user(CPUArchState *env, target_ulong addr,
  *
  * The returned string should be freed using uaccess_unlock_user().
  */
-char *uaccess_lock_user_string(CPUArchState *env, target_ulong addr);
+char *uaccess_lock_user_string(CPUArchState *env, vaddr addr);
 /**
  * uaccess_lock_user_string:
  *
@@ -112,10 +112,10 @@ char *uaccess_lock_user_string(CPUArchState *env, target_ulong addr);
 #define lock_user_string(p) uaccess_lock_user_string(env, p)
 
 void uaccess_unlock_user(CPUArchState *env, void *p,
-                         target_ulong addr, target_ulong len);
+                         vaddr addr, size_t len);
 #define unlock_user(s, args, len) uaccess_unlock_user(env, s, args, len)
 
-ssize_t uaccess_strlen_user(CPUArchState *env, target_ulong addr);
+ssize_t uaccess_strlen_user(CPUArchState *env, vaddr addr);
 #define target_strlen(p) uaccess_strlen_user(env, p)
 
 #endif /* SEMIHOSTING_SOFTMMU_UACCESS_H */
diff --git a/semihosting/uaccess.c b/semihosting/uaccess.c
index 4554844e15b..ff944d8c2f7 100644
--- a/semihosting/uaccess.c
+++ b/semihosting/uaccess.c
@@ -14,8 +14,8 @@
 #include "exec/tlb-flags.h"
 #include "semihosting/uaccess.h"
 
-void *uaccess_lock_user(CPUArchState *env, target_ulong addr,
-                        target_ulong len, bool copy)
+void *uaccess_lock_user(CPUArchState *env, vaddr addr,
+                        size_t len, bool copy)
 {
     void *p = malloc(len);
     if (p && copy) {
@@ -27,7 +27,7 @@ void *uaccess_lock_user(CPUArchState *env, target_ulong addr,
     return p;
 }
 
-ssize_t uaccess_strlen_user(CPUArchState *env, target_ulong addr)
+ssize_t uaccess_strlen_user(CPUArchState *env, vaddr addr)
 {
     int mmu_idx = cpu_mmu_index(env_cpu(env), false);
     size_t len = 0;
@@ -75,7 +75,7 @@ ssize_t uaccess_strlen_user(CPUArchState *env, target_ulong addr)
     }
 }
 
-char *uaccess_lock_user_string(CPUArchState *env, target_ulong addr)
+char *uaccess_lock_user_string(CPUArchState *env, vaddr addr)
 {
     ssize_t len = uaccess_strlen_user(env, addr);
     if (len < 0) {
@@ -85,7 +85,7 @@ char *uaccess_lock_user_string(CPUArchState *env, target_ulong addr)
 }
 
 void uaccess_unlock_user(CPUArchState *env, void *p,
-                         target_ulong addr, target_ulong len)
+                         vaddr addr, size_t len)
 {
     if (len) {
         cpu_memory_rw_debug(env_cpu(env), addr, p, len, 1);
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] semihosting/uaccess: Compile once
  2025-05-09 11:07 [PATCH v2 0/2] semihosting/uaccess: Compile once Philippe Mathieu-Daudé
  2025-05-09 11:07 ` [PATCH v2 1/2] semihosting/uaccess: Remove uses of target_ulong type Philippe Mathieu-Daudé
@ 2025-05-09 11:07 ` Philippe Mathieu-Daudé
  2025-05-09 16:06   ` Pierrick Bouvier
  1 sibling, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-09 11:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alex Bennée, Pierrick Bouvier, Philippe Mathieu-Daudé

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 semihosting/meson.build | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/semihosting/meson.build b/semihosting/meson.build
index f3d38dda91d..d0819891bc3 100644
--- a/semihosting/meson.build
+++ b/semihosting/meson.build
@@ -3,9 +3,7 @@ specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
   'syscalls.c',
 ))
 
-specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_true: files(
-  'uaccess.c',
-))
+system_ss.add(when: 'CONFIG_TCG', if_true: files('uaccess.c'))
 
 common_ss.add(when: 'CONFIG_SEMIHOSTING', if_false: files('stubs-all.c'))
 user_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files('user.c'))
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] semihosting/uaccess: Compile once
  2025-05-09 11:07 ` [PATCH v2 2/2] semihosting/uaccess: Compile once Philippe Mathieu-Daudé
@ 2025-05-09 16:06   ` Pierrick Bouvier
  0 siblings, 0 replies; 4+ messages in thread
From: Pierrick Bouvier @ 2025-05-09 16:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Alex Bennée

Hi Philippe,

On 5/9/25 4:07 AM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   semihosting/meson.build | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/semihosting/meson.build b/semihosting/meson.build
> index f3d38dda91d..d0819891bc3 100644
> --- a/semihosting/meson.build
> +++ b/semihosting/meson.build
> @@ -3,9 +3,7 @@ specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
>     'syscalls.c',
>   ))
>   
> -specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_true: files(
> -  'uaccess.c',
> -))
> +system_ss.add(when: 'CONFIG_TCG', if_true: files('uaccess.c'))
>   
>   common_ss.add(when: 'CONFIG_SEMIHOSTING', if_false: files('stubs-all.c'))
>   user_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files('user.c'))

It doesn't compile applied on master [1].

Does it compile on your side?
If yes, could you include the additional patches allowing you to get rid 
of CONFIG_USER_ONLY in included headers?

My previous answer on v1 was giving a solution, and an associated meson 
patch. In case we can't remove CONFIG_USER_ONLY from the headers 
included, it's the only possible solution I still see today.

[1] 
https://github.com/pbo-linaro/qemu-ci/actions/runs/14927715244/job/41936282521

Regards,
Pierrick


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-09 16:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-09 11:07 [PATCH v2 0/2] semihosting/uaccess: Compile once Philippe Mathieu-Daudé
2025-05-09 11:07 ` [PATCH v2 1/2] semihosting/uaccess: Remove uses of target_ulong type Philippe Mathieu-Daudé
2025-05-09 11:07 ` [PATCH v2 2/2] semihosting/uaccess: Compile once Philippe Mathieu-Daudé
2025-05-09 16:06   ` Pierrick Bouvier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).