Re: objtool warnings in prerelease clang-9

From: Nick Desaulniers
Date: Wed Jul 10 2019 - 19:42:58 EST


On Wed, Jul 10, 2019 at 4:22 PM Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
>
> On Sat, Jul 06, 2019 at 10:50:01AM -0500, Josh Poimboeuf wrote:
> > On Tue, Jul 02, 2019 at 11:58:27PM +0200, Thomas Gleixner wrote:
> > > platform-quirks.o:
> > >
> > > if (x86_platform.set_legacy_features)
> > > 74: 4c 8b 1d 00 00 00 00 mov 0x0(%rip),%r11 # 7b <x86_early_init_platform_quirks+0x7b>
> > > 7b: 4d 85 db test %r11,%r11
> > > 7e: 0f 85 00 00 00 00 jne 84 <x86_early_init_platform_quirks+0x84>
> > > x86_platform.set_legacy_features();
> > > }
> > > 84: c3 retq
> > >
> > > That jne jumps to __x86_indirect_thunk_r11, aka. ratpoutine.
> > >
> > > No idea why objtool thinks that the instruction at 0x84 is not
> > > reachable. Josh?
> >
> > That's a conditional tail call, which is something GCC never does.
> > Objtool doesn't understand that, so we'll need to fix it.
>
> Can somebody test this patch to see if it fixes the platform-quirks.o
> warning?

$ make CC=clang -j71 2>&1 | grep platform-quirks
CC arch/x86/kernel/platform-quirks.o
arch/x86/kernel/platform-quirks.o: warning: objtool:
x86_early_init_platform_quirks()+0x84: unreachable instruction
$ git am /tmp/objtool.patch
$ make CC=clang -j71 clean
$ make CC=clang -j71 2>&1 | grep platform-quirks
CC arch/x86/kernel/platform-quirks.o
arch/x86/kernel/platform-quirks.o: warning: objtool:
x86_early_init_platform_quirks()+0x84: unreachable instruction

:(

$ llvm-objdump -dr arch/x86/kernel/platform-quirks.o

arch/x86/kernel/platform-quirks.o: file format ELF64-x86-64


Disassembly of section .init.text:

0000000000000000 x86_early_init_platform_quirks:
0: 48 b8 02 00 00 00 01 00 00 00 movabsq $4294967298, %rax
a: 48 89 05 00 00 00 00 movq %rax, (%rip)
000000000000000d: R_X86_64_PC32 x86_platform+84
11: c7 05 00 00 00 00 01 00 00 00 movl $1, (%rip)
0000000000000013: R_X86_64_PC32 x86_platform+88
1b: 48 b8 00 00 00 00 01 00 00 00 movabsq $4294967296, %rax
25: 48 89 05 00 00 00 00 movq %rax, (%rip)
0000000000000028: R_X86_64_PC32 x86_platform+100
2c: 8b 05 00 00 00 00 movl (%rip), %eax
000000000000002e: R_X86_64_PC32 boot_params+568
32: 8d 48 fd leal -3(%rax), %ecx
35: 83 f9 02 cmpl $2, %ecx
38: 72 15 jb 21
<x86_early_init_platform_quirks+0x4f>
3a: 83 f8 02 cmpl $2, %eax
3d: 74 27 je 39
<x86_early_init_platform_quirks+0x66>
3f: 85 c0 testl %eax, %eax
41: 75 31 jne 49
<x86_early_init_platform_quirks+0x74>
43: c7 05 00 00 00 00 01 00 00 00 movl $1, (%rip)
0000000000000045: R_X86_64_PC32 x86_platform+96
4d: eb 25 jmp 37
<x86_early_init_platform_quirks+0x74>
4f: c7 05 00 00 00 00 00 00 00 00 movl $0, (%rip)
0000000000000051: R_X86_64_PC32 x86_platform+100
59: 48 c7 05 00 00 00 00 00 00 00 00 movq $0, (%rip)
000000000000005c: R_X86_64_PC32 x86_platform+80
64: eb 0e jmp 14
<x86_early_init_platform_quirks+0x74>
66: 31 c0 xorl %eax, %eax
68: 89 05 00 00 00 00 movl %eax, (%rip)
000000000000006a: R_X86_64_PC32 x86_platform+104
6e: 89 05 00 00 00 00 movl %eax, (%rip)
0000000000000070: R_X86_64_PC32 x86_platform+88
74: 4c 8b 1d 00 00 00 00 movq (%rip), %r11
0000000000000077: R_X86_64_PC32 x86_platform+108
7b: 4d 85 db testq %r11, %r11
7e: 0f 85 00 00 00 00 jne 0
<x86_early_init_platform_quirks+0x84>
0000000000000080: R_X86_64_PC32 __x86_indirect_thunk_r11-4
84: c3 retq

I've sent you the .o file off thread as well. Thanks for taking a
look into this. :D
--
Thanks,
~Nick Desaulniers