]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.18/objtool-fix-function-fallthrough-detection.patch
Linux 4.19.45
[thirdparty/kernel/stable-queue.git] / releases / 5.0.18 / objtool-fix-function-fallthrough-detection.patch
1 From e6f393bc939d566ce3def71232d8013de9aaadde Mon Sep 17 00:00:00 2001
2 From: Josh Poimboeuf <jpoimboe@redhat.com>
3 Date: Mon, 13 May 2019 12:01:32 -0500
4 Subject: objtool: Fix function fallthrough detection
5
6 From: Josh Poimboeuf <jpoimboe@redhat.com>
7
8 commit e6f393bc939d566ce3def71232d8013de9aaadde upstream.
9
10 When a function falls through to the next function due to a compiler
11 bug, objtool prints some obscure warnings. For example:
12
13 drivers/regulator/core.o: warning: objtool: regulator_count_voltages()+0x95: return with modified stack frame
14 drivers/regulator/core.o: warning: objtool: regulator_count_voltages()+0x0: stack state mismatch: cfa1=7+32 cfa2=7+8
15
16 Instead it should be printing:
17
18 drivers/regulator/core.o: warning: objtool: regulator_supply_is_couple() falls through to next function regulator_count_voltages()
19
20 This used to work, but was broken by the following commit:
21
22 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions")
23
24 The padding nops at the end of a function aren't actually part of the
25 function, as defined by the symbol table. So the 'func' variable in
26 validate_branch() is getting cleared to NULL when a padding nop is
27 encountered, breaking the fallthrough detection.
28
29 If the current instruction doesn't have a function associated with it,
30 just consider it to be part of the previously detected function by not
31 overwriting the previous value of 'func'.
32
33 Reported-by: kbuild test robot <lkp@intel.com>
34 Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
35 Cc: Linus Torvalds <torvalds@linux-foundation.org>
36 Cc: Peter Zijlstra <peterz@infradead.org>
37 Cc: Thomas Gleixner <tglx@linutronix.de>
38 Cc: <stable@vger.kernel.org>
39 Fixes: 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions")
40 Link: http://lkml.kernel.org/r/546d143820cd08a46624ae8440d093dd6c902cae.1557766718.git.jpoimboe@redhat.com
41 Signed-off-by: Ingo Molnar <mingo@kernel.org>
42 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
43
44 ---
45 tools/objtool/check.c | 3 ++-
46 1 file changed, 2 insertions(+), 1 deletion(-)
47
48 --- a/tools/objtool/check.c
49 +++ b/tools/objtool/check.c
50 @@ -1832,7 +1832,8 @@ static int validate_branch(struct objtoo
51 return 1;
52 }
53
54 - func = insn->func ? insn->func->pfunc : NULL;
55 + if (insn->func)
56 + func = insn->func->pfunc;
57
58 if (func && insn->ignore) {
59 WARN_FUNC("BUG: why am I validating an ignored function?",