Skip to content

Commit

Permalink
target/arm: Fix A64 LDRA immediate decode
Browse files Browse the repository at this point in the history
In commit be23a04 in the conversion to decodetree we broke the
decoding of the immediate value in the LDRA instruction.  This should
be a 10 bit signed value that is scaled by 8, but in the conversion
we incorrectly ended up scaling it only by 2.  Fix the scaling
factor.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1970
Fixes: be23a04 ("target/arm: Convert load (pointer auth) insns to decodetree")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20231106113445.1163063-1-peter.maydell@linaro.org
(cherry picked from commit 5722fc4)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
pm215 authored and Michael Tokarev committed Nov 9, 2023
1 parent 1f560fa commit fe8eb31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion target/arm/tcg/a64.decode
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ LDAPR sz:2 111 0 00 1 0 1 11111 1100 00 rn:5 rt:5
# Load/store register (pointer authentication)

# LDRA immediate is 10 bits signed and scaled, but the bits aren't all contiguous
%ldra_imm 22:s1 12:9 !function=times_2
%ldra_imm 22:s1 12:9 !function=times_8

LDRA 11 111 0 00 m:1 . 1 ......... w:1 1 rn:5 rt:5 imm=%ldra_imm

Expand Down
5 changes: 5 additions & 0 deletions target/arm/tcg/translate.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ static inline int times_4(DisasContext *s, int x)
return x * 4;
}

static inline int times_8(DisasContext *s, int x)
{
return x * 8;
}

static inline int times_2_plus_1(DisasContext *s, int x)
{
return x * 2 + 1;
Expand Down

0 comments on commit fe8eb31

Please sign in to comment.