Skip to content

Commit fcbc38b

Browse files
committed
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
2 parents 844056f + a356d2a commit fcbc38b

File tree

15 files changed

+72
-40
lines changed

15 files changed

+72
-40
lines changed

include/linux/compiler.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,22 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
8888

8989
/* Unreachable code */
9090
#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+
*/
9196
#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__)); \
96101
})
97102
#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__)); \
102107
})
103108
#define ASM_UNREACHABLE \
104109
"999:\n\t" \

tools/objtool/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
arch/x86/insn/inat-tables.c
1+
arch/x86/lib/inat-tables.c
22
objtool
33
fixdep

tools/objtool/Makefile

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ OBJTOOL_IN := $(OBJTOOL)-in.o
2525

2626
all: $(OBJTOOL)
2727

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
2931
WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
3032
CFLAGS += -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES)
3133
LDFLAGS += -lelf $(LIBSUBCMD)
@@ -41,22 +43,8 @@ include $(srctree)/tools/build/Makefile.include
4143
$(OBJTOOL_IN): fixdep FORCE
4244
@$(MAKE) $(build)=objtool
4345

44-
# Busybox's diff doesn't have -I, avoid warning in that case
45-
#
4646
$(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN)
47-
@(diff -I 2>&1 | grep -q 'option requires an argument' && \
48-
test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \
49-
diff -I'^#include' arch/x86/insn/insn.c ../../arch/x86/lib/insn.c >/dev/null && \
50-
diff -I'^#include' arch/x86/insn/inat.c ../../arch/x86/lib/inat.c >/dev/null && \
51-
diff arch/x86/insn/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \
52-
diff arch/x86/insn/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null && \
53-
diff -I'^#include' arch/x86/insn/insn.h ../../arch/x86/include/asm/insn.h >/dev/null && \
54-
diff -I'^#include' arch/x86/insn/inat.h ../../arch/x86/include/asm/inat.h >/dev/null && \
55-
diff -I'^#include' arch/x86/insn/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) \
56-
|| echo "warning: objtool: x86 instruction decoder differs from kernel" >&2 )) || true
57-
@(test -d ../../kernel -a -d ../../tools -a -d ../objtool && (( \
58-
diff ../../arch/x86/include/asm/orc_types.h orc_types.h >/dev/null) \
59-
|| echo "warning: objtool: orc_types.h differs from kernel" >&2 )) || true
47+
@./sync-check.sh
6048
$(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@
6149

6250

@@ -66,7 +54,7 @@ $(LIBSUBCMD): fixdep FORCE
6654
clean:
6755
$(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL)
6856
$(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
69-
$(Q)$(RM) $(OUTPUT)arch/x86/insn/inat-tables.c $(OUTPUT)fixdep
57+
$(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep
7058

7159
FORCE:
7260

tools/objtool/arch/x86/Build

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
objtool-y += decode.o
22

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
55

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)
77
$(call rule_mkdir)
88
$(Q)$(call echo-cmd,gen)$(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@
99

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
1111

12-
CFLAGS_decode.o += -I$(OUTPUT)arch/x86/insn
12+
CFLAGS_decode.o += -I$(OUTPUT)arch/x86/lib

tools/objtool/arch/x86/decode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#include <stdlib.h>
2020

2121
#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"
2525

2626
#include "../../elf.h"
2727
#include "../../arch.h"

tools/objtool/arch/x86/insn/inat.h renamed to tools/objtool/arch/x86/include/asm/inat.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2121
*
2222
*/
23-
#include "inat_types.h"
23+
#include <asm/inat_types.h>
2424

2525
/*
2626
* Internal bits. Don't use bitmasks directly, because these bits are
@@ -97,6 +97,16 @@
9797
#define INAT_MAKE_GROUP(grp) ((grp << INAT_GRP_OFFS) | INAT_MODRM)
9898
#define INAT_MAKE_IMM(imm) (imm << INAT_IMM_OFFS)
9999

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
109+
100110
/* Attribute search APIs */
101111
extern insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode);
102112
extern int inat_get_last_prefix_id(insn_byte_t last_pfx);
File renamed without changes.

tools/objtool/arch/x86/insn/insn.h renamed to tools/objtool/arch/x86/include/asm/insn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222

2323
/* insn_attr_t is defined in inat.h */
24-
#include "inat.h"
24+
#include <asm/inat.h>
2525

2626
struct insn_field {
2727
union {
File renamed without changes.

tools/objtool/arch/x86/insn/inat.c renamed to tools/objtool/arch/x86/lib/inat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1919
*
2020
*/
21-
#include "insn.h"
21+
#include <asm/insn.h>
2222

2323
/* Attribute tables are generated from opcode map */
2424
#include "inat-tables.c"

0 commit comments

Comments
 (0)