-
Notifications
You must be signed in to change notification settings - Fork 15
Boot failure on s390 with llvm-objcopy #1996
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I had a quick look, and it seems llvm-objcopy with -O binary only outputs sections marked as ALLOC. Due the --sec-section-flags argument, the flags of .vmlinux.info are set to LOAD only, which means the ALLOC flag is removed. Now, I'm not quite sure what LOAD without ALLOC even means exactly. (ALLOC without LOAD is used for .bss, ALLOC and LOAD together are used for sections mapped at run-time, and neither ALLOC nor LOAD is used for debug and similar sections.) Should the kernel Makefile use |
Yeah, seems entirely reasonable to me, especially since I see no visible difference with GNU objcopy. Patch submitted: https://lore.kernel.org/20240216-s390-fix-boot-with-llvm-objcopy-v1-1-0ac623daf42b@kernel.org/ |
… with LLVM tip of tree s390 support in ld.lld has recently landed in the main branch of LLVM. With this, it makes sense to start cutting s390 over to full LLVM=1, versus the current situation of just CC=clang. linux-next is the only tree that currently has the necessary changes to support ld.lld but they will trickle down to other trees in time. llvm-objcopy currently works on LLVM main as well but that needs a kernel side fix to boot properly, so we will stick with GNU objcopy until that is fixed. Closes: ClangBuiltLinux#710 Link: ClangBuiltLinux/linux#1996 Link: llvm/llvm-project@fe3406e Link: llvm/llvm-project@3c02cb7 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
When attempting to boot a kernel compiled with OBJCOPY=llvm-objcopy, there is a crash right at boot: Out of memory allocating 6d7800 bytes 8 aligned in range 0:20000000 Reserved memory ranges: 0000000000000000 a394c3c30d90cdaf DECOMPRESSOR Usable online memory ranges (info source: sclp read info [3]): 0000000000000000 0000000020000000 Usable online memory total: 20000000 Reserved: a394c3c30d90cdaf Free: 0 Call Trace: (sp:0000000000033e90 [<0000000000012fbc>] physmem_alloc_top_down+0x5c/0x104) sp:0000000000033f00 [<0000000000011d56>] startup_kernel+0x3a6/0x77c sp:0000000000033f60 [<00000000000100f4>] startup_normal+0xd4/0xd4 GNU objcopy does not have any issues. Looking at differences between the object files in each build reveals info.bin does not get properly populated with llvm-objcopy, which results in an empty .vmlinux.info section. $ file {gnu,llvm}-objcopy/arch/s390/boot/info.bin gnu-objcopy/arch/s390/boot/info.bin: data llvm-objcopy/arch/s390/boot/info.bin: empty $ llvm-readelf --section-headers {gnu,llvm}-objcopy/arch/s390/boot/vmlinux | rg 'File:|\.vmlinux\.info|\.decompressor\.syms' File: gnu-objcopy/arch/s390/boot/vmlinux [12] .vmlinux.info PROGBITS 0000000000034000 035000 000078 00 WA 0 0 1 [13] .decompressor.syms PROGBITS 0000000000034078 035078 000b00 00 WA 0 0 1 File: llvm-objcopy/arch/s390/boot/vmlinux [12] .vmlinux.info PROGBITS 0000000000034000 035000 000000 00 WA 0 0 1 [13] .decompressor.syms PROGBITS 0000000000034000 035000 000b00 00 WA 0 0 1 Ulrich points out that llvm-objcopy only copies sections marked as alloc with a binary output target, whereas the .vmlinux.info section is only marked as load. Add 'alloc' in addition to 'load', so that both objcopy implementations work properly: $ file {gnu,llvm}-objcopy/arch/s390/boot/info.bin gnu-objcopy/arch/s390/boot/info.bin: data llvm-objcopy/arch/s390/boot/info.bin: data $ llvm-readelf --section-headers {gnu,llvm}-objcopy/arch/s390/boot/vmlinux | rg 'File:|\.vmlinux\.info|\.decompressor\.syms' File: gnu-objcopy/arch/s390/boot/vmlinux [12] .vmlinux.info PROGBITS 0000000000034000 035000 000078 00 WA 0 0 1 [13] .decompressor.syms PROGBITS 0000000000034078 035078 000b00 00 WA 0 0 1 File: llvm-objcopy/arch/s390/boot/vmlinux [12] .vmlinux.info PROGBITS 0000000000034000 035000 000078 00 WA 0 0 1 [13] .decompressor.syms PROGBITS 0000000000034078 035078 000b00 00 WA 0 0 1 Closes: ClangBuiltLinux#1996 Link: llvm/llvm-project@3c02cb7 Suggested-by: Ulrich Weigand <ulrich.weigand@de.ibm.com> Signed-off-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20240216-s390-fix-boot-with-llvm-objcopy-v1-1-0ac623daf42b@kernel.org Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
…ee LLVM With LLVM main, which has the necessary changes to ld.lld and llvm-objcopy to support s390, and linux-next, which has the necessary changes to the kernel to support these tools, ARCH=s390 builds cleanly with LLVM=1. Cut builds that satisfy these conditions over to LLVM=1 so that regressions with this working setup do not occur. Link: llvm/llvm-project@fe3406e Link: llvm/llvm-project@3c02cb7 Link: ClangBuiltLinux/linux#859 Link: ClangBuiltLinux/linux#1991 Link: ClangBuiltLinux/linux#1992 Link: ClangBuiltLinux/linux#1993 Link: ClangBuiltLinux/linux#1994 Link: ClangBuiltLinux/linux#1995 Link: ClangBuiltLinux/linux#1996 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Merged into mainline: https://git.kernel.org/linus/9ea30fd166e9b869546059f714beab78cb150b11 |
I have been testing the s390
llvm-objcopy
pull request, which results in no new build warnings or errors onnext-20240215
:However, the resulting kernel image does not boot:
With
OBJCOPY=s390x-linux-gnu-objcopy
, there are no issues when booting:Looking at the files that are generated by
objcopy
during the build, I notice thatarch/s390/boot/info.bin
is different between the two builds...If I take a directory built with
OBJCOPY=llvm-obcopy
and move thearch/s390/boot/info.bin
from a directory built withOBJCOPY=s390x-linux-gnu-objcopy
and runmake
again, the resulting image boots.Looking at the build logs,
info.bin
is generated fromvmlinux
withThis was done initially as part of https://git.kernel.org/linus/369f91c374514f9491d52fec12f7ee9ef6d44b23.
cc @MaskRay and @uweigand (even though this doesn't seem like anything specific to s390 but just in case)
The text was updated successfully, but these errors were encountered: