1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_KUP_H_
3 #define _ASM_POWERPC_KUP_H_
6 #include <asm/book3s/64/kup-radix.h>
9 #include <asm/nohash/32/kup-8xx.h>
11 #ifdef CONFIG_PPC_BOOK3S_32
12 #include <asm/book3s/32/kup.h>
16 #ifndef CONFIG_PPC_KUAP
17 .macro kuap_save_and_lock sp, thread, gpr1, gpr2, gpr3
20 .macro kuap_restore sp, current, gpr1, gpr2, gpr3
23 .macro kuap_check current, gpr
28 #else /* !__ASSEMBLY__ */
30 #include <asm/pgtable.h>
34 #ifdef CONFIG_PPC_KUEP
35 void setup_kuep(bool disabled);
37 static inline void setup_kuep(bool disabled) { }
38 #endif /* CONFIG_PPC_KUEP */
40 #ifdef CONFIG_PPC_KUAP
41 void setup_kuap(bool disabled);
43 static inline void setup_kuap(bool disabled) { }
44 static inline void allow_user_access(void __user *to, const void __user *from,
45 unsigned long size) { }
46 static inline void prevent_user_access(void __user *to, const void __user *from,
47 unsigned long size) { }
48 static inline bool bad_kuap_fault(struct pt_regs *regs, bool is_write) { return false; }
49 #endif /* CONFIG_PPC_KUAP */
51 static inline void allow_read_from_user(const void __user *from, unsigned long size)
53 allow_user_access(NULL, from, size);
56 static inline void allow_write_to_user(void __user *to, unsigned long size)
58 allow_user_access(to, NULL, size);
61 static inline void prevent_read_from_user(const void __user *from, unsigned long size)
63 prevent_user_access(NULL, from, size);
66 static inline void prevent_write_to_user(void __user *to, unsigned long size)
68 prevent_user_access(to, NULL, size);
71 #endif /* !__ASSEMBLY__ */
73 #endif /* _ASM_POWERPC_KUP_H_ */