diff mbox

[03/31] target/s390x: Use unwind data for helper_nc

Message ID 20170523030312.6360-4-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson May 23, 2017, 3:02 a.m. UTC
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target/s390x/mem_helper.c | 18 +++++++++---------
 target/s390x/translate.c  |  1 -
 2 files changed, 9 insertions(+), 10 deletions(-)

Comments

Thomas Huth May 23, 2017, 8:33 a.m. UTC | #1
On 23.05.2017 05:02, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  target/s390x/mem_helper.c | 18 +++++++++---------
>  target/s390x/translate.c  |  1 -
>  2 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
> index db80d53..1018fe0 100644
> --- a/target/s390x/mem_helper.c
> +++ b/target/s390x/mem_helper.c
> @@ -122,20 +122,20 @@ static void fast_memmove(CPUS390XState *env, uint64_t dest, uint64_t src,
>  uint32_t HELPER(nc)(CPUS390XState *env, uint32_t l, uint64_t dest,
>                      uint64_t src)
>  {
> -    int i;
> -    unsigned char x;
> -    uint32_t cc = 0;
> +    uintptr_t ra = GETPC();
> +    uint8_t cc = 0;
> +    uint32_t i;
>  
>      HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n",
>                 __func__, l, dest, src);
> +
>      for (i = 0; i <= l; i++) {
> -        x = cpu_ldub_data(env, dest + i) & cpu_ldub_data(env, src + i);
> -        if (x) {
> -            cc = 1;
> -        }
> -        cpu_stb_data(env, dest + i, x);
> +        uint8_t x = cpu_ldub_data_ra(env, dest + i, ra);
> +        x &= cpu_ldub_data_ra(env, src + i, ra);

I'd maybe do the access to src first, before  the access to dest ...
though I did not find anything in the PoP that really indicates that
access exceptions for src would have a higher priority here... so it
likely does not really matter...

> +        cc |= x;
> +        cpu_stb_data_ra(env, dest + i, x, ra);
>      }
> -    return cc;
> +    return cc != 0;
>  }
>  
>  /* xor on array */
> diff --git a/target/s390x/translate.c b/target/s390x/translate.c
> index 3a72c38..6aa9c90 100644
> --- a/target/s390x/translate.c
> +++ b/target/s390x/translate.c
> @@ -3048,7 +3048,6 @@ static ExitStatus op_nabsf128(DisasContext *s, DisasOps *o)
>  static ExitStatus op_nc(DisasContext *s, DisasOps *o)
>  {
>      TCGv_i32 l = tcg_const_i32(get_field(s->fields, l1));
> -    potential_page_fault(s);
>      gen_helper_nc(cc_op, cpu_env, l, o->addr1, o->in2);
>      tcg_temp_free_i32(l);
>      set_cc_static(s);
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
Aurelien Jarno May 23, 2017, 10:49 a.m. UTC | #2
On 2017-05-23 10:33, Thomas Huth wrote:
> On 23.05.2017 05:02, Richard Henderson wrote:
> > Signed-off-by: Richard Henderson <rth@twiddle.net>
> > ---
> >  target/s390x/mem_helper.c | 18 +++++++++---------
> >  target/s390x/translate.c  |  1 -
> >  2 files changed, 9 insertions(+), 10 deletions(-)

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
diff mbox

Patch

diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
index db80d53..1018fe0 100644
--- a/target/s390x/mem_helper.c
+++ b/target/s390x/mem_helper.c
@@ -122,20 +122,20 @@  static void fast_memmove(CPUS390XState *env, uint64_t dest, uint64_t src,
 uint32_t HELPER(nc)(CPUS390XState *env, uint32_t l, uint64_t dest,
                     uint64_t src)
 {
-    int i;
-    unsigned char x;
-    uint32_t cc = 0;
+    uintptr_t ra = GETPC();
+    uint8_t cc = 0;
+    uint32_t i;
 
     HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n",
                __func__, l, dest, src);
+
     for (i = 0; i <= l; i++) {
-        x = cpu_ldub_data(env, dest + i) & cpu_ldub_data(env, src + i);
-        if (x) {
-            cc = 1;
-        }
-        cpu_stb_data(env, dest + i, x);
+        uint8_t x = cpu_ldub_data_ra(env, dest + i, ra);
+        x &= cpu_ldub_data_ra(env, src + i, ra);
+        cc |= x;
+        cpu_stb_data_ra(env, dest + i, x, ra);
     }
-    return cc;
+    return cc != 0;
 }
 
 /* xor on array */
diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index 3a72c38..6aa9c90 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -3048,7 +3048,6 @@  static ExitStatus op_nabsf128(DisasContext *s, DisasOps *o)
 static ExitStatus op_nc(DisasContext *s, DisasOps *o)
 {
     TCGv_i32 l = tcg_const_i32(get_field(s->fields, l1));
-    potential_page_fault(s);
     gen_helper_nc(cc_op, cpu_env, l, o->addr1, o->in2);
     tcg_temp_free_i32(l);
     set_cc_static(s);