Lines Matching full:regs

41 static int copy_code(struct pt_regs *regs, u16 *val, const u16 *insns)  in copy_code()  argument
45 if (!user_mode(regs)) in copy_code()
49 if (regs != task_pt_regs(current)) in copy_code()
55 static void dump_instr(const char *loglvl, struct pt_regs *regs) in dump_instr() argument
58 const u16 *insns = (u16 *)instruction_pointer(regs); in dump_instr()
64 bad = copy_code(regs, &val, &insns[i]); in dump_instr()
76 void die(struct pt_regs *regs, const char *str) in die() argument
91 if (regs) { in die()
92 show_regs(regs); in die()
93 dump_instr(KERN_EMERG, regs); in die()
96 cause = regs ? regs->cause : -1; in die()
97 ret = notify_die(DIE_OOPS, str, regs, 0, cause, SIGSEGV); in die()
100 crash_kexec(regs); in die()
115 void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr) in do_trap() argument
123 print_vma_addr(KERN_CONT " in ", instruction_pointer(regs)); in do_trap()
125 __show_regs(regs); in do_trap()
126 dump_instr(KERN_INFO, regs); in do_trap()
132 static void do_trap_error(struct pt_regs *regs, int signo, int code, in do_trap_error() argument
135 current->thread.bad_cause = regs->cause; in do_trap_error()
137 if (user_mode(regs)) { in do_trap_error()
138 do_trap(regs, signo, code, addr); in do_trap_error()
140 if (!fixup_exception(regs)) in do_trap_error()
141 die(regs, str); in do_trap_error()
151 asmlinkage __visible __trap_section void name(struct pt_regs *regs) \
153 if (user_mode(regs)) { \
154 irqentry_enter_from_user_mode(regs); \
156 do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \
158 irqentry_exit_to_user_mode(regs); \
160 irqentry_state_t state = irqentry_nmi_enter(regs); \
161 do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \
162 irqentry_nmi_exit(regs, state); \
173 asmlinkage __visible __trap_section void do_trap_insn_illegal(struct pt_regs *regs) in do_trap_insn_illegal() argument
177 if (user_mode(regs)) { in do_trap_insn_illegal()
178 irqentry_enter_from_user_mode(regs); in do_trap_insn_illegal()
181 handled = riscv_v_first_use_handler(regs); in do_trap_insn_illegal()
183 do_trap_error(regs, SIGILL, ILL_ILLOPC, regs->epc, in do_trap_insn_illegal()
187 irqentry_exit_to_user_mode(regs); in do_trap_insn_illegal()
189 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_insn_illegal()
191 do_trap_error(regs, SIGILL, ILL_ILLOPC, regs->epc, in do_trap_insn_illegal()
194 irqentry_nmi_exit(regs, state); in do_trap_insn_illegal()
207 int (*handler)(struct pt_regs *regs);
219 static void do_trap_misaligned(struct pt_regs *regs, enum misaligned_access_type type) in do_trap_misaligned() argument
223 if (user_mode(regs)) { in do_trap_misaligned()
224 irqentry_enter_from_user_mode(regs); in do_trap_misaligned()
227 state = irqentry_nmi_enter(regs); in do_trap_misaligned()
230 if (misaligned_handler[type].handler(regs)) in do_trap_misaligned()
231 do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc, in do_trap_misaligned()
234 if (user_mode(regs)) { in do_trap_misaligned()
236 irqentry_exit_to_user_mode(regs); in do_trap_misaligned()
238 irqentry_nmi_exit(regs, state); in do_trap_misaligned()
242 asmlinkage __visible __trap_section void do_trap_load_misaligned(struct pt_regs *regs) in do_trap_load_misaligned() argument
244 do_trap_misaligned(regs, MISALIGNED_LOAD); in do_trap_load_misaligned()
247 asmlinkage __visible __trap_section void do_trap_store_misaligned(struct pt_regs *regs) in do_trap_store_misaligned() argument
249 do_trap_misaligned(regs, MISALIGNED_STORE); in do_trap_store_misaligned()
269 static bool probe_single_step_handler(struct pt_regs *regs) in probe_single_step_handler() argument
271 bool user = user_mode(regs); in probe_single_step_handler()
273 return user ? uprobe_single_step_handler(regs) : kprobe_single_step_handler(regs); in probe_single_step_handler()
276 static bool probe_breakpoint_handler(struct pt_regs *regs) in probe_breakpoint_handler() argument
278 bool user = user_mode(regs); in probe_breakpoint_handler()
280 return user ? uprobe_breakpoint_handler(regs) : kprobe_breakpoint_handler(regs); in probe_breakpoint_handler()
283 void handle_break(struct pt_regs *regs) in handle_break() argument
285 if (probe_single_step_handler(regs)) in handle_break()
288 if (probe_breakpoint_handler(regs)) in handle_break()
291 current->thread.bad_cause = regs->cause; in handle_break()
293 if (user_mode(regs)) in handle_break()
294 force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->epc); in handle_break()
296 else if (notify_die(DIE_TRAP, "EBREAK", regs, 0, regs->cause, SIGTRAP) in handle_break()
300 else if (report_bug(regs->epc, regs) == BUG_TRAP_TYPE_WARN || in handle_break()
301 handle_cfi_failure(regs) == BUG_TRAP_TYPE_WARN) in handle_break()
302 regs->epc += get_break_insn_length(regs->epc); in handle_break()
304 die(regs, "Kernel BUG"); in handle_break()
307 asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs) in do_trap_break() argument
309 if (user_mode(regs)) { in do_trap_break()
310 irqentry_enter_from_user_mode(regs); in do_trap_break()
313 handle_break(regs); in do_trap_break()
316 irqentry_exit_to_user_mode(regs); in do_trap_break()
318 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_break()
320 handle_break(regs); in do_trap_break()
322 irqentry_nmi_exit(regs, state); in do_trap_break()
327 void do_trap_ecall_u(struct pt_regs *regs) in do_trap_ecall_u() argument
329 if (user_mode(regs)) { in do_trap_ecall_u()
330 long syscall = regs->a7; in do_trap_ecall_u()
332 regs->epc += 4; in do_trap_ecall_u()
333 regs->orig_a0 = regs->a0; in do_trap_ecall_u()
334 regs->a0 = -ENOSYS; in do_trap_ecall_u()
336 riscv_v_vstate_discard(regs); in do_trap_ecall_u()
338 syscall = syscall_enter_from_user_mode(regs, syscall); in do_trap_ecall_u()
344 syscall_handler(regs, syscall); in do_trap_ecall_u()
347 syscall_exit_to_user_mode(regs); in do_trap_ecall_u()
349 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_ecall_u()
351 do_trap_error(regs, SIGILL, ILL_ILLTRP, regs->epc, in do_trap_ecall_u()
354 irqentry_nmi_exit(regs, state); in do_trap_ecall_u()
362 bool handle_user_cfi_violation(struct pt_regs *regs) in handle_user_cfi_violation() argument
374 if (is_fcfi && probe_breakpoint_handler(regs)) { in handle_user_cfi_violation()
375 regs->status &= ~SR_ELP; in handle_user_cfi_violation()
380 do_trap_error(regs, SIGSEGV, SEGV_CPERR, regs->epc, in handle_user_cfi_violation()
397 asmlinkage __visible __trap_section void do_trap_software_check(struct pt_regs *regs) in do_trap_software_check() argument
399 if (user_mode(regs)) { in do_trap_software_check()
400 irqentry_enter_from_user_mode(regs); in do_trap_software_check()
403 if (!handle_user_cfi_violation(regs)) in do_trap_software_check()
404 do_trap_unknown(regs); in do_trap_software_check()
406 irqentry_exit_to_user_mode(regs); in do_trap_software_check()
409 die(regs, "Kernel BUG"); in do_trap_software_check()
414 asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs) in do_page_fault() argument
416 irqentry_state_t state = irqentry_enter(regs); in do_page_fault()
418 handle_page_fault(regs); in do_page_fault()
422 irqentry_exit(regs, state); in do_page_fault()
426 static void noinstr handle_riscv_irq(struct pt_regs *regs) in handle_riscv_irq() argument
431 old_regs = set_irq_regs(regs); in handle_riscv_irq()
432 handle_arch_irq(regs); in handle_riscv_irq()
437 asmlinkage void noinstr do_irq(struct pt_regs *regs) in do_irq() argument
439 irqentry_state_t state = irqentry_enter(regs); in do_irq()
442 call_on_irq_stack(regs, handle_riscv_irq); in do_irq()
444 handle_riscv_irq(regs); in do_irq()
446 irqentry_exit(regs, state); in do_irq()
469 asmlinkage void handle_bad_stack(struct pt_regs *regs) in handle_bad_stack() argument
482 __show_regs(regs); in handle_bad_stack()