Skip to content

Commit 5d0cc7e

Browse files
committed
LoongArch: Refactor bug_handler() implementation
1. Early return for user mode triggered exception with all types. 2. Give a chance to call fixup_exception() for default types (like S390). Signed-off-by: Huacai Chen <[email protected]>
1 parent 0816b2e commit 5d0cc7e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

arch/loongarch/kernel/traps.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,17 +597,24 @@ int is_valid_bugaddr(unsigned long addr)
597597

598598
static void bug_handler(struct pt_regs *regs)
599599
{
600+
if (user_mode(regs)) {
601+
force_sig(SIGTRAP);
602+
return;
603+
}
604+
600605
switch (report_bug(regs->csr_era, regs)) {
601606
case BUG_TRAP_TYPE_BUG:
602-
case BUG_TRAP_TYPE_NONE:
603-
die_if_kernel("Oops - BUG", regs);
604-
force_sig(SIGTRAP);
607+
die("Oops - BUG", regs);
605608
break;
606609

607610
case BUG_TRAP_TYPE_WARN:
608611
/* Skip the BUG instruction and continue */
609612
regs->csr_era += LOONGARCH_INSN_SIZE;
610613
break;
614+
615+
default:
616+
if (!fixup_exception(regs))
617+
die("Oops - BUG", regs);
611618
}
612619
}
613620

0 commit comments

Comments
 (0)