powerpc/mm/hash64: Map all the kernel regions in the same 0xc range
[linux-2.6-block.git] / arch / powerpc / include / asm / kup.h
CommitLineData
69795cab
CL
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_POWERPC_KUP_H_
3#define _ASM_POWERPC_KUP_H_
4
890274c2
ME
5#ifdef CONFIG_PPC64
6#include <asm/book3s/64/kup-radix.h>
7#endif
2679f9bd
CL
8#ifdef CONFIG_PPC_8xx
9#include <asm/nohash/32/kup-8xx.h>
10#endif
31ed2b13
CL
11#ifdef CONFIG_PPC_BOOK3S_32
12#include <asm/book3s/32/kup.h>
13#endif
890274c2 14
e2fb9f54
CL
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 /* !__ASSEMBLY__ */
69795cab 29
de78a9c4
CL
30#include <asm/pgtable.h>
31
69795cab
CL
32void setup_kup(void);
33
0fb1c25a
CL
34#ifdef CONFIG_PPC_KUEP
35void setup_kuep(bool disabled);
36#else
37static inline void setup_kuep(bool disabled) { }
38#endif /* CONFIG_PPC_KUEP */
39
de78a9c4
CL
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) { }
5e5be3ae 48static inline bool bad_kuap_fault(struct pt_regs *regs, bool is_write) { return false; }
de78a9c4
CL
49#endif /* CONFIG_PPC_KUAP */
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
69795cab
CL
71#endif /* !__ASSEMBLY__ */
72
73#endif /* _ASM_POWERPC_KUP_H_ */