blob: 28ad4654eed25057848fabe695f23cb3095f5535 [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
Michael Ellerman890274c2019-04-18 16:51:24 +10005#ifdef CONFIG_PPC64
6#include <asm/book3s/64/kup-radix.h>
7#endif
8
Christophe Leroy69795ca2019-04-18 16:51:18 +10009#ifndef __ASSEMBLY__
10
Christophe Leroyde78a9c2019-04-18 16:51:20 +100011#include <asm/pgtable.h>
12
Christophe Leroy69795ca2019-04-18 16:51:18 +100013void setup_kup(void);
14
Christophe Leroy0fb1c252019-04-18 16:51:19 +100015#ifdef CONFIG_PPC_KUEP
16void setup_kuep(bool disabled);
17#else
18static inline void setup_kuep(bool disabled) { }
19#endif /* CONFIG_PPC_KUEP */
20
Christophe Leroyde78a9c2019-04-18 16:51:20 +100021#ifdef CONFIG_PPC_KUAP
22void setup_kuap(bool disabled);
23#else
24static inline void setup_kuap(bool disabled) { }
25static inline void allow_user_access(void __user *to, const void __user *from,
26 unsigned long size) { }
27static inline void prevent_user_access(void __user *to, const void __user *from,
28 unsigned long size) { }
Michael Ellerman5e5be3a2019-04-18 16:51:25 +100029static inline bool bad_kuap_fault(struct pt_regs *regs, bool is_write) { return false; }
Christophe Leroyde78a9c2019-04-18 16:51:20 +100030#endif /* CONFIG_PPC_KUAP */
31
32static inline void allow_read_from_user(const void __user *from, unsigned long size)
33{
34 allow_user_access(NULL, from, size);
35}
36
37static inline void allow_write_to_user(void __user *to, unsigned long size)
38{
39 allow_user_access(to, NULL, size);
40}
41
42static inline void prevent_read_from_user(const void __user *from, unsigned long size)
43{
44 prevent_user_access(NULL, from, size);
45}
46
47static inline void prevent_write_to_user(void __user *to, unsigned long size)
48{
49 prevent_user_access(to, NULL, size);
50}
51
Christophe Leroy69795ca2019-04-18 16:51:18 +100052#endif /* !__ASSEMBLY__ */
53
54#endif /* _ASM_POWERPC_KUP_H_ */