From: Nathan Chancellor <natechancellor@gmail.com>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Kees Cook <keescook@chromium.org>,
Zhenyu Ye <yezhenyu2@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com,
Marc Zyngier <maz@kernel.org>, Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] arm64: use a common .arch preamble for inline assembly
Date: Thu, 27 Aug 2020 13:57:20 -0700 [thread overview]
Message-ID: <20200827205720.GA987541@ubuntu-n2-xlarge-x86> (raw)
In-Reply-To: <20200827203608.1225689-1-samitolvanen@google.com>
On Thu, Aug 27, 2020 at 01:36:08PM -0700, Sami Tolvanen wrote:
> Commit 7c78f67e9bd9 ("arm64: enable tlbi range instructions") breaks
> LLVM's integrated assembler, because -Wa,-march is only passed to
> external assemblers and therefore, the new instructions are not enabled
> when IAS is used.
>
> This change adds a common architecture version preamble, which can be
> used in inline assembly blocks that contain instructions that require
> a newer architecture version, and uses it to fix __TLBI_0 and __TLBI_1
> with ARM64_TLB_RANGE.
>
> Fixes: 7c78f67e9bd9 ("arm64: enable tlbi range instructions")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1106
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
I have verified that this fixes the build with LLVM_IAS=1. Additionally,
I have booted a kernel with this patch on my Raspberry Pi and saw no
adverse affects through a compilation workload.
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> Changes in v2:
> - Switched to a standard preamble for the architecture version.
>
> ---
> arch/arm64/Makefile | 11 ++++++++---
> arch/arm64/include/asm/compiler.h | 6 ++++++
> arch/arm64/include/asm/tlbflush.h | 6 ++++--
> 3 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index b45f0124cc16..20ab5c9375a5 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -82,8 +82,8 @@ endif
> # compiler to generate them and consequently to break the single image contract
> # we pass it only to the assembler. This option is utilized only in case of non
> # integrated assemblers.
> -ifneq ($(CONFIG_AS_HAS_ARMV8_4), y)
> -branch-prot-flags-$(CONFIG_AS_HAS_PAC) += -Wa,-march=armv8.3-a
> +ifeq ($(CONFIG_AS_HAS_PAC), y)
> +asm-arch := armv8.3-a
> endif
> endif
>
> @@ -91,7 +91,12 @@ KBUILD_CFLAGS += $(branch-prot-flags-y)
>
> ifeq ($(CONFIG_AS_HAS_ARMV8_4), y)
> # make sure to pass the newest target architecture to -march.
> -KBUILD_CFLAGS += -Wa,-march=armv8.4-a
> +asm-arch := armv8.4-a
> +endif
> +
> +ifdef asm-arch
> +KBUILD_CFLAGS += -Wa,-march=$(asm-arch) \
> + -DARM64_ASM_ARCH='"$(asm-arch)"'
> endif
>
> ifeq ($(CONFIG_SHADOW_CALL_STACK), y)
> diff --git a/arch/arm64/include/asm/compiler.h b/arch/arm64/include/asm/compiler.h
> index 51a7ce87cdfe..6fb2e6bcc392 100644
> --- a/arch/arm64/include/asm/compiler.h
> +++ b/arch/arm64/include/asm/compiler.h
> @@ -2,6 +2,12 @@
> #ifndef __ASM_COMPILER_H
> #define __ASM_COMPILER_H
>
> +#ifdef ARM64_ASM_ARCH
> +#define ARM64_ASM_PREAMBLE ".arch " ARM64_ASM_ARCH "\n"
> +#else
> +#define ARM64_ASM_PREAMBLE
> +#endif
> +
> /*
> * The EL0/EL1 pointer bits used by a pointer authentication code.
> * This is dependent on TBI0/TBI1 being enabled, or bits 63:56 would also apply.
> diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
> index d493174415db..cc3f5a33ff9c 100644
> --- a/arch/arm64/include/asm/tlbflush.h
> +++ b/arch/arm64/include/asm/tlbflush.h
> @@ -28,14 +28,16 @@
> * not. The macros handles invoking the asm with or without the
> * register argument as appropriate.
> */
> -#define __TLBI_0(op, arg) asm ("tlbi " #op "\n" \
> +#define __TLBI_0(op, arg) asm (ARM64_ASM_PREAMBLE \
> + "tlbi " #op "\n" \
> ALTERNATIVE("nop\n nop", \
> "dsb ish\n tlbi " #op, \
> ARM64_WORKAROUND_REPEAT_TLBI, \
> CONFIG_ARM64_WORKAROUND_REPEAT_TLBI) \
> : : )
>
> -#define __TLBI_1(op, arg) asm ("tlbi " #op ", %0\n" \
> +#define __TLBI_1(op, arg) asm (ARM64_ASM_PREAMBLE \
> + "tlbi " #op ", %0\n" \
> ALTERNATIVE("nop\n nop", \
> "dsb ish\n tlbi " #op ", %0", \
> ARM64_WORKAROUND_REPEAT_TLBI, \
>
> base-commit: 15bc20c6af4ceee97a1f90b43c0e386643c071b4
> --
> 2.28.0.297.g1956fa8f8d-goog
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2020-08-27 20:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-05 18:19 [PATCH] arm64: tlb: fix ARM64_TLB_RANGE with LLVM's integrated assembler Sami Tolvanen
2020-08-05 19:15 ` Nick Desaulniers
2020-08-06 11:30 ` Catalin Marinas
2020-08-06 7:17 ` Zhenyu Ye
2020-08-06 11:33 ` Catalin Marinas
2020-08-06 12:01 ` Catalin Marinas
2020-08-06 19:17 ` Sami Tolvanen
2020-08-27 20:36 ` [PATCH v2] arm64: use a common .arch preamble for inline assembly Sami Tolvanen
2020-08-27 20:57 ` Nathan Chancellor [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200827205720.GA987541@ubuntu-n2-xlarge-x86 \
--to=natechancellor@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=clang-built-linux@googlegroups.com \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=ndesaulniers@google.com \
--cc=samitolvanen@google.com \
--cc=will@kernel.org \
--cc=yezhenyu2@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).