2020-07-29 21:54:51

by Sami Tolvanen

[permalink] [raw]
Subject: [PATCH] arm64/alternatives: move length validation inside the subsection

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
Cc: <[email protected]> # 4.14+
Signed-off-by: Sami Tolvanen <[email protected]>
---
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"

#define __ALTERNATIVE_CFG_CB(oldinstr, feature, cfg_enabled, cb) \

base-commit: 6ba1b005ffc388c2aeaddae20da29e4810dea298
--
2.28.0.163.g6104cc2f0b6-goog


2020-07-30 12:23:02

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH] arm64/alternatives: move length validation inside the subsection

On Wed, Jul 29, 2020 at 02:51:52PM -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
> Cc: <[email protected]> # 4.14+

Commit f7b93d42945c went in 5.8-rc4. Why is this cc stable from 4.14? If
Will picks it up for 5.8, it doesn't even need a cc stable.

Please add a Fixes: tag as well.

--
Catalin

2020-07-30 15:13:51

by Sami Tolvanen

[permalink] [raw]
Subject: Re: [PATCH] arm64/alternatives: move length validation inside the subsection

On Thu, Jul 30, 2020 at 5:22 AM Catalin Marinas <[email protected]> wrote:
>
> On Wed, Jul 29, 2020 at 02:51:52PM -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
> > Cc: <[email protected]> # 4.14+
>
> Commit f7b93d42945c went in 5.8-rc4. Why is this cc stable from 4.14? If
> Will picks it up for 5.8, it doesn't even need a cc stable.

Greg or Sasha can probably answer why, but this patch is in 4.14.189,
4.19.134, 5.4.53, and 5.7.10, which ended up breaking some downstream
Android kernel builds.

> Please add a Fixes: tag as well.

Sure, I'll send v2 shortly with the tag. Thanks.

Sami

2020-07-30 15:25:14

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH] arm64/alternatives: move length validation inside the subsection

On Thu, Jul 30, 2020 at 08:13:05AM -0700, Sami Tolvanen wrote:
> On Thu, Jul 30, 2020 at 5:22 AM Catalin Marinas <[email protected]> wrote:
> >
> > On Wed, Jul 29, 2020 at 02:51:52PM -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
> > > Cc: <[email protected]> # 4.14+
> >
> > Commit f7b93d42945c went in 5.8-rc4. Why is this cc stable from 4.14? If
> > Will picks it up for 5.8, it doesn't even need a cc stable.
>
> Greg or Sasha can probably answer why, but this patch is in 4.14.189,
> 4.19.134, 5.4.53, and 5.7.10, which ended up breaking some downstream
> Android kernel builds.

I see but I don't think we need the explicit cc stable for 4.14. That's
why the Fixes tag is important. If a patch was back-ported, the
subsequent fixes should be picked by the stable maintainers as well.

--
Catalin

2020-07-30 15:39:55

by Sami Tolvanen

[permalink] [raw]
Subject: [PATCH v2] arm64/alternatives: move length validation inside the subsection

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 <[email protected]>
---
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"

#define __ALTERNATIVE_CFG_CB(oldinstr, feature, cfg_enabled, cb) \

base-commit: 83bdc7275e6206f560d247be856bceba3e1ed8f2
--
2.28.0.163.g6104cc2f0b6-goog

2020-07-30 16:53:20

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH v2] arm64/alternatives: move length validation inside the subsection

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,
--
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

2020-07-30 16:58:43

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH v2] arm64/alternatives: move length validation inside the subsection

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 <[email protected]>
> ---
> 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

2020-07-30 17:25:21

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH v2] arm64/alternatives: move length validation inside the subsection

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 <[email protected]>
> ---
> 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 <[email protected]>

There are a few instances of the .org test outside the subsection,
though using in .S files. Are those ok?

--
Catalin

2020-07-30 17:35:09

by Sami Tolvanen

[permalink] [raw]
Subject: Re: [PATCH v2] arm64/alternatives: move length validation inside the subsection

On Thu, Jul 30, 2020 at 10:24 AM Catalin Marinas
<[email protected]> 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 <[email protected]>
> > ---
> > 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 <[email protected]>
>
> 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

2020-07-31 06:50:07

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] arm64/alternatives: move length validation inside the subsection

On Thu, Jul 30, 2020 at 04:23:31PM +0100, Catalin Marinas wrote:
> On Thu, Jul 30, 2020 at 08:13:05AM -0700, Sami Tolvanen wrote:
> > On Thu, Jul 30, 2020 at 5:22 AM Catalin Marinas <[email protected]> wrote:
> > >
> > > On Wed, Jul 29, 2020 at 02:51:52PM -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
> > > > Cc: <[email protected]> # 4.14+
> > >
> > > Commit f7b93d42945c went in 5.8-rc4. Why is this cc stable from 4.14? If
> > > Will picks it up for 5.8, it doesn't even need a cc stable.
> >
> > Greg or Sasha can probably answer why, but this patch is in 4.14.189,
> > 4.19.134, 5.4.53, and 5.7.10, which ended up breaking some downstream
> > Android kernel builds.
>
> I see but I don't think we need the explicit cc stable for 4.14. That's
> why the Fixes tag is important. If a patch was back-ported, the
> subsequent fixes should be picked by the stable maintainers as well.

If you know it ahead of time, the explict "# kernel.version" hint is
always nice to have as it ensures I will try to backport it that far,
and if I have problems, I will ask for help.

thanks,

greg k-h

2020-07-31 09:34:32

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH] arm64/alternatives: move length validation inside the subsection

On Fri, Jul 31, 2020 at 08:49:15AM +0200, Greg Kroah-Hartman wrote:
> On Thu, Jul 30, 2020 at 04:23:31PM +0100, Catalin Marinas wrote:
> > On Thu, Jul 30, 2020 at 08:13:05AM -0700, Sami Tolvanen wrote:
> > > On Thu, Jul 30, 2020 at 5:22 AM Catalin Marinas <[email protected]> wrote:
> > > >
> > > > On Wed, Jul 29, 2020 at 02:51:52PM -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
> > > > > Cc: <[email protected]> # 4.14+
> > > >
> > > > Commit f7b93d42945c went in 5.8-rc4. Why is this cc stable from 4.14? If
> > > > Will picks it up for 5.8, it doesn't even need a cc stable.
> > >
> > > Greg or Sasha can probably answer why, but this patch is in 4.14.189,
> > > 4.19.134, 5.4.53, and 5.7.10, which ended up breaking some downstream
> > > Android kernel builds.
> >
> > I see but I don't think we need the explicit cc stable for 4.14. That's
> > why the Fixes tag is important. If a patch was back-ported, the
> > subsequent fixes should be picked by the stable maintainers as well.
>
> If you know it ahead of time, the explict "# kernel.version" hint is
> always nice to have as it ensures I will try to backport it that far,
> and if I have problems, I will ask for help.

Good to know. Thanks for the clarification.

--
Catalin