[PATCH] tcg/arm: Fix goto_tb for large translation blocks

Richard Henderson posted 1 patch 1 week, 5 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240212215604.27999-1-richard.henderson@linaro.org
Maintainers: Richard Henderson <richard.henderson@linaro.org>
tcg/arm/tcg-target.c.inc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] tcg/arm: Fix goto_tb for large translation blocks
Posted by Richard Henderson 1 week, 5 days ago
Correct arithmetic for separating high and low
on a large negative number.

Fixes: 79ffece4447 ("tcg/arm: Implement direct branch for goto_tb")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1714
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/arm/tcg-target.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc
index ffd23ef789..6a04c73c76 100644
--- a/tcg/arm/tcg-target.c.inc
+++ b/tcg/arm/tcg-target.c.inc
@@ -1771,9 +1771,9 @@ static void tcg_out_goto_tb(TCGContext *s, int which)
          * shifted immediate from pc.
          */
         int h = -i_disp;
-        int l = h & 0xfff;
+        int l = -(h & 0xfff);
 
-        h = encode_imm_nofail(h - l);
+        h = encode_imm_nofail(h + l);
         tcg_out_dat_imm(s, COND_AL, ARITH_SUB, TCG_REG_R0, TCG_REG_PC, h);
         tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_R0, l);
     }
-- 
2.34.1
Re: [PATCH] tcg/arm: Fix goto_tb for large translation blocks
Posted by Michael Tokarev 1 week, 4 days ago
13.02.2024 00:56, Richard Henderson:
> Correct arithmetic for separating high and low
> on a large negative number.
> 
> Fixes: 79ffece4447 ("tcg/arm: Implement direct branch for goto_tb")
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1714
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Cc: qemu-stable@
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>

> ---
>   tcg/arm/tcg-target.c.inc | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc
> index ffd23ef789..6a04c73c76 100644
> --- a/tcg/arm/tcg-target.c.inc
> +++ b/tcg/arm/tcg-target.c.inc
> @@ -1771,9 +1771,9 @@ static void tcg_out_goto_tb(TCGContext *s, int which)
>            * shifted immediate from pc.
>            */
>           int h = -i_disp;
> -        int l = h & 0xfff;
> +        int l = -(h & 0xfff);
>   
> -        h = encode_imm_nofail(h - l);
> +        h = encode_imm_nofail(h + l);
>           tcg_out_dat_imm(s, COND_AL, ARITH_SUB, TCG_REG_R0, TCG_REG_PC, h);
>           tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_R0, l);
>       }