Lines Matching refs: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()
201 asmlinkage __visible __trap_section void do_trap_load_misaligned(struct pt_regs *regs) in do_trap_load_misaligned() argument
203 if (user_mode(regs)) { in do_trap_load_misaligned()
204 irqentry_enter_from_user_mode(regs); in do_trap_load_misaligned()
206 if (handle_misaligned_load(regs)) in do_trap_load_misaligned()
207 do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc, in do_trap_load_misaligned()
210 irqentry_exit_to_user_mode(regs); in do_trap_load_misaligned()
212 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_load_misaligned()
214 if (handle_misaligned_load(regs)) in do_trap_load_misaligned()
215 do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc, in do_trap_load_misaligned()
218 irqentry_nmi_exit(regs, state); in do_trap_load_misaligned()
222 asmlinkage __visible __trap_section void do_trap_store_misaligned(struct pt_regs *regs) in do_trap_store_misaligned() argument
224 if (user_mode(regs)) { in do_trap_store_misaligned()
225 irqentry_enter_from_user_mode(regs); in do_trap_store_misaligned()
227 if (handle_misaligned_store(regs)) in do_trap_store_misaligned()
228 do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc, in do_trap_store_misaligned()
231 irqentry_exit_to_user_mode(regs); in do_trap_store_misaligned()
233 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_store_misaligned()
235 if (handle_misaligned_store(regs)) in do_trap_store_misaligned()
236 do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc, in do_trap_store_misaligned()
239 irqentry_nmi_exit(regs, state); in do_trap_store_misaligned()
259 static bool probe_single_step_handler(struct pt_regs *regs) in probe_single_step_handler() argument
261 bool user = user_mode(regs); in probe_single_step_handler()
263 return user ? uprobe_single_step_handler(regs) : kprobe_single_step_handler(regs); in probe_single_step_handler()
266 static bool probe_breakpoint_handler(struct pt_regs *regs) in probe_breakpoint_handler() argument
268 bool user = user_mode(regs); in probe_breakpoint_handler()
270 return user ? uprobe_breakpoint_handler(regs) : kprobe_breakpoint_handler(regs); in probe_breakpoint_handler()
273 void handle_break(struct pt_regs *regs) in handle_break() argument
275 if (probe_single_step_handler(regs)) in handle_break()
278 if (probe_breakpoint_handler(regs)) in handle_break()
281 current->thread.bad_cause = regs->cause; in handle_break()
283 if (user_mode(regs)) in handle_break()
284 force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->epc); in handle_break()
286 else if (notify_die(DIE_TRAP, "EBREAK", regs, 0, regs->cause, SIGTRAP) in handle_break()
290 else if (report_bug(regs->epc, regs) == BUG_TRAP_TYPE_WARN || in handle_break()
291 handle_cfi_failure(regs) == BUG_TRAP_TYPE_WARN) in handle_break()
292 regs->epc += get_break_insn_length(regs->epc); in handle_break()
294 die(regs, "Kernel BUG"); in handle_break()
297 asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs) in do_trap_break() argument
299 if (user_mode(regs)) { in do_trap_break()
300 irqentry_enter_from_user_mode(regs); in do_trap_break()
302 handle_break(regs); in do_trap_break()
304 irqentry_exit_to_user_mode(regs); in do_trap_break()
306 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_break()
308 handle_break(regs); in do_trap_break()
310 irqentry_nmi_exit(regs, state); in do_trap_break()
315 void do_trap_ecall_u(struct pt_regs *regs) in do_trap_ecall_u() argument
317 if (user_mode(regs)) { in do_trap_ecall_u()
318 long syscall = regs->a7; in do_trap_ecall_u()
320 regs->epc += 4; in do_trap_ecall_u()
321 regs->orig_a0 = regs->a0; in do_trap_ecall_u()
322 regs->a0 = -ENOSYS; in do_trap_ecall_u()
324 riscv_v_vstate_discard(regs); in do_trap_ecall_u()
326 syscall = syscall_enter_from_user_mode(regs, syscall); in do_trap_ecall_u()
331 syscall_handler(regs, syscall); in do_trap_ecall_u()
345 syscall_exit_to_user_mode(regs); in do_trap_ecall_u()
347 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_ecall_u()
349 do_trap_error(regs, SIGILL, ILL_ILLTRP, regs->epc, in do_trap_ecall_u()
352 irqentry_nmi_exit(regs, state); in do_trap_ecall_u()
358 asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs) in do_page_fault() argument
360 irqentry_state_t state = irqentry_enter(regs); in do_page_fault()
362 handle_page_fault(regs); in do_page_fault()
366 irqentry_exit(regs, state); in do_page_fault()
370 static void noinstr handle_riscv_irq(struct pt_regs *regs) in handle_riscv_irq() argument
375 old_regs = set_irq_regs(regs); in handle_riscv_irq()
376 handle_arch_irq(regs); in handle_riscv_irq()
381 asmlinkage void noinstr do_irq(struct pt_regs *regs) in do_irq() argument
383 irqentry_state_t state = irqentry_enter(regs); in do_irq()
386 call_on_irq_stack(regs, handle_riscv_irq); in do_irq()
388 handle_riscv_irq(regs); in do_irq()
390 irqentry_exit(regs, state); in do_irq()
413 asmlinkage void handle_bad_stack(struct pt_regs *regs) in handle_bad_stack() argument
426 __show_regs(regs); in handle_bad_stack()