Investigate libbpf errors when building kernels on K3 hardware. #20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally reported around May 11 2026 @kashyapc reported seeing the following from a kernel build running in a container on a SpacemiT K3 he had access to.
https://matrix.to/#/!GhnNOKFLyvWBmnjqRS:fedoraproject.org/$dGYwmYpjCmM9rObd09u-JVvfM8TRxKmTC8zPwWOHhjw?via=fedoraproject.org&via=matrix.org&via=fedora.im
June 2 on a K3 Koji Builder running 7.1-rc6 omni kernel we see similar:
https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=222282
Yaneti reported reproducing more or less the same error doing a mock build on a K3 system running the Bianbu kernel.
https://matrix.to/#/!GhnNOKFLyvWBmnjqRS:fedoraproject.org/$atuU1ZN4FcXyHW2IHSt_gVT8h7zOE1jgtyUBqG56jiY?via=fedoraproject.org&via=matrix.org&via=fedora.im
The same build succeeded in Copr:
https://copr.fedorainfracloud.org/coprs/g/forge-riscv-members/riscv64_omni_mainline_kernel/build/10550035/
Investigate K3 libbpf errors when building kernels on K3 hardware.to Investigate libbpf errors when building kernels on K3 hardware.Thanks, Jason! (Copy/pasting my comment from the kernel benchmark here: #17 (comment))
Intervention on K3: disable BTF kernel module
I had to disable BTF because I was hitting a crash with this error:
I got the Fedora omni kernel build from here:
Disabled the BTF module:
Recompile. The build succeeds in ~3h24 minutes:
Some things I want to try
I am using the same kernel the K3 is running on a bpi-f3 to try and build the same package to help elliminate anything related with either. I don't think the host kernel is responsible since we observe this on hosts running Bianbu vendor kernels as well.
Build a vanilla Fedora kernel on K3 and make sure it's not related to any patches in the omni kernel. Every failed build attempt is of an omni kernel so far.
In the past with eswin vendor kernels they were copying header files around during module build which triggered a vmlinux rebuild after modules built. In the eswin case the failures were 100% reproducible every build attempt, on any hardware, so I really don't think this is what is going on here. But it would be good to closely watch a mock build, check the vmlinux modification time after the initial build and make sure the build isn't rerunning and we don't end up with a newer vmlinux to try and rule this scenario out.
Other suggests are welcome.
@davidlt suggested
Gemini 3.5 FLash basically suggests make V=2, then maybe make V=1 -d modules > build_debug.log 2>&1, or just run -j1 1st and 2nd option might tell what's causing vmlinux to be rebuilt.We can rpmbuild -bp rpmbuild/SPECS/kernel.spec, copy kernel-riscv64-fedora.config from rpmbuild/SOURCES to rpmbuild/BUILD/.../.config and run make commands manually to try and diagnose as well.
Another failure on the K3, albeit a different error message:
Host kernel was:
Using the same kernel on a bpi-f3 the build succeeded.
In both case the mock build command was
/mock -r fedora-44-riscv64 --rebuild ./kernel-7.1.0-0.rc6.40.2.0.riscv64.omni.fc43.src.rpmAfter the initial vmlinuz.efi build:
After the failure the file was unchanged so I do not believe it is being recompiled
src.fedoraproject.org/rpms/kernel@bfa612b934/f/kernel-riscv64-fedora.configThe build succeeds with:
make -s -j8 vmlinuz.efi; make -s -j8 modulesThe build fails with:
make -s 'HOSTCFLAGS=-O2 -fPIE' 'HOSTLDFLAGS=-pie' -j8 vmlinuz.efi; make -s 'HOSTCFLAGS=-O2 -fPIE' 'HOSTLDFLAGS=-pie' -j8 modulesDoing the same and compiling on bianbu didn't error for me, so it specific to Fedora.
So is it Fedora
defconfigor-s 'HOSTCFLAGS=-O2 -fPIE' 'HOSTLDFLAGS=-pie'flags that we pass?The binutils error is strange. yaneti ran things in a loop + stress-ng at the same time. We got some crash reports. I fed it into Gemini 3.1 Flash + max thinking effort. I haven't looked too deep, but in all cases it was an invalid pointer IIRC. Surprisingly it was 56 (mostly) and 57 bits flipping, otherwise the address seemed somewhat okay (not verified). Gemini started speculating if this could be related to memory tagging extension (RVA23). Is it a memory corruption somewhere, or a tag which is somehow not ignored. Anyways, unknown.
At this point I don't really feel I have a grasp of what's actually causing the error. All I can provide are my observations.
To date I have never managed to reproduce it running just
make -j8 vmlinuz.efi; make -j8 moduleswith the defconfig or kernel-riscv64-fedora.config from Fedora.I have never produced it with defconfig+btf no matter what I pass to make, but defconfig is around 100 modules and Fedora is something like 4100, so I suppose it may take several tries with defconfig to reproduce the error if it's a game of numbers and I have not tried much.
I have never reproduced it trying to build with Bianbu userspace, but I haven't tried this much either. I want to try some more builds to see if I can cause the error to occur in Bianbu. If we can't make it occur in Bianbu I feel it must be a bug in a version of something in Fedora rather than memory corruption or something else along those lines.
kernel seems irrelevant. We've boot into Bianbu with 6.18.3 and seen it in a podman containers, I've seen it in a Fedora chroot booted in Bianbu and I've seen it booted into Fedora with the 7.1-rc6 omni kernel.
I had some successful builds just omitting
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors(-specs=/usr/lib/rpm/redhat/redhat-hardened-ld basically sets HOSTLDFLAGS=-pie IIUC) and was again able to reproduce failure several times simplifying the make flags tomake -s 'HOSTCFLAGS=-O2 -fPIE' 'HOSTLDFLAGS=-pie' -j8 vmlinuz.efi; make -s 'HOSTCFLAGS=-O2 -fPIE' 'HOSTLDFLAGS=-pie' -j8 modules.Perhaps most frustratingly, after several builds reproducing it I had suddenly had several successes.
I am suspicious of memory corruption or maybe reading from storage. Today I ran rpmbuild -bb to start a kernel build and a patch failed to apply on the first run:
The patch was generated via the kernel-ark scripts so there wasn't really room for manual error in generating it and anyway simply rerunning rpmbuild -bb a moment later it applied successfully.