BpfRingbuf: Add support for 32 bit kernels

This change adds support for 32 bit kernels by capping mProducerPos to
4 bytes. mConsumerPos (which is written to by userspace) continues to
use 8 bytes. (This can be done because an entire page is allocated for
mConsumerPos to control access permissions). In a 32 bit kernel, that
means that the top order bits are just ignored. In addition, comparisons
in userspace only use the bottom 4 bytes to be bitness agnostic.

Test: atest BpfRingbufTest
Change-Id: I7fe6d9000a151512785f1aa2a53fa97d31967d19
This commit is contained in:
Patrick Rohr
2023-05-17 16:22:05 -07:00
parent 0d6edeef83
commit 52954ff505
2 changed files with 14 additions and 17 deletions

View File

@@ -50,10 +50,6 @@ class BpfRingbufTest : public ::testing::Test {
GTEST_SKIP() << "BPF ring buffers not supported below 5.8";
}
if (!isKernel64Bit()) {
GTEST_SKIP() << "BPF ring buffers not supported on 32 bit kernel";
}
errno = 0;
mProgram.reset(retrieveProgram(mProgPath.c_str()));
EXPECT_EQ(errno, 0);