Skip to content

Commit 1764c3e

Browse files
samitolvanenctmarinas
authored andcommitted
arm64: use a common .arch preamble for inline assembly
Commit 7c78f67 ("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: 7c78f67 ("arm64: enable tlbi range instructions") Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Tested-by: Nathan Chancellor <natechancellor@gmail.com> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> Link: ClangBuiltLinux/linux#1106 Link: https://lore.kernel.org/r/20200827203608.1225689-1-samitolvanen@google.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent d012a71 commit 1764c3e

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎arch/arm64/Makefile‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,21 @@ endif
8282
# compiler to generate them and consequently to break the single image contract
8383
# we pass it only to the assembler. This option is utilized only in case of non
8484
# integrated assemblers.
85-
ifneq ($(CONFIG_AS_HAS_ARMV8_4), y)
86-
branch-prot-flags-$(CONFIG_AS_HAS_PAC) += -Wa,-march=armv8.3-a
85+
ifeq ($(CONFIG_AS_HAS_PAC), y)
86+
asm-arch := armv8.3-a
8787
endif
8888
endif
8989

9090
KBUILD_CFLAGS += $(branch-prot-flags-y)
9191

9292
ifeq ($(CONFIG_AS_HAS_ARMV8_4), y)
9393
# make sure to pass the newest target architecture to -march.
94-
KBUILD_CFLAGS += -Wa,-march=armv8.4-a
94+
asm-arch := armv8.4-a
95+
endif
96+
97+
ifdef asm-arch
98+
KBUILD_CFLAGS += -Wa,-march=$(asm-arch) \
99+
-DARM64_ASM_ARCH='"$(asm-arch)"'
95100
endif
96101

97102
ifeq ($(CONFIG_SHADOW_CALL_STACK), y)

‎arch/arm64/include/asm/compiler.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
#ifndef __ASM_COMPILER_H
33
#define __ASM_COMPILER_H
44

5+
#ifdef ARM64_ASM_ARCH
6+
#define ARM64_ASM_PREAMBLE ".arch " ARM64_ASM_ARCH "\n"
7+
#else
8+
#define ARM64_ASM_PREAMBLE
9+
#endif
10+
511
/*
612
* The EL0/EL1 pointer bits used by a pointer authentication code.
713
* This is dependent on TBI0/TBI1 being enabled, or bits 63:56 would also apply.

‎arch/arm64/include/asm/tlbflush.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@
2828
* not. The macros handles invoking the asm with or without the
2929
* register argument as appropriate.
3030
*/
31-
#define __TLBI_0(op, arg) asm ("tlbi " #op "\n" \
31+
#define __TLBI_0(op, arg) asm (ARM64_ASM_PREAMBLE \
32+
"tlbi " #op "\n" \
3233
ALTERNATIVE("nop\n nop", \
3334
"dsb ish\n tlbi " #op, \
3435
ARM64_WORKAROUND_REPEAT_TLBI, \
3536
CONFIG_ARM64_WORKAROUND_REPEAT_TLBI) \
3637
: : )
3738

38-
#define __TLBI_1(op, arg) asm ("tlbi " #op ", %0\n" \
39+
#define __TLBI_1(op, arg) asm (ARM64_ASM_PREAMBLE \
40+
"tlbi " #op ", %0\n" \
3941
ALTERNATIVE("nop\n nop", \
4042
"dsb ish\n tlbi " #op ", %0", \
4143
ARM64_WORKAROUND_REPEAT_TLBI, \

0 commit comments

Comments
 (0)