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