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

Changed files
+47 -27
arch
x86
boot
kernel
cpu
mtrr
lib
purgatory
+8
arch/x86/boot/string.c
··· 37 37 return diff; 38 38 } 39 39 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 + 40 48 int strcmp(const char *str1, const char *str2) 41 49 { 42 50 const unsigned char *s1 = (const unsigned char *)str1;
+1
arch/x86/kernel/cpu/mtrr/cyrix.c
··· 98 98 case 7: 99 99 if (size < 0x40) 100 100 break; 101 + /* Else, fall through */ 101 102 case 6: 102 103 case 5: 103 104 case 4:
+1
arch/x86/kernel/ptrace.c
··· 201 201 case offsetof(struct user_regs_struct, ss): 202 202 if (unlikely(value == 0)) 203 203 return -EIO; 204 + /* Else, fall through */ 204 205 205 206 default: 206 207 *pt_regs_access(task_pt_regs(task), offset) = value;
+1
arch/x86/lib/cpu.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 #include <linux/types.h> 3 3 #include <linux/export.h> 4 + #include <asm/cpu.h> 4 5 5 6 unsigned int x86_family(unsigned int sig) 6 7 {
+30 -4
arch/x86/purgatory/Makefile
··· 6 6 targets += $(purgatory-y) 7 7 PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y)) 8 8 9 + $(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE 10 + $(call if_changed_rule,cc_o_c) 11 + 9 12 $(obj)/sha256.o: $(srctree)/lib/sha256.c FORCE 10 13 $(call if_changed_rule,cc_o_c) 11 14 ··· 20 17 21 18 # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That 22 19 # in turn leaves some undefined symbols like __fentry__ in purgatory and not 23 - # sure how to relocate those. Like kexec-tools, use custom flags. 20 + # sure how to relocate those. 21 + ifdef CONFIG_FUNCTION_TRACER 22 + CFLAGS_REMOVE_sha256.o += $(CC_FLAGS_FTRACE) 23 + CFLAGS_REMOVE_purgatory.o += $(CC_FLAGS_FTRACE) 24 + CFLAGS_REMOVE_string.o += $(CC_FLAGS_FTRACE) 25 + CFLAGS_REMOVE_kexec-purgatory.o += $(CC_FLAGS_FTRACE) 26 + endif 24 27 25 - KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -fno-builtin -ffreestanding -c -Os -mcmodel=large 26 - KBUILD_CFLAGS += -m$(BITS) 27 - KBUILD_CFLAGS += $(call cc-option,-fno-PIE) 28 + ifdef CONFIG_STACKPROTECTOR 29 + CFLAGS_REMOVE_sha256.o += -fstack-protector 30 + CFLAGS_REMOVE_purgatory.o += -fstack-protector 31 + CFLAGS_REMOVE_string.o += -fstack-protector 32 + CFLAGS_REMOVE_kexec-purgatory.o += -fstack-protector 33 + endif 34 + 35 + ifdef CONFIG_STACKPROTECTOR_STRONG 36 + CFLAGS_REMOVE_sha256.o += -fstack-protector-strong 37 + CFLAGS_REMOVE_purgatory.o += -fstack-protector-strong 38 + CFLAGS_REMOVE_string.o += -fstack-protector-strong 39 + CFLAGS_REMOVE_kexec-purgatory.o += -fstack-protector-strong 40 + endif 41 + 42 + ifdef CONFIG_RETPOLINE 43 + CFLAGS_REMOVE_sha256.o += $(RETPOLINE_CFLAGS) 44 + CFLAGS_REMOVE_purgatory.o += $(RETPOLINE_CFLAGS) 45 + CFLAGS_REMOVE_string.o += $(RETPOLINE_CFLAGS) 46 + CFLAGS_REMOVE_kexec-purgatory.o += $(RETPOLINE_CFLAGS) 47 + endif 28 48 29 49 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE 30 50 $(call if_changed,ld)
+6
arch/x86/purgatory/purgatory.c
··· 68 68 } 69 69 copy_backup_region(); 70 70 } 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) {}
-23
arch/x86/purgatory/string.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * Simple string functions. 4 - * 5 - * Copyright (C) 2014 Red Hat Inc. 6 - * 7 - * Author: 8 - * Vivek Goyal <vgoyal@redhat.com> 9 - */ 10 - 11 - #include <linux/types.h> 12 - 13 - #include "../boot/string.c" 14 - 15 - void *memcpy(void *dst, const void *src, size_t len) 16 - { 17 - return __builtin_memcpy(dst, src, len); 18 - } 19 - 20 - void *memset(void *dst, int c, size_t len) 21 - { 22 - return __builtin_memset(dst, c, len); 23 - }