75cebc80474e60d86c072ffd4e7d388be88b7454
[linux-2.6-microblaze.git] / arch / s390 / include / asm / entry-common.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef ARCH_S390_ENTRY_COMMON_H
3 #define ARCH_S390_ENTRY_COMMON_H
4
5 #include <linux/sched.h>
6 #include <linux/audit.h>
7 #include <linux/tracehook.h>
8 #include <linux/processor.h>
9 #include <linux/uaccess.h>
10 #include <asm/fpu/api.h>
11
12 #define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_GUARDED_STORAGE | _TIF_PER_TRAP)
13
14 void do_per_trap(struct pt_regs *regs);
15 void do_syscall(struct pt_regs *regs);
16
17 typedef void (*pgm_check_func)(struct pt_regs *regs);
18
19 extern pgm_check_func pgm_check_table[128];
20
21 #ifdef CONFIG_DEBUG_ENTRY
22 static __always_inline void arch_check_user_regs(struct pt_regs *regs)
23 {
24         debug_user_asce(0);
25 }
26
27 #define arch_check_user_regs arch_check_user_regs
28 #endif /* CONFIG_DEBUG_ENTRY */
29
30 static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs,
31                                                         unsigned long ti_work)
32 {
33         if (ti_work & _TIF_PER_TRAP) {
34                 clear_thread_flag(TIF_PER_TRAP);
35                 do_per_trap(regs);
36         }
37
38         if (ti_work & _TIF_GUARDED_STORAGE)
39                 gs_load_bc_cb(regs);
40 }
41
42 #define arch_exit_to_user_mode_work arch_exit_to_user_mode_work
43
44 static __always_inline void arch_exit_to_user_mode(void)
45 {
46         if (test_cpu_flag(CIF_FPU))
47                 __load_fpu_regs();
48
49         if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
50                 debug_user_asce(1);
51 }
52
53 #define arch_exit_to_user_mode arch_exit_to_user_mode
54
55 static inline bool on_thread_stack(void)
56 {
57         return !(((unsigned long)(current->stack) ^ current_stack_pointer()) & ~(THREAD_SIZE - 1));
58 }
59
60 #endif