[PULL 55/59] include/user: Use vaddr in guest-host.h

Richard Henderson posted 59 patches 6 months, 2 weeks ago
There is a newer version of this series
[PULL 55/59] include/user: Use vaddr in guest-host.h
Posted by Richard Henderson 6 months, 2 weeks ago
Replace abi_ptr and abi_ulong with vaddr.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/user/guest-host.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/user/guest-host.h b/include/user/guest-host.h
index 8e10d36948..0656f2e356 100644
--- a/include/user/guest-host.h
+++ b/include/user/guest-host.h
@@ -8,7 +8,7 @@
 #ifndef USER_GUEST_HOST_H
 #define USER_GUEST_HOST_H
 
-#include "user/abitypes.h"
+#include "exec/vaddr.h"
 #include "user/guest-base.h"
 #include "cpu.h"
 
@@ -30,29 +30,29 @@ extern unsigned long reserved_va;
 extern unsigned long guest_addr_max;
 
 #ifndef TARGET_TAGGED_ADDRESSES
-static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x)
+static inline vaddr cpu_untagged_addr(CPUState *cs, vaddr x)
 {
     return x;
 }
 #endif
 
 /* All direct uses of g2h and h2g need to go away for usermode softmmu.  */
-static inline void *g2h_untagged(abi_ptr x)
+static inline void *g2h_untagged(vaddr x)
 {
     return (void *)((uintptr_t)(x) + guest_base);
 }
 
-static inline void *g2h(CPUState *cs, abi_ptr x)
+static inline void *g2h(CPUState *cs, vaddr x)
 {
     return g2h_untagged(cpu_untagged_addr(cs, x));
 }
 
-static inline bool guest_addr_valid_untagged(abi_ulong x)
+static inline bool guest_addr_valid_untagged(vaddr x)
 {
     return x <= guest_addr_max;
 }
 
-static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len)
+static inline bool guest_range_valid_untagged(vaddr start, vaddr len)
 {
     return len - 1 <= guest_addr_max && start <= guest_addr_max - len + 1;
 }
@@ -62,7 +62,7 @@ static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len)
 
 #define h2g_nocheck(x) ({ \
     uintptr_t __ret = (uintptr_t)(x) - guest_base; \
-    (abi_ptr)__ret; \
+    (vaddr)__ret; \
 })
 
 #define h2g(x) ({ \
-- 
2.43.0
Re: [PULL 55/59] include/user: Use vaddr in guest-host.h
Posted by Laurent Vivier 3 months ago
Hi,

this commit breaks something when I try to debootstrap an etch-m68k chroot (not fixed in 
5836af078321):

unshare --time --ipc --uts --pid --fork --kill-child --mount --mount-proc --root 
chroot/m68k/etch-m68k apt-get update --yes
Get:1 http://archive.debian.org etch-m68k Release.gpg [835B]
Hit http://archive.debian.org etch-m68k Release
Err http://archive.debian.org etch-m68k Release

Get:2 http://archive.debian.org etch-m68k Release [8670B]
Ign http://archive.debian.org etch-m68k Release
Ign http://archive.debian.org etch-m68k/main Packages/DiffIndex
Hit http://archive.debian.org etch-m68k/main Packages
Fetched 9505B in 0s (12.9kB/s)
Reading package lists... Error!
W: GPG error: http://archive.debian.org etch-m68k Release: The following signatures 
couldn't be verified because the public key is not available: NO_PUBKEY 9AA38DCD55BE302B
E: Unable to write mmap - msync (12 Cannot allocate memory)
E: The package lists or status file could not be parsed or opened.

(it's using my create_chroot.sh from https://github.com/vivier/linux-user-test-scrips.
set RELEASES=etch in targets.conf, then run ./create_all.sh)

Thanks,
Laurent

On 01/05/2025 23:21, Richard Henderson wrote:
> Replace abi_ptr and abi_ulong with vaddr.
> 
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   include/user/guest-host.h | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/include/user/guest-host.h b/include/user/guest-host.h
> index 8e10d36948..0656f2e356 100644
> --- a/include/user/guest-host.h
> +++ b/include/user/guest-host.h
> @@ -8,7 +8,7 @@
>   #ifndef USER_GUEST_HOST_H
>   #define USER_GUEST_HOST_H
>   
> -#include "user/abitypes.h"
> +#include "exec/vaddr.h"
>   #include "user/guest-base.h"
>   #include "cpu.h"
>   
> @@ -30,29 +30,29 @@ extern unsigned long reserved_va;
>   extern unsigned long guest_addr_max;
>   
>   #ifndef TARGET_TAGGED_ADDRESSES
> -static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x)
> +static inline vaddr cpu_untagged_addr(CPUState *cs, vaddr x)
>   {
>       return x;
>   }
>   #endif
>   
>   /* All direct uses of g2h and h2g need to go away for usermode softmmu.  */
> -static inline void *g2h_untagged(abi_ptr x)
> +static inline void *g2h_untagged(vaddr x)
>   {
>       return (void *)((uintptr_t)(x) + guest_base);
>   }
>   
> -static inline void *g2h(CPUState *cs, abi_ptr x)
> +static inline void *g2h(CPUState *cs, vaddr x)
>   {
>       return g2h_untagged(cpu_untagged_addr(cs, x));
>   }
>   
> -static inline bool guest_addr_valid_untagged(abi_ulong x)
> +static inline bool guest_addr_valid_untagged(vaddr x)
>   {
>       return x <= guest_addr_max;
>   }
>   
> -static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len)
> +static inline bool guest_range_valid_untagged(vaddr start, vaddr len)
>   {
>       return len - 1 <= guest_addr_max && start <= guest_addr_max - len + 1;
>   }
> @@ -62,7 +62,7 @@ static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len)
>   
>   #define h2g_nocheck(x) ({ \
>       uintptr_t __ret = (uintptr_t)(x) - guest_base; \
> -    (abi_ptr)__ret; \
> +    (vaddr)__ret; \
>   })
>   
>   #define h2g(x) ({ \