1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _ASM_X86_ENTRY_COMMON_H
3 #define _ASM_X86_ENTRY_COMMON_H
5 /* Check that the stack and regs on entry from user mode are sane. */
6 static __always_inline void arch_check_user_regs(struct pt_regs *regs)
8 if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) {
10 * Make sure that the entry code gave us a sensible EFLAGS
11 * register. Native because we want to check the actual CPU
12 * state, not the interrupt state as imagined by Xen.
14 unsigned long flags = native_save_fl();
15 WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF |
18 /* We think we came from user mode. Make sure pt_regs agrees. */
19 WARN_ON_ONCE(!user_mode(regs));
22 * All entries from user mode (except #DF) should be on the
23 * normal thread stack and should have user pt_regs in the
26 WARN_ON_ONCE(!on_thread_stack());
27 WARN_ON_ONCE(regs != task_pt_regs(current));
30 #define arch_check_user_regs arch_check_user_regs