Lines Matching refs:regs

96 		  struct pt_regs *regs,	long error_code)
98 if (v8086_mode(regs)) {
104 if (!handle_vm86_trap((struct kernel_vm86_regs *) regs,
108 } else if (!user_mode(regs)) {
109 if (fixup_exception(regs, trapnr, error_code, 0))
114 die(str, regs, error_code);
116 if (fixup_vdso_exception(regs, trapnr, error_code, 0))
137 struct pt_regs *regs, long error_code)
143 regs->ip, regs->sp, error_code);
144 print_vma_addr(KERN_CONT " in ", regs->ip);
150 do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
155 if (!do_trap_no_signal(tsk, trapnr, str, regs, error_code))
158 show_signal(tsk, signr, "trap ", str, regs, error_code);
167 static void do_error_trap(struct pt_regs *regs, long error_code, char *str,
172 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) !=
174 cond_local_irq_enable(regs);
175 do_trap(trapnr, signr, str, regs, error_code, sicode, addr);
176 cond_local_irq_disable(regs);
184 * This address is usually regs->ip, but when an uprobe moved the code out
185 * of line then regs->ip points to the XOL code which would confuse
187 * a trap happened in XOL code then uprobe maps regs->ip back to the
190 static __always_inline void __user *error_get_trap_addr(struct pt_regs *regs)
192 return (void __user *)uprobe_get_trap_addr(regs);
197 do_error_trap(regs, 0, "divide error", X86_TRAP_DE, SIGFPE,
198 FPE_INTDIV, error_get_trap_addr(regs));
203 do_error_trap(regs, 0, "overflow", X86_TRAP_OF, SIGSEGV, 0, NULL);
207 void handle_invalid_op(struct pt_regs *regs)
209 static inline void handle_invalid_op(struct pt_regs *regs)
212 do_error_trap(regs, 0, "invalid opcode", X86_TRAP_UD, SIGILL,
213 ILL_ILLOPN, error_get_trap_addr(regs));
216 static noinstr bool handle_bug(struct pt_regs *regs)
221 * Normally @regs are unpoisoned by irqentry_enter(), but handle_bug()
222 * is a rare case that uses @regs without passing them to
225 kmsan_unpoison_entry_regs(regs);
226 if (!is_valid_bugaddr(regs->ip))
237 if (regs->flags & X86_EFLAGS_IF)
239 if (report_bug(regs->ip, regs) == BUG_TRAP_TYPE_WARN ||
240 handle_cfi_failure(regs) == BUG_TRAP_TYPE_WARN) {
241 regs->ip += LEN_UD2;
244 if (regs->flags & X86_EFLAGS_IF)
260 if (!user_mode(regs) && handle_bug(regs))
263 state = irqentry_enter(regs);
265 handle_invalid_op(regs);
267 irqentry_exit(regs, state);
272 do_error_trap(regs, 0, "coprocessor segment overrun",
278 do_error_trap(regs, error_code, "invalid TSS", X86_TRAP_TS, SIGSEGV,
284 do_error_trap(regs, error_code, "segment not present", X86_TRAP_NP,
290 do_error_trap(regs, error_code, "stack segment", X86_TRAP_SS, SIGBUS,
298 if (notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_AC, SIGBUS) == NOTIFY_STOP)
301 if (!user_mode(regs))
302 die("Split lock detected\n", regs, error_code);
306 if (handle_user_split_lock(regs, error_code))
309 do_trap(X86_TRAP_AC, SIGBUS, "alignment check", regs,
317 __visible void __noreturn handle_stack_overflow(struct pt_regs *regs,
326 die("stack guard page", regs, 0);
344 * On x86_32, this is entered through a task gate, and regs are synthesized
345 * from the TSS. Returning is, in principle, okay, but changes to regs will
347 * regs, the shim code could be adjusted to synchronize the registers.
379 if (((long)regs->sp >> P4D_SHIFT) == ESPFIX_PGD_ENTRY &&
380 regs->cs == __KERNEL_CS &&
381 regs->ip == (unsigned long)native_irq_return_iret)
384 unsigned long *p = (unsigned long *)regs->sp;
387 * regs->sp points to the failing IRET frame on the
410 regs->ip = (unsigned long)asm_exc_general_protection;
411 regs->sp = (unsigned long)&gpregs->orig_ax;
417 irqentry_nmi_enter(regs);
419 notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV);
463 handle_stack_overflow(regs, address, &info);
467 die("double fault", regs, error_code);
474 if (notify_die(DIE_TRAP, "bounds", regs, 0,
477 cond_local_irq_enable(regs);
479 if (!user_mode(regs))
480 die("bounds", regs, 0);
482 do_trap(X86_TRAP_BR, SIGSEGV, "bounds", regs, 0, 0, NULL);
484 cond_local_irq_disable(regs);
498 static enum kernel_gp_hint get_kernel_gp_address(struct pt_regs *regs,
505 if (copy_from_kernel_nofault(insn_buf, (void *)regs->ip,
513 *addr = (unsigned long)insn_get_addr_ref(&insn, regs);
533 static bool fixup_iopl_exception(struct pt_regs *regs)
542 if (insn_get_effective_ip(regs, &ip))
559 regs->ip += 1;
614 static bool gp_try_fixup_and_notify(struct pt_regs *regs, int trapnr,
618 if (fixup_exception(regs, trapnr, error_code, address))
629 kprobe_fault_handler(regs, trapnr))
632 return notify_die(DIE_GPF, str, regs, error_code, trapnr, SIGSEGV) == NOTIFY_STOP;
635 static void gp_user_force_sig_segv(struct pt_regs *regs, int trapnr,
640 show_signal(current, SIGSEGV, "", str, regs, error_code);
650 if (user_mode(regs) && try_fixup_enqcmd_gp())
653 cond_local_irq_enable(regs);
656 if (user_mode(regs) && fixup_umip_exception(regs))
660 if (v8086_mode(regs)) {
662 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
667 if (user_mode(regs)) {
668 if (fixup_iopl_exception(regs))
671 if (fixup_vdso_exception(regs, X86_TRAP_GP, error_code, 0))
674 gp_user_force_sig_segv(regs, X86_TRAP_GP, error_code, desc);
678 if (gp_try_fixup_and_notify(regs, X86_TRAP_GP, error_code, desc, 0))
684 hint = get_kernel_gp_address(regs, &gp_addr);
699 die_addr(desc, regs, error_code, gp_addr);
702 cond_local_irq_disable(regs);
705 static bool do_int3(struct pt_regs *regs)
710 if (kgdb_ll_trap(DIE_INT3, "int3", regs, 0, X86_TRAP_BP,
716 if (kprobe_int3_handler(regs))
719 res = notify_die(DIE_INT3, "int3", regs, 0, X86_TRAP_BP, SIGTRAP);
725 static void do_int3_user(struct pt_regs *regs)
727 if (do_int3(regs))
730 cond_local_irq_enable(regs);
731 do_trap(X86_TRAP_BP, SIGTRAP, "int3", regs, 0, 0, NULL);
732 cond_local_irq_disable(regs);
742 if (poke_int3_handler(regs))
752 if (user_mode(regs)) {
753 irqentry_enter_from_user_mode(regs);
755 do_int3_user(regs);
757 irqentry_exit_to_user_mode(regs);
759 irqentry_state_t irq_state = irqentry_nmi_enter(regs);
762 if (!do_int3(regs))
763 die("int3", regs, 0);
765 irqentry_nmi_exit(regs, irq_state);
777 struct pt_regs *regs = (struct pt_regs *)current_top_of_stack() - 1;
778 if (regs != eregs)
779 *regs = *eregs;
780 return regs;
784 asmlinkage __visible noinstr struct pt_regs *vc_switch_off_ist(struct pt_regs *regs)
794 if (ip_within_syscall_gap(regs)) {
804 sp = regs->sp;
820 *regs_ret = *regs;
854 static bool is_sysenter_singlestep(struct pt_regs *regs)
865 return (regs->ip - (unsigned long)__begin_SYSENTER_singlestep_region) <
869 return (regs->ip - (unsigned long)entry_SYSENTER_compat) <
924 static bool notify_debug(struct pt_regs *regs, unsigned long *dr6)
933 if (notify_die(DIE_DEBUG, "debug", regs, (long)dr6, 0, SIGTRAP) == NOTIFY_STOP)
939 static noinstr void exc_debug_kernel(struct pt_regs *regs, unsigned long dr6)
958 irqentry_state_t irq_state = irqentry_nmi_enter(regs);
965 WARN_ON_ONCE(user_mode(regs));
986 (dr6 & DR_STEP) && is_sysenter_singlestep(regs))
995 if (notify_debug(regs, &dr6))
1010 regs->flags &= ~X86_EFLAGS_TF;
1013 irqentry_nmi_exit(regs, irq_state);
1018 static noinstr void exc_debug_user(struct pt_regs *regs, unsigned long dr6)
1026 WARN_ON_ONCE(!user_mode(regs));
1037 irqentry_enter_from_user_mode(regs);
1063 if (notify_debug(regs, &dr6))
1069 if (v8086_mode(regs)) {
1070 handle_vm86_trap((struct kernel_vm86_regs *)regs, 0, X86_TRAP_DB);
1076 handle_bus_lock(regs);
1081 send_sigtrap(regs, 0, get_si_code(dr6));
1087 irqentry_exit_to_user_mode(regs);
1094 exc_debug_kernel(regs, debug_read_clear_dr6());
1100 exc_debug_user(regs, debug_read_clear_dr6());
1121 unsigned long dr6 = fred_event_data(regs);
1123 if (user_mode(regs))
1124 exc_debug_user(regs, dr6);
1126 exc_debug_kernel(regs, dr6);
1136 if (user_mode(regs))
1137 exc_debug_user(regs, dr6);
1139 exc_debug_kernel(regs, dr6);
1148 static void math_error(struct pt_regs *regs, int trapnr)
1156 cond_local_irq_enable(regs);
1158 if (!user_mode(regs)) {
1159 if (fixup_exception(regs, trapnr, 0, 0))
1165 if (notify_die(DIE_TRAP, str, regs, 0, trapnr,
1167 die(str, regs, 0);
1185 if (fixup_vdso_exception(regs, trapnr, 0, 0))
1189 (void __user *)uprobe_get_trap_addr(regs));
1191 cond_local_irq_disable(regs);
1196 math_error(regs, X86_TRAP_MF);
1204 __exc_general_protection(regs, 0);
1208 math_error(regs, X86_TRAP_XF);
1234 static bool handle_xfd_event(struct pt_regs *regs)
1249 if (WARN_ON(!user_mode(regs)))
1258 force_sig_fault(SIGILL, ILL_ILLOPC, error_get_trap_addr(regs));
1273 if (handle_xfd_event(regs))
1280 cond_local_irq_enable(regs);
1282 info.regs = regs;
1285 cond_local_irq_disable(regs);
1300 die("unexpected #NM exception", regs, 0);
1308 static void ve_raise_fault(struct pt_regs *regs, long error_code,
1311 if (user_mode(regs)) {
1312 gp_user_force_sig_segv(regs, X86_TRAP_VE, error_code, VE_FAULT_STR);
1316 if (gp_try_fixup_and_notify(regs, X86_TRAP_VE, error_code,
1321 die_addr(VE_FAULT_STR, regs, error_code, address);
1378 cond_local_irq_enable(regs);
1384 if (!tdx_handle_virt_exception(regs, &ve))
1385 ve_raise_fault(regs, 0, ve.gla);
1387 cond_local_irq_disable(regs);
1396 if (notify_die(DIE_TRAP, "iret exception", regs, 0,
1398 do_trap(X86_TRAP_IRET, SIGILL, "iret exception", regs, 0,