[PATCH 2/2] target/s390x/tcg: Use vaddr in s390_probe_access()

Philippe Mathieu-Daudé posted 2 patches 5 months, 1 week ago
Maintainers: Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Thomas Huth <thuth@redhat.com>
[PATCH 2/2] target/s390x/tcg: Use vaddr in s390_probe_access()
Posted by Philippe Mathieu-Daudé 5 months, 1 week ago
Commit 70ebd9ce1cb ("s390x/tcg: Fault-safe memset") passed
vaddr type to access_prepare(), and commit b6c636f2cd6
("s390x/tcg: Fault-safe memmove") to do_access_get_byte(),
but declared S390Access::vaddr[1,2] as target_ulong.
Directly declare these as vaddr type, and have
s390_probe_access() use that type as argument.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/s390x/tcg/mem_helper.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
index a03609a1406..f1acb1618f7 100644
--- a/target/s390x/tcg/mem_helper.c
+++ b/target/s390x/tcg/mem_helper.c
@@ -126,8 +126,8 @@ static inline void cpu_stsize_data_ra(CPUS390XState *env, uint64_t addr,
 
 /* An access covers at most 4096 bytes and therefore at most two pages. */
 typedef struct S390Access {
-    target_ulong vaddr1;
-    target_ulong vaddr2;
+    vaddr vaddr1;
+    vaddr vaddr2;
     void *haddr1;
     void *haddr2;
     uint16_t size1;
@@ -148,7 +148,7 @@ typedef struct S390Access {
  * For !CONFIG_USER_ONLY, the TEC is stored stored to env->tlb_fill_tec.
  * For CONFIG_USER_ONLY, the faulting address is stored to env->__excp_addr.
  */
-static inline int s390_probe_access(CPUArchState *env, target_ulong addr,
+static inline int s390_probe_access(CPUArchState *env, vaddr addr,
                                     int size, MMUAccessType access_type,
                                     int mmu_idx, bool nonfault,
                                     void **phost, uintptr_t ra)
@@ -258,7 +258,7 @@ static void access_memset(CPUS390XState *env, S390Access *desta,
 static uint8_t access_get_byte(CPUS390XState *env, S390Access *access,
                                int offset, uintptr_t ra)
 {
-    target_ulong vaddr = access->vaddr1;
+    vaddr vaddr = access->vaddr1;
     void *haddr = access->haddr1;
 
     if (unlikely(offset >= access->size1)) {
@@ -278,7 +278,7 @@ static uint8_t access_get_byte(CPUS390XState *env, S390Access *access,
 static void access_set_byte(CPUS390XState *env, S390Access *access,
                             int offset, uint8_t byte, uintptr_t ra)
 {
-    target_ulong vaddr = access->vaddr1;
+    vaddr vaddr = access->vaddr1;
     void *haddr = access->haddr1;
 
     if (unlikely(offset >= access->size1)) {
-- 
2.49.0


Re: [PATCH 2/2] target/s390x/tcg: Use vaddr in s390_probe_access()
Posted by Richard Henderson 5 months, 1 week ago
On 7/7/25 11:10, Philippe Mathieu-Daudé wrote:
> Commit 70ebd9ce1cb ("s390x/tcg: Fault-safe memset") passed
> vaddr type to access_prepare(), and commit b6c636f2cd6
> ("s390x/tcg: Fault-safe memmove") to do_access_get_byte(),
> but declared S390Access::vaddr[1,2] as target_ulong.
> Directly declare these as vaddr type, and have
> s390_probe_access() use that type as argument.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/s390x/tcg/mem_helper.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
> index a03609a1406..f1acb1618f7 100644
> --- a/target/s390x/tcg/mem_helper.c
> +++ b/target/s390x/tcg/mem_helper.c
> @@ -126,8 +126,8 @@ static inline void cpu_stsize_data_ra(CPUS390XState *env, uint64_t addr,
>   
>   /* An access covers at most 4096 bytes and therefore at most two pages. */
>   typedef struct S390Access {
> -    target_ulong vaddr1;
> -    target_ulong vaddr2;
> +    vaddr vaddr1;
> +    vaddr vaddr2;
>       void *haddr1;
>       void *haddr2;
>       uint16_t size1;
> @@ -148,7 +148,7 @@ typedef struct S390Access {
>    * For !CONFIG_USER_ONLY, the TEC is stored stored to env->tlb_fill_tec.
>    * For CONFIG_USER_ONLY, the faulting address is stored to env->__excp_addr.
>    */
> -static inline int s390_probe_access(CPUArchState *env, target_ulong addr,
> +static inline int s390_probe_access(CPUArchState *env, vaddr addr,
>                                       int size, MMUAccessType access_type,
>                                       int mmu_idx, bool nonfault,
>                                       void **phost, uintptr_t ra)
> @@ -258,7 +258,7 @@ static void access_memset(CPUS390XState *env, S390Access *desta,
>   static uint8_t access_get_byte(CPUS390XState *env, S390Access *access,
>                                  int offset, uintptr_t ra)
>   {
> -    target_ulong vaddr = access->vaddr1;
> +    vaddr vaddr = access->vaddr1;
>       void *haddr = access->haddr1;
>   
>       if (unlikely(offset >= access->size1)) {
> @@ -278,7 +278,7 @@ static uint8_t access_get_byte(CPUS390XState *env, S390Access *access,
>   static void access_set_byte(CPUS390XState *env, S390Access *access,
>                               int offset, uint8_t byte, uintptr_t ra)
>   {
> -    target_ulong vaddr = access->vaddr1;
> +    vaddr vaddr = access->vaddr1;
>       void *haddr = access->haddr1;
>   
>       if (unlikely(offset >= access->size1)) {

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~