diff mbox series

[2/3] target/mips: Cast offset field of Octeon BBIT to int16_t

Message ID 20221029020030.13936-3-jiaxun.yang@flygoat.com
State New
Headers show
Series MIPS system emulation miscellaneous fixes | expand

Commit Message

Jiaxun Yang Oct. 29, 2022, 2 a.m. UTC
As per "Cavium Networks OCTEON Plus CN50XX Hardware Reference
Manual" offset field is signed 16 bit value. However arg_BBIT.offset
is unsigned. We need to cast it as signed to do address calculation.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 target/mips/tcg/octeon_translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Oct. 29, 2022, 5:48 p.m. UTC | #1
On 29/10/22 04:00, Jiaxun Yang wrote:
> As per "Cavium Networks OCTEON Plus CN50XX Hardware Reference
> Manual" offset field is signed 16 bit value. However arg_BBIT.offset
> is unsigned. We need to cast it as signed to do address calculation.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>   target/mips/tcg/octeon_translate.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/mips/tcg/octeon_translate.c b/target/mips/tcg/octeon_translate.c
> index 6a207d2e7e..e8f2277c51 100644
> --- a/target/mips/tcg/octeon_translate.c
> +++ b/target/mips/tcg/octeon_translate.c
> @@ -38,7 +38,7 @@ static bool trans_BBIT(DisasContext *ctx, arg_BBIT *a)
>       }
>   
>       ctx->hflags |= MIPS_HFLAG_BC;
> -    ctx->btarget = ctx->base.pc_next + 4 + a->offset * 4;
> +    ctx->btarget = ctx->base.pc_next + 4 + (int16_t)a->offset * 4;
>       ctx->hflags |= MIPS_HFLAG_BDS32;
>   
>       tcg_temp_free(t0);

In target/mips/tcg/octeon.decode:

-BBIT         11 set:1 . 10 rs:5 ..... offset:16 p=%bbit_p
+BBIT         11 set:1 . 10 rs:5 ..... offset:s16 p=%bbit_p
diff mbox series

Patch

diff --git a/target/mips/tcg/octeon_translate.c b/target/mips/tcg/octeon_translate.c
index 6a207d2e7e..e8f2277c51 100644
--- a/target/mips/tcg/octeon_translate.c
+++ b/target/mips/tcg/octeon_translate.c
@@ -38,7 +38,7 @@  static bool trans_BBIT(DisasContext *ctx, arg_BBIT *a)
     }
 
     ctx->hflags |= MIPS_HFLAG_BC;
-    ctx->btarget = ctx->base.pc_next + 4 + a->offset * 4;
+    ctx->btarget = ctx->base.pc_next + 4 + (int16_t)a->offset * 4;
     ctx->hflags |= MIPS_HFLAG_BDS32;
 
     tcg_temp_free(t0);