Skip to content

Commit 7b749aa

Browse files
linuswRussell King (Oracle)
authored and
Russell King (Oracle)
committed
ARM: 9393/1: mm: Use conditionals for CFI branches
Commit 9385/2 introduced a few branches inside function prototypes when using CFI in order to deal with the situation where CFI inserts a few bytes of function information in front of the symbol. This is not good for older CPUs where every cycle counts. Commit 9386/2 alleviated the situation a bit by using aliases for the cache functions with identical signatures. This leaves the coherent cache flush functions *_coherent_kern_range() with these branches to the corresponing *_coherent_user_range() around, since their return type differ and they therefore cannot be aliased. Solve this by a simple ifdef so at least we can use fallthroughs when compiling without CFI enabled. Link: https://lore.kernel.org/linux-arm-kernel/Zi+e9M%2Ff5b%2FSto9H@shell.armlinux.org.uk/ Suggested-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
1 parent 1a4fec4 commit 7b749aa

20 files changed

+42
-0
lines changed

arch/arm/mm/cache-fa.S

+2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ SYM_FUNC_END(fa_flush_user_cache_range)
112112
* - end - virtual end address
113113
*/
114114
SYM_TYPED_FUNC_START(fa_coherent_kern_range)
115+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
115116
b fa_coherent_user_range
117+
#endif
116118
SYM_FUNC_END(fa_coherent_kern_range)
117119

118120
/*

arch/arm/mm/cache-v4.S

+2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ SYM_FUNC_END(v4_coherent_user_range)
104104
* - size - region size
105105
*/
106106
SYM_TYPED_FUNC_START(v4_flush_kern_dcache_area)
107+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
107108
b v4_dma_flush_range
109+
#endif
108110
SYM_FUNC_END(v4_flush_kern_dcache_area)
109111

110112
/*

arch/arm/mm/cache-v4wb.S

+4
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ SYM_FUNC_END(v4wb_flush_user_cache_range)
136136
*/
137137
SYM_TYPED_FUNC_START(v4wb_flush_kern_dcache_area)
138138
add r1, r0, r1
139+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
139140
b v4wb_coherent_user_range
141+
#endif
140142
SYM_FUNC_END(v4wb_flush_kern_dcache_area)
141143

142144
/*
@@ -150,7 +152,9 @@ SYM_FUNC_END(v4wb_flush_kern_dcache_area)
150152
* - end - virtual end address
151153
*/
152154
SYM_TYPED_FUNC_START(v4wb_coherent_kern_range)
155+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
153156
b v4wb_coherent_user_range
157+
#endif
154158
SYM_FUNC_END(v4wb_coherent_kern_range)
155159

156160
/*

arch/arm/mm/cache-v4wt.S

+2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ SYM_FUNC_END(v4wt_flush_user_cache_range)
108108
* - end - virtual end address
109109
*/
110110
SYM_TYPED_FUNC_START(v4wt_coherent_kern_range)
111+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
111112
b v4wt_coherent_user_range
113+
#endif
112114
SYM_FUNC_END(v4wt_coherent_kern_range)
113115

114116
/*

arch/arm/mm/cache-v6.S

+2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ SYM_FUNC_END(v6_flush_user_cache_range)
117117
* - the Icache does not read data from the write buffer
118118
*/
119119
SYM_TYPED_FUNC_START(v6_coherent_kern_range)
120+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
120121
b v6_coherent_user_range
122+
#endif
121123
SYM_FUNC_END(v6_coherent_kern_range)
122124

123125
/*

arch/arm/mm/cache-v7.S

+2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ SYM_FUNC_END(v7_flush_user_cache_range)
261261
* - the Icache does not read data from the write buffer
262262
*/
263263
SYM_TYPED_FUNC_START(v7_coherent_kern_range)
264+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
264265
b v7_coherent_user_range
266+
#endif
265267
SYM_FUNC_END(v7_coherent_kern_range)
266268

267269
/*

arch/arm/mm/cache-v7m.S

+2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ SYM_FUNC_END(v7m_flush_user_cache_range)
286286
* - the Icache does not read data from the write buffer
287287
*/
288288
SYM_TYPED_FUNC_START(v7m_coherent_kern_range)
289+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
289290
b v7m_coherent_user_range
291+
#endif
290292
SYM_FUNC_END(v7m_coherent_kern_range)
291293

292294
/*

arch/arm/mm/proc-arm1020.S

+2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ SYM_FUNC_END(arm1020_flush_user_cache_range)
203203
* - end - virtual end address
204204
*/
205205
SYM_TYPED_FUNC_START(arm1020_coherent_kern_range)
206+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
206207
b arm1020_coherent_user_range
208+
#endif
207209
SYM_FUNC_END(arm1020_coherent_kern_range)
208210

209211
/*

arch/arm/mm/proc-arm1020e.S

+2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ SYM_FUNC_END(arm1020e_flush_user_cache_range)
200200
* - end - virtual end address
201201
*/
202202
SYM_TYPED_FUNC_START(arm1020e_coherent_kern_range)
203+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
203204
b arm1020e_coherent_user_range
205+
#endif
204206
SYM_FUNC_END(arm1020e_coherent_kern_range)
205207

206208
/*

arch/arm/mm/proc-arm1022.S

+2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ SYM_FUNC_END(arm1022_flush_user_cache_range)
199199
* - end - virtual end address
200200
*/
201201
SYM_TYPED_FUNC_START(arm1022_coherent_kern_range)
202+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
202203
b arm1022_coherent_user_range
204+
#endif
203205
SYM_FUNC_END(arm1022_coherent_kern_range)
204206

205207
/*

arch/arm/mm/proc-arm1026.S

+2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ SYM_FUNC_END(arm1026_flush_user_cache_range)
194194
* - end - virtual end address
195195
*/
196196
SYM_TYPED_FUNC_START(arm1026_coherent_kern_range)
197+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
197198
b arm1026_coherent_user_range
199+
#endif
198200
SYM_FUNC_END(arm1026_coherent_kern_range)
199201

200202
/*

arch/arm/mm/proc-arm920.S

+2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ SYM_FUNC_END(arm920_flush_user_cache_range)
180180
* - end - virtual end address
181181
*/
182182
SYM_TYPED_FUNC_START(arm920_coherent_kern_range)
183+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
183184
b arm920_coherent_user_range
185+
#endif
184186
SYM_FUNC_END(arm920_coherent_kern_range)
185187

186188
/*

arch/arm/mm/proc-arm922.S

+2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ SYM_FUNC_END(arm922_flush_user_cache_range)
182182
* - end - virtual end address
183183
*/
184184
SYM_TYPED_FUNC_START(arm922_coherent_kern_range)
185+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
185186
b arm922_coherent_user_range
187+
#endif
186188
SYM_FUNC_END(arm922_coherent_kern_range)
187189

188190
/*

arch/arm/mm/proc-arm925.S

+2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ SYM_FUNC_END(arm925_flush_user_cache_range)
229229
* - end - virtual end address
230230
*/
231231
SYM_TYPED_FUNC_START(arm925_coherent_kern_range)
232+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
232233
b arm925_coherent_user_range
234+
#endif
233235
SYM_FUNC_END(arm925_coherent_kern_range)
234236

235237
/*

arch/arm/mm/proc-arm926.S

+2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ SYM_FUNC_END(arm926_flush_user_cache_range)
192192
* - end - virtual end address
193193
*/
194194
SYM_TYPED_FUNC_START(arm926_coherent_kern_range)
195+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
195196
b arm926_coherent_user_range
197+
#endif
196198
SYM_FUNC_END(arm926_coherent_kern_range)
197199

198200
/*

arch/arm/mm/proc-arm940.S

+2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ SYM_FUNC_END(arm940_coherent_kern_range)
153153
* - end - virtual end address
154154
*/
155155
SYM_TYPED_FUNC_START(arm940_coherent_user_range)
156+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
156157
b arm940_flush_kern_dcache_area
158+
#endif
157159
SYM_FUNC_END(arm940_coherent_user_range)
158160

159161
/*

arch/arm/mm/proc-arm946.S

+2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ SYM_FUNC_END(arm946_flush_user_cache_range)
173173
* - end - virtual end address
174174
*/
175175
SYM_TYPED_FUNC_START(arm946_coherent_kern_range)
176+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
176177
b arm946_coherent_user_range
178+
#endif
177179
SYM_FUNC_END(arm946_coherent_kern_range)
178180

179181
/*

arch/arm/mm/proc-feroceon.S

+2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ SYM_FUNC_END(feroceon_flush_user_cache_range)
208208
*/
209209
.align 5
210210
SYM_TYPED_FUNC_START(feroceon_coherent_kern_range)
211+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
211212
b feroceon_coherent_user_range
213+
#endif
212214
SYM_FUNC_END(feroceon_coherent_kern_range)
213215

214216
/*

arch/arm/mm/proc-mohawk.S

+2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ SYM_FUNC_END(mohawk_flush_user_cache_range)
163163
* - end - virtual end address
164164
*/
165165
SYM_TYPED_FUNC_START(mohawk_coherent_kern_range)
166+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
166167
b mohawk_coherent_user_range
168+
#endif
167169
SYM_FUNC_END(mohawk_coherent_kern_range)
168170

169171
/*

arch/arm/mm/proc-xsc3.S

+2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ SYM_FUNC_END(xsc3_flush_user_cache_range)
223223
* it also trashes the mini I-cache used by JTAG debuggers.
224224
*/
225225
SYM_TYPED_FUNC_START(xsc3_coherent_kern_range)
226+
#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
226227
b xsc3_coherent_user_range
228+
#endif
227229
SYM_FUNC_END(xsc3_coherent_kern_range)
228230

229231
SYM_TYPED_FUNC_START(xsc3_coherent_user_range)

0 commit comments

Comments
 (0)