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
6 From: Josh Poimboeuf <jpoimboe@redhat.com>
8 commit 3c1f05835cbf9fdfe60b81c718d82ceb94b6c55e upstream.
10 Since the ORC unwinder was made the default on x86_64, Clang-built
11 defconfig kernels have triggered some new objtool warnings:
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
16 The problem is that objtool has never seen clang-built binaries before.
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:
22 67c: 48 89 ec mov %rbp,%rsp
25 Teach objtool about this new code sequence.
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>
38 tools/objtool/check.c | 11 +++++++++++
39 1 file changed, 11 insertions(+)
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;
47 + else if (op->src.reg == CFI_BP && op->dest.reg == CFI_SP &&
48 + cfa->base == CFI_BP) {
53 + * Restore the original stack pointer (Clang).
55 + state->stack_size = -state->regs[CFI_BP].offset;
58 else if (op->dest.reg == cfa->base) {