Skip to content
This repository was archived by the owner on Apr 13, 2024. It is now read-only.

Commit 4ac3482

Browse files
Merge pull request #125 from nathanchance/x86-patch-update
patches: linux: x86_64: Update first patch for new conflicts
2 parents 8a28826 + b56ff43 commit 4ac3482

5 files changed

+183
-98
lines changed

patches/linux-next/x86_64

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../linux/x86_64/0001-DO-NOT-UPSTREAM-x86-Revert-two-commits-that-break-th.patch
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
From 85baf6f33eae98342d45032e1b20ef9c7cf74f20 Mon Sep 17 00:00:00 2001
2+
From: Nathan Chancellor <[email protected]>
3+
Date: Tue, 25 Sep 2018 13:32:33 -0700
4+
Subject: [PATCH 2/2] DO-NOT-UPSTREAM: x86: Avoid warnings/errors due to lack
5+
of asm goto
6+
7+
We don't want to see an inordinate amount of warning spam from
8+
the BPF samples and after reverting commits 4a789213c9a5 ("x86
9+
uaccess: Introduce __put_user_goto") and a959dc88f9c8 ("Use
10+
__put_user_goto in __put_user_size() and unsafe_put_user()"), we
11+
can successfully compile an x86 kernel with Clang.
12+
13+
This is obviously not a long term solution. LLVM/Clang support for
14+
asm goto can be tracked at the below link.
15+
16+
Link: https://github.com/ClangBuiltLinux/linux/issues/6
17+
Signed-off-by: Nathan Chancellor <[email protected]>
18+
---
19+
arch/x86/Makefile | 9 +++++----
20+
arch/x86/boot/compressed/Makefile | 3 +++
21+
drivers/firmware/efi/libstub/Makefile | 4 ++++
22+
3 files changed, 12 insertions(+), 4 deletions(-)
23+
24+
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
25+
index 2d8b9d8ca4f8..2329b1af60f9 100644
26+
--- a/arch/x86/Makefile
27+
+++ b/arch/x86/Makefile
28+
@@ -223,6 +223,11 @@ ifdef CONFIG_RETPOLINE
29+
KBUILD_CFLAGS += $(call cc-option,--param=case-values-threshold=20)
30+
endif
31+
32+
+# Avoid warnings in arch/x86/include/asm/cpufeature.h when building with Clang
33+
+ifndef CONFIG_CC_HAS_ASM_GOTO
34+
+ KBUILD_CFLAGS += -D__BPF_TRACING__
35+
+endif
36+
+
37+
archscripts: scripts_basic
38+
$(Q)$(MAKE) $(build)=arch/x86/tools relocs
39+
40+
@@ -293,10 +298,6 @@ vdso_install:
41+
42+
archprepare: checkbin
43+
checkbin:
44+
-ifndef CONFIG_CC_HAS_ASM_GOTO
45+
- @echo Compiler lacks asm-goto support.
46+
- @exit 1
47+
-endif
48+
ifdef CONFIG_RETPOLINE
49+
ifeq ($(RETPOLINE_CFLAGS),)
50+
@echo "You are building kernel with non-retpoline compiler." >&2
51+
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
52+
index 6b84afdd7538..c7265084dd78 100644
53+
--- a/arch/x86/boot/compressed/Makefile
54+
+++ b/arch/x86/boot/compressed/Makefile
55+
@@ -38,6 +38,9 @@ KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
56+
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
57+
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
58+
KBUILD_CFLAGS += -Wno-pointer-sign
59+
+ifndef CONFIG_CC_HAS_ASM_GOTO
60+
+KBUILD_CFLAGS += -D__BPF_TRACING__
61+
+endif
62+
63+
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
64+
GCOV_PROFILE := n
65+
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
66+
index b0103e16fc1b..d8019c714b4d 100644
67+
--- a/drivers/firmware/efi/libstub/Makefile
68+
+++ b/drivers/firmware/efi/libstub/Makefile
69+
@@ -24,6 +24,10 @@ cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \
70+
71+
cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt
72+
73+
+ifndef CONFIG_CC_HAS_ASM_GOTO
74+
+cflags-$(CONFIG_X86) += -D__BPF_TRACING__
75+
+endif
76+
+
77+
KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \
78+
-D__NO_FORTIFY \
79+
$(call cc-option,-ffreestanding) \
80+
--
81+
2.21.0
82+
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From e6676062c603d696e70b06041580c62ca364fd18 Mon Sep 17 00:00:00 2001
1+
From ee0b6f5504052a34cc38d68014d7234dc608f2e0 Mon Sep 17 00:00:00 2001
22
From: Nathan Chancellor <[email protected]>
33
Date: Sat, 5 Jan 2019 11:51:39 -0700
44
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
1010
We've been fortunate enough to get around the asm goto requirement
1111
introduced in commit e501ce957a78 ("x86: Force asm-goto") until now.
1212

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+
1316
Link: https://github.com/ClangBuiltLinux/linux/issues/6
1417
Signed-off-by: Nathan Chancellor <[email protected]>
1518
---
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(-)
1821

1922
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
2124
--- a/arch/x86/include/asm/uaccess.h
2225
+++ b/arch/x86/include/asm/uaccess.h
2326
@@ -186,14 +186,19 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
@@ -59,7 +62,7 @@ index 780f2b42c8ef..122e42319acc 100644
5962
#define __put_user_asm_ex_u64(x, addr) \
6063
__put_user_asm_ex(x, addr, "q", "", "er")
6164
#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);
6366
__builtin_expect(__ret_pu, 0); \
6467
})
6568

@@ -82,28 +85,29 @@ index 780f2b42c8ef..122e42319acc 100644
8285
+ __put_user_asm(x, ptr, retval, "l", "k", "ir", errret); \
8386
break; \
8487
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); \
8890
break; \
8991
default: \
9092
__put_user_bad(); \
91-
@@ -429,12 +436,9 @@ do { \
93+
@@ -429,14 +435,11 @@ do { \
9294

9395
#define __put_user_nocheck(x, ptr, size) \
9496
({ \
9597
- __label__ __pu_label; \
9698
- int __pu_err = -EFAULT; \
9799
+ int __pu_err; \
100+
__typeof__(*(ptr)) __pu_val; \
101+
__pu_val = x; \
98102
__uaccess_begin(); \
99-
- __put_user_size((x), (ptr), (size), __pu_label); \
103+
- __put_user_size(__pu_val, (ptr), (size), __pu_label); \
100104
- __pu_err = 0; \
101105
-__pu_label: \
102-
+ __put_user_size((x), (ptr), (size), __pu_err, -EFAULT); \
106+
+ __put_user_size(__pu_val, (ptr), (size), __pu_err, -EFAULT); \
103107
__uaccess_end(); \
104108
__builtin_expect(__pu_err, 0); \
105109
})
106-
@@ -459,23 +463,17 @@ struct __large_struct { unsigned long buf[100]; };
110+
@@ -461,23 +464,17 @@ struct __large_struct { unsigned long buf[100]; };
107111
* we do not write to any memory gcc knows about, so there are no
108112
* aliasing issues.
109113
*/
@@ -138,7 +142,7 @@ index 780f2b42c8ef..122e42319acc 100644
138142

139143
#define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
140144
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
142146
#define user_access_begin(a,b) user_access_begin(a,b)
143147
#define user_access_end() __uaccess_end()
144148

@@ -155,88 +159,5 @@ index 780f2b42c8ef..122e42319acc 100644
155159
#define unsafe_get_user(x, ptr, err_label) \
156160
do { \
157161
--
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
242163

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
From 54fff575943226a41edd644fc3549458ab728143 Mon Sep 17 00:00:00 2001
2+
From: Nathan Chancellor <[email protected]>
3+
Date: Tue, 25 Sep 2018 13:32:33 -0700
4+
Subject: [PATCH 2/2] DO-NOT-UPSTREAM: x86: Avoid warnings/errors due to lack
5+
of asm goto
6+
7+
We don't want to see an inordinate amount of warning spam from
8+
the BPF samples and after reverting commits 4a789213c9a5 ("x86
9+
uaccess: Introduce __put_user_goto") and a959dc88f9c8 ("Use
10+
__put_user_goto in __put_user_size() and unsafe_put_user()"), we
11+
can successfully compile an x86 kernel with Clang.
12+
13+
This is obviously not a long term solution. LLVM/Clang support for
14+
asm goto can be tracked at the below link.
15+
16+
Link: https://github.com/ClangBuiltLinux/linux/issues/6
17+
Signed-off-by: Nathan Chancellor <[email protected]>
18+
---
19+
arch/x86/Makefile | 9 +++++----
20+
arch/x86/boot/compressed/Makefile | 3 +++
21+
drivers/firmware/efi/libstub/Makefile | 4 ++++
22+
3 files changed, 12 insertions(+), 4 deletions(-)
23+
24+
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
25+
index 9c5a67d1b9c1..95baa56c2de0 100644
26+
--- a/arch/x86/Makefile
27+
+++ b/arch/x86/Makefile
28+
@@ -219,6 +219,11 @@ ifdef CONFIG_RETPOLINE
29+
KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
30+
endif
31+
32+
+# Avoid warnings in arch/x86/include/asm/cpufeature.h when building with Clang
33+
+ifndef CONFIG_CC_HAS_ASM_GOTO
34+
+ KBUILD_CFLAGS += -D__BPF_TRACING__
35+
+endif
36+
+
37+
archscripts: scripts_basic
38+
$(Q)$(MAKE) $(build)=arch/x86/tools relocs
39+
40+
@@ -289,10 +294,6 @@ vdso_install:
41+
42+
archprepare: checkbin
43+
checkbin:
44+
-ifndef CONFIG_CC_HAS_ASM_GOTO
45+
- @echo Compiler lacks asm-goto support.
46+
- @exit 1
47+
-endif
48+
ifdef CONFIG_RETPOLINE
49+
ifeq ($(RETPOLINE_CFLAGS),)
50+
@echo "You are building kernel with non-retpoline compiler." >&2
51+
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
52+
index f0515ac895a4..24cca31995ae 100644
53+
--- a/arch/x86/boot/compressed/Makefile
54+
+++ b/arch/x86/boot/compressed/Makefile
55+
@@ -38,6 +38,9 @@ KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
56+
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
57+
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
58+
KBUILD_CFLAGS += -Wno-pointer-sign
59+
+ifndef CONFIG_CC_HAS_ASM_GOTO
60+
+KBUILD_CFLAGS += -D__BPF_TRACING__
61+
+endif
62+
63+
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
64+
GCOV_PROFILE := n
65+
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
66+
index d9845099635e..68ff33dc075d 100644
67+
--- a/drivers/firmware/efi/libstub/Makefile
68+
+++ b/drivers/firmware/efi/libstub/Makefile
69+
@@ -24,6 +24,10 @@ cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \
70+
71+
cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt
72+
73+
+ifndef CONFIG_CC_HAS_ASM_GOTO
74+
+cflags-$(CONFIG_X86) += -D__BPF_TRACING__
75+
+endif
76+
+
77+
KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \
78+
-D__NO_FORTIFY \
79+
$(call cc-option,-ffreestanding) \
80+
--
81+
2.21.0
82+

0 commit comments

Comments
 (0)