diff mbox series

[v2] arm64/alternatives: move length validation inside the subsection

Message ID 20200730153701.3892953-1-samitolvanen@google.com (mailing list archive)
State Mainlined
Commit 966a0acce2fca776391823381dba95c40e03c339
Headers show
Series [v2] arm64/alternatives: move length validation inside the subsection | expand

Commit Message

Sami Tolvanen July 30, 2020, 3:37 p.m. UTC
Commit f7b93d42945c ("arm64/alternatives: use subsections for replacement
sequences") breaks LLVM's integrated assembler, because due to its
one-pass design, it cannot compute instruction sequence lengths before the
layout for the subsection has been finalized. This change fixes the build
by moving the .org directives inside the subsection, so they are processed
after the subsection layout is known.

Link: https://github.com/ClangBuiltLinux/linux/issues/1078
Fixes: f7b93d42945c ("arm64/alternatives: use subsections for replacement sequences")
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
v1 -> v2:
- Added the missing Fixes tag and dropped CC: stable@.

---
 arch/arm64/include/asm/alternative.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


base-commit: 83bdc7275e6206f560d247be856bceba3e1ed8f2

Comments

Will Deacon July 30, 2020, 4:52 p.m. UTC | #1
On Thu, 30 Jul 2020 08:37:01 -0700, Sami Tolvanen wrote:
> Commit f7b93d42945c ("arm64/alternatives: use subsections for replacement
> sequences") breaks LLVM's integrated assembler, because due to its
> one-pass design, it cannot compute instruction sequence lengths before the
> layout for the subsection has been finalized. This change fixes the build
> by moving the .org directives inside the subsection, so they are processed
> after the subsection layout is known.

Applied to arm64 (for-next/fixes), thanks!

[1/1] arm64/alternatives: move length validation inside the subsection
      https://git.kernel.org/arm64/c/966a0acce2fc

Cheers,
Nathan Chancellor July 30, 2020, 4:57 p.m. UTC | #2
On Thu, Jul 30, 2020 at 08:37:01AM -0700, 'Sami Tolvanen' via Clang Built Linux wrote:
> Commit f7b93d42945c ("arm64/alternatives: use subsections for replacement
> sequences") breaks LLVM's integrated assembler, because due to its
> one-pass design, it cannot compute instruction sequence lengths before the
> layout for the subsection has been finalized. This change fixes the build
> by moving the .org directives inside the subsection, so they are processed
> after the subsection layout is known.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/1078
> Fixes: f7b93d42945c ("arm64/alternatives: use subsections for replacement sequences")
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> ---
> v1 -> v2:
> - Added the missing Fixes tag and dropped CC: stable@.

I think that the cc to stable should have been kept even with the
addition of the fixes tag. AUTOSEL will still most likely pick this up
(or even Chrome OS's patch bot that they now have) but the cc to stable
would have made it clear that we do need it there and the fixes tag
would have guided how far back it should go (rather than an explicit
version that is added).

Something for the future I supppose.

Cheers,
Nathan
Catalin Marinas July 30, 2020, 5:24 p.m. UTC | #3
On Thu, Jul 30, 2020 at 08:37:01AM -0700, Sami Tolvanen wrote:
> Commit f7b93d42945c ("arm64/alternatives: use subsections for replacement
> sequences") breaks LLVM's integrated assembler, because due to its
> one-pass design, it cannot compute instruction sequence lengths before the
> layout for the subsection has been finalized. This change fixes the build
> by moving the .org directives inside the subsection, so they are processed
> after the subsection layout is known.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/1078
> Fixes: f7b93d42945c ("arm64/alternatives: use subsections for replacement sequences")
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> ---
> v1 -> v2:
> - Added the missing Fixes tag and dropped CC: stable@.
> 
> ---
>  arch/arm64/include/asm/alternative.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
> index 12f0eb56a1cc..619db9b4c9d5 100644
> --- a/arch/arm64/include/asm/alternative.h
> +++ b/arch/arm64/include/asm/alternative.h
> @@ -77,9 +77,9 @@ static inline void apply_alternatives_module(void *start, size_t length) { }
>  	"663:\n\t"							\
>  	newinstr "\n"							\
>  	"664:\n\t"							\
> -	".previous\n\t"							\
>  	".org	. - (664b-663b) + (662b-661b)\n\t"			\
> -	".org	. - (662b-661b) + (664b-663b)\n"			\
> +	".org	. - (662b-661b) + (664b-663b)\n\t"			\
> +	".previous\n"							\
>  	".endif\n"

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

There are a few instances of the .org test outside the subsection,
though using in .S files. Are those ok?
Sami Tolvanen July 30, 2020, 5:34 p.m. UTC | #4
On Thu, Jul 30, 2020 at 10:24 AM Catalin Marinas
<catalin.marinas@arm.com> wrote:
>
> On Thu, Jul 30, 2020 at 08:37:01AM -0700, Sami Tolvanen wrote:
> > Commit f7b93d42945c ("arm64/alternatives: use subsections for replacement
> > sequences") breaks LLVM's integrated assembler, because due to its
> > one-pass design, it cannot compute instruction sequence lengths before the
> > layout for the subsection has been finalized. This change fixes the build
> > by moving the .org directives inside the subsection, so they are processed
> > after the subsection layout is known.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1078
> > Fixes: f7b93d42945c ("arm64/alternatives: use subsections for replacement sequences")
> > Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> > ---
> > v1 -> v2:
> > - Added the missing Fixes tag and dropped CC: stable@.
> >
> > ---
> >  arch/arm64/include/asm/alternative.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
> > index 12f0eb56a1cc..619db9b4c9d5 100644
> > --- a/arch/arm64/include/asm/alternative.h
> > +++ b/arch/arm64/include/asm/alternative.h
> > @@ -77,9 +77,9 @@ static inline void apply_alternatives_module(void *start, size_t length) { }
> >       "663:\n\t"                                                      \
> >       newinstr "\n"                                                   \
> >       "664:\n\t"                                                      \
> > -     ".previous\n\t"                                                 \
> >       ".org   . - (664b-663b) + (662b-661b)\n\t"                      \
> > -     ".org   . - (662b-661b) + (664b-663b)\n"                        \
> > +     ".org   . - (662b-661b) + (664b-663b)\n\t"                      \
> > +     ".previous\n"                                                   \
> >       ".endif\n"
>
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>
>
> There are a few instances of the .org test outside the subsection,
> though using in .S files. Are those ok?

Yes, this only appears to be a problem when used in inline assembly.

Sami
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
index 12f0eb56a1cc..619db9b4c9d5 100644
--- a/arch/arm64/include/asm/alternative.h
+++ b/arch/arm64/include/asm/alternative.h
@@ -77,9 +77,9 @@  static inline void apply_alternatives_module(void *start, size_t length) { }
 	"663:\n\t"							\
 	newinstr "\n"							\
 	"664:\n\t"							\
-	".previous\n\t"							\
 	".org	. - (664b-663b) + (662b-661b)\n\t"			\
-	".org	. - (662b-661b) + (664b-663b)\n"			\
+	".org	. - (662b-661b) + (664b-663b)\n\t"			\
+	".previous\n"							\
 	".endif\n"
 
 #define __ALTERNATIVE_CFG_CB(oldinstr, feature, cfg_enabled, cb)	\