Initial unified commit for Android 14, with TrebleDroid GSI target, syncing up to 20240208

This commit is contained in:
Andy CrossGate Yan
2024-02-17 16:46:38 +08:00
commit e9902a4450
281 changed files with 169698 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
From 4b484de1b55acb758be89fbbdffd25a02b2dde5b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 13 Oct 2021 10:56:52 -0400
Subject: [PATCH 1/2] Support no-bpf usecase
Change-Id: I75a427a2a41aa4ab1104ad88a891bef0dc2d9c91
---
bpfloader/BpfLoader.cpp | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/bpfloader/BpfLoader.cpp b/bpfloader/BpfLoader.cpp
index e53669a..158dca6 100644
--- a/bpfloader/BpfLoader.cpp
+++ b/bpfloader/BpfLoader.cpp
@@ -284,7 +284,9 @@ int main(int argc, char** argv) {
// which could otherwise fail with ENOENT during object pinning or renaming,
// due to ordering issues)
for (const auto& location : locations) {
- if (createSysFsBpfSubDir(location.prefix)) return 1;
+ if (createSysFsBpfSubDir(location.prefix)) {
+ goto fail;
+ }
}
// Note: there's no actual src dir for fs_bpf_loader .o's,
@@ -292,18 +294,15 @@ int main(int argc, char** argv) {
// This is because this is primarily meant for triggering genfscon rules,
// and as such this will likely always be the case.
// Thus we need to manually create the /sys/fs/bpf/loader subdirectory.
- if (createSysFsBpfSubDir("loader")) return 1;
+ if (createSysFsBpfSubDir("loader")) {
+ goto fail;
+ return 1;
+ }
// Load all ELF objects, create programs and maps, and pin them
for (const auto& location : locations) {
if (loadAllElfObjects(location) != 0) {
- ALOGE("=== CRITICAL FAILURE LOADING BPF PROGRAMS FROM %s ===", location.dir);
- ALOGE("If this triggers reliably, you're probably missing kernel options or patches.");
- ALOGE("If this triggers randomly, you might be hitting some memory allocation "
- "problems or startup script race.");
- ALOGE("--- DO NOT EXPECT SYSTEM TO BOOT SUCCESSFULLY ---");
- sleep(20);
- return 2;
+ goto fail;
}
}
@@ -321,5 +320,13 @@ int main(int argc, char** argv) {
return 1;
}
+ return 0;
+fail:
+ ALOGE("=== CRITICAL FAILURE LOADING BPF PROGRAMS ===");
+ ALOGE("If this triggers reliably, you're probably missing kernel options or patches.");
+ ALOGE("If this triggers randomly, you might be hitting some memory allocation "
+ "problems or startup script race.");
+ ALOGE("--- DO NOT EXPECT SYSTEM TO BOOT SUCCESSFULLY ---");
+ android::base::SetProperty("bpf.progs_loaded", "1");
return 0;
}
--
2.25.1

View File

@@ -0,0 +1,34 @@
From 059cfff8796aa45e138c67fc9cd6aa966cb8ef68 Mon Sep 17 00:00:00 2001
From: Andy CrossGate Yan <GeForce8800Ultra@gmail.com>
Date: Wed, 19 Oct 2022 02:20:05 +0000
Subject: [PATCH 2/2] Revert "detect inability to write to index != 0 of bpf
map array"
This reverts commit ead9d83423877458023056f6ccf9390950d6726f.
---
bpfloader/BpfLoader.cpp | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/bpfloader/BpfLoader.cpp b/bpfloader/BpfLoader.cpp
index 158dca6..0af23c9 100644
--- a/bpfloader/BpfLoader.cpp
+++ b/bpfloader/BpfLoader.cpp
@@ -306,15 +306,6 @@ int main(int argc, char** argv) {
}
}
- int key = 1;
- int value = 123;
- android::base::unique_fd map(
- android::bpf::createMap(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value), 2, 0));
- if (android::bpf::writeToMapEntry(map, &key, &value, BPF_ANY)) {
- ALOGE("Critical kernel bug - failure to write into index 1 of 2 element bpf map array.");
- return 1;
- }
-
if (android::base::SetProperty("bpf.progs_loaded", "1") == false) {
ALOGE("Failed to set bpf.progs_loaded property");
return 1;
--
2.25.1