Commit graph android_system_bpf/include/vmlinux
Message SHA1
bpf: vmlinux: Add OWNERS
Bug: 421990777
Test: N/A
Change-Id: I89a4c1d2b908f997c92eaa210f2006420e7a30cf
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>

Kalesh Singh   commited 2025-06-20 14:40:47 -07:00
d2852e8687
bpf: vmlinux: Remove android15_6.6 headers
These are now generated by the build system when needed.

Bug: 421990777
Test: m
Change-Id: I961ba203989325e58428a7b3068326fc89debaa8
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>

Kalesh Singh   commited 2025-06-20 12:04:31 -07:00
a6156a9122
bpf: vmlinux: Update Readme
Convert readme to markdown; refactor existing descriptions;
add instructions on how to add vmlinux.h for new kernels.

Bug: 421990777
Test: N/A
Change-Id: Idc61221e729d034c5fedb458bd18db02fade713a
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>

Kalesh Singh   commited 2025-06-20 11:47:41 -07:00
9462a3d7aa
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>

Kalesh Singh   commited 2025-06-12 09:33:39 -07:00
2e61afb442
Add 6.6 vmlinux.h genrules
Generate vmlinux.h from the kernel prebuilt vmlinux

Bug: 421990777
Test: Manual; build bpf prog with "vmlinux_h_6_6" header
Change-Id: I6b172b1dd13dfc9750a9075616c596916d1473a9
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>

Kalesh Singh   commited 2025-06-11 15:45:46 -07:00
7a037f8346
Add 6.12 vmlinux.h genrules
Generate vmlinux.h from the kernel prebuilt vmlinux

Bug: 421990777
Test: Manual; build bpf prog with "vmlinux_h_6_12" header
Change-Id: I5647a3c2d7d1695aa42fd9636dd7f7abd4a1dc44
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>

Kalesh Singh   commited 2025-06-11 15:41:44 -07:00
655664e3cd
BPF: Add vmlinux.h
Generated from aosp_kernel-common-android15_6.6 build 12345991
Tagged as android15-6.6-2024-08-r7

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.

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

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

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

The vmlinux artifact can be downloaded through this process:

Navigate to
https://source.android.com/docs/core/architecture/kernel/gki-android15-6_6-release-builds#launch-releases

and identify the link to the latest release kernel artifacts, in this
case android15-6.6-2024-08-r7 is linked to
https://ci.android.com/builds/submitted/12345991/kernel_aarch64/latest

Appending '/vmlinux' to the end will take you directly to the artifact
download for aarch64.

Change the 'kernel_aarch64' path to 'kernel_x86_64' to download the
x86_64 vmlinux file.

The final download paths for the vmlinux files used in this change are:
https://ci.android.com/builds/submitted/12345991/kernel_aarch64/latest/vmlinux
https://ci.android.com/builds/submitted/12345991/kernel_x86_64/latest/vmlinux

Internally, this can be done with:
/google/data/ro/projects/android/fetch_artifact --bid 12345991 --target kernel_aarch64 'vmlinux'
/google/data/ro/projects/android/fetch_artifact --bid 12345991 --target kernel_x86_64 'vmlinux'

Using bpftool v7.3.0 with libbpf v1.3 with llvm, skeletons enabled:

cd system/bpf/imclude/vmlinux/arm64/
<cp aarch64 vmlinux file here>
bpftool btf dump file vmlinux format c > vmlinux.h
rm vmlinux

cd ../x86_64
<cp x86_64 vmlinux file here>
bpftool btf dump file vmlinux format c > vmlinux.h
rm vmlinux

For future automation use, the following command may be useful in
identifying the latest kernel release tag:

git -c  'versionsort.suffix=-' ls-remote --tags --refs \
https://android.googlesource.com/kernel/common/ android15-6.6-202\* \
| tail --lines=1

Test: Manual / TH
Bug: 359646531
Change-Id: I59946a6ea1a724b5ed9c2d8edff061236702c32d
Signed-off-by: Neill Kapron <nkapron@google.com>

Neill Kapron   commited 2024-09-17 22:13:54 +00:00
432d150808