[PATCH v3 04/18] arm64: assembler: user_alt label optional

Fuad Tabba tabba at google.com
Fri May 21 04:46:14 PDT 2021


Hi Mark,

On Thu, May 20, 2021 at 1:57 PM Mark Rutland <mark.rutland at arm.com> wrote:
>
> On Thu, May 20, 2021 at 01:43:52PM +0100, Fuad Tabba wrote:
> > Make the label for the extable entry in user_alt optional, only
> > generating an extable entry if provided.
> >
> > This is needed later in the series, to avoid instruction
> > duplication in the assembly code.
> >
> > While at it, clean up the label used to be globally unique using
> > \@ as for other macros.
>
> Nice; thanks for cleaning up the labels too!
>
> >
> > Signed-off-by: Fuad Tabba <tabba at google.com>
> > ---
> >  arch/arm64/include/asm/alternative-macros.h | 9 ++++++---
> >  arch/arm64/mm/cache.S                       | 2 +-
> >  2 files changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/arm64/include/asm/alternative-macros.h b/arch/arm64/include/asm/alternative-macros.h
> > index 8a078fc662ac..01ef954c9b2d 100644
> > --- a/arch/arm64/include/asm/alternative-macros.h
> > +++ b/arch/arm64/include/asm/alternative-macros.h
> > @@ -197,9 +197,12 @@ alternative_endif
> >  #define _ALTERNATIVE_CFG(insn1, insn2, cap, cfg, ...)        \
> >       alternative_insn insn1, insn2, cap, IS_ENABLED(cfg)
> >
> > -.macro user_alt, label, oldinstr, newinstr, cond
> > -9999:        alternative_insn "\oldinstr", "\newinstr", \cond
> > -     _asm_extable 9999b, \label
> > +.macro user_alt, oldinstr, newinstr, cond, label
> > +.Lextable_\@:
> > +     alternative_insn "\oldinstr", "\newinstr", \cond
> > +     .ifnc \label,
> > +     _asm_extable .Lextable_\@, \label
> > +     .endif
> >  .endm
>
> We can use _cond_extable here to simplify this to:
>
> | .macro user_alt, oldinstr, newinstr, cond, label
> | .Lextable_\@:
> |       alternative_insn "\oldinstr", "\newinstr", \cond
> |       _cond_extable .Lextable_\@, \label
> | .endm
>
> However, since we only use user_alt in __flush_icache_range /
> __flush_cache_user_range, I reckon it would be simpler overall to have
> those use alternative_insn and _cond_extable directly. Then that would
> align with the style of the *_by_line macros, and we could delete
> user_alt.

Thanks for this, and for the comments on the other patches in this
series. I'll rebase this series on rc3 when it comes out, apply your
suggestions, and send it out.

Cheers,
/fuad


>
> Either way, this looks good, so:
>
> Acked-by: Mark Rutland <mark.rutland at arm.com>
>
> >
> >  #endif  /*  __ASSEMBLY__  */
> > diff --git a/arch/arm64/mm/cache.S b/arch/arm64/mm/cache.S
> > index 2d881f34dd9d..5ff8dfa86975 100644
> > --- a/arch/arm64/mm/cache.S
> > +++ b/arch/arm64/mm/cache.S
> > @@ -47,7 +47,7 @@ alternative_else_nop_endif
> >       sub     x3, x2, #1
> >       bic     x4, x0, x3
> >  1:
> > -user_alt 9f, "dc cvau, x4",  "dc civac, x4",  ARM64_WORKAROUND_CLEAN_CACHE
> > +user_alt "dc cvau, x4",  "dc civac, x4",  ARM64_WORKAROUND_CLEAN_CACHE, 9f
> >       add     x4, x4, x2
> >       cmp     x4, x1
> >       b.lo    1b
> > --
> > 2.31.1.751.gd2f1c929bd-goog
> >



More information about the linux-arm-kernel mailing list