android_system_bpf/include/vmlinux
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Kalesh Singh 2e61afb442 Add 6.1 vmlinux.h genrules
Generate vmlinux.h from the kernel prebuilt vmlinux

Bug: 421990777
Test: Manual; build bpf prog with "vmlinux_h_6_1" header
Change-Id: Ib1b7a24c470610ea6d1ee6c84f1c656e7139340b
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2025-06-12 09:33:39 -07:00
..
android15_6.6 BPF: Add vmlinux.h 2024-09-17 22:13:54 +00:00
Android.bp Add 6.1 vmlinux.h genrules 2025-06-12 09:33:39 -07:00
README BPF: Add vmlinux.h 2024-09-17 22:13:54 +00:00

These vmlinux.h files are manually generated using the following command:

bpftool btf dump file <path/to/vmlinux> format c > vmlinux.h

In the future, it would be good to create the infrastructure to periodically update this to a version with the latest tracking kernel.

These vmlinux.h files are used for bpf programs leveraging CO-RE to access internal kernel data structures. They do not need to track the target kernel perfectly, but if fields are added to an internal kernel data structure, they must be regenerated before these fields are used.

Similarly, the BPF programs which use vmlinux.h should be compiled against a vmlinux.h file which is generated from the vmlinux of the same architecture. On Android, this is not a problem for arm64 or x86_64 architectures, as the 64bit system userspace matches the 64bit kernel.

However, for 32 bit Android userspace, either arm or x86, we currently have no way to determine at build time if the kernel we will be running on will be 32bit or 64bit. For this reason, we default to 32bit userspace running on 64bit kernel, and therefore loading libbpf programs will be disabled at runtime for systems with 32bit kernels.