blob: 4d78b9d8c99c0181a6cc3d0b857fce8270fd4064 [file] [log] [blame]
Christophe Leroy69795ca2019-04-18 16:51:18 +10001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_POWERPC_KUP_H_
3#define _ASM_POWERPC_KUP_H_
4
5#ifndef __ASSEMBLY__
6
Christophe Leroyde78a9c2019-04-18 16:51:20 +10007#include <asm/pgtable.h>
8
Christophe Leroy69795ca2019-04-18 16:51:18 +10009void setup_kup(void);
10
Christophe Leroy0fb1c252019-04-18 16:51:19 +100011#ifdef CONFIG_PPC_KUEP
12void setup_kuep(bool disabled);
13#else
14static inline void setup_kuep(bool disabled) { }
15#endif /* CONFIG_PPC_KUEP */
16
Christophe Leroyde78a9c2019-04-18 16:51:20 +100017#ifdef CONFIG_PPC_KUAP
18void setup_kuap(bool disabled);
19#else
20static inline void setup_kuap(bool disabled) { }
21static inline void allow_user_access(void __user *to, const void __user *from,
22 unsigned long size) { }
23static inline void prevent_user_access(void __user *to, const void __user *from,
24 unsigned long size) { }
25#endif /* CONFIG_PPC_KUAP */
26
27static inline void allow_read_from_user(const void __user *from, unsigned long size)
28{
29 allow_user_access(NULL, from, size);
30}
31
32static inline void allow_write_to_user(void __user *to, unsigned long size)
33{
34 allow_user_access(to, NULL, size);
35}
36
37static inline void prevent_read_from_user(const void __user *from, unsigned long size)
38{
39 prevent_user_access(NULL, from, size);
40}
41
42static inline void prevent_write_to_user(void __user *to, unsigned long size)
43{
44 prevent_user_access(to, NULL, size);
45}
46
Christophe Leroy69795ca2019-04-18 16:51:18 +100047#endif /* !__ASSEMBLY__ */
48
49#endif /* _ASM_POWERPC_KUP_H_ */