From: Richard Henderson <[email protected]>

The encoding of rev8 is different for rv32 and rv64.

Cc: [email protected]
Fixes: 02c1b569a15 ("disas/riscv: Add Zb[abcs] instructions")
Reviewed-by: Alistair Francis <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
(cherry picked from commit d610e55c8390a8bfd15d0a4f1521d7fc46e4e0b7)
Signed-off-by: Michael Tokarev <[email protected]>

diff --git a/disas/riscv.c b/disas/riscv.c
index 491896d4a09..acf8930f541 100644
--- a/disas/riscv.c
+++ b/disas/riscv.c
@@ -2972,8 +2972,16 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa 
isa)
                 case 0b01100: op = rv_op_rori; break;
                 case 0b01101:
                     switch ((inst >> 20) & 0b1111111) {
-                    case 0b0011000: op = rv_op_rev8; break;
-                    case 0b0111000: op = rv_op_rev8; break;
+                    case 0b0011000:
+                        if (isa == rv32) {
+                            op = rv_op_rev8;
+                        }
+                        break;
+                    case 0b0111000:
+                        if (isa == rv64) {
+                            op = rv_op_rev8;
+                        }
+                        break;
                     case 0b0000111: op = rv_op_brev8; break;
                     }
                     break;
-- 
2.47.3


Reply via email to