Commit graph

2,487 commits

Message SHA1
Merge "Move CPU time in state bpf maps to their own dir," into main
Simon MacMullen   authored and   Android (Google) Code Review   commited 2025-06-27 07:49:37 -07:00
f84cb04bd7
Move CPU time in state bpf maps to their own dir,
This will allow us to use a genfscon SELinux rule to get finer grained access control.

Bug: 422976190

Test: Recorded a Perfetto trace with statsd atom  CPU_CYCLES_PER_UID_CLUSTER, tested manually with go/atomtester.
Change-Id: Ic16da605b9d7150d42176c428f0e1ecaf4a9472f

Simon MacMullen   commited 2025-06-26 16:31:52 +00:00
8546ea34c6
Merge changes I89a4c1d2,I961ba203,Idc61221e into main
* changes:
  bpf: vmlinux: Add OWNERS
  bpf: vmlinux: Remove android15_6.6 headers
  bpf: vmlinux: Update Readme

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-23 08:09:45 -07:00
d6c84caf3e
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
Merge "Use platform bpf_helpers.h and bpf_map_def.h for platform bpfloader" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-06-18 04:40:48 -07:00
16e017f20e
Merge "Add missing vendor_available: true property" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-17 15:53:01 -07:00
bd3fd05c3a
Merge "bpfloader: refactor C++ loader to just one function" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-17 05:56:59 -07:00
32075d5ef9
bpfloader: refactor C++ loader to just one function
no need for the complexity, as it is only for vendor now

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia807f7ee8aeca25d92e60e46f180ffe536eef87c

Maciej Żenczykowski   commited 2025-06-17 04:18:41 -07:00
d689e6e01a
make platform bpfloader require bpftool cli
Test: TreeHugger
Flag: EXEMPT adds as yet unused cli tool
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib6c2be3c40338743f3482010d7500fef8964adc6

Maciej Żenczykowski   commited 2025-06-17 03:55:14 -07:00
7d62694b8f
Add missing vendor_available: true property
Due to b/424439549, Soong wasn't enforcing that vendor modules could only link against
other vendor modules.  Add vendor_available to any modules that are being used by
vendor modules in order to allow re-enabling the error in Soong.

Bug: 424439549
Flag: EXEMPT build only fix
Test: builds
Change-Id: I3aff720d743bc63d4a9f13505b39c55fde90116d

Colin Cross   commited 2025-06-16 20:45:39 +00:00
6169de2adc
bpf: remove /system/etc/bpf from the loader
These directories are not populated on real devices
and are not part of the test suite.
This change removes them from the BPF loader.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I719d0feb9ef1a6f0a1e41265af47916410590ac7

Maciej Żenczykowski   commited 2025-06-16 01:28:45 -07:00
c041c4825b
Merge changes from topic "bpf_header_files1" into main
* changes:
  Remove unused bpfRingbufProg.o
  Add copy of bpf header files for platform use

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-13 04:32:44 -07:00
821600428c
Use platform bpf_helpers.h and bpf_map_def.h for platform bpfloader
Platform BPF programs rely on platform bpf_helpers.h and bpf_map_def.h.
To ensure consistency and correctness, the loader must use these platform
headers instead of those from p/m/Connectivity.

Bug: 424341374
Test: TH
Change-Id: Id5f1bc8fdd29e54c28a3ec9e01f6a9292f6bb9e1

Motomu Utsumi   commited 2025-06-13 13:04:02 +09:00
1f5cd4b9a1
Remove unused bpfRingbufProg.o
Test: TH
Bug: 410982483
Change-Id: Ib2fdedc63d5503aca38757f020fbe0466bbaca83

Motomu Utsumi   commited 2025-06-13 12:14:20 +09:00
e0fd4cdc6c
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 copy of bpf header files for platform use
$ cp packages/modules/Connectivity/bpf/headers/include/bpf_helpers.h system/bpf/include/bpf/
$ cp packages/modules/Connectivity/bpf/headers/include/bpf_map_def.h system/bpf/include/bpf/

Bug: 424341374
Test: TH
Change-Id: I81eb6485956a1674c1c23b8ff91599862446061e

Motomu Utsumi   commited 2025-06-12 16:58:12 +09:00
64550b51c5
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
Merge "Load bpfRingbufProg by rust bpfloader" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-06-02 00:33:05 -07:00
a2c132b118
Merge "Fix the group of gpu_mem_total_map" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-06-02 00:32:15 -07:00
0a3358f0ea
Merge "Skip loading bpfMemEventsTest on user build" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-06-02 00:31:45 -07:00
6d7d61e364
Load bpfRingbufProg by rust bpfloader
No behavior change is expected.

Before this CL
"""
$ adb shell ls /etc/bpf/bpfRingbufProg.o
/etc/bpf/bpfRingbufProg.o
$ adb shell ls -lZ /sys/fs/bpf/*bpfRingbufProg*
-rw-rw---- 1 root root u:object_r:fs_bpf:s0  0 2025-05-28 12:40 /sys/fs/bpf/map_bpfRingbufProg_test_ringbuf
-r--r----- 1 root root u:object_r:fs_bpf:s0  0 2025-05-28 12:40 /sys/fs/bpf/prog_bpfRingbufProg_skfilter_ringbuf_test
"""

After this CL
"""
$ adb shell ls /etc/bpf/bpfRingbufProg.bpf
/etc/bpf/bpfRingbufProg.bpf
$ adb shell ls -lZ /sys/fs/bpf/*bpfRingbufProg*
-rw-rw---- 1 root root u:object_r:fs_bpf:s0  0 2025-05-28 15:12 /sys/fs/bpf/map_bpfRingbufProg_test_ringbuf
-r--r----- 1 root root u:object_r:fs_bpf:s0  0 2025-05-28 15:12 /sys/fs/bpf/prog_bpfRingbufProg_skfilter_ringbuf_test
"""

Test: Loaded successfully on kernel 5.10, 5.15, 6.1, 6.12
Test: Load is skipped on user build
Bug: 410982483
Change-Id: I17563ea55a34d216c0d3ccd100a19ca52aa4d7ac

Motomu Utsumi   commited 2025-05-30 16:15:21 +09:00
87f696e2c3
Merge "bpf: Fix double inclusions" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-05-29 15:10:18 -07:00
c8789bf207
bpf: Fix double inclusions
Don't include <linux/bpf.h> if using vmlinux; as this causes
double inclusions.

Bug: 419635765
Test: manual; build and load a CO-RE BPF program
Change-Id: I4419778ea71b65ce46ac5e0e6358c33d7f78b82e
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>

Kalesh Singh   commited 2025-05-29 13:33:01 -07:00
0227ca2982
Fix the group of gpu_mem_total_map
Test: adb shell ls -lZ /sys/fs/bpf/*gpuMem_*
Bug: 410982483
Change-Id: I4576d219c5a22164c3b7d57a27f58bde272802cf

Motomu Utsumi   commited 2025-05-28 16:19:27 +09:00
bebda53162
Skip loading bpfMemEventsTest on user build
bpfMemEventsTest is installed only on debuggable devices.

Test: TH
Bug: 410982483
Change-Id: Ibf21f0cd639881058580d473dd0aae80bf3c480d

Motomu Utsumi   commited 2025-05-28 15:48:21 +09:00
9f53399e6c
Merge changes I471532a8,Ic1301be9,I076aed22,I156024bf,I2d2f4d09, ... into main
* changes:
  Allow rust bpfloader to load filterPowerSupplyEvents.bpf
  Allow rust bpfloader to load bpfRingbufProg.bpf
  Allow rust bpfloader to load bpfMemEventsTest.bpf
  Allow rust bpfloader to load bpfMemEvents.bpf
  Allow rust bpfloader to load gpuWork.bpf
  Allow rust bpfloader to load gpuMem.bpf

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-05-26 06:22:24 -07:00
7714bcfe30
Merge "Allow bpfloader to skip loading bpf object on user build" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-05-26 01:53:21 -07:00
5be3ce428e
Merge "KVER_5_8 -> KVER_5_10 for program that depends on ringbuf" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-05-26 00:17:01 -07:00
413aa0645f
Merge "Fix C++23 build: add missing #include." into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-05-25 19:41:11 -07:00
87ff39a16b
Allow rust bpfloader to load filterPowerSupplyEvents.bpf
Test: TH
Bug: 410982483
Change-Id: I471532a80ea872191f1ae880d3c5de2937d289ba

Motomu Utsumi   commited 2025-05-26 10:13:24 +09:00
f89e35a924
Allow rust bpfloader to load bpfRingbufProg.bpf
Test: TH
Bug: 410982483
Change-Id: Ic1301be9a49935f4845d09d70d6b80d215dce5fa

Motomu Utsumi   commited 2025-05-26 10:13:21 +09:00
256af2c856
Merge "Remove platform C++ bpfloader test" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-05-23 04:34:44 -07:00
3532e597aa
TEST_MAPPING: remove libbpf_load_test
(the test is being removed as it tests the obsolete C++
 platform bpf loader)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ica990e6fcc0f34374d32946298ae85f86d664dcc

Maciej Żenczykowski   commited 2025-05-23 03:00:08 -07:00
87674a8141
Allow rust bpfloader to load bpfMemEventsTest.bpf
Test: TH
Bug: 410982483
Change-Id: I076aed2206e47c9432628d4383edf9e64159ee67

Motomu Utsumi   commited 2025-05-23 11:46:25 +09:00
f088c4a66e
Allow rust bpfloader to load bpfMemEvents.bpf
Test: TH
Bug: 410982483
Change-Id: I156024bf130c1a808d657b9b501b64d2ae0d607b

Motomu Utsumi   commited 2025-05-23 11:46:25 +09:00
d8506e9151
Allow rust bpfloader to load gpuWork.bpf
Test: TH
Bug: 410982483
Change-Id: I2d2f4d0995eb8533751c91465afcdc71619375cd

Motomu Utsumi   commited 2025-05-23 11:46:25 +09:00
3023601201
Allow rust bpfloader to load gpuMem.bpf
Test: TH
Bug: 410982483
Change-Id: Ie801f58d8cb338bb99af2010c8a693c13c16579d

Motomu Utsumi   commited 2025-05-23 11:46:25 +09:00
8b9682001f
Allow bpfloader to skip loading bpf object on user build
Test: TH
Bug: 410982483
Change-Id: Ic13708deccefa330ce0c584fb6b0d0151fb872ed

Motomu Utsumi   commited 2025-05-23 11:45:51 +09:00
a1f21dd717
Remove platform C++ bpfloader test
C/C++ platform bpf loader is being replaced by rust version.

This test never had much value, and additional relies on
a sepolicy violation being allowed by su.

The bpf ring buf test is far better.

Test: TreeHugger
Flag: EXEMPT test code removal
Signed-off-by: Maciej Żenczykowski maze@google.com>
Change-Id: I448cc543aa9a0c161515ae2189020bf98db7bca3

Maciej Żenczykowski   commited 2025-05-22 14:10:18 -07:00
d93083a979
Fix C++23 build: add missing #include.
Change-Id: I21ab3f589ba1c9c0df4570264c9a25bc8c2ee427

Elliott Hughes   commited 2025-05-22 15:42:22 -04:00
7d08e8803d
KVER_5_8 -> KVER_5_10 for program that depends on ringbuf
ringbuf_test depends on the ring buffer that is loaded on 5.10+ kernel.

Test: TH
Bug: 410982483
Change-Id: If9d6a7f4483655cd5931bf64acfe34239f72cbe1

Motomu Utsumi   commited 2025-05-22 17:19:55 +09:00
92460e1c89
Fix kernel version check for program loading
Before this CL, the kernel version check occurred after all programs
were loaded by `open_file.load()`.

This CL moves the check before `open_file.load()`. It calls
`prog.set_autoload(false)` for programs incompatible with the current
kernel, preventing their auto-load by libbpf.

Test: Verify the program is not loaded if the kver is out of range
Bug: 410982483
Change-Id: Ifacd9dd8696a7bb4fd186ad1faf01fba9f021c6d

Motomu Utsumi   commited 2025-05-21 15:29:27 +09:00
315feea5fc
Fix kernel version check for map loading
Before this CL, the kernel version check occurred after all maps
were loaded by `open_file.load()`.

This CL moves the check before `open_file.load()`. It calls
`map.set_autocreate(false)` for maps incompatible with the current
kernel, preventing their auto-creation by libbpf.

Test: Verify the map is not loaded if the kver is out of range
Bug: 410982483
Change-Id: I7a102dd2ef4b24f87c6efa5a105848fddc08d501

Motomu Utsumi   commited 2025-05-21 15:10:28 +09:00
91e5b0ba66
Load fuseMedia.bpf
Bug: 410982483
Test: adb shell ls /etc/bpf/
Test: adb shell ls /sys/fs/bpf/
Test: adb logcat | grep -i bpf
Change-Id: I609707e0c3767bf7098b3f96e9c8aeb0fe3afe5e

Motomu Utsumi   commited 2025-05-20 15:25:00 +09:00
7f3f0f1c78
Skip pinning .rodata array map
libbpf creates an array map for the .rodata section to allow BPF
programs to access its data. However, the loader does not need
to pin this map as userspace processes do not require access to it.

This does not break existing code as the legacy bpfloader did not
create a map for .rodata.

Bug: 410982483
Test: TH
Change-Id: I036c93849731c25e8d1b6a2c1778ffc60935bbe2

Motomu Utsumi   commited 2025-05-20 15:18:17 +09:00
294bb70ec9
Skip loading unexisting bpf object while BPF loader migration
This makes bpfloader.rs simpler while BPF loader migration.

Bug: 410982483
Test: TH
Change-Id: I32fbbaed3efed45b5297634dbcfc7c80132cabc8

Motomu Utsumi   commited 2025-05-20 14:57:13 +09:00
a6a915dd12
Explicitly set bpf fuse program type for fuse/ programs
This is a no-op for existing timeInState.bpf

Bug: 410982483
Test: TH
Change-Id: Iaedc96c673241ffb2d040db17c5119a23543c923

Motomu Utsumi   commited 2025-05-19 13:37:50 +09:00
1b036d6475