ClangBuiltLinux / linux

Linux kernel source tree
Other
241 stars 14 forks source link

drivers/net/wwan/iosm/iosm.o: warning: objtool: .text.ipc_imem_run_state_worker: unexpected end of section #1683

Open dileks opened 2 years ago

dileks commented 2 years ago

When CONFIG_IOSM=m I see this objtool warning:

drivers/net/wwan/iosm/iosm.o: warning: objtool: .text.ipc_imem_run_state_worker: unexpected end of section

Debian-5.19 kernel activated the Kconfig recently.

My linux-config is attached.

config-5.19.0-3-amd64-clang15-kcfi.txt

dileks commented 2 years ago
$ /opt/llvm/bin/llvm-objdump -Dr --disassemble-symbols=".text.ipc_imem_run_state_worker" drivers/net/wwan/iosm/iosm.o

drivers/net/wwan/iosm/iosm.o:   file format elf64-x86-64
/opt/llvm/bin/llvm-objdump: warning: 'drivers/net/wwan/iosm/iosm.o': failed to disassemble missing symbol .text.ipc_imem_run_state_worker
dileks commented 2 years ago

@samitolvanen @nickdesaulniers @nathanchance

Looks more useful:

$ /opt/llvm/bin/llvm-objdump -Dr --section=".text.ipc_imem_run_state_worker" drivers/net/wwan/iosm/iosm.o

drivers/net/wwan/iosm/iosm.o:   file format elf64-x86-64

Disassembly of section .text.ipc_imem_run_state_worker:

0000000000000000 <__cfi_ipc_imem_run_state_worker>:
       0: 90                            nop
       1: 90                            nop
       2: 90                            nop
       3: 90                            nop
       4: 90                            nop
       5: 90                            nop
       6: 90                            nop
       7: 90                            nop
       8: 90                            nop
       9: 90                            nop
       a: 90                            nop
       b: b8 b6 01 60 b8                movl    $3093299638, %eax       # imm = 0xB86001B6

0000000000000010 <ipc_imem_run_state_worker>:
      10: 0f 1f 44 00 00                nopl    (%rax,%rax)
                0000000000000011:  R_X86_64_NONE        __fentry__-0x4
      15: 41 57                         pushq   %r15
      17: 41 56                         pushq   %r14
      19: 41 54                         pushq   %r12
      1b: 53                            pushq   %rbx
      1c: 48 83 ec 38                   subq    $56, %rsp
      20: 49 89 ff                      movq    %rdi, %r15
      23: 65 48 8b 04 25 28 00 00 00    movq    %gs:40, %rax
      2c: 48 89 44 24 30                movq    %rax, 48(%rsp)
      31: 48 c7 44 24 28 00 00 00 00    movq    $0, 40(%rsp)
      3a: 48 c7 44 24 20 00 00 00 00    movq    $0, 32(%rsp)
      43: 48 c7 44 24 18 00 00 00 00    movq    $0, 24(%rsp)
      4c: 48 c7 44 24 10 00 00 00 00    movq    $0, 16(%rsp)
      55: 83 7f ec 07                   cmpl    $7, -20(%rdi)
      59: 0f 85 83 01 00 00             jne     0x1e2 <ipc_imem_run_state_worker+0x1d2>
      5f: 4d 8d b7 f8 f5 ff ff          leaq    -2568(%r15), %r14
      66: f0                            lock
      67: 49 0f ba 77 28 01             btrq    $1, 40(%r15)
      6d: 73 0c                         jae     0x7b <ipc_imem_run_state_worker+0x6b>
      6f: 49 8b bf 40 fe ff ff          movq    -448(%r15), %rdi
      76: e8 00 00 00 00                callq   0x7b <ipc_imem_run_state_worker+0x6b>
                0000000000000077:  R_X86_64_PLT32       ipc_devlink_deinit-0x4
      7b: 49 8b 3e                      movq    (%r14), %rdi
      7e: e8 00 00 00 00                callq   0x83 <ipc_imem_run_state_worker+0x73>
                000000000000007f:  R_X86_64_PLT32       ipc_mmio_update_cp_capability-0x4
      83: 49 8b 06                      movq    (%r14), %rax
      86: 8b 48 50                      movl    80(%rax), %ecx
      89: 85 c9                         testl   %ecx, %ecx
      8b: 0f 84 6b 01 00 00             je      0x1fc <ipc_imem_run_state_worker+0x1ec>
      91: 89 0c 24                      movl    %ecx, (%rsp)
      94: 0f b6 40 54                   movzbl  84(%rax), %eax
      98: 83 e0 01                      andl    $1, %eax
      9b: ff c0                         incl    %eax
      9d: 89 44 24 04                   movl    %eax, 4(%rsp)
      a1: c7 44 24 08 00 00 00 00       movl    $0, 8(%rsp)
      a9: 48 89 e7                      movq    %rsp, %rdi
      ac: 4c 89 f6                      movq    %r14, %rsi
      af: e8 00 00 00 00                callq   0xb4 <ipc_imem_run_state_worker+0xa4>
                00000000000000b0:  R_X86_64_PLT32       ipc_mux_init-0x4
      b4: 49 89 87 18 f6 ff ff          movq    %rax, -2536(%r15)
      bb: 8b 34 24                      movl    (%rsp), %esi
      be: 4c 89 f7                      movq    %r14, %rdi
      c1: e8 00 00 00 00                callq   0xc6 <ipc_imem_run_state_worker+0xb6>
                00000000000000c2:  R_X86_64_PLT32       ipc_imem_wwan_channel_init-0x4
      c6: 49 8b 87 18 f6 ff ff          movq    -2536(%r15), %rax
      cd: 48 85 c0                      testq   %rax, %rax
      d0: 74 0e                         je      0xe0 <ipc_imem_run_state_worker+0xd0>
      d2: 49 8b 8f 10 f6 ff ff          movq    -2544(%r15), %rcx
      d9: 48 89 88 60 02 00 00          movq    %rcx, 608(%rax)
      e0: 31 db                         xorl    %ebx, %ebx
      e2: 4c 8d 64 24 10                leaq    16(%rsp), %r12
      e7: eb 14                         jmp     0xfd <ipc_imem_run_state_worker+0xed>
      e9: 0f 1f 80 00 00 00 00          nopl    (%rax)
      f0: 48 ff c3                      incq    %rbx
      f3: 48 83 fb 08                   cmpq    $8, %rbx
      f7: 0f 84 9e 00 00 00             je      0x19b <ipc_imem_run_state_worker+0x18b>
      fd: 4c 89 e7                      movq    %r12, %rdi
     100: 89 de                         movl    %ebx, %esi
     102: e8 00 00 00 00                callq   0x107 <ipc_imem_run_state_worker+0xf7>
                0000000000000103:  R_X86_64_PLT32       ipc_chnl_cfg_get-0x4
     107: 85 c0                         testl   %eax, %eax
     109: 75 e5                         jne     0xf0 <ipc_imem_run_state_worker+0xe0>
     10b: 49 c7 84 df 20 f6 ff ff 00 00 00 00   movq    $0, -2528(%r15,%rbx,8)
     117: 49 8b 87 60 f6 ff ff          movq    -2464(%r15), %rax
     11e: 48 8b 00                      movq    (%rax), %rax
     121: 0f b7 40 3e                   movzwl  62(%rax), %eax
     125: 3d 60 73 00 00                cmpl    $29536, %eax            # imm = 0x7360
     12a: 0f 94 c1                      sete    %cl
     12d: 8b 44 24 28                   movl    40(%rsp), %eax
     131: 83 f8 01                      cmpl    $1, %eax
     134: 0f 94 c2                      sete    %dl
     137: 84 d1                         testb   %dl, %cl
     139: 75 b5                         jne     0xf0 <ipc_imem_run_state_worker+0xe0>
     13b: 83 f8 05                      cmpl    $5, %eax
     13e: 74 b0                         je      0xf0 <ipc_imem_run_state_worker+0xe0>
     140: 48 8b 44 24 28                movq    40(%rsp), %rax
     145: 48 8b 4c 24 20                movq    32(%rsp), %rcx
     14a: 4c 8b 44 24 10                movq    16(%rsp), %r8
     14f: 48 8b 54 24 18                movq    24(%rsp), %rdx
     154: 4c 89 f7                      movq    %r14, %rdi
     157: be 01 00 00 00                movl    $1, %esi
     15c: 50                            pushq   %rax
     15d: 51                            pushq   %rcx
     15e: 52                            pushq   %rdx
     15f: 41 50                         pushq   %r8
     161: e8 00 00 00 00                callq   0x166 <ipc_imem_run_state_worker+0x156>
                0000000000000162:  R_X86_64_PLT32       ipc_imem_channel_init-0x4
     166: 48 83 c4 20                   addq    $32, %rsp
     16a: 48 8b 44 24 28                movq    40(%rsp), %rax
     16f: 48 8b 4c 24 20                movq    32(%rsp), %rcx
     174: 48 8b 54 24 10                movq    16(%rsp), %rdx
     179: 48 8b 74 24 18                movq    24(%rsp), %rsi
     17e: 4c 89 f7                      movq    %r14, %rdi
     181: 50                            pushq   %rax
     182: 51                            pushq   %rcx
     183: 56                            pushq   %rsi
     184: 52                            pushq   %rdx
     185: e8 00 00 00 00                callq   0x18a <ipc_imem_run_state_worker+0x17a>
                0000000000000186:  R_X86_64_PLT32       ipc_port_init-0x4
     18a: 48 83 c4 20                   addq    $32, %rsp
     18e: 49 89 84 df 20 f6 ff ff       movq    %rax, -2528(%r15,%rbx,8)
     196: e9 55 ff ff ff                jmp     0xf0 <ipc_imem_run_state_worker+0xe0>
     19b: 4c 89 f7                      movq    %r14, %rdi
     19e: e8 00 00 00 00                callq   0x1a3 <ipc_imem_run_state_worker+0x193>
                000000000000019f:  R_X86_64_PLT32       ipc_debugfs_init-0x4
     1a3: 4c 89 f7                      movq    %r14, %rdi
     1a6: 48 c7 c6 00 00 00 00          movq    $0, %rsi
                00000000000001a9:  R_X86_64_32S .text.ipc_imem_send_mdm_rdy_cb+0x10
     1ad: 31 d2                         xorl    %edx, %edx
     1af: 31 c9                         xorl    %ecx, %ecx
     1b1: 45 31 c0                      xorl    %r8d, %r8d
     1b4: 45 31 c9                      xorl    %r9d, %r9d
     1b7: e8 00 00 00 00                callq   0x1bc <ipc_imem_run_state_worker+0x1ac>
                00000000000001b8:  R_X86_64_PLT32       ipc_task_queue_send_task-0x4
     1bc: f0                            lock
     1bd: 41 80 4f 28 01                orb     $1, 40(%r15)
     1c2: 65 48 8b 04 25 28 00 00 00    movq    %gs:40, %rax
     1cb: 48 3b 44 24 30                cmpq    48(%rsp), %rax
     1d0: 75 25                         jne     0x1f7 <ipc_imem_run_state_worker+0x1e7>
     1d2: 48 83 c4 38                   addq    $56, %rsp
     1d6: 5b                            popq    %rbx
     1d7: 41 5c                         popq    %r12
     1d9: 41 5e                         popq    %r14
     1db: 41 5f                         popq    %r15
     1dd: e9 00 00 00 00                jmp     0x1e2 <ipc_imem_run_state_worker+0x1d2>
                00000000000001de:  R_X86_64_PLT32       __x86_return_thunk-0x4
     1e2: 49 8b bf 70 f6 ff ff          movq    -2448(%r15), %rdi
     1e9: 48 c7 c6 00 00 00 00          movq    $0, %rsi
                00000000000001ec:  R_X86_64_32S .rodata.str1.1+0x16f4
     1f0: e8 00 00 00 00                callq   0x1f5 <ipc_imem_run_state_worker+0x1e5>
                00000000000001f1:  R_X86_64_PLT32       _dev_err-0x4
     1f5: eb cb                         jmp     0x1c2 <ipc_imem_run_state_worker+0x1b2>
     1f7: e8 00 00 00 00                callq   0x1fc <ipc_imem_run_state_worker+0x1ec>
                00000000000001f8:  R_X86_64_PLT32       __stack_chk_fail-0x4
     1fc: 49 8b bf 70 f6 ff ff          movq    -2448(%r15), %rdi
     203: 48 c7 c6 00 00 00 00          movq    $0, %rsi
                0000000000000206:  R_X86_64_32S .rodata.str1.1+0x1082
     20a: e8 00 00 00 00                callq   0x20f <ipc_imem_run_state_worker+0x1ff>
                000000000000020b:  R_X86_64_PLT32       _dev_err-0x4
dileks commented 2 years ago

Attached as file:

$ /opt/llvm/bin/llvm-objdump -Dr --section=".text.ipc_imem_run_state_worker" drivers/net/wwan/iosm/iosm.o > ../llvm-objdump_iosm_o.txt

llvm-objdump_iosm_o.txt

dileks commented 2 years ago

CC @jpoimboe

With this diff the warning goes away:

--- a/drivers/net/wwan/iosm/Makefile
+++ b/drivers/net/wwan/iosm/Makefile
@@ -3,6 +3,12 @@
 # Copyright (C) 2020-21 Intel Corporation.
 #

+# https://github.com/ClangBuiltLinux/linux/issues/1683
+# LLVM-14
+ccflags-y += $(call cc-option, -Xclang -disable-noundef-analysis)
+# LLVM-15
+ccflags-y += $(call cc-option, -Xclang -no-enable-noundef-analysis)
+
 iosm-y = \
        iosm_ipc_task_queue.o   \
        iosm_ipc_imem.o                 \

Attached is the corresponding llvm-objdump.

I can provide both object-files if needed.

llvm-objdump_iosm_o_fixed.txt

dileks commented 2 years ago

Here is the diff of the llvm-objdump#s:

--- a/iosm-BROKEN/llvm-objdump_iosm_o.txt
+++ b/iosm-fixed/llvm-objdump_iosm_o_fixed.txt
@@ -47,7 +47,7 @@ Disassembly of section .text.ipc_imem_run_state_worker:
       83: 49 8b 06                             movq    (%r14), %rax
       86: 8b 48 50                             movl    80(%rax), %ecx
       89: 85 c9                                testl   %ecx, %ecx
-      8b: 0f 84 6b 01 00 00                    je      0x1fc <ipc_imem_run_state_worker+0x1ec>
+      8b: 0f 84 66 01 00 00                    je      0x1f7 <ipc_imem_run_state_worker+0x1e7>
       91: 89 0c 24                             movl    %ecx, (%rsp)
       94: 0f b6 40 54                          movzbl  84(%rax), %eax
       98: 83 e0 01                             andl    $1, %eax
@@ -137,7 +137,7 @@ Disassembly of section .text.ipc_imem_run_state_worker:
      1bd: 41 80 4f 28 01                       orb     $1, 40(%r15)
      1c2: 65 48 8b 04 25 28 00 00 00           movq    %gs:40, %rax
      1cb: 48 3b 44 24 30                       cmpq    48(%rsp), %rax
-     1d0: 75 25                                jne     0x1f7 <ipc_imem_run_state_worker+0x1e7>
+     1d0: 75 3d                                jne     0x20f <ipc_imem_run_state_worker+0x1ff>
      1d2: 48 83 c4 38                          addq    $56, %rsp
      1d6: 5b                                   popq    %rbx
      1d7: 41 5c                                popq    %r12
@@ -151,10 +151,11 @@ Disassembly of section .text.ipc_imem_run_state_worker:
      1f0: e8 00 00 00 00                       callq   0x1f5 <ipc_imem_run_state_worker+0x1e5>
                00000000000001f1:  R_X86_64_PLT32       _dev_err-0x4
      1f5: eb cb                                jmp     0x1c2 <ipc_imem_run_state_worker+0x1b2>
-     1f7: e8 00 00 00 00                       callq   0x1fc <ipc_imem_run_state_worker+0x1ec>
-               00000000000001f8:  R_X86_64_PLT32       __stack_chk_fail-0x4
-     1fc: 49 8b bf 70 f6 ff ff                 movq    -2448(%r15), %rdi
-     203: 48 c7 c6 00 00 00 00                 movq    $0, %rsi
-               0000000000000206:  R_X86_64_32S .rodata.str1.1+0x1082
-     20a: e8 00 00 00 00                       callq   0x20f <ipc_imem_run_state_worker+0x1ff>
-               000000000000020b:  R_X86_64_PLT32       _dev_err-0x4
+     1f7: 49 8b bf 70 f6 ff ff                 movq    -2448(%r15), %rdi
+     1fe: 48 c7 c6 00 00 00 00                 movq    $0, %rsi
+               0000000000000201:  R_X86_64_32S .rodata.str1.1+0x1082
+     205: e8 00 00 00 00                       callq   0x20a <ipc_imem_run_state_worker+0x1fa>
+               0000000000000206:  R_X86_64_PLT32       _dev_err-0x4
+     20a: e9 af fe ff ff                       jmp     0xbe <ipc_imem_run_state_worker+0xae>
+     20f: e8 00 00 00 00                       callq   0x214 <ipc_imem_run_state_worker+0x204>
+               0000000000000210:  R_X86_64_PLT32       __stack_chk_fail-0x4
nickdesaulniers commented 2 years ago

With this diff the warning goes away:

We can't ship that. There's a call to _dev_err in ipc_imem_run_state_worker. There's possibly UB in ipc_imem_run_state_worker.

dileks commented 2 years ago

What do you need for a proper fix?

Object Files?

Nick Desaulniers @.***> schrieb am Mo., 8. Aug. 2022, 20:33:

With this diff the warning goes away:

We can't ship that. There's a call to _dev_err in ipc_imem_run_state_worker. There's possibly UB in ipc_imem_run_state_worker.

— Reply to this email directly, view it on GitHub https://github.com/ClangBuiltLinux/linux/issues/1683#issuecomment-1208468654, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFQTSBUWMCH2MWZCRH3PJTVYFHH5ANCNFSM55ZWMWQQ . You are receiving this because you authored the thread.Message ID: @.***>

jpoimboe commented 2 years ago

Looks like a compiler bug to me. After the call to _dev_err() it just falls off the end of the function.