Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o: warning: objtool: .text.rtl92cu_hw_init: unexpected end of section #1613

Open
dileks opened this issue Mar 24, 2022 · 27 comments
Labels
[ARCH] x86_64 This bug impacts ARCH=x86_64 [FEATURE] LTO Related to building the kernel with LLVM Link Time Optimization [TOOL] objtool warning is produced by the kernel's objtool

Comments

@dileks
Copy link
Collaborator

dileks commented Mar 24, 2022

I see this new objtool warning when using LLVM-14 version 14.0.0 (Debian or selfmade/stage1-only) and CONFIG_LTO_CLANG_THIN=y:

drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o: warning: objtool: .text.rtl92cu_hw_init: unexpected end of section

With LLVM-13 v13.0.0 I do not see it.

On a first view in the issue-tracker I have not seen this reported.

@dileks dileks added [ARCH] x86_64 This bug impacts ARCH=x86_64 [TOOL] objtool warning is produced by the kernel's objtool [FEATURE] LTO Related to building the kernel with LLVM Link Time Optimization labels Mar 24, 2022
@dileks
Copy link
Collaborator Author

dileks commented Mar 24, 2022

Here my kernel-config.

config-5.17.0-2-amd64-clang14-lto.txt

@dileks
Copy link
Collaborator Author

dileks commented Mar 24, 2022

My make line:

/usr/bin/perf stat make V=1 -j4 LLVM=1 LLVM_IAS=1 PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-2-amd64-clang14-lto KBUILD_BUILD_HOST=iniza KBUILD_BUILD_USER=sedat.dilek@gmail.com KBUILD_BUILD_TIMESTAMP=2022-03-24 bindeb-pkg KDEB_PKGVERSION=5.17.0-2~bookworm+dileks1

@nathanchance
Copy link
Member

I suspect this is just one instance of #1480. You could try to verify it by adding KCFLAGS="-Xclang -no-enable-noundef-analysis" to your make invocation to see if the warning disappears (or changes).

@dileks
Copy link
Collaborator Author

dileks commented Mar 24, 2022

This here seems not to work:

--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/Makefile
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/Makefile
@@ -10,4 +10,8 @@ rtl8192cu-objs :=             \
                table.o         \
                trx.o
 
+# CBL issue #1613
+# https://github.com/ClangBuiltLinux/linux/issues/1613
+CFLAGS_rtl8192cu.o += -Xclang -no-enable-noundef-analysis
+
 obj-$(CONFIG_RTL8192CU) += rtl8192cu.o

@dileks
Copy link
Collaborator Author

dileks commented Mar 24, 2022

I do not want to re-compile the whole Linux-kernel again by passing KCFLAGS to make.

Looks like this will be in LLVM-15:

$ git describe --contains 1b1c8d83d3567a60280291c0adb95d1d60335509
llvmorg-15-init~2146

$ git log --oneline -1 1b1c8d83d3567a60280291c0adb95d1d60335509
1b1c8d83d356 [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

With this diff:

--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/Makefile
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/Makefile
@@ -1,4 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
+
+# https://github.com/ClangBuiltLinux/linux/issues/1613
+ccflags-y += -disable-noundef-analysis
+
 rtl8192cu-objs :=              \
                dm.o            \
                hw.o            \

Nope.

$ grep disable-noundef-analysis ../build-log_5.17.0-2-amd64-clang14-lto.txt | wc -l
18

$ grep warning: ../build-log_5.17.0-2-amd64-clang14-lto.txt 
9:dpkg-architecture: warning: specified GNU system type x86_64-linux-gnu does not match CC system type x86_64-unknown-linux-gnu, try setting a correct CC environment variable
4019:drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o: warning: objtool: .text.rtl92cu_hw_init: unexpected end of section

@dileks
Copy link
Collaborator Author

dileks commented Mar 24, 2022

Just as a note:

$ /opt/llvm-toolchain/bin/clang -cc1 --help | grep -A1 disable-noundef-analysis
  -disable-noundef-analysis
                          Disable analyzing function argument and return types for mandatory definedness

$ /opt/llvm-toolchain/bin/clang -v
dileks clang version 14.0.0 (https://github.com/llvm/llvm-project.git 3f43d803382d57e3fc010ca19833077d1023e9c9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/llvm-toolchain/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

@nathanchance
Copy link
Member

nathanchance commented Mar 24, 2022

With this diff:

--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/Makefile
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/Makefile
@@ -1,4 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
+
+# https://github.com/ClangBuiltLinux/linux/issues/1613
+ccflags-y += -disable-noundef-analysis
+
 rtl8192cu-objs :=              \
                dm.o            \
                hw.o            \

Nope.

ccflags-y += -Xclang -disable-noundef-analysis

@dileks
Copy link
Collaborator Author

dileks commented Mar 24, 2022

Nope.

3462:  clang -Wp,-MMD,drivers/net/wireless/realtek/rtlwifi/rtl8192cu/.dm.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -Qunused-arguments -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu11 --target=x86_64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mstack-alignment=8 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mretpoline-external-thunk -fno-delete-null-pointer-checks -Wno-frame-address -Wno-address-of-packed-member -O2 -Wframe-larger-than=2048 -fstack-protector-strong -Wimplicit-fallthrough -Wno-gnu -mno-global-merge -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-stack-clash-protection -pg -mfentry -DCC_USING_NOP_MCOUNT -DCC_USING_FENTRY -fno-lto -flto=thin -fsplit-lto-unit -fvisibility=hidden -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -fno-strict-overflow -fno-stack-check -Werror=date-time -Werror=incompatible-pointer-types -Wno-initializer-overrides -Wno-format -Wno-sign-compare -Wno-format-zero-length -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -g -gdwarf-5 -Xclang -no-enable-noundef-analysis  -DMODULE  -DKBUILD_BASENAME='"dm"' -DKBUILD_MODNAME='"rtl8192cu"' -D__KBUILD_MODNAME=kmod_rtl8192cu -c -o drivers/net/wireless/realtek/rtlwifi/rtl8192cu/dm.o drivers/net/wireless/realtek/rtlwifi/rtl8192cu/dm.c 
3463:error: unknown argument: '-no-enable-noundef-analysis'

@nathanchance
Copy link
Member

Ah, the flag was only renamed in main, my apologies (I did correct it after the fact but that is not obvious): llvm/llvm-project@b529744

Regardless, if I add ccflags-y += -Xclang -disable-noundef-analysis or the equivalent for LLVM main to drivers/net/wireless/realtek/rtlwifi/rtl8192cu/Makefile, the warning goes away, so this is indeed just another instance of #1480.

I won't dupe this report for now though, as this might be a bug in the kernel sources.

@nickdesaulniers
Copy link
Member

@dileks
Copy link
Collaborator Author

dileks commented Mar 24, 2022

This fixes the warning for me:

--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/Makefile
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/Makefile
@@ -1,4 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
+
+# https://github.com/ClangBuiltLinux/linux/issues/1613
+ccflags-y += -Xclang -disable-noundef-analysis
+
 rtl8192cu-objs :=              \
                dm.o            \
                hw.o            \

@nickdesaulniers
Copy link
Member

@dileks can you please supply the output of llvm-objdump -Dr --disassemble-symbols=.text.rtl92cu_hw_init drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o. Consider attaching a file if the output is larger than 10 lines of asm.

@dileks
Copy link
Collaborator Author

dileks commented Mar 25, 2022

@nickdesaulniers

With and without patch:

$ llvm-objdump-14 -Dr --disassemble-symbols=.text.rtl92cu_hw_init drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o 

drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o: file format elf64-x86-64
llvm-objdump-14: warning: 'drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o': failed to disassemble missing symbol .text.rtl92cu_hw_init

NOTE: I have commented the ccflags line and have re-run my build-script.

@dileks
Copy link
Collaborator Author

dileks commented Mar 25, 2022

Checking again:

$ llvm-objdump-14 -Dr drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o | grep hw_init | grep -i disass
Disassembly of section .text.rtl92cu_hw_init:
Disassembly of section .rela.text.rtl92cu_hw_init:

$ llvm-objdump-14 -Dr --disassemble-symbols=.text.rtl92cu_hw_init drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o

drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o: file format elf64-x86-64
llvm-objdump-14: warning: 'drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o': failed to disassemble missing symbol .text.rtl92cu_hw_init

$ llvm-objdump-14 -Dr --disassemble-symbols=.rela.text.rtl92cu_hw_init drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o
File: llvm-objdump-14_rtl8192cu_lto_o-rela_text_rtl92cu_hw_init.txt

Attached output of the last {.rela}.text.rtl92cu_hw_init.

llvm-objdump-14_rtl8192cu_lto_o-text_rtl92cu_hw_init.txt

llvm-objdump-14_rtl8192cu_lto_o-rela_text_rtl92cu_hw_init.txt

@dileks
Copy link
Collaborator Author

dileks commented Mar 25, 2022

Seeing:

$ llvm-objdump-14 -Dr drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o | grep -n -A2 'Disassembly of section' | grep text.rtl92cu_hw_init
1263579:Disassembly of section .text.rtl92cu_hw_init:
1264711:Disassembly of section .rela.text.rtl92cu_hw_init:
1264713-0000000000000000 <.rela.text.rtl92cu_hw_init>:

@dileks
Copy link
Collaborator Author

dileks commented Mar 25, 2022

@nickdesaulniers

I can send you the llvm-objdumps if you desire.

$ zstd -19 -T0 -v <file>

$ du -k *.txt.zst
5352    llvm-objdump-14_rtl8192cu_lto_o_BAD.txt.zst
5360    llvm-objdump-14_rtl8192cu_lto_o_GOOD.txt.zst

@dileks
Copy link
Collaborator Author

dileks commented Mar 25, 2022

For the posterity:

$ grep warning: build-log_5.17.0-3-amd64-clang14-lto.txt 
27:dpkg-architecture: warning: specified GNU system type x86_64-linux-gnu does not match CC system type x86_64-pc-linux-gnu, try setting a correct CC environment variable

$ egrep 'chacha|rtl' patches.series 
6:5a822a5f4c6a rtlwifi: rtl8192cu: Fix warning with LLVM-14
7:90bac147c484 x86/chacha20: Avoid spurious jumps to other functions

[ Update 2022-03-25 ] Patch of PeterZ crypto: x86/chacha20 - Avoid spurious jumps to other functionnow in crypto-2.6.git:
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git/commit/?id=4327d168515fd8b5b92fa1efdf1d219fb6514460

@dileks
Copy link
Collaborator Author

dileks commented Mar 31, 2022

Re-checking:

1263666:Disassembly of section .text.rtl92cu_hw_init:
1263667-
1263668-0000000000000000 <rtl92cu_hw_init>:

1264808:Disassembly of section .rela.text.rtl92cu_hw_init:
1264809-
1264810-0000000000000000 <.rela.text.rtl92cu_hw_init>:

Looks like .text. prefix is removed in case of section .text.rtl92cu_hw_init.

UPDATE: For both cases BAD and GOOD the same.

@dileks
Copy link
Collaborator Author

dileks commented Mar 31, 2022

Attached output of:

llvm-objdump-14 -Dr --disassemble-symbols=rtl92cu_hw_init drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.lto.o > ../llvm-objdump-14-Dr-disassemble_symbols-rtl92cu_hw_init_rtl8192cu-lto-o.txt

llvm-objdump-14-Dr-disassemble_symbols-rtl92cu_hw_init_rtl8192cu-lto-o.txt

@dileks
Copy link
Collaborator Author

dileks commented Mar 31, 2022

Above was with my patch applied and from my today's build.

Here now without (BAD) and with my patch (GOOD):

cd BAD
llvm-objdump-14 -Dr --disassemble-symbols=rtl92cu_hw_init rtl8192cu.lto.o > BAD_rtl92cu_hw_init.txt

cd GOOD
llvm-objdump-14 -Dr --disassemble-symbols=rtl92cu_hw_init rtl8192cu.lto.o > GOOD_rtl92cu_hw_init.txt

BAD_rtl92cu_hw_init.txt
GOOD_rtl92cu_hw_init.txt

@dileks
Copy link
Collaborator Author

dileks commented May 21, 2022

See this issue with Linux v5.18-rc7+.

38982:drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.prelink.o: warning: objtool: .text.rtl92cu_hw_init: unexpected end of section

@dileks
Copy link
Collaborator Author

dileks commented Jul 17, 2022

[ drivers/net/wireless/realtek/rtlwifi/rtl8192cu/Makefile ]
# SPDX-License-Identifier: GPL-2.0

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

Is there a more elegant way to check for the LLVM version?

@nickdesaulniers
Copy link
Member

I'm not yet convinced that noundef-analysis is broken; I don't think disabling the analysis in Kbuild is the way to go.

@dileks can you confirm that you don't have CONFIG_UBSAN_DIV_ZERO=y set in your .config? Otherwise, based on this comment, I think this may be a dupe of #1657.

@dileks
Copy link
Collaborator Author

dileks commented Jul 23, 2022

@nickdesaulniers

# grep CONFIG_UBSAN_DIV_ZERO /boot/config-5.19.0-rc6-1-amd64-clang15-lto
[empty]

Full kernel-config attached.

config-5.19.0-rc6-1-amd64-clang15-lto.txt

@dileks
Copy link
Collaborator Author

dileks commented Aug 7, 2022

With patch applied (no objtool warnings):

$ /opt/llvm/bin/llvm-objdump -Dr --section=".text.rtl92cu_hw_init" drivers/net/wireless/realtek/rtlwifi/rtl8192cu/rtl8192cu.o > ../llvm-objdump_rtl8192cu_o.txt

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

@dileks
Copy link
Collaborator Author

dileks commented Aug 7, 2022

@jpoimboe

Attached llvm-objdump without patch applied (objtool warning visible).

I can provide both object-files if needed.

llvm-objdump_rtl8192cu_o_BROKEN.txt

@jpoimboe
Copy link

@dileks I'm not sure about this one, please provide the .o file for the broken case and I can take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] x86_64 This bug impacts ARCH=x86_64 [FEATURE] LTO Related to building the kernel with LLVM Link Time Optimization [TOOL] objtool warning is produced by the kernel's objtool
Projects
None yet
Development

No branches or pull requests

4 participants