lib: Redirect illegal instruction trap to S-mode when not handled

Currently, we fail with error SBI_ENOTSUPP when we are not able
to handle illegal instruction trap. Instead, we should just
redirect illegal instruction trap to S-mode when not handled.

This redirection of illegal instruction trap will help lazy
save/restore of floating point registers to work correctly in
Linux kernel.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
Anup Patel
2018-12-27 21:39:13 +05:30
committed by Anup Patel
parent 56e41f7a8d
commit 5959312a5c
4 changed files with 56 additions and 6 deletions

View File

@@ -26,8 +26,7 @@ static int truly_illegal_insn(ulong insn,
struct sbi_trap_regs *regs,
struct sbi_scratch *scratch)
{
/* For now, always fails */
return SBI_ENOTSUPP;
return sbi_trap_redirect(regs, scratch, regs->mepc, mcause, insn);
}
static int system_opcode_insn(ulong insn,
@@ -132,7 +131,8 @@ int sbi_illegal_insn_handler(u32 hartid, ulong mcause,
insn = get_insn(regs->mepc, &mstatus);
}
if ((insn & 3) != 3)
return SBI_ENOTSUPP;
return truly_illegal_insn(insn, hartid, mcause,
regs, scratch);
}
return illegal_insn_table[(insn & 0x7c) >> 2](insn, hartid, mcause,