^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/user.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/kallsyms.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/rtc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/kprobes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/kdebug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/sched/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <asm/traps.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <asm/pgalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <asm/siginfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <asm/mmu_context.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #ifdef CONFIG_CPU_HAS_FPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <abi/fpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int show_unhandled_signals = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /* Defined in entry.S */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) asmlinkage void csky_trap(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) asmlinkage void csky_systemcall(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) asmlinkage void csky_cmpxchg(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) asmlinkage void csky_get_tls(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) asmlinkage void csky_irq(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) asmlinkage void csky_tlbinvalidl(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) asmlinkage void csky_tlbinvalids(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) asmlinkage void csky_tlbmodified(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* Defined in head.S */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) asmlinkage void _start_smp_secondary(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) void __init pre_trap_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) mtcr("vbr", vec_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) for (i = 1; i < 128; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) VEC_INIT(i, csky_trap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) void __init trap_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) VEC_INIT(VEC_AUTOVEC, csky_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* setup trap0 trap2 trap3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) VEC_INIT(VEC_TRAP0, csky_systemcall);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) VEC_INIT(VEC_TRAP2, csky_cmpxchg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) VEC_INIT(VEC_TRAP3, csky_get_tls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /* setup MMU TLB exception */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) VEC_INIT(VEC_TLBINVALIDL, csky_tlbinvalidl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) VEC_INIT(VEC_TLBINVALIDS, csky_tlbinvalids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) VEC_INIT(VEC_TLBMODIFIED, csky_tlbmodified);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #ifdef CONFIG_CPU_HAS_FPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) init_fpu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) mtcr("cr<28, 0>", virt_to_phys(vec_base));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) VEC_INIT(VEC_RESET, (void *)virt_to_phys(_start_smp_secondary));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static DEFINE_SPINLOCK(die_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) void die(struct pt_regs *regs, const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) static int die_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) oops_enter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) spin_lock_irq(&die_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) console_verbose();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) bust_spinlocks(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) pr_emerg("%s [#%d]\n", str, ++die_counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) print_modules();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) show_regs(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) show_stack(current, (unsigned long *)regs->regs[4], KERN_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) ret = notify_die(DIE_OOPS, str, regs, 0, trap_no(regs), SIGSEGV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) bust_spinlocks(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) spin_unlock_irq(&die_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) oops_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (in_interrupt())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) panic("Fatal exception in interrupt");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (panic_on_oops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) panic("Fatal exception");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (ret != NOTIFY_STOP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) do_exit(SIGSEGV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct task_struct *tsk = current;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if (show_unhandled_signals && unhandled_signal(tsk, signo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) && printk_ratelimit()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) pr_info("%s[%d]: unhandled signal %d code 0x%x at 0x%08lx",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) tsk->comm, task_pid_nr(tsk), signo, code, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) print_vma_addr(KERN_CONT " in ", instruction_pointer(regs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) show_regs(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) force_sig_fault(signo, code, (void __user *)addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static void do_trap_error(struct pt_regs *regs, int signo, int code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) unsigned long addr, const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) current->thread.trap_no = trap_no(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (user_mode(regs)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) do_trap(regs, signo, code, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (!fixup_exception(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) die(regs, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define DO_ERROR_INFO(name, signo, code, str) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) asmlinkage __visible void name(struct pt_regs *regs) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) do_trap_error(regs, signo, code, regs->pc, "Oops - " str); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) DO_ERROR_INFO(do_trap_unknown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) SIGILL, ILL_ILLTRP, "unknown exception");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) DO_ERROR_INFO(do_trap_zdiv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) SIGFPE, FPE_INTDIV, "error zero div exception");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) DO_ERROR_INFO(do_trap_buserr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) SIGSEGV, ILL_ILLADR, "error bus error exception");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) asmlinkage void do_trap_misaligned(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #ifdef CONFIG_CPU_NEED_SOFTALIGN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) csky_alignment(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) current->thread.trap_no = trap_no(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->pc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) "Oops - load/store address misaligned");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) asmlinkage void do_trap_bkpt(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #ifdef CONFIG_KPROBES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (kprobe_single_step_handler(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) #ifdef CONFIG_UPROBES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (uprobe_single_step_handler(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) if (user_mode(regs)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) send_sig(SIGTRAP, current, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) do_trap_error(regs, SIGILL, ILL_ILLTRP, regs->pc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) "Oops - illegal trap exception");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) asmlinkage void do_trap_illinsn(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) current->thread.trap_no = trap_no(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) #ifdef CONFIG_KPROBES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (kprobe_breakpoint_handler(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #ifdef CONFIG_UPROBES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (uprobe_breakpoint_handler(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #ifndef CONFIG_CPU_NO_USER_BKPT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (*(uint16_t *)instruction_pointer(regs) != USR_BKPT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) send_sig(SIGTRAP, current, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) do_trap_error(regs, SIGILL, ILL_ILLOPC, regs->pc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) "Oops - illegal instruction exception");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) asmlinkage void do_trap_fpe(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #ifdef CONFIG_CPU_HAS_FPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return fpu_fpe(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) do_trap_error(regs, SIGILL, ILL_ILLOPC, regs->pc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) "Oops - fpu instruction exception");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) asmlinkage void do_trap_priv(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) #ifdef CONFIG_CPU_HAS_FPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (user_mode(regs) && fpu_libc_helper(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) do_trap_error(regs, SIGILL, ILL_PRVOPC, regs->pc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) "Oops - illegal privileged exception");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) asmlinkage void trap_c(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) switch (trap_no(regs)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) case VEC_ZERODIV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) do_trap_zdiv(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) case VEC_TRACE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) do_trap_bkpt(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) case VEC_ILLEGAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) do_trap_illinsn(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) case VEC_TRAP1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) case VEC_BREAKPOINT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) do_trap_bkpt(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) case VEC_ACCESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) do_trap_buserr(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) case VEC_ALIGN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) do_trap_misaligned(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) case VEC_FPE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) do_trap_fpe(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) case VEC_PRIV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) do_trap_priv(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) do_trap_unknown(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }