Skip to content

Commit 7b749aa

Browse files
linuswRussell King (Oracle)
authored andcommitted
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%[email protected]/ Suggested-by: Ard Biesheuvel <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]>
1 parent 1a4fec4 commit 7b749aa

20 files changed

+42
-0
lines changed

arch/arm/mm/cache-fa.S

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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
/*

0 commit comments

Comments
 (0)