ARM: 9393/1: mm: Use conditionals for CFI branches
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 2 May 2024 07:13:24 +0000 (08:13 +0100)
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tue, 7 May 2024 09:30:24 +0000 (10:30 +0100)
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>
20 files changed:
arch/arm/mm/cache-fa.S
arch/arm/mm/cache-v4.S
arch/arm/mm/cache-v4wb.S
arch/arm/mm/cache-v4wt.S
arch/arm/mm/cache-v6.S
arch/arm/mm/cache-v7.S
arch/arm/mm/cache-v7m.S
arch/arm/mm/proc-arm1020.S
arch/arm/mm/proc-arm1020e.S
arch/arm/mm/proc-arm1022.S
arch/arm/mm/proc-arm1026.S
arch/arm/mm/proc-arm920.S
arch/arm/mm/proc-arm922.S
arch/arm/mm/proc-arm925.S
arch/arm/mm/proc-arm926.S
arch/arm/mm/proc-arm940.S
arch/arm/mm/proc-arm946.S
arch/arm/mm/proc-feroceon.S
arch/arm/mm/proc-mohawk.S
arch/arm/mm/proc-xsc3.S

index db454033b76ff3c3fa7b3409859f7e7d0e9fb352..4a3668b52a2db076b92ebfed6fd42f59d692842f 100644 (file)
@@ -112,7 +112,9 @@ SYM_FUNC_END(fa_flush_user_cache_range)
  *     - end    - virtual end address
  */
 SYM_TYPED_FUNC_START(fa_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       fa_coherent_user_range
+#endif
 SYM_FUNC_END(fa_coherent_kern_range)
 
 /*
index 0df97a610026b6d2e9a02262668b77d189e59f94..0e94e5193dbd41fc31ec58e9455f54bfcbb97c2e 100644 (file)
@@ -104,7 +104,9 @@ SYM_FUNC_END(v4_coherent_user_range)
  *     - size  - region size
  */
 SYM_TYPED_FUNC_START(v4_flush_kern_dcache_area)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       v4_dma_flush_range
+#endif
 SYM_FUNC_END(v4_flush_kern_dcache_area)
 
 /*
index 1912f559968cd9e7040f64bcd76055a1ec549be7..ce55a2eef5da40c33fce52a4fe6fa453c88e62c6 100644 (file)
@@ -136,7 +136,9 @@ SYM_FUNC_END(v4wb_flush_user_cache_range)
  */
 SYM_TYPED_FUNC_START(v4wb_flush_kern_dcache_area)
        add     r1, r0, r1
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       v4wb_coherent_user_range
+#endif
 SYM_FUNC_END(v4wb_flush_kern_dcache_area)
 
 /*
@@ -150,7 +152,9 @@ SYM_FUNC_END(v4wb_flush_kern_dcache_area)
  *     - end    - virtual end address
  */
 SYM_TYPED_FUNC_START(v4wb_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       v4wb_coherent_user_range
+#endif
 SYM_FUNC_END(v4wb_coherent_kern_range)
 
 /*
index 43b4275ab680274ff40417e48cb312a71a50fc0d..a97dc267b3b0d76f3dc7086b1fce2945aaa8e99b 100644 (file)
@@ -108,7 +108,9 @@ SYM_FUNC_END(v4wt_flush_user_cache_range)
  *     - end    - virtual end address
  */
 SYM_TYPED_FUNC_START(v4wt_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       v4wt_coherent_user_range
+#endif
 SYM_FUNC_END(v4wt_coherent_kern_range)
 
 /*
index 86affd60d6d4f057619b6766b41120414d7ad0cd..9f415476e2183dbd1fc8b351f71526341dace87f 100644 (file)
@@ -117,7 +117,9 @@ SYM_FUNC_END(v6_flush_user_cache_range)
  *     - the Icache does not read data from the write buffer
  */
 SYM_TYPED_FUNC_START(v6_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       v6_coherent_user_range
+#endif
 SYM_FUNC_END(v6_coherent_kern_range)
 
 /*
index 170b9ac72331f21c594785777b95e8bb5d657b0e..201ca05436fad542e32df8c03abb718b0d690112 100644 (file)
@@ -261,7 +261,9 @@ SYM_FUNC_END(v7_flush_user_cache_range)
  *     - the Icache does not read data from the write buffer
  */
 SYM_TYPED_FUNC_START(v7_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       v7_coherent_user_range
+#endif
 SYM_FUNC_END(v7_coherent_kern_range)
 
 /*
index 4e670697eabc850857143d684ba21c7e09c2e57b..14d719eba729de3216bfbf7868cb2a212b8fda0b 100644 (file)
@@ -286,7 +286,9 @@ SYM_FUNC_END(v7m_flush_user_cache_range)
  *     - the Icache does not read data from the write buffer
  */
 SYM_TYPED_FUNC_START(v7m_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       v7m_coherent_user_range
+#endif
 SYM_FUNC_END(v7m_coherent_kern_range)
 
 /*
index ddda04929dae18b00f1e99d92f46fcae9e8ef007..d0ce3414a13e26561b43452447e8b6b1a1a041d1 100644 (file)
@@ -203,7 +203,9 @@ SYM_FUNC_END(arm1020_flush_user_cache_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(arm1020_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       arm1020_coherent_user_range
+#endif
 SYM_FUNC_END(arm1020_coherent_kern_range)
 
 /*
index 60169f4ca391be04247fcd87b07b1a96f7173605..64f031bf6eff5a5c6f733fde9abbc94bb1a9047d 100644 (file)
@@ -200,7 +200,9 @@ SYM_FUNC_END(arm1020e_flush_user_cache_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(arm1020e_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       arm1020e_coherent_user_range
+#endif
 SYM_FUNC_END(arm1020e_coherent_kern_range)
 
 /*
index 30b0e4d05a05a1ce39d036aad8e43888de93e32c..42ed5ed07252854e6ec2ea04b7e38f268c568716 100644 (file)
@@ -199,7 +199,9 @@ SYM_FUNC_END(arm1022_flush_user_cache_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(arm1022_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       arm1022_coherent_user_range
+#endif
 SYM_FUNC_END(arm1022_coherent_kern_range)
 
 /*
index ae06262ca779a953d54d79af6b849d0fcbf00405..b3ae62cd553aacf0be48773288afa1749d595b7d 100644 (file)
@@ -194,7 +194,9 @@ SYM_FUNC_END(arm1026_flush_user_cache_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(arm1026_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       arm1026_coherent_user_range
+#endif
 SYM_FUNC_END(arm1026_coherent_kern_range)
 
 /*
index e47411243b08a9ca9b7c77544880f32bc20c3e90..a30df54ad5fae2d4f80ef39f0a38aec42d100460 100644 (file)
@@ -180,7 +180,9 @@ SYM_FUNC_END(arm920_flush_user_cache_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(arm920_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       arm920_coherent_user_range
+#endif
 SYM_FUNC_END(arm920_coherent_kern_range)
 
 /*
index 092f8b7656a734d7c1ffad2f428db6cf210b09e3..aac4e048100d012b7f53535ce14071115cc65941 100644 (file)
@@ -182,7 +182,9 @@ SYM_FUNC_END(arm922_flush_user_cache_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(arm922_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       arm922_coherent_user_range
+#endif
 SYM_FUNC_END(arm922_coherent_kern_range)
 
 /*
index a06039a3b2a8777717c9760b794f05810648406c..035941faeb2ed47a4ff8d7217ead0ca1aebbbfa9 100644 (file)
@@ -229,7 +229,9 @@ SYM_FUNC_END(arm925_flush_user_cache_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(arm925_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       arm925_coherent_user_range
+#endif
 SYM_FUNC_END(arm925_coherent_kern_range)
 
 /*
index 2c8b93d446a9c5fc0cc041b3d777ccd458354d35..6f43d6af2d9a7ac874bd0bd76329c629a62225d8 100644 (file)
@@ -192,7 +192,9 @@ SYM_FUNC_END(arm926_flush_user_cache_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(arm926_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       arm926_coherent_user_range
+#endif
 SYM_FUNC_END(arm926_coherent_kern_range)
 
 /*
index fbe168213ec1c75d29924dd97a2dd49ac378d5f4..0d30bb25c42bf1cab6c169fdc25f4ab389dcd9ee 100644 (file)
@@ -153,7 +153,9 @@ SYM_FUNC_END(arm940_coherent_kern_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(arm940_coherent_user_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       arm940_flush_kern_dcache_area
+#endif
 SYM_FUNC_END(arm940_coherent_user_range)
 
 /*
index 4772b46064e6d9fdbe02c84605133c29f497b231..27750ace2cedaadfe6644420912d5bb141aad30d 100644 (file)
@@ -173,7 +173,9 @@ SYM_FUNC_END(arm946_flush_user_cache_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(arm946_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       arm946_coherent_user_range
+#endif
 SYM_FUNC_END(arm946_coherent_kern_range)
 
 /*
index 8519ff60e512015ad4b7b1bfb1bbaa76cfcec31b..f67b2ffac85411682c92f249b4387e6ef8b20c52 100644 (file)
@@ -208,7 +208,9 @@ SYM_FUNC_END(feroceon_flush_user_cache_range)
  */
        .align  5
 SYM_TYPED_FUNC_START(feroceon_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       feroceon_coherent_user_range
+#endif
 SYM_FUNC_END(feroceon_coherent_kern_range)
 
 /*
index 091f6c6719a894f873ffb662dbb69c152f244d50..8e9f38da863a524550936addab5cb287a582a20c 100644 (file)
@@ -163,7 +163,9 @@ SYM_FUNC_END(mohawk_flush_user_cache_range)
  *     - end   - virtual end address
  */
 SYM_TYPED_FUNC_START(mohawk_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       mohawk_coherent_user_range
+#endif
 SYM_FUNC_END(mohawk_coherent_kern_range)
 
 /*
index f4889911eca25412b78a22db7a95d1f9c9119c32..14927b3804524495f9b0129262dac4073811c026 100644 (file)
@@ -223,7 +223,9 @@ SYM_FUNC_END(xsc3_flush_user_cache_range)
  *     it also trashes the mini I-cache used by JTAG debuggers.
  */
 SYM_TYPED_FUNC_START(xsc3_coherent_kern_range)
+#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
        b       xsc3_coherent_user_range
+#endif
 SYM_FUNC_END(xsc3_coherent_kern_range)
 
 SYM_TYPED_FUNC_START(xsc3_coherent_user_range)