kup.h (d008f8f8a0c3efe4fe1008a797f9497ea5965e27) kup.h (cb2f1fb205cc20695fcaef84baf80d9d3e54c88b)
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_POWERPC_KUP_H_
3#define _ASM_POWERPC_KUP_H_
4
5#define KUAP_READ 1
6#define KUAP_WRITE 2
7#define KUAP_READ_WRITE (KUAP_READ | KUAP_WRITE)
8

--- 58 unchanged lines hidden (view full) ---

67/*
68 * book3s/64/kup-radix.h defines these functions for the !KUAP case to flush
69 * the L1D cache after user accesses. Only include the empty stubs for other
70 * platforms.
71 */
72#ifndef CONFIG_PPC_BOOK3S_64
73static inline void allow_user_access(void __user *to, const void __user *from,
74 unsigned long size, unsigned long dir) { }
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_POWERPC_KUP_H_
3#define _ASM_POWERPC_KUP_H_
4
5#define KUAP_READ 1
6#define KUAP_WRITE 2
7#define KUAP_READ_WRITE (KUAP_READ | KUAP_WRITE)
8

--- 58 unchanged lines hidden (view full) ---

67/*
68 * book3s/64/kup-radix.h defines these functions for the !KUAP case to flush
69 * the L1D cache after user accesses. Only include the empty stubs for other
70 * platforms.
71 */
72#ifndef CONFIG_PPC_BOOK3S_64
73static inline void allow_user_access(void __user *to, const void __user *from,
74 unsigned long size, unsigned long dir) { }
75static inline void prevent_user_access(void __user *to, const void __user *from,
76 unsigned long size, unsigned long dir) { }
75static inline void prevent_user_access(unsigned long dir) { }
77static inline unsigned long prevent_user_access_return(void) { return 0UL; }
78static inline void restore_user_access(unsigned long flags) { }
79#endif /* CONFIG_PPC_BOOK3S_64 */
80#endif /* CONFIG_PPC_KUAP */
81
82static __always_inline void setup_kup(void)
83{
84 setup_kuep(disable_kuep);

--- 15 unchanged lines hidden (view full) ---

100 unsigned long size)
101{
102 barrier_nospec();
103 allow_user_access(to, from, size, KUAP_READ_WRITE);
104}
105
106static inline void prevent_read_from_user(const void __user *from, unsigned long size)
107{
76static inline unsigned long prevent_user_access_return(void) { return 0UL; }
77static inline void restore_user_access(unsigned long flags) { }
78#endif /* CONFIG_PPC_BOOK3S_64 */
79#endif /* CONFIG_PPC_KUAP */
80
81static __always_inline void setup_kup(void)
82{
83 setup_kuep(disable_kuep);

--- 15 unchanged lines hidden (view full) ---

99 unsigned long size)
100{
101 barrier_nospec();
102 allow_user_access(to, from, size, KUAP_READ_WRITE);
103}
104
105static inline void prevent_read_from_user(const void __user *from, unsigned long size)
106{
108 prevent_user_access(NULL, from, size, KUAP_READ);
107 prevent_user_access(KUAP_READ);
109}
110
111static inline void prevent_write_to_user(void __user *to, unsigned long size)
112{
108}
109
110static inline void prevent_write_to_user(void __user *to, unsigned long size)
111{
113 prevent_user_access(to, NULL, size, KUAP_WRITE);
112 prevent_user_access(KUAP_WRITE);
114}
115
116static inline void prevent_read_write_user(void __user *to, const void __user *from,
117 unsigned long size)
118{
113}
114
115static inline void prevent_read_write_user(void __user *to, const void __user *from,
116 unsigned long size)
117{
119 prevent_user_access(to, from, size, KUAP_READ_WRITE);
118 prevent_user_access(KUAP_READ_WRITE);
120}
121
122static inline void prevent_current_access_user(void)
123{
119}
120
121static inline void prevent_current_access_user(void)
122{
124 prevent_user_access(NULL, NULL, ~0UL, KUAP_READ_WRITE);
123 prevent_user_access(KUAP_READ_WRITE);
125}
126
127static inline void prevent_current_read_from_user(void)
128{
124}
125
126static inline void prevent_current_read_from_user(void)
127{
129 prevent_user_access(NULL, NULL, ~0UL, KUAP_READ);
128 prevent_user_access(KUAP_READ);
130}
131
132static inline void prevent_current_write_to_user(void)
133{
129}
130
131static inline void prevent_current_write_to_user(void)
132{
134 prevent_user_access(NULL, NULL, ~0UL, KUAP_WRITE);
133 prevent_user_access(KUAP_WRITE);
135}
136
137#endif /* !__ASSEMBLY__ */
138
139#endif /* _ASM_POWERPC_KUAP_H_ */
134}
135
136#endif /* !__ASSEMBLY__ */
137
138#endif /* _ASM_POWERPC_KUAP_H_ */