Christophe Leroy | 69795ca | 2019-04-18 16:51:18 +1000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _ASM_POWERPC_KUP_H_ |
| 3 | #define _ASM_POWERPC_KUP_H_ |
| 4 | |
| 5 | #ifndef __ASSEMBLY__ |
| 6 | |
Christophe Leroy | de78a9c | 2019-04-18 16:51:20 +1000 | [diff] [blame^] | 7 | #include <asm/pgtable.h> |
| 8 | |
Christophe Leroy | 69795ca | 2019-04-18 16:51:18 +1000 | [diff] [blame] | 9 | void setup_kup(void); |
| 10 | |
Christophe Leroy | 0fb1c25 | 2019-04-18 16:51:19 +1000 | [diff] [blame] | 11 | #ifdef CONFIG_PPC_KUEP |
| 12 | void setup_kuep(bool disabled); |
| 13 | #else |
| 14 | static inline void setup_kuep(bool disabled) { } |
| 15 | #endif /* CONFIG_PPC_KUEP */ |
| 16 | |
Christophe Leroy | de78a9c | 2019-04-18 16:51:20 +1000 | [diff] [blame^] | 17 | #ifdef CONFIG_PPC_KUAP |
| 18 | void setup_kuap(bool disabled); |
| 19 | #else |
| 20 | static inline void setup_kuap(bool disabled) { } |
| 21 | static inline void allow_user_access(void __user *to, const void __user *from, |
| 22 | unsigned long size) { } |
| 23 | static inline void prevent_user_access(void __user *to, const void __user *from, |
| 24 | unsigned long size) { } |
| 25 | #endif /* CONFIG_PPC_KUAP */ |
| 26 | |
| 27 | static inline void allow_read_from_user(const void __user *from, unsigned long size) |
| 28 | { |
| 29 | allow_user_access(NULL, from, size); |
| 30 | } |
| 31 | |
| 32 | static inline void allow_write_to_user(void __user *to, unsigned long size) |
| 33 | { |
| 34 | allow_user_access(to, NULL, size); |
| 35 | } |
| 36 | |
| 37 | static inline void prevent_read_from_user(const void __user *from, unsigned long size) |
| 38 | { |
| 39 | prevent_user_access(NULL, from, size); |
| 40 | } |
| 41 | |
| 42 | static inline void prevent_write_to_user(void __user *to, unsigned long size) |
| 43 | { |
| 44 | prevent_user_access(to, NULL, size); |
| 45 | } |
| 46 | |
Christophe Leroy | 69795ca | 2019-04-18 16:51:18 +1000 | [diff] [blame] | 47 | #endif /* !__ASSEMBLY__ */ |
| 48 | |
| 49 | #endif /* _ASM_POWERPC_KUP_H_ */ |