[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABCJKueJjOguo7-PUR1yhZm4sX4F7t-7ZMcjU8pAMBQyv6Pmnw@mail.gmail.com>
Date: Wed, 14 Apr 2021 10:46:49 -0700
From: Sami Tolvanen <samitolvanen@...gle.com>
To: Nathan Chancellor <nathan@...nel.org>
Cc: Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Jian Cai <jiancai@...gle.com>,
linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
"# 3.4.x" <stable@...r.kernel.org>
Subject: Re: [PATCH] arm64: alternatives: Move length validation in alternative_{insn,endif}
Hi Nathan,
On Tue, Apr 13, 2021 at 5:09 PM Nathan Chancellor <nathan@...nel.org> wrote:
>
> After commit 2decad92f473 ("arm64: mte: Ensure TIF_MTE_ASYNC_FAULT is
> set atomically"), LLVM's integrated assembler fails to build entry.S:
>
> <instantiation>:5:7: error: expected assembly-time absolute expression
> .org . - (664b-663b) + (662b-661b)
> ^
> <instantiation>:6:7: error: expected assembly-time absolute expression
> .org . - (662b-661b) + (664b-663b)
> ^
>
> The root cause is LLVM's assembler has a one-pass design, meaning it
> cannot figure out these instruction lengths when the .org directive is
> outside of the subsection that they are in, which was changed by the
> .arch_extension directive added in the above commit.
>
> Apply the same fix from commit 966a0acce2fc ("arm64/alternatives: move
> length validation inside the subsection") to the alternative_endif
> macro, shuffling the .org directives so that the length validation
> happen will always happen in the same subsections. alternative_insn has
> not shown any issue yet but it appears that it could have the same issue
> in the future so just preemptively change it.
>
> Cc: stable@...r.kernel.org
> Fixes: f7b93d42945c ("arm64/alternatives: use subsections for replacement sequences")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1347
> Signed-off-by: Nathan Chancellor <nathan@...nel.org>
> ---
>
> Apologies if my explanation or terminology is off, I am only now getting
> more familiar with assembly.
>
> arch/arm64/include/asm/alternative-macros.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/include/asm/alternative-macros.h b/arch/arm64/include/asm/alternative-macros.h
> index 5df500dcc627..8a078fc662ac 100644
> --- a/arch/arm64/include/asm/alternative-macros.h
> +++ b/arch/arm64/include/asm/alternative-macros.h
> @@ -97,9 +97,9 @@
> .popsection
> .subsection 1
> 663: \insn2
> -664: .previous
> - .org . - (664b-663b) + (662b-661b)
> +664: .org . - (664b-663b) + (662b-661b)
> .org . - (662b-661b) + (664b-663b)
> + .previous
> .endif
> .endm
>
> @@ -169,11 +169,11 @@
> */
> .macro alternative_endif
> 664:
> + .org . - (664b-663b) + (662b-661b)
> + .org . - (662b-661b) + (664b-663b)
> .if .Lasm_alt_mode==0
> .previous
> .endif
> - .org . - (664b-663b) + (662b-661b)
> - .org . - (662b-661b) + (664b-663b)
> .endm
>
> /*
Thank you for fixing these!
The patch looks correct to me, next-20210413 builds with LLVM_IAS=1
after I applied it, and defconfig built with both Clang and gcc boots
normally. Please feel free to add:
Reviewed-by: Sami Tolvanen <samitolvanen@...gle.com>
Tested-by: Sami Tolvanen <samitolvanen@...gle.com>
Sami
Powered by blists - more mailing lists