This source file includes following definitions.
- setup_kuep
- setup_kuap
- allow_user_access
- prevent_user_access
- bad_kuap_fault
- allow_read_from_user
- allow_write_to_user
- allow_read_write_user
- prevent_read_from_user
- prevent_write_to_user
- prevent_read_write_user
1
2 #ifndef _ASM_POWERPC_KUP_H_
3 #define _ASM_POWERPC_KUP_H_
4
5 #define KUAP_READ 1
6 #define KUAP_WRITE 2
7 #define KUAP_READ_WRITE (KUAP_READ | KUAP_WRITE)
8
9 #ifdef CONFIG_PPC64
10 #include <asm/book3s/64/kup-radix.h>
11 #endif
12 #ifdef CONFIG_PPC_8xx
13 #include <asm/nohash/32/kup-8xx.h>
14 #endif
15 #ifdef CONFIG_PPC_BOOK3S_32
16 #include <asm/book3s/32/kup.h>
17 #endif
18
19 #ifdef __ASSEMBLY__
20 #ifndef CONFIG_PPC_KUAP
21 .macro kuap_save_and_lock sp, thread, gpr1, gpr2, gpr3
22 .endm
23
24 .macro kuap_restore sp, current, gpr1, gpr2, gpr3
25 .endm
26
27 .macro kuap_check current, gpr
28 .endm
29
30 #endif
31
32 #else
33
34 #include <asm/pgtable.h>
35
36 void setup_kup(void);
37
38 #ifdef CONFIG_PPC_KUEP
39 void setup_kuep(bool disabled);
40 #else
41 static inline void setup_kuep(bool disabled) { }
42 #endif
43
44 #ifdef CONFIG_PPC_KUAP
45 void setup_kuap(bool disabled);
46 #else
47 static inline void setup_kuap(bool disabled) { }
48 static inline void allow_user_access(void __user *to, const void __user *from,
49 unsigned long size, unsigned long dir) { }
50 static inline void prevent_user_access(void __user *to, const void __user *from,
51 unsigned long size, unsigned long dir) { }
52 static inline bool
53 bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
54 {
55 return false;
56 }
57 #endif
58
59 static inline void allow_read_from_user(const void __user *from, unsigned long size)
60 {
61 allow_user_access(NULL, from, size, KUAP_READ);
62 }
63
64 static inline void allow_write_to_user(void __user *to, unsigned long size)
65 {
66 allow_user_access(to, NULL, size, KUAP_WRITE);
67 }
68
69 static inline void allow_read_write_user(void __user *to, const void __user *from,
70 unsigned long size)
71 {
72 allow_user_access(to, from, size, KUAP_READ_WRITE);
73 }
74
75 static inline void prevent_read_from_user(const void __user *from, unsigned long size)
76 {
77 prevent_user_access(NULL, from, size, KUAP_READ);
78 }
79
80 static inline void prevent_write_to_user(void __user *to, unsigned long size)
81 {
82 prevent_user_access(to, NULL, size, KUAP_WRITE);
83 }
84
85 static inline void prevent_read_write_user(void __user *to, const void __user *from,
86 unsigned long size)
87 {
88 prevent_user_access(to, from, size, KUAP_READ_WRITE);
89 }
90
91 #endif
92
93 #endif