11
11
12
12
#ifdef __ASSEMBLY__
13
13
14
- .macro kuap_restore_amr gpr
15
14
#ifdef CONFIG_PPC_KUAP
15
+ .macro kuap_restore_amr gpr
16
16
BEGIN_MMU_FTR_SECTION_NESTED (67 )
17
17
ld \gpr , STACK_REGS_KUAP (r1 )
18
18
mtspr SPRN_AMR , \gpr
19
19
END_MMU_FTR_SECTION_NESTED_IFSET (MMU_FTR_RADIX_KUAP , 67 )
20
- #endif
21
20
.endm
22
21
23
22
.macro kuap_check_amr gpr1 , gpr2
31
30
END_MMU_FTR_SECTION_NESTED_IFSET (MMU_FTR_RADIX_KUAP , 67 )
32
31
#endif
33
32
.endm
33
+ #endif
34
34
35
35
.macro kuap_save_amr_and_lock gpr1 , gpr2 , use_cr , msr_pr_cr
36
36
#ifdef CONFIG_PPC_KUAP
54
54
55
55
#else /* !__ASSEMBLY__ */
56
56
57
+ DECLARE_STATIC_KEY_FALSE (uaccess_flush_key );
58
+
57
59
#ifdef CONFIG_PPC_KUAP
58
60
59
61
#include < asm/reg .h >
@@ -77,6 +79,18 @@ static inline void set_kuap(unsigned long value)
77
79
isync ();
78
80
}
79
81
82
+ static inline bool
83
+ bad_kuap_fault (struct pt_regs * regs , unsigned long address , bool is_write )
84
+ {
85
+ return WARN (mmu_has_feature (MMU_FTR_RADIX_KUAP ) &&
86
+ (regs -> kuap & (is_write ? AMR_KUAP_BLOCK_WRITE : AMR_KUAP_BLOCK_READ )),
87
+ "Bug: %s fault blocked by AMR!" , is_write ? "Write" : "Read" );
88
+ }
89
+ #else /* CONFIG_PPC_KUAP */
90
+ static inline void kuap_restore_amr (struct pt_regs * regs , unsigned long amr ) { }
91
+ static inline void set_kuap (unsigned long value ) { }
92
+ #endif /* !CONFIG_PPC_KUAP */
93
+
80
94
static __always_inline void allow_user_access (void __user * to , const void __user * from ,
81
95
unsigned long size , unsigned long dir )
82
96
{
@@ -94,17 +108,10 @@ static inline void prevent_user_access(void __user *to, const void __user *from,
94
108
unsigned long size , unsigned long dir )
95
109
{
96
110
set_kuap (AMR_KUAP_BLOCKED );
111
+ if (static_branch_unlikely (& uaccess_flush_key ))
112
+ do_uaccess_flush ();
97
113
}
98
114
99
- static inline bool
100
- bad_kuap_fault (struct pt_regs * regs , unsigned long address , bool is_write )
101
- {
102
- return WARN (mmu_has_feature (MMU_FTR_RADIX_KUAP ) &&
103
- (regs -> kuap & (is_write ? AMR_KUAP_BLOCK_WRITE : AMR_KUAP_BLOCK_READ )),
104
- "Bug: %s fault blocked by AMR!" , is_write ? "Write" : "Read" );
105
- }
106
- #endif /* CONFIG_PPC_KUAP */
107
-
108
115
#endif /* __ASSEMBLY__ */
109
116
110
117
#endif /* _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H */
0 commit comments