From d98da90a19b5c71a5865ae17c8b2d8d210e78f19 Mon Sep 17 00:00:00 2001 From: Rahul Pathak Date: Fri, 12 Aug 2022 19:24:42 +0530 Subject: [PATCH] lib: sbi_illegal_insn: Fix FENCE.TSO emulation infinite trap loop 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 Reviewed-by: Andrew Jones Reviewed-by: Xiang W Reviewed-by: Samuel Holland --- lib/sbi/sbi_illegal_insn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sbi/sbi_illegal_insn.c b/lib/sbi/sbi_illegal_insn.c index fb67c28..45e7ce9 100644 --- a/lib/sbi/sbi_illegal_insn.c +++ b/lib/sbi/sbi_illegal_insn.c @@ -37,6 +37,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; }