]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
LoongArch: Refactor bug_handler() implementation
authorHuacai Chen <chenhuacai@loongson.cn>
Sat, 25 Jan 2025 10:51:42 +0000 (18:51 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Sat, 25 Jan 2025 10:51:42 +0000 (18:51 +0800)
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 <chenhuacai@loongson.cn>
arch/loongarch/kernel/traps.c

index c57b4134f3e84bafbd1d5ffd4c9936adfe40f217..2ec3106c0da3d115061d79b2c4d7bde5af3bef0e 100644 (file)
@@ -597,17 +597,24 @@ int is_valid_bugaddr(unsigned long addr)
 
 static void bug_handler(struct pt_regs *regs)
 {
+       if (user_mode(regs)) {
+               force_sig(SIGTRAP);
+               return;
+       }
+
        switch (report_bug(regs->csr_era, regs)) {
        case BUG_TRAP_TYPE_BUG:
-       case BUG_TRAP_TYPE_NONE:
-               die_if_kernel("Oops - BUG", regs);
-               force_sig(SIGTRAP);
+               die("Oops - BUG", regs);
                break;
 
        case BUG_TRAP_TYPE_WARN:
                /* Skip the BUG instruction and continue */
                regs->csr_era += LOONGARCH_INSN_SIZE;
                break;
+
+       default:
+               if (!fixup_exception(regs))
+                       die("Oops - BUG", regs);
        }
 }