Lines Matching full:regs
40 static int copy_code(struct pt_regs *regs, u16 *val, const u16 *insns) in copy_code() argument
44 if (!user_mode(regs)) in copy_code()
48 if (regs != task_pt_regs(current)) in copy_code()
54 static void dump_instr(const char *loglvl, struct pt_regs *regs) in dump_instr() argument
57 const u16 *insns = (u16 *)instruction_pointer(regs); in dump_instr()
63 bad = copy_code(regs, &val, &insns[i]); in dump_instr()
75 void die(struct pt_regs *regs, const char *str) in die() argument
90 if (regs) { in die()
91 show_regs(regs); in die()
92 dump_instr(KERN_EMERG, regs); in die()
95 cause = regs ? regs->cause : -1; in die()
96 ret = notify_die(DIE_OOPS, str, regs, 0, cause, SIGSEGV); in die()
99 crash_kexec(regs); in die()
114 void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr) in do_trap() argument
122 print_vma_addr(KERN_CONT " in ", instruction_pointer(regs)); in do_trap()
124 __show_regs(regs); in do_trap()
125 dump_instr(KERN_INFO, regs); in do_trap()
131 static void do_trap_error(struct pt_regs *regs, int signo, int code, in do_trap_error() argument
134 current->thread.bad_cause = regs->cause; in do_trap_error()
136 if (user_mode(regs)) { in do_trap_error()
137 do_trap(regs, signo, code, addr); in do_trap_error()
139 if (!fixup_exception(regs)) in do_trap_error()
140 die(regs, str); in do_trap_error()
150 asmlinkage __visible __trap_section void name(struct pt_regs *regs) \
152 if (user_mode(regs)) { \
153 irqentry_enter_from_user_mode(regs); \
154 do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \
155 irqentry_exit_to_user_mode(regs); \
157 irqentry_state_t state = irqentry_nmi_enter(regs); \
158 do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \
159 irqentry_nmi_exit(regs, state); \
170 asmlinkage __visible __trap_section void do_trap_insn_illegal(struct pt_regs *regs) in do_trap_insn_illegal() argument
174 if (user_mode(regs)) { in do_trap_insn_illegal()
175 irqentry_enter_from_user_mode(regs); in do_trap_insn_illegal()
179 handled = riscv_v_first_use_handler(regs); in do_trap_insn_illegal()
184 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()
312 handle_break(regs); in do_trap_break()
314 irqentry_exit_to_user_mode(regs); in do_trap_break()
316 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_break()
318 handle_break(regs); in do_trap_break()
320 irqentry_nmi_exit(regs, state); in do_trap_break()
325 void do_trap_ecall_u(struct pt_regs *regs) in do_trap_ecall_u() argument
327 if (user_mode(regs)) { in do_trap_ecall_u()
328 long syscall = regs->a7; in do_trap_ecall_u()
330 regs->epc += 4; in do_trap_ecall_u()
331 regs->orig_a0 = regs->a0; in do_trap_ecall_u()
332 regs->a0 = -ENOSYS; in do_trap_ecall_u()
334 riscv_v_vstate_discard(regs); in do_trap_ecall_u()
336 syscall = syscall_enter_from_user_mode(regs, syscall); in do_trap_ecall_u()
341 syscall_handler(regs, syscall); in do_trap_ecall_u()
355 syscall_exit_to_user_mode(regs); in do_trap_ecall_u()
357 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_ecall_u()
359 do_trap_error(regs, SIGILL, ILL_ILLTRP, regs->epc, in do_trap_ecall_u()
362 irqentry_nmi_exit(regs, state); in do_trap_ecall_u()
368 asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs) in do_page_fault() argument
370 irqentry_state_t state = irqentry_enter(regs); in do_page_fault()
372 handle_page_fault(regs); in do_page_fault()
376 irqentry_exit(regs, state); in do_page_fault()
380 static void noinstr handle_riscv_irq(struct pt_regs *regs) in handle_riscv_irq() argument
385 old_regs = set_irq_regs(regs); in handle_riscv_irq()
386 handle_arch_irq(regs); in handle_riscv_irq()
391 asmlinkage void noinstr do_irq(struct pt_regs *regs) in do_irq() argument
393 irqentry_state_t state = irqentry_enter(regs); in do_irq()
396 call_on_irq_stack(regs, handle_riscv_irq); in do_irq()
398 handle_riscv_irq(regs); in do_irq()
400 irqentry_exit(regs, state); in do_irq()
423 asmlinkage void handle_bad_stack(struct pt_regs *regs) in handle_bad_stack() argument
436 __show_regs(regs); in handle_bad_stack()