[PATCH] ARM: Use conditionals for CFI branches

Ard Biesheuvel ardb at kernel.org
Tue Apr 30 02:37:16 PDT 2024


On Tue, 30 Apr 2024 at 11:23, Russell King (Oracle)
<linux at armlinux.org.uk> wrote:
>
> On Tue, Apr 30, 2024 at 11:18:55AM +0200, Ard Biesheuvel wrote:
> > On Tue, 30 Apr 2024 at 10:26, Linus Walleij <linus.walleij at linaro.org> wrote:
> > > 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)
>
> I don't see that makes any difference. Whether or not they're called
> indirectly, the symbol is the entry point to the function. If called
> directly and the useless branch is there, we'll incur the overhead of
> the BL instruction flushing the pipeline followed immediately by the
> overhead of the B instruction flushing the pipeline again.

That is not what I meant.

I meant that, if you decide to enable CFI clang for these targets, you
still only need the branch if MULTI_CACHE is enabled.

IOW, we can avoid the branch entirely in even more situations.



More information about the linux-arm-kernel mailing list