Lines Matching full:regs

39 static int copy_code(struct pt_regs *regs, u16 *val, const u16 *insns)  in copy_code()  argument
43 if (!user_mode(regs)) in copy_code()
47 if (regs != task_pt_regs(current)) in copy_code()
53 static void dump_instr(const char *loglvl, struct pt_regs *regs) in dump_instr() argument
56 const u16 *insns = (u16 *)instruction_pointer(regs); in dump_instr()
62 bad = copy_code(regs, &val, &insns[i]); in dump_instr()
74 void die(struct pt_regs *regs, const char *str) in die() argument
89 if (regs) { in die()
90 show_regs(regs); in die()
91 dump_instr(KERN_EMERG, regs); in die()
94 cause = regs ? regs->cause : -1; in die()
95 ret = notify_die(DIE_OOPS, str, regs, 0, cause, SIGSEGV); in die()
98 crash_kexec(regs); in die()
113 void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr) in do_trap() argument
121 print_vma_addr(KERN_CONT " in ", instruction_pointer(regs)); in do_trap()
123 __show_regs(regs); in do_trap()
124 dump_instr(KERN_EMERG, regs); in do_trap()
130 static void do_trap_error(struct pt_regs *regs, int signo, int code, in do_trap_error() argument
133 current->thread.bad_cause = regs->cause; in do_trap_error()
135 if (user_mode(regs)) { in do_trap_error()
136 do_trap(regs, signo, code, addr); in do_trap_error()
138 if (!fixup_exception(regs)) in do_trap_error()
139 die(regs, str); in do_trap_error()
149 asmlinkage __visible __trap_section void name(struct pt_regs *regs) \
151 if (user_mode(regs)) { \
152 irqentry_enter_from_user_mode(regs); \
153 do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \
154 irqentry_exit_to_user_mode(regs); \
156 irqentry_state_t state = irqentry_nmi_enter(regs); \
157 do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \
158 irqentry_nmi_exit(regs, state); \
169 asmlinkage __visible __trap_section void do_trap_insn_illegal(struct pt_regs *regs) in do_trap_insn_illegal() argument
173 if (user_mode(regs)) { in do_trap_insn_illegal()
174 irqentry_enter_from_user_mode(regs); in do_trap_insn_illegal()
178 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()
186 irqentry_exit_to_user_mode(regs); in do_trap_insn_illegal()
188 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_insn_illegal()
190 do_trap_error(regs, SIGILL, ILL_ILLOPC, regs->epc, in do_trap_insn_illegal()
193 irqentry_nmi_exit(regs, state); in do_trap_insn_illegal()
200 asmlinkage __visible __trap_section void do_trap_load_misaligned(struct pt_regs *regs) in do_trap_load_misaligned() argument
202 if (user_mode(regs)) { in do_trap_load_misaligned()
203 irqentry_enter_from_user_mode(regs); in do_trap_load_misaligned()
205 if (handle_misaligned_load(regs)) in do_trap_load_misaligned()
206 do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc, in do_trap_load_misaligned()
209 irqentry_exit_to_user_mode(regs); in do_trap_load_misaligned()
211 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_load_misaligned()
213 if (handle_misaligned_load(regs)) in do_trap_load_misaligned()
214 do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc, in do_trap_load_misaligned()
217 irqentry_nmi_exit(regs, state); in do_trap_load_misaligned()
221 asmlinkage __visible __trap_section void do_trap_store_misaligned(struct pt_regs *regs) in do_trap_store_misaligned() argument
223 if (user_mode(regs)) { in do_trap_store_misaligned()
224 irqentry_enter_from_user_mode(regs); in do_trap_store_misaligned()
226 if (handle_misaligned_store(regs)) in do_trap_store_misaligned()
227 do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc, in do_trap_store_misaligned()
230 irqentry_exit_to_user_mode(regs); in do_trap_store_misaligned()
232 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_store_misaligned()
234 if (handle_misaligned_store(regs)) in do_trap_store_misaligned()
235 do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc, in do_trap_store_misaligned()
238 irqentry_nmi_exit(regs, state); in do_trap_store_misaligned()
258 static bool probe_single_step_handler(struct pt_regs *regs) in probe_single_step_handler() argument
260 bool user = user_mode(regs); in probe_single_step_handler()
262 return user ? uprobe_single_step_handler(regs) : kprobe_single_step_handler(regs); in probe_single_step_handler()
265 static bool probe_breakpoint_handler(struct pt_regs *regs) in probe_breakpoint_handler() argument
267 bool user = user_mode(regs); in probe_breakpoint_handler()
269 return user ? uprobe_breakpoint_handler(regs) : kprobe_breakpoint_handler(regs); in probe_breakpoint_handler()
272 void handle_break(struct pt_regs *regs) in handle_break() argument
274 if (probe_single_step_handler(regs)) in handle_break()
277 if (probe_breakpoint_handler(regs)) in handle_break()
280 current->thread.bad_cause = regs->cause; in handle_break()
282 if (user_mode(regs)) in handle_break()
283 force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->epc); in handle_break()
285 else if (notify_die(DIE_TRAP, "EBREAK", regs, 0, regs->cause, SIGTRAP) in handle_break()
289 else if (report_bug(regs->epc, regs) == BUG_TRAP_TYPE_WARN || in handle_break()
290 handle_cfi_failure(regs) == BUG_TRAP_TYPE_WARN) in handle_break()
291 regs->epc += get_break_insn_length(regs->epc); in handle_break()
293 die(regs, "Kernel BUG"); in handle_break()
296 asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs) in do_trap_break() argument
298 if (user_mode(regs)) { in do_trap_break()
299 irqentry_enter_from_user_mode(regs); in do_trap_break()
301 handle_break(regs); in do_trap_break()
303 irqentry_exit_to_user_mode(regs); in do_trap_break()
305 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_break()
307 handle_break(regs); in do_trap_break()
309 irqentry_nmi_exit(regs, state); in do_trap_break()
313 asmlinkage __visible __trap_section void do_trap_ecall_u(struct pt_regs *regs) in do_trap_ecall_u() argument
315 if (user_mode(regs)) { in do_trap_ecall_u()
316 long syscall = regs->a7; in do_trap_ecall_u()
318 regs->epc += 4; in do_trap_ecall_u()
319 regs->orig_a0 = regs->a0; in do_trap_ecall_u()
321 riscv_v_vstate_discard(regs); in do_trap_ecall_u()
323 syscall = syscall_enter_from_user_mode(regs, syscall); in do_trap_ecall_u()
326 syscall_handler(regs, syscall); in do_trap_ecall_u()
328 regs->a0 = -ENOSYS; in do_trap_ecall_u()
330 syscall_exit_to_user_mode(regs); in do_trap_ecall_u()
332 irqentry_state_t state = irqentry_nmi_enter(regs); in do_trap_ecall_u()
334 do_trap_error(regs, SIGILL, ILL_ILLTRP, regs->epc, in do_trap_ecall_u()
337 irqentry_nmi_exit(regs, state); in do_trap_ecall_u()
343 asmlinkage __visible noinstr void do_page_fault(struct pt_regs *regs) in do_page_fault() argument
345 irqentry_state_t state = irqentry_enter(regs); in do_page_fault()
347 handle_page_fault(regs); in do_page_fault()
351 irqentry_exit(regs, state); in do_page_fault()
355 static void noinstr handle_riscv_irq(struct pt_regs *regs) in handle_riscv_irq() argument
360 old_regs = set_irq_regs(regs); in handle_riscv_irq()
361 handle_arch_irq(regs); in handle_riscv_irq()
366 asmlinkage void noinstr do_irq(struct pt_regs *regs) in do_irq() argument
368 irqentry_state_t state = irqentry_enter(regs); in do_irq()
371 call_on_irq_stack(regs, handle_riscv_irq); in do_irq()
373 handle_riscv_irq(regs); in do_irq()
375 irqentry_exit(regs, state); in do_irq()
398 asmlinkage void handle_bad_stack(struct pt_regs *regs) in handle_bad_stack() argument
411 __show_regs(regs); in handle_bad_stack()