lib: sbi_illegal_insn: Fix FENCE.TSO emulation infinite trap loop
authorRahul Pathak <rpathak@ventanamicro.com>
Fri, 12 Aug 2022 13:54:42 +0000 (19:24 +0530)
committerAnup Patel <anup@brainfault.org>
Mon, 22 Aug 2022 03:27:23 +0000 (08:57 +0530)
In case of missing "FENCE.TSO" instruction implementation,
opensbi can emulate the "FENCE.TSO" with "FENCE RW,RW", but
mepc was not incremented to continue from the next instruction
causing infinite trap.

Fixes: cb8271c8 ("lib: sbi_illegal_insn: Add emulation for fence.tso")
Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
lib/sbi/sbi_illegal_insn.c

index ecd3508..9691bce 100644 (file)
@@ -40,6 +40,7 @@ static int misc_mem_opcode_insn(ulong insn, struct sbi_trap_regs *regs)
        /* Errata workaround: emulate `fence.tso` as `fence rw, rw`. */
        if ((insn & INSN_MASK_FENCE_TSO) == INSN_MATCH_FENCE_TSO) {
                smp_mb();
+               regs->mepc += 4;
                return 0;
        }