1
- From e6676062c603d696e70b06041580c62ca364fd18 Mon Sep 17 00:00:00 2001
1
+ From ee0b6f5504052a34cc38d68014d7234dc608f2e0 Mon Sep 17 00:00:00 2001
2
2
From: Nathan Chancellor <
[email protected] >
3
3
Date: Sat, 5 Jan 2019 11:51:39 -0700
4
4
Subject: [PATCH 1/2] DO-NOT-UPSTREAM: x86: Revert two commits that break the
@@ -10,14 +10,17 @@ Subject: [PATCH 1/2] DO-NOT-UPSTREAM: x86: Revert two commits that break the
10
10
We've been fortunate enough to get around the asm goto requirement
11
11
introduced in commit e501ce957a78 ("x86: Force asm-goto") until now.
12
12
13
+ This is not a clean revert because of commit 2a418cf3f5f1 ("x86/uaccess:
14
+ Don't leak the AC flag into __put_user() value evaluation").
15
+
13
16
Link: https://github.com/ClangBuiltLinux/linux/issues/6
14
17
Signed-off-by: Nathan Chancellor <
[email protected] >
15
18
---
16
- arch/x86/include/asm/uaccess.h | 81 ++++++++++++++++++ ----------------
17
- 1 file changed, 42 insertions(+), 39 deletions(-)
19
+ arch/x86/include/asm/uaccess.h | 80 +++++++++++++++++- ----------------
20
+ 1 file changed, 41 insertions(+), 39 deletions(-)
18
21
19
22
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
20
- index 780f2b42c8ef..122e42319acc 100644
23
+ index c1334aaaa78d..27c48c8fa8e9 100644
21
24
--- a/arch/x86/include/asm/uaccess.h
22
25
+++ b/arch/x86/include/asm/uaccess.h
23
26
@@ -186,14 +186,19 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
@@ -59,7 +62,7 @@ index 780f2b42c8ef..122e42319acc 100644
59
62
#define __put_user_asm_ex_u64(x, addr) \
60
63
__put_user_asm_ex(x, addr, "q", "", "er")
61
64
#define __put_user_x8(x, ptr, __ret_pu) __put_user_x(8, x, ptr, __ret_pu)
62
- @@ -270,21 +275,23 @@ extern void __put_user_8(void);
65
+ @@ -270,21 +275,22 @@ extern void __put_user_8(void);
63
66
__builtin_expect(__ret_pu, 0); \
64
67
})
65
68
@@ -82,28 +85,29 @@ index 780f2b42c8ef..122e42319acc 100644
82
85
+ __put_user_asm(x, ptr, retval, "l", "k", "ir", errret); \
83
86
break; \
84
87
case 8: \
85
- - __put_user_goto_u64((__typeof__(*ptr))(x), ptr, label); \
86
- + __put_user_asm_u64((__typeof__(*ptr))(x), ptr, retval, \
87
- + errret); \
88
+ - __put_user_goto_u64(x, ptr, label); \
89
+ + __put_user_asm_u64(x, ptr, retval, errret); \
88
90
break; \
89
91
default: \
90
92
__put_user_bad(); \
91
- @@ -429,12 +436,9 @@ do { \
93
+ @@ -429,14 +435,11 @@ do { \
92
94
93
95
#define __put_user_nocheck(x, ptr, size) \
94
96
({ \
95
97
- __label__ __pu_label; \
96
98
- int __pu_err = -EFAULT; \
97
99
+ int __pu_err; \
100
+ __typeof__(*(ptr)) __pu_val; \
101
+ __pu_val = x; \
98
102
__uaccess_begin(); \
99
- - __put_user_size((x) , (ptr), (size), __pu_label); \
103
+ - __put_user_size(__pu_val , (ptr), (size), __pu_label); \
100
104
- __pu_err = 0; \
101
105
- __pu_label: \
102
- + __put_user_size((x) , (ptr), (size), __pu_err, -EFAULT); \
106
+ + __put_user_size(__pu_val , (ptr), (size), __pu_err, -EFAULT); \
103
107
__uaccess_end(); \
104
108
__builtin_expect(__pu_err, 0); \
105
109
})
106
- @@ -459 ,23 +463 ,17 @@ struct __large_struct { unsigned long buf[100]; };
110
+ @@ -461 ,23 +464 ,17 @@ struct __large_struct { unsigned long buf[100]; };
107
111
* we do not write to any memory gcc knows about, so there are no
108
112
* aliasing issues.
109
113
*/
@@ -138,7 +142,7 @@ index 780f2b42c8ef..122e42319acc 100644
138
142
139
143
#define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
140
144
asm volatile("1: mov"itype" %"rtype"0,%1\n" \
141
- @@ -717 ,8 +715 ,13 @@ static __must_check inline bool user_access_begin(const void __user *ptr, size_t
145
+ @@ -719 ,8 +716 ,13 @@ static __must_check inline bool user_access_begin(const void __user *ptr, size_t
142
146
#define user_access_begin(a,b) user_access_begin(a,b)
143
147
#define user_access_end() __uaccess_end()
144
148
@@ -155,88 +159,5 @@ index 780f2b42c8ef..122e42319acc 100644
155
159
#define unsafe_get_user(x, ptr, err_label) \
156
160
do { \
157
161
- -
158
- 2.20.1
159
-
160
-
161
- From ebbb36f656831313b8ef5d75e864a0ab8bc83bc9 Mon Sep 17 00:00:00 2001
162
- From: Nathan Chancellor <
[email protected] >
163
- Date: Tue, 25 Sep 2018 13:32:33 -0700
164
- Subject: [PATCH 2/2] DO-NOT-UPSTREAM: x86: Avoid warnings/errors due to lack
165
- of asm goto
166
-
167
- We don't want to see an inordinate amount of warning spam from
168
- the BPF samples and after reverting commits 4a789213c9a5 ("x86
169
- uaccess: Introduce __put_user_goto") and a959dc88f9c8 ("Use
170
- __put_user_goto in __put_user_size() and unsafe_put_user()"), we
171
- can successfully compile an x86 kernel with Clang.
172
-
173
- This is obviously not a long term solution. LLVM/Clang support for
174
- asm goto can be tracked at the below link.
175
-
176
- Link: https://github.com/ClangBuiltLinux/linux/issues/6
177
- Signed-off-by: Nathan Chancellor <
[email protected] >
178
- ---
179
- arch/x86/Makefile | 9 +++++----
180
- arch/x86/boot/compressed/Makefile | 3 +++
181
- drivers/firmware/efi/libstub/Makefile | 4 ++++
182
- 3 files changed, 12 insertions(+), 4 deletions(-)
183
-
184
- diff --git a/arch/x86/Makefile b/arch/x86/Makefile
185
- index 9c5a67d1b9c1..95baa56c2de0 100644
186
- --- a/arch/x86/Makefile
187
- +++ b/arch/x86/Makefile
188
- @@ -219,6 +219,11 @@ ifdef CONFIG_RETPOLINE
189
- KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
190
- endif
191
-
192
- + # Avoid warnings in arch/x86/include/asm/cpufeature.h when building with Clang
193
- + ifndef CONFIG_CC_HAS_ASM_GOTO
194
- + KBUILD_CFLAGS += -D__BPF_TRACING__
195
- + endif
196
- +
197
- archscripts: scripts_basic
198
- $(Q)$(MAKE) $(build)=arch/x86/tools relocs
199
-
200
- @@ -289,10 +294,6 @@ vdso_install:
201
-
202
- archprepare: checkbin
203
- checkbin:
204
- - ifndef CONFIG_CC_HAS_ASM_GOTO
205
- - @echo Compiler lacks asm-goto support.
206
- - @exit 1
207
- - endif
208
- ifdef CONFIG_RETPOLINE
209
- ifeq ($(RETPOLINE_CFLAGS),)
210
- @echo "You are building kernel with non-retpoline compiler." >&2
211
- diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
212
- index f0515ac895a4..24cca31995ae 100644
213
- --- a/arch/x86/boot/compressed/Makefile
214
- +++ b/arch/x86/boot/compressed/Makefile
215
- @@ -38,6 +38,9 @@ KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
216
- KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
217
- KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
218
- KBUILD_CFLAGS += -Wno-pointer-sign
219
- + ifndef CONFIG_CC_HAS_ASM_GOTO
220
- + KBUILD_CFLAGS += -D__BPF_TRACING__
221
- + endif
222
-
223
- KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
224
- GCOV_PROFILE := n
225
- diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
226
- index d9845099635e..68ff33dc075d 100644
227
- --- a/drivers/firmware/efi/libstub/Makefile
228
- +++ b/drivers/firmware/efi/libstub/Makefile
229
- @@ -24,6 +24,10 @@ cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \
230
-
231
- cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt
232
-
233
- + ifndef CONFIG_CC_HAS_ASM_GOTO
234
- + cflags-$(CONFIG_X86) += -D__BPF_TRACING__
235
- + endif
236
- +
237
- KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \
238
- -D__NO_FORTIFY \
239
- $(call cc-option,-ffreestanding) \
240
- - -
241
- 2.20.1
162
+ 2.21.0
242
163
0 commit comments