[PATCH] ARM: Use conditionals for CFI branches
Ard Biesheuvel
ardb at kernel.org
Tue Apr 30 02:18:55 PDT 2024
On Tue, 30 Apr 2024 at 10:26, Linus Walleij <linus.walleij at linaro.org> wrote:
>
> 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.
>
> Suggested-by: Ard Biesheuvel <ardb at kernel.org>
> Link: https://lore.kernel.org/linux-arm-kernel/Zi+e9M%2Ff5b%2FSto9H@shell.armlinux.org.uk/
> Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
> ---
> arch/arm/mm/cache-fa.S | 2 ++
> arch/arm/mm/cache-v4.S | 2 ++
> arch/arm/mm/cache-v4wb.S | 4 ++++
> arch/arm/mm/cache-v4wt.S | 2 ++
> arch/arm/mm/cache-v6.S | 2 ++
> arch/arm/mm/cache-v7.S | 2 ++
> arch/arm/mm/cache-v7m.S | 2 ++
> arch/arm/mm/proc-arm1020.S | 2 ++
> arch/arm/mm/proc-arm1020e.S | 2 ++
> arch/arm/mm/proc-arm1022.S | 2 ++
> arch/arm/mm/proc-arm1026.S | 2 ++
> arch/arm/mm/proc-arm920.S | 2 ++
> arch/arm/mm/proc-arm922.S | 2 ++
> arch/arm/mm/proc-arm925.S | 2 ++
> arch/arm/mm/proc-arm926.S | 2 ++
> arch/arm/mm/proc-arm940.S | 2 ++
> arch/arm/mm/proc-arm946.S | 2 ++
> arch/arm/mm/proc-feroceon.S | 2 ++
> arch/arm/mm/proc-mohawk.S | 2 ++
> arch/arm/mm/proc-xsc3.S | 2 ++
> 20 files changed, 42 insertions(+)
>
> diff --git a/arch/arm/mm/cache-fa.S b/arch/arm/mm/cache-fa.S
> index db454033b76f..4a3668b52a2d 100644
> --- a/arch/arm/mm/cache-fa.S
> +++ b/arch/arm/mm/cache-fa.S
> @@ -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 */
These functions are only called indirectly if MULTI_CACHE is enabled,
right? If so, this could be
#if defined(CONFIG_CFI_CLANG) && defined(MULTI_CACHE)
In any case, with or without that tweak
Reviewed-by: Ard Biesheuvel <ardb at kernel.org>
More information about the linux-arm-kernel
mailing list