diff mbox series

[for-8.0] target/ppc: Fix temp usage in gen_op_arith_modw

Message ID 20230407183628.3239304-1-richard.henderson@linaro.org
State Superseded
Headers show
Series [for-8.0] target/ppc: Fix temp usage in gen_op_arith_modw | expand

Commit Message

Richard Henderson April 7, 2023, 6:36 p.m. UTC
Fix a crash writing to 't3', which is now a constant.
Instead, write the result of the remu to 'ret'.

Fixes: 7058ff5231a ("target/ppc: Avoid tcg_const_* in translate.c")
Reported-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/ppc/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Xingtao Yao (Fujitsu)" via April 7, 2023, 6:54 p.m. UTC | #1
On 4/7/23 20:36, Richard Henderson wrote:
> Fix a crash writing to 't3', which is now a constant.
> Instead, write the result of the remu to 'ret'.
>
> Fixes: 7058ff5231a ("target/ppc: Avoid tcg_const_* in translate.c")
> Reported-by: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/ppc/translate.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Anton Johansson <anjo@rev.ng>
Cédric Le Goater April 8, 2023, 5:44 a.m. UTC | #2
On 4/7/23 20:36, Richard Henderson wrote:
> Fix a crash writing to 't3', which is now a constant.
> Instead, write the result of the remu to 'ret'.
> 
> Fixes: 7058ff5231a ("target/ppc: Avoid tcg_const_* in translate.c")
> Reported-by: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/ppc/translate.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index 9d05357d03..906fc46723 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -1807,8 +1807,8 @@ static inline void gen_op_arith_modw(DisasContext *ctx, TCGv ret, TCGv arg1,
>           TCGv_i32 t2 = tcg_constant_i32(1);
>           TCGv_i32 t3 = tcg_constant_i32(0);
>           tcg_gen_movcond_i32(TCG_COND_EQ, t1, t1, t3, t2, t1);
> -        tcg_gen_remu_i32(t3, t0, t1);
> -        tcg_gen_extu_i32_tl(ret, t3);
> +        tcg_gen_remu_i32(ret, t0, t1);
> +        tcg_gen_extu_i32_tl(ret, ret);

These routines require a TCGv_i32 and ret is not on ppc64 :

../target/ppc/translate.c: In function ‘gen_op_arith_modw’:
../target/ppc/translate.c:1810:26: error: passing argument 1 of ‘tcg_gen_remu_i32’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  1810 |         tcg_gen_remu_i32(ret, t0, t1);
       |                          ^~~
       |                          |
       |                          TCGv_i64 {aka struct TCGv_i64_d *}

and

../target/ppc/translate.c:1811:34: error: passing argument 2 of ‘tcg_gen_extu_i32_i64’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  1811 |         tcg_gen_extu_i32_tl(ret, ret);
       |                                  ^~~
       |                                  |
       |                                  TCGv_i64 {aka struct TCGv_i64_d *}


C.
diff mbox series

Patch

diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 9d05357d03..906fc46723 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -1807,8 +1807,8 @@  static inline void gen_op_arith_modw(DisasContext *ctx, TCGv ret, TCGv arg1,
         TCGv_i32 t2 = tcg_constant_i32(1);
         TCGv_i32 t3 = tcg_constant_i32(0);
         tcg_gen_movcond_i32(TCG_COND_EQ, t1, t1, t3, t2, t1);
-        tcg_gen_remu_i32(t3, t0, t1);
-        tcg_gen_extu_i32_tl(ret, t3);
+        tcg_gen_remu_i32(ret, t0, t1);
+        tcg_gen_extu_i32_tl(ret, ret);
     }
 }