Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull objtool fixes from Ingo Molnar:
"A handful of objtool fixes, most of them related to making the UAPI
header-syncing warnings easier to read and easier to act upon"

* 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
tools/headers: Sync objtool UAPI header
objtool: Fix cross-build
objtool: Move kernel headers/code sync check to a script
objtool: Move synced files to their original relative locations
objtool: Make unreachable annotation inline asms explicitly volatile
objtool: Add a comment for the unreachable annotation macros

+72 -40
+13 -8
include/linux/compiler.h
··· 88 88 89 89 /* Unreachable code */ 90 90 #ifdef CONFIG_STACK_VALIDATION 91 + /* 92 + * These macros help objtool understand GCC code flow for unreachable code. 93 + * The __COUNTER__ based labels are a hack to make each instance of the macros 94 + * unique, to convince GCC not to merge duplicate inline asm statements. 95 + */ 91 96 #define annotate_reachable() ({ \ 92 - asm("%c0:\n\t" \ 93 - ".pushsection .discard.reachable\n\t" \ 94 - ".long %c0b - .\n\t" \ 95 - ".popsection\n\t" : : "i" (__COUNTER__)); \ 97 + asm volatile("%c0:\n\t" \ 98 + ".pushsection .discard.reachable\n\t" \ 99 + ".long %c0b - .\n\t" \ 100 + ".popsection\n\t" : : "i" (__COUNTER__)); \ 96 101 }) 97 102 #define annotate_unreachable() ({ \ 98 - asm("%c0:\n\t" \ 99 - ".pushsection .discard.unreachable\n\t" \ 100 - ".long %c0b - .\n\t" \ 101 - ".popsection\n\t" : : "i" (__COUNTER__)); \ 103 + asm volatile("%c0:\n\t" \ 104 + ".pushsection .discard.unreachable\n\t" \ 105 + ".long %c0b - .\n\t" \ 106 + ".popsection\n\t" : : "i" (__COUNTER__)); \ 102 107 }) 103 108 #define ASM_UNREACHABLE \ 104 109 "999:\n\t" \
+1 -1
tools/objtool/.gitignore
··· 1 - arch/x86/insn/inat-tables.c 1 + arch/x86/lib/inat-tables.c 2 2 objtool 3 3 fixdep
+5 -17
tools/objtool/Makefile
··· 25 25 26 26 all: $(OBJTOOL) 27 27 28 - INCLUDES := -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi 28 + INCLUDES := -I$(srctree)/tools/include \ 29 + -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ 30 + -I$(srctree)/tools/objtool/arch/$(ARCH)/include 29 31 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed 30 32 CFLAGS += -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES) 31 33 LDFLAGS += -lelf $(LIBSUBCMD) ··· 43 41 $(OBJTOOL_IN): fixdep FORCE 44 42 @$(MAKE) $(build)=objtool 45 43 46 - # Busybox's diff doesn't have -I, avoid warning in that case 47 - # 48 44 $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) 49 - @(diff -I 2>&1 | grep -q 'option requires an argument' && \ 50 - test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \ 51 - diff -I'^#include' arch/x86/insn/insn.c ../../arch/x86/lib/insn.c >/dev/null && \ 52 - diff -I'^#include' arch/x86/insn/inat.c ../../arch/x86/lib/inat.c >/dev/null && \ 53 - diff arch/x86/insn/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \ 54 - diff arch/x86/insn/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null && \ 55 - diff -I'^#include' arch/x86/insn/insn.h ../../arch/x86/include/asm/insn.h >/dev/null && \ 56 - diff -I'^#include' arch/x86/insn/inat.h ../../arch/x86/include/asm/inat.h >/dev/null && \ 57 - diff -I'^#include' arch/x86/insn/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) \ 58 - || echo "warning: objtool: x86 instruction decoder differs from kernel" >&2 )) || true 59 - @(test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \ 60 - diff ../../arch/x86/include/asm/orc_types.h orc_types.h >/dev/null) \ 61 - || echo "warning: objtool: orc_types.h differs from kernel" >&2 )) || true 45 + @./sync-check.sh 62 46 $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@ 63 47 64 48 ··· 54 66 clean: 55 67 $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) 56 68 $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete 57 - $(Q)$(RM) $(OUTPUT)arch/x86/insn/inat-tables.c $(OUTPUT)fixdep 69 + $(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep 58 70 59 71 FORCE: 60 72
+5 -5
tools/objtool/arch/x86/Build
··· 1 1 objtool-y += decode.o 2 2 3 - inat_tables_script = arch/x86/insn/gen-insn-attr-x86.awk 4 - inat_tables_maps = arch/x86/insn/x86-opcode-map.txt 3 + inat_tables_script = arch/x86/tools/gen-insn-attr-x86.awk 4 + inat_tables_maps = arch/x86/lib/x86-opcode-map.txt 5 5 6 - $(OUTPUT)arch/x86/insn/inat-tables.c: $(inat_tables_script) $(inat_tables_maps) 6 + $(OUTPUT)arch/x86/lib/inat-tables.c: $(inat_tables_script) $(inat_tables_maps) 7 7 $(call rule_mkdir) 8 8 $(Q)$(call echo-cmd,gen)$(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@ 9 9 10 - $(OUTPUT)arch/x86/decode.o: $(OUTPUT)arch/x86/insn/inat-tables.c 10 + $(OUTPUT)arch/x86/decode.o: $(OUTPUT)arch/x86/lib/inat-tables.c 11 11 12 - CFLAGS_decode.o += -I$(OUTPUT)arch/x86/insn 12 + CFLAGS_decode.o += -I$(OUTPUT)arch/x86/lib
+3 -3
tools/objtool/arch/x86/decode.c
··· 19 19 #include <stdlib.h> 20 20 21 21 #define unlikely(cond) (cond) 22 - #include "insn/insn.h" 23 - #include "insn/inat.c" 24 - #include "insn/insn.c" 22 + #include <asm/insn.h> 23 + #include "lib/inat.c" 24 + #include "lib/insn.c" 25 25 26 26 #include "../../elf.h" 27 27 #include "../../arch.h"
tools/objtool/arch/x86/insn/gen-insn-attr-x86.awk tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk
+1 -1
tools/objtool/arch/x86/insn/inat.c tools/objtool/arch/x86/lib/inat.c
··· 18 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 19 * 20 20 */ 21 - #include "insn.h" 21 + #include <asm/insn.h> 22 22 23 23 /* Attribute tables are generated from opcode map */ 24 24 #include "inat-tables.c"
+11 -1
tools/objtool/arch/x86/insn/inat.h tools/objtool/arch/x86/include/asm/inat.h
··· 20 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 21 * 22 22 */ 23 - #include "inat_types.h" 23 + #include <asm/inat_types.h> 24 24 25 25 /* 26 26 * Internal bits. Don't use bitmasks directly, because these bits are ··· 96 96 #define INAT_MAKE_ESCAPE(esc) (esc << INAT_ESC_OFFS) 97 97 #define INAT_MAKE_GROUP(grp) ((grp << INAT_GRP_OFFS) | INAT_MODRM) 98 98 #define INAT_MAKE_IMM(imm) (imm << INAT_IMM_OFFS) 99 + 100 + /* Identifiers for segment registers */ 101 + #define INAT_SEG_REG_IGNORE 0 102 + #define INAT_SEG_REG_DEFAULT 1 103 + #define INAT_SEG_REG_CS 2 104 + #define INAT_SEG_REG_SS 3 105 + #define INAT_SEG_REG_DS 4 106 + #define INAT_SEG_REG_ES 5 107 + #define INAT_SEG_REG_FS 6 108 + #define INAT_SEG_REG_GS 7 99 109 100 110 /* Attribute search APIs */ 101 111 extern insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode);
tools/objtool/arch/x86/insn/inat_types.h tools/objtool/arch/x86/include/asm/inat_types.h
+2 -2
tools/objtool/arch/x86/insn/insn.c tools/objtool/arch/x86/lib/insn.c
··· 23 23 #else 24 24 #include <string.h> 25 25 #endif 26 - #include "inat.h" 27 - #include "insn.h" 26 + #include <asm/inat.h> 27 + #include <asm/insn.h> 28 28 29 29 /* Verify next sizeof(t) bytes can be on the same instruction */ 30 30 #define validate_next(t, insn, n) \
+1 -1
tools/objtool/arch/x86/insn/insn.h tools/objtool/arch/x86/include/asm/insn.h
··· 21 21 */ 22 22 23 23 /* insn_attr_t is defined in inat.h */ 24 - #include "inat.h" 24 + #include <asm/inat.h> 25 25 26 26 struct insn_field { 27 27 union {
tools/objtool/arch/x86/insn/x86-opcode-map.txt tools/objtool/arch/x86/lib/x86-opcode-map.txt
+1 -1
tools/objtool/orc.h
··· 18 18 #ifndef _ORC_H 19 19 #define _ORC_H 20 20 21 - #include "orc_types.h" 21 + #include <asm/orc_types.h> 22 22 23 23 struct objtool_file; 24 24
tools/objtool/orc_types.h tools/objtool/arch/x86/include/asm/orc_types.h
+29
tools/objtool/sync-check.sh
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + FILES=' 5 + arch/x86/lib/insn.c 6 + arch/x86/lib/inat.c 7 + arch/x86/lib/x86-opcode-map.txt 8 + arch/x86/tools/gen-insn-attr-x86.awk 9 + arch/x86/include/asm/insn.h 10 + arch/x86/include/asm/inat.h 11 + arch/x86/include/asm/inat_types.h 12 + arch/x86/include/asm/orc_types.h 13 + ' 14 + 15 + check() 16 + { 17 + local file=$1 18 + 19 + diff $file ../../$file > /dev/null || 20 + echo "Warning: synced file at 'tools/objtool/$file' differs from latest kernel version at '$file'" 21 + } 22 + 23 + if [ ! -d ../../kernel ] || [ ! -d ../../tools ] || [ ! -d ../objtool ]; then 24 + exit 0 25 + fi 26 + 27 + for i in $FILES; do 28 + check $i 29 + done