[PATCH v2 2/9] ARM: assembler: introduce bl_r and bl_m macros

Ard Biesheuvel ardb at kernel.org
Tue Oct 5 05:14:37 PDT 2021


On Tue, 5 Oct 2021 at 14:10, Arnd Bergmann <arnd at arndb.de> wrote:
>
> On Tue, Oct 5, 2021 at 9:15 AM Ard Biesheuvel <ardb at kernel.org> wrote:
> >
> > Add some macros that abstract the difference between the ways indirect
> > calls are performed on older and newer ARM architecture revisions.
> >
> > The main difference is to prefer blx instructions over explicit LR
> > assignments when possible, as these tend to confuse the prediction logic
> > in out-of-order cores when speculating across a function return.
> >
> > Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
>
> Reviewed-by: Arnd Bergmann <arnd at arndb.de>
>
> > +       .macro          bl_r, dst:req, c
> > +       .if             __LINUX_ARM_ARCH__ < 6
> > +       mov\c           lr, pc
> > +       mov\c           pc, \dst
> > +       .else
> > +       blx\c           \dst
> > +       .endif
> > +       .endm
>
> I suppose we could use blx on ARMv5 as well, but it wouldn't make a difference
> there, right?
>

No, it wouldn't. And the only reason for using '6' here is so that we
use blx in code that may run on both v6 and v7.



More information about the linux-arm-kernel mailing list