]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.34/objtool-add-clang-support.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 4.14.34 / objtool-add-clang-support.patch
1 From 3c1f05835cbf9fdfe60b81c718d82ceb94b6c55e Mon Sep 17 00:00:00 2001
2 From: Josh Poimboeuf <jpoimboe@redhat.com>
3 Date: Thu, 22 Mar 2018 13:00:37 -0500
4 Subject: objtool: Add Clang support
5
6 From: Josh Poimboeuf <jpoimboe@redhat.com>
7
8 commit 3c1f05835cbf9fdfe60b81c718d82ceb94b6c55e upstream.
9
10 Since the ORC unwinder was made the default on x86_64, Clang-built
11 defconfig kernels have triggered some new objtool warnings:
12
13 drivers/gpu/drm/i915/i915_gpu_error.o: warning: objtool: i915_error_printf()+0x6c: return with modified stack frame
14 drivers/gpu/drm/i915/intel_display.o: warning: objtool: pipe_config_err()+0xa6: return with modified stack frame
15
16 The problem is that objtool has never seen clang-built binaries before.
17
18 Shockingly enough, objtool is apparently able to follow the code flow
19 mostly fine, except for one instruction sequence. Instead of a LEAVE
20 instruction, clang restores RSP and RBP the long way:
21
22 67c: 48 89 ec mov %rbp,%rsp
23 67f: 5d pop %rbp
24
25 Teach objtool about this new code sequence.
26
27 Reported-and-test-by: Matthias Kaehlcke <mka@chromium.org>
28 Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
29 Cc: Linus Torvalds <torvalds@linux-foundation.org>
30 Cc: Matthias Kaehlcke <mka@chromium.org>
31 Cc: Peter Zijlstra <peterz@infradead.org>
32 Cc: Thomas Gleixner <tglx@linutronix.de>
33 Link: http://lkml.kernel.org/r/fce88ce81c356eedcae7f00ed349cfaddb3363cc.1521741586.git.jpoimboe@redhat.com
34 Signed-off-by: Ingo Molnar <mingo@kernel.org>
35 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36
37 ---
38 tools/objtool/check.c | 11 +++++++++++
39 1 file changed, 11 insertions(+)
40
41 --- a/tools/objtool/check.c
42 +++ b/tools/objtool/check.c
43 @@ -1385,6 +1385,17 @@ static int update_insn_state(struct inst
44 state->vals[op->dest.reg].offset = -state->stack_size;
45 }
46
47 + else if (op->src.reg == CFI_BP && op->dest.reg == CFI_SP &&
48 + cfa->base == CFI_BP) {
49 +
50 + /*
51 + * mov %rbp, %rsp
52 + *
53 + * Restore the original stack pointer (Clang).
54 + */
55 + state->stack_size = -state->regs[CFI_BP].offset;
56 + }
57 +
58 else if (op->dest.reg == cfa->base) {
59
60 /* mov %reg, %rsp */