]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-5.1/objtool-don-t-use-ignore-flag-for-fake-jumps.patch
4.19-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.1 / objtool-don-t-use-ignore-flag-for-fake-jumps.patch
CommitLineData
d50b8c78
SL
1From fb905e7fa732b1df131bebbe01194ae6c0469cbd Mon Sep 17 00:00:00 2001
2From: Josh Poimboeuf <jpoimboe@redhat.com>
3Date: Mon, 13 May 2019 12:01:31 -0500
4Subject: objtool: Don't use ignore flag for fake jumps
5
6[ Upstream commit e6da9567959e164f82bc81967e0d5b10dee870b4 ]
7
8The ignore flag is set on fake jumps in order to keep
9add_jump_destinations() from setting their jump_dest, since it already
10got set when the fake jump was created.
11
12But using the ignore flag is a bit of a hack. It's normally used to
13skip validation of an instruction, which doesn't really make sense for
14fake jumps.
15
16Also, after the next patch, using the ignore flag for fake jumps can
17trigger a false "why am I validating an ignored function?" warning.
18
19Instead just add an explicit check in add_jump_destinations() to skip
20fake jumps.
21
22Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
23Cc: Linus Torvalds <torvalds@linux-foundation.org>
24Cc: Peter Zijlstra <peterz@infradead.org>
25Cc: Thomas Gleixner <tglx@linutronix.de>
26Link: http://lkml.kernel.org/r/71abc072ff48b2feccc197723a9c52859476c068.1557766718.git.jpoimboe@redhat.com
27Signed-off-by: Ingo Molnar <mingo@kernel.org>
28Signed-off-by: Sasha Levin <sashal@kernel.org>
29---
30 tools/objtool/check.c | 8 +++++---
31 1 file changed, 5 insertions(+), 3 deletions(-)
32
33diff --git a/tools/objtool/check.c b/tools/objtool/check.c
34index 2cd57730381b..ecf5fc77f50b 100644
35--- a/tools/objtool/check.c
36+++ b/tools/objtool/check.c
37@@ -28,6 +28,8 @@
38 #include <linux/hashtable.h>
39 #include <linux/kernel.h>
40
41+#define FAKE_JUMP_OFFSET -1
42+
43 struct alternative {
44 struct list_head list;
45 struct instruction *insn;
46@@ -501,7 +503,7 @@ static int add_jump_destinations(struct objtool_file *file)
47 insn->type != INSN_JUMP_UNCONDITIONAL)
48 continue;
49
50- if (insn->ignore)
51+ if (insn->ignore || insn->offset == FAKE_JUMP_OFFSET)
52 continue;
53
54 rela = find_rela_by_dest_range(insn->sec, insn->offset,
55@@ -670,10 +672,10 @@ static int handle_group_alt(struct objtool_file *file,
56 clear_insn_state(&fake_jump->state);
57
58 fake_jump->sec = special_alt->new_sec;
59- fake_jump->offset = -1;
60+ fake_jump->offset = FAKE_JUMP_OFFSET;
61 fake_jump->type = INSN_JUMP_UNCONDITIONAL;
62 fake_jump->jump_dest = list_next_entry(last_orig_insn, list);
63- fake_jump->ignore = true;
64+ fake_jump->func = orig_insn->func;
65 }
66
67 if (!special_alt->new_len) {
68--
692.20.1
70