]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-3.18/arm-8833-1-ensure-that-neon-code-always-compiles-wit.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / queue-3.18 / arm-8833-1-ensure-that-neon-code-always-compiles-wit.patch
1 From ffb91ff7e5711dfd82ea69cba1744a9041acae2b Mon Sep 17 00:00:00 2001
2 From: Nathan Chancellor <natechancellor@gmail.com>
3 Date: Sat, 2 Feb 2019 03:34:36 +0100
4 Subject: ARM: 8833/1: Ensure that NEON code always compiles with Clang
5
6 [ Upstream commit de9c0d49d85dc563549972edc5589d195cd5e859 ]
7
8 While building arm32 allyesconfig, I ran into the following errors:
9
10 arch/arm/lib/xor-neon.c:17:2: error: You should compile this file with
11 '-mfloat-abi=softfp -mfpu=neon'
12
13 In file included from lib/raid6/neon1.c:27:
14 /home/nathan/cbl/prebuilt/lib/clang/8.0.0/include/arm_neon.h:28:2:
15 error: "NEON support not enabled"
16
17 Building V=1 showed NEON_FLAGS getting passed along to Clang but
18 __ARM_NEON__ was not getting defined. Ultimately, it boils down to Clang
19 only defining __ARM_NEON__ when targeting armv7, rather than armv6k,
20 which is the '-march' value for allyesconfig.
21
22 >From lib/Basic/Targets/ARM.cpp in the Clang source:
23
24 // This only gets set when Neon instructions are actually available, unlike
25 // the VFP define, hence the soft float and arch check. This is subtly
26 // different from gcc, we follow the intent which was that it should be set
27 // when Neon instructions are actually available.
28 if ((FPU & NeonFPU) && !SoftFloat && ArchVersion >= 7) {
29 Builder.defineMacro("__ARM_NEON", "1");
30 Builder.defineMacro("__ARM_NEON__");
31 // current AArch32 NEON implementations do not support double-precision
32 // floating-point even when it is present in VFP.
33 Builder.defineMacro("__ARM_NEON_FP",
34 "0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP));
35 }
36
37 Ard Biesheuvel recommended explicitly adding '-march=armv7-a' at the
38 beginning of the NEON_FLAGS definitions so that __ARM_NEON__ always gets
39 definined by Clang. This doesn't functionally change anything because
40 that code will only run where NEON is supported, which is implicitly
41 armv7.
42
43 Link: https://github.com/ClangBuiltLinux/linux/issues/287
44
45 Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
46 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
47 Acked-by: Nicolas Pitre <nico@linaro.org>
48 Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
49 Reviewed-by: Stefan Agner <stefan@agner.ch>
50 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
51 Signed-off-by: Sasha Levin <sashal@kernel.org>
52 ---
53 Documentation/arm/kernel_mode_neon.txt | 4 ++--
54 arch/arm/lib/Makefile | 2 +-
55 arch/arm/lib/xor-neon.c | 2 +-
56 lib/raid6/Makefile | 2 +-
57 4 files changed, 5 insertions(+), 5 deletions(-)
58
59 diff --git a/Documentation/arm/kernel_mode_neon.txt b/Documentation/arm/kernel_mode_neon.txt
60 index 525452726d31..b9e060c5b61e 100644
61 --- a/Documentation/arm/kernel_mode_neon.txt
62 +++ b/Documentation/arm/kernel_mode_neon.txt
63 @@ -6,7 +6,7 @@ TL;DR summary
64 * Use only NEON instructions, or VFP instructions that don't rely on support
65 code
66 * Isolate your NEON code in a separate compilation unit, and compile it with
67 - '-mfpu=neon -mfloat-abi=softfp'
68 + '-march=armv7-a -mfpu=neon -mfloat-abi=softfp'
69 * Put kernel_neon_begin() and kernel_neon_end() calls around the calls into your
70 NEON code
71 * Don't sleep in your NEON code, and be aware that it will be executed with
72 @@ -87,7 +87,7 @@ instructions appearing in unexpected places if no special care is taken.
73 Therefore, the recommended and only supported way of using NEON/VFP in the
74 kernel is by adhering to the following rules:
75 * isolate the NEON code in a separate compilation unit and compile it with
76 - '-mfpu=neon -mfloat-abi=softfp';
77 + '-march=armv7-a -mfpu=neon -mfloat-abi=softfp';
78 * issue the calls to kernel_neon_begin(), kernel_neon_end() as well as the calls
79 into the unit containing the NEON code from a compilation unit which is *not*
80 built with the GCC flag '-mfpu=neon' set.
81 diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
82 index 0573faab96ad..830b2ddcc346 100644
83 --- a/arch/arm/lib/Makefile
84 +++ b/arch/arm/lib/Makefile
85 @@ -46,7 +46,7 @@ $(obj)/csumpartialcopy.o: $(obj)/csumpartialcopygeneric.S
86 $(obj)/csumpartialcopyuser.o: $(obj)/csumpartialcopygeneric.S
87
88 ifeq ($(CONFIG_KERNEL_MODE_NEON),y)
89 - NEON_FLAGS := -mfloat-abi=softfp -mfpu=neon
90 + NEON_FLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon
91 CFLAGS_xor-neon.o += $(NEON_FLAGS)
92 obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o
93 endif
94 diff --git a/arch/arm/lib/xor-neon.c b/arch/arm/lib/xor-neon.c
95 index 2c40aeab3eaa..c691b901092f 100644
96 --- a/arch/arm/lib/xor-neon.c
97 +++ b/arch/arm/lib/xor-neon.c
98 @@ -14,7 +14,7 @@
99 MODULE_LICENSE("GPL");
100
101 #ifndef __ARM_NEON__
102 -#error You should compile this file with '-mfloat-abi=softfp -mfpu=neon'
103 +#error You should compile this file with '-march=armv7-a -mfloat-abi=softfp -mfpu=neon'
104 #endif
105
106 /*
107 diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile
108 index c7dab0645554..1c3330dc5eab 100644
109 --- a/lib/raid6/Makefile
110 +++ b/lib/raid6/Makefile
111 @@ -23,7 +23,7 @@ endif
112 ifeq ($(CONFIG_KERNEL_MODE_NEON),y)
113 NEON_FLAGS := -ffreestanding
114 ifeq ($(ARCH),arm)
115 -NEON_FLAGS += -mfloat-abi=softfp -mfpu=neon
116 +NEON_FLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=neon
117 endif
118 ifeq ($(ARCH),arm64)
119 CFLAGS_REMOVE_neon1.o += -mgeneral-regs-only
120 --
121 2.19.1
122