1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef ARCH_S390_ENTRY_COMMON_H
3 #define ARCH_S390_ENTRY_COMMON_H
5 #include <linux/sched.h>
6 #include <linux/audit.h>
7 #include <linux/randomize_kstack.h>
8 #include <linux/processor.h>
9 #include <linux/uaccess.h>
10 #include <asm/timex.h>
11 #include <asm/fpu/api.h>
14 #define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_GUARDED_STORAGE | _TIF_PER_TRAP)
16 void do_per_trap(struct pt_regs *regs);
18 static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)
20 if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
23 pai_kernel_enter(regs);
26 #define arch_enter_from_user_mode arch_enter_from_user_mode
28 static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs,
29 unsigned long ti_work)
31 if (ti_work & _TIF_PER_TRAP) {
32 clear_thread_flag(TIF_PER_TRAP);
36 if (ti_work & _TIF_GUARDED_STORAGE)
40 #define arch_exit_to_user_mode_work arch_exit_to_user_mode_work
42 static __always_inline void arch_exit_to_user_mode(void)
44 if (test_cpu_flag(CIF_FPU))
47 if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
50 pai_kernel_exit(current_pt_regs());
53 #define arch_exit_to_user_mode arch_exit_to_user_mode
55 static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
56 unsigned long ti_work)
58 choose_random_kstack_offset(get_tod_clock_fast() & 0xff);
61 #define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare