Skip to content

Commit 6d8f809

Browse files
committed
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Thomas Gleixner: "A few fixes for x86: - Don't reset the carefully adjusted build flags for the purgatory and remove the unwanted flags instead. The 'reset all' approach led to build fails under certain circumstances. - Unbreak CLANG build of the purgatory by avoiding the builtin memcpy/memset implementations. - Address missing prototype warnings by including the proper header - Fix yet more fall-through issues" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/lib/cpu: Address missing prototypes warning x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS x86/purgatory: Do not use __builtin_memcpy and __builtin_memset x86: mtrr: cyrix: Mark expected switch fall-through x86/ptrace: Mark expected switch fall-through
2 parents d2359a5 + 04f5bda commit 6d8f809

File tree

7 files changed

+48
-28
lines changed

7 files changed

+48
-28
lines changed

arch/x86/boot/string.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ int memcmp(const void *s1, const void *s2, size_t len)
3737
return diff;
3838
}
3939

40+
/*
41+
* Clang may lower `memcmp == 0` to `bcmp == 0`.
42+
*/
43+
int bcmp(const void *s1, const void *s2, size_t len)
44+
{
45+
return memcmp(s1, s2, len);
46+
}
47+
4048
int strcmp(const char *str1, const char *str2)
4149
{
4250
const unsigned char *s1 = (const unsigned char *)str1;

arch/x86/kernel/cpu/mtrr/cyrix.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ cyrix_get_free_region(unsigned long base, unsigned long size, int replace_reg)
9898
case 7:
9999
if (size < 0x40)
100100
break;
101+
/* Else, fall through */
101102
case 6:
102103
case 5:
103104
case 4:

arch/x86/kernel/ptrace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ static int set_segment_reg(struct task_struct *task,
201201
case offsetof(struct user_regs_struct, ss):
202202
if (unlikely(value == 0))
203203
return -EIO;
204+
/* Else, fall through */
204205

205206
default:
206207
*pt_regs_access(task_pt_regs(task), offset) = value;

arch/x86/lib/cpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
#include <linux/types.h>
33
#include <linux/export.h>
4+
#include <asm/cpu.h>
45

56
unsigned int x86_family(unsigned int sig)
67
{

arch/x86/purgatory/Makefile

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ purgatory-y := purgatory.o stack.o setup-x86_$(BITS).o sha256.o entry64.o string
66
targets += $(purgatory-y)
77
PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
88

9+
$(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE
10+
$(call if_changed_rule,cc_o_c)
11+
912
$(obj)/sha256.o: $(srctree)/lib/sha256.c FORCE
1013
$(call if_changed_rule,cc_o_c)
1114

@@ -17,11 +20,34 @@ KCOV_INSTRUMENT := n
1720

1821
# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
1922
# in turn leaves some undefined symbols like __fentry__ in purgatory and not
20-
# sure how to relocate those. Like kexec-tools, use custom flags.
21-
22-
KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -fno-builtin -ffreestanding -c -Os -mcmodel=large
23-
KBUILD_CFLAGS += -m$(BITS)
24-
KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
23+
# sure how to relocate those.
24+
ifdef CONFIG_FUNCTION_TRACER
25+
CFLAGS_REMOVE_sha256.o += $(CC_FLAGS_FTRACE)
26+
CFLAGS_REMOVE_purgatory.o += $(CC_FLAGS_FTRACE)
27+
CFLAGS_REMOVE_string.o += $(CC_FLAGS_FTRACE)
28+
CFLAGS_REMOVE_kexec-purgatory.o += $(CC_FLAGS_FTRACE)
29+
endif
30+
31+
ifdef CONFIG_STACKPROTECTOR
32+
CFLAGS_REMOVE_sha256.o += -fstack-protector
33+
CFLAGS_REMOVE_purgatory.o += -fstack-protector
34+
CFLAGS_REMOVE_string.o += -fstack-protector
35+
CFLAGS_REMOVE_kexec-purgatory.o += -fstack-protector
36+
endif
37+
38+
ifdef CONFIG_STACKPROTECTOR_STRONG
39+
CFLAGS_REMOVE_sha256.o += -fstack-protector-strong
40+
CFLAGS_REMOVE_purgatory.o += -fstack-protector-strong
41+
CFLAGS_REMOVE_string.o += -fstack-protector-strong
42+
CFLAGS_REMOVE_kexec-purgatory.o += -fstack-protector-strong
43+
endif
44+
45+
ifdef CONFIG_RETPOLINE
46+
CFLAGS_REMOVE_sha256.o += $(RETPOLINE_CFLAGS)
47+
CFLAGS_REMOVE_purgatory.o += $(RETPOLINE_CFLAGS)
48+
CFLAGS_REMOVE_string.o += $(RETPOLINE_CFLAGS)
49+
CFLAGS_REMOVE_kexec-purgatory.o += $(RETPOLINE_CFLAGS)
50+
endif
2551

2652
$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
2753
$(call if_changed,ld)

arch/x86/purgatory/purgatory.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@ void purgatory(void)
6868
}
6969
copy_backup_region();
7070
}
71+
72+
/*
73+
* Defined in order to reuse memcpy() and memset() from
74+
* arch/x86/boot/compressed/string.c
75+
*/
76+
void warn(const char *msg) {}

arch/x86/purgatory/string.c

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)