diff mbox series

[v6,36/66] target/s390x: Use probe_access_flags in s390_probe_access

Message ID 20211030171635.1689530-37-richard.henderson@linaro.org
State Superseded
Headers show
Series user-only: Cleanup SIGSEGV and SIGBUS handling | expand

Commit Message

Richard Henderson Oct. 30, 2021, 5:16 p.m. UTC
Not sure why the user-only code wasn't rewritten to use
probe_access_flags at the same time that the sysemu code
was converted.  For the purpose of user-only, this is an
exact replacement.

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

---
 target/s390x/tcg/mem_helper.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

-- 
2.25.1

Comments

Philippe Mathieu-Daudé Oct. 31, 2021, 10:20 a.m. UTC | #1
On 10/30/21 19:16, Richard Henderson wrote:
> Not sure why the user-only code wasn't rewritten to use

> probe_access_flags at the same time that the sysemu code

> was converted.  For the purpose of user-only, this is an

> exact replacement.

> 

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

> ---

>  target/s390x/tcg/mem_helper.c | 18 +++++-------------

>  1 file changed, 5 insertions(+), 13 deletions(-)

> 

> diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c

> index 17e3f83641..362a30d99e 100644

> --- a/target/s390x/tcg/mem_helper.c

> +++ b/target/s390x/tcg/mem_helper.c

> @@ -141,20 +141,12 @@ static int s390_probe_access(CPUArchState *env, target_ulong addr, int size,

>                               MMUAccessType access_type, int mmu_idx,

>                               bool nonfault, void **phost, uintptr_t ra)

>  {

> +#if defined(CONFIG_USER_ONLY)

> +    return probe_access_flags(env, addr, access_type, mmu_idx,

> +                              nonfault, phost, ra);

> +#else

>      int flags;

>  

> -#if defined(CONFIG_USER_ONLY)

> -    flags = page_get_flags(addr);

> -    if (!(flags & (access_type == MMU_DATA_LOAD ?  PAGE_READ : PAGE_WRITE_ORG))) {

> -        env->__excp_addr = addr;

> -        flags = (flags & PAGE_VALID) ? PGM_PROTECTION : PGM_ADDRESSING;

> -        if (nonfault) {

> -            return flags;

> -        }

> -        tcg_s390_program_interrupt(env, flags, ra);

> -    }

> -    *phost = g2h(env_cpu(env), addr);

> -#else

>      /*

>       * For !CONFIG_USER_ONLY, we cannot rely on TLB_INVALID_MASK or haddr==NULL

>       * to detect if there was an exception during tlb_fill().

> @@ -173,8 +165,8 @@ static int s390_probe_access(CPUArchState *env, target_ulong addr, int size,

>                               (access_type == MMU_DATA_STORE

>                                ? BP_MEM_WRITE : BP_MEM_READ), ra);

>      }

> -#endif

>      return 0;

> +#endif

>  }

>  

>  static int access_prepare_nf(S390Access *access, CPUS390XState *env,

> 


Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
diff mbox series

Patch

diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
index 17e3f83641..362a30d99e 100644
--- a/target/s390x/tcg/mem_helper.c
+++ b/target/s390x/tcg/mem_helper.c
@@ -141,20 +141,12 @@  static int s390_probe_access(CPUArchState *env, target_ulong addr, int size,
                              MMUAccessType access_type, int mmu_idx,
                              bool nonfault, void **phost, uintptr_t ra)
 {
+#if defined(CONFIG_USER_ONLY)
+    return probe_access_flags(env, addr, access_type, mmu_idx,
+                              nonfault, phost, ra);
+#else
     int flags;
 
-#if defined(CONFIG_USER_ONLY)
-    flags = page_get_flags(addr);
-    if (!(flags & (access_type == MMU_DATA_LOAD ?  PAGE_READ : PAGE_WRITE_ORG))) {
-        env->__excp_addr = addr;
-        flags = (flags & PAGE_VALID) ? PGM_PROTECTION : PGM_ADDRESSING;
-        if (nonfault) {
-            return flags;
-        }
-        tcg_s390_program_interrupt(env, flags, ra);
-    }
-    *phost = g2h(env_cpu(env), addr);
-#else
     /*
      * For !CONFIG_USER_ONLY, we cannot rely on TLB_INVALID_MASK or haddr==NULL
      * to detect if there was an exception during tlb_fill().
@@ -173,8 +165,8 @@  static int s390_probe_access(CPUArchState *env, target_ulong addr, int size,
                              (access_type == MMU_DATA_STORE
                               ? BP_MEM_WRITE : BP_MEM_READ), ra);
     }
-#endif
     return 0;
+#endif
 }
 
 static int access_prepare_nf(S390Access *access, CPUS390XState *env,