Merge "libsnapshot: configure num worker threads" into main
diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/read_worker.cpp b/fs_mgr/libsnapshot/snapuserd/user-space-merge/read_worker.cpp
index ef311d4..33767d6 100644
--- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/read_worker.cpp
+++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/read_worker.cpp
@@ -104,6 +104,8 @@
}
bool ReadWorker::ProcessXorOp(const CowOperation* cow_op, void* buffer) {
+ using WordType = std::conditional_t<sizeof(void*) == sizeof(uint64_t), uint64_t, uint32_t>;
+
if (!ReadFromSourceDevice(cow_op, buffer)) {
return false;
}
@@ -120,9 +122,12 @@
return false;
}
- auto xor_out = reinterpret_cast<uint8_t*>(buffer);
- for (size_t i = 0; i < BLOCK_SZ; i++) {
- xor_out[i] ^= xor_buffer_[i];
+ auto xor_in = reinterpret_cast<const WordType*>(xor_buffer_.data());
+ auto xor_out = reinterpret_cast<WordType*>(buffer);
+ auto num_words = BLOCK_SZ / sizeof(WordType);
+
+ for (auto i = 0; i < num_words; i++) {
+ xor_out[i] ^= xor_in[i];
}
return true;
}
diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_readahead.cpp b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_readahead.cpp
index 6b1ed0c..9a1d441 100644
--- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_readahead.cpp
+++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_readahead.cpp
@@ -458,6 +458,7 @@
void ReadAhead::ProcessXorData(size_t& block_xor_index, size_t& xor_index,
std::vector<const CowOperation*>& xor_op_vec, void* buffer,
loff_t& buffer_offset) {
+ using WordType = std::conditional_t<sizeof(void*) == sizeof(uint64_t), uint64_t, uint32_t>;
loff_t xor_buf_offset = 0;
while (block_xor_index < blocks_.size()) {
@@ -470,13 +471,14 @@
// Check if this block is an XOR op
if (xor_op->new_block == new_block) {
// Pointer to the data read from base device
- uint8_t* buffer = reinterpret_cast<uint8_t*>(bufptr);
+ auto buffer_words = reinterpret_cast<WordType*>(bufptr);
// Get the xor'ed data read from COW device
- uint8_t* xor_data = reinterpret_cast<uint8_t*>((char*)bufsink_.GetPayloadBufPtr() +
- xor_buf_offset);
+ auto xor_data_words = reinterpret_cast<WordType*>(
+ (char*)bufsink_.GetPayloadBufPtr() + xor_buf_offset);
+ auto num_words = BLOCK_SZ / sizeof(WordType);
- for (size_t byte_offset = 0; byte_offset < BLOCK_SZ; byte_offset++) {
- buffer[byte_offset] ^= xor_data[byte_offset];
+ for (auto i = 0; i < num_words; i++) {
+ buffer_words[i] ^= xor_data_words[i];
}
// Move to next XOR op
diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp
index c26b31e..ece430b 100644
--- a/init/first_stage_mount.cpp
+++ b/init/first_stage_mount.cpp
@@ -156,13 +156,6 @@
return fstab;
}
-static bool IsRequestingMicrodroidVendorPartition(const std::string& cmdline) {
- if (virtualization::IsEnableTpuAssignableDeviceFlagEnabled()) {
- return access("/proc/device-tree/avf/vendor_hashtree_descriptor_root_digest", F_OK) == 0;
- }
- return cmdline.find("androidboot.microdroid.mount_vendor=1") != std::string::npos;
-}
-
// Note: this is a temporary solution to avoid blocking devs that depend on /vendor partition in
// Microdroid. For the proper solution the /vendor fstab should probably be defined in the DT.
// TODO(b/285855430): refactor this
@@ -173,7 +166,7 @@
if (!ReadDefaultFstab(&fstab)) {
return Error() << "failed to read fstab";
}
- if (!IsRequestingMicrodroidVendorPartition(cmdline)) {
+ if (cmdline.find("androidboot.microdroid.mount_vendor=1") == std::string::npos) {
// We weren't asked to mount /vendor partition, filter it out from the fstab.
auto predicate = [](const auto& entry) { return entry.mount_point == "/vendor"; };
fstab.erase(std::remove_if(fstab.begin(), fstab.end(), predicate), fstab.end());
diff --git a/libcutils/sched_policy_test.cpp b/libcutils/sched_policy_test.cpp
index 50bd6d0..2641743 100644
--- a/libcutils/sched_policy_test.cpp
+++ b/libcutils/sched_policy_test.cpp
@@ -67,13 +67,6 @@
}
TEST(SchedPolicy, set_sched_policy) {
- if (!schedboost_enabled()) {
- // schedboost_enabled() (i.e. CONFIG_CGROUP_SCHEDTUNE) is optional;
- // it's only needed on devices using energy-aware scheduler.
- GTEST_LOG_(INFO) << "skipping test that requires CONFIG_CGROUP_SCHEDTUNE";
- return;
- }
-
ASSERT_EQ(0, set_sched_policy(0, SP_BACKGROUND));
ASSERT_EQ(0, set_cpuset_policy(0, SP_BACKGROUND));
AssertPolicy(SP_BACKGROUND);
diff --git a/libprocessgroup/include/processgroup/sched_policy.h b/libprocessgroup/include/processgroup/sched_policy.h
index 1b6ea66..92cd367 100644
--- a/libprocessgroup/include/processgroup/sched_policy.h
+++ b/libprocessgroup/include/processgroup/sched_policy.h
@@ -29,14 +29,6 @@
*/
extern bool cpusets_enabled();
-/*
- * Check if Linux kernel enables SCHEDTUNE feature (only available in Android
- * common kernel or Linaro LSK, not in mainline Linux as of v4.9)
- *
- * Return value: 1 if Linux kernel CONFIG_CGROUP_SCHEDTUNE=y; 0 otherwise.
- */
-extern bool schedboost_enabled();
-
/* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */
typedef enum {
SP_DEFAULT = -1,
diff --git a/libprocessgroup/profiles/Android.bp b/libprocessgroup/profiles/Android.bp
index 885971a..1ec9f7f 100644
--- a/libprocessgroup/profiles/Android.bp
+++ b/libprocessgroup/profiles/Android.bp
@@ -19,11 +19,6 @@
prebuilt_etc {
name: "cgroups.json",
src: "cgroups.json",
- required: [
- "cgroups_28.json",
- "cgroups_29.json",
- "cgroups_30.json",
- ],
}
prebuilt_etc {
@@ -34,49 +29,8 @@
}
prebuilt_etc {
- name: "cgroups_28.json",
- src: "cgroups_28.json",
- sub_dir: "task_profiles",
-}
-
-prebuilt_etc {
- name: "cgroups_29.json",
- src: "cgroups_29.json",
- sub_dir: "task_profiles",
-}
-
-prebuilt_etc {
- name: "cgroups_30.json",
- src: "cgroups_30.json",
- sub_dir: "task_profiles",
-}
-
-prebuilt_etc {
name: "task_profiles.json",
src: "task_profiles.json",
- required: [
- "task_profiles_28.json",
- "task_profiles_29.json",
- "task_profiles_30.json",
- ],
-}
-
-prebuilt_etc {
- name: "task_profiles_28.json",
- src: "task_profiles_28.json",
- sub_dir: "task_profiles",
-}
-
-prebuilt_etc {
- name: "task_profiles_29.json",
- src: "task_profiles_29.json",
- sub_dir: "task_profiles",
-}
-
-prebuilt_etc {
- name: "task_profiles_30.json",
- src: "task_profiles_30.json",
- sub_dir: "task_profiles",
}
cc_defaults {
diff --git a/libprocessgroup/profiles/cgroups_28.json b/libprocessgroup/profiles/cgroups_28.json
deleted file mode 100644
index 17d4929..0000000
--- a/libprocessgroup/profiles/cgroups_28.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "Cgroups": [
- {
- "Controller": "schedtune",
- "Path": "/dev/stune",
- "Mode": "0755",
- "UID": "system",
- "GID": "system"
- }
- ]
-}
diff --git a/libprocessgroup/profiles/cgroups_29.json b/libprocessgroup/profiles/cgroups_29.json
deleted file mode 100644
index 17d4929..0000000
--- a/libprocessgroup/profiles/cgroups_29.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "Cgroups": [
- {
- "Controller": "schedtune",
- "Path": "/dev/stune",
- "Mode": "0755",
- "UID": "system",
- "GID": "system"
- }
- ]
-}
diff --git a/libprocessgroup/profiles/cgroups_30.json b/libprocessgroup/profiles/cgroups_30.json
deleted file mode 100644
index 80a074b..0000000
--- a/libprocessgroup/profiles/cgroups_30.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "Cgroups": [
- {
- "Controller": "schedtune",
- "Path": "/dev/stune",
- "Mode": "0755",
- "UID": "system",
- "GID": "system",
- "Optional": true
- }
- ]
-}
diff --git a/libprocessgroup/profiles/task_profiles_28.json b/libprocessgroup/profiles/task_profiles_28.json
deleted file mode 100644
index e7be548..0000000
--- a/libprocessgroup/profiles/task_profiles_28.json
+++ /dev/null
@@ -1,160 +0,0 @@
-{
- "Attributes": [
- {
- "Name": "STuneBoost",
- "Controller": "schedtune",
- "File": "schedtune.boost"
- },
- {
- "Name": "STunePreferIdle",
- "Controller": "schedtune",
- "File": "schedtune.prefer_idle"
- }
- ],
-
- "Profiles": [
- {
- "Name": "HighEnergySaving",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "NormalPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": ""
- }
- }
- ]
- },
- {
- "Name": "ServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "HighPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "foreground"
- }
- }
- ]
- },
- {
- "Name": "MaxPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "top-app"
- }
- }
- ]
- },
- {
- "Name": "RealtimePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "rt"
- }
- }
- ]
- },
- {
- "Name": "CameraServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "camera-daemon"
- }
- }
- ]
- },
- {
- "Name": "NNApiHALPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "nnapi-hal"
- }
- }
- ]
- },
- {
- "Name": "Dex2oatPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicySpread",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "1"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicyPack",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "0"
- }
- }
- ]
- }
- ]
-}
diff --git a/libprocessgroup/profiles/task_profiles_29.json b/libprocessgroup/profiles/task_profiles_29.json
deleted file mode 100644
index 6174c8d..0000000
--- a/libprocessgroup/profiles/task_profiles_29.json
+++ /dev/null
@@ -1,160 +0,0 @@
-{
- "Attributes": [
- {
- "Name": "STuneBoost",
- "Controller": "schedtune",
- "File": "schedtune.boost"
- },
- {
- "Name": "STunePreferIdle",
- "Controller": "schedtune",
- "File": "schedtune.prefer_idle"
- }
- ],
-
- "Profiles": [
- {
- "Name": "HighEnergySaving",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "NormalPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": ""
- }
- }
- ]
- },
- {
- "Name": "HighPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "foreground"
- }
- }
- ]
- },
- {
- "Name": "ServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "MaxPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "top-app"
- }
- }
- ]
- },
- {
- "Name": "RealtimePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "rt"
- }
- }
- ]
- },
- {
- "Name": "CameraServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "camera-daemon"
- }
- }
- ]
- },
- {
- "Name": "NNApiHALPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "nnapi-hal"
- }
- }
- ]
- },
- {
- "Name": "Dex2oatPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicySpread",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "1"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicyPack",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "0"
- }
- }
- ]
- }
- ]
-}
diff --git a/libprocessgroup/profiles/task_profiles_30.json b/libprocessgroup/profiles/task_profiles_30.json
deleted file mode 100644
index e7be548..0000000
--- a/libprocessgroup/profiles/task_profiles_30.json
+++ /dev/null
@@ -1,160 +0,0 @@
-{
- "Attributes": [
- {
- "Name": "STuneBoost",
- "Controller": "schedtune",
- "File": "schedtune.boost"
- },
- {
- "Name": "STunePreferIdle",
- "Controller": "schedtune",
- "File": "schedtune.prefer_idle"
- }
- ],
-
- "Profiles": [
- {
- "Name": "HighEnergySaving",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "NormalPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": ""
- }
- }
- ]
- },
- {
- "Name": "ServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "HighPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "foreground"
- }
- }
- ]
- },
- {
- "Name": "MaxPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "top-app"
- }
- }
- ]
- },
- {
- "Name": "RealtimePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "rt"
- }
- }
- ]
- },
- {
- "Name": "CameraServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "camera-daemon"
- }
- }
- ]
- },
- {
- "Name": "NNApiHALPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "nnapi-hal"
- }
- }
- ]
- },
- {
- "Name": "Dex2oatPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicySpread",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "1"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicyPack",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "0"
- }
- }
- ]
- }
- ]
-}
diff --git a/libprocessgroup/sched_policy.cpp b/libprocessgroup/sched_policy.cpp
index 042bcd2..5a53c35 100644
--- a/libprocessgroup/sched_policy.cpp
+++ b/libprocessgroup/sched_policy.cpp
@@ -148,20 +148,10 @@
return enabled;
}
-static bool schedtune_enabled() {
- return (CgroupMap::GetInstance().FindController("schedtune").IsUsable());
-}
-
static bool cpuctl_enabled() {
return (CgroupMap::GetInstance().FindController("cpu").IsUsable());
}
-bool schedboost_enabled() {
- static bool enabled = schedtune_enabled() || cpuctl_enabled();
-
- return enabled;
-}
-
static int getCGroupSubsys(pid_t tid, const char* subsys, std::string& subgroup) {
auto controller = CgroupMap::GetInstance().FindController(subsys);
@@ -201,9 +191,8 @@
}
std::string group;
- if (schedboost_enabled()) {
- if ((getCGroupSubsys(tid, "schedtune", group) < 0) &&
- (getCGroupSubsys(tid, "cpu", group) < 0)) {
+ if (cpuctl_enabled()) {
+ if (getCGroupSubsys(tid, "cpu", group) < 0) {
LOG(ERROR) << "Failed to find cpu cgroup for tid " << tid;
return -1;
}
diff --git a/libstats/expresslog/Android.bp b/libstats/expresslog/Android.bp
index 96ab59b..f70252a 100644
--- a/libstats/expresslog/Android.bp
+++ b/libstats/expresslog/Android.bp
@@ -1,4 +1,3 @@
-
//
// Copyright (C) 2023 The Android Open Source Project
//
@@ -16,6 +15,7 @@
//
package {
default_applicable_licenses: ["Android-Apache-2.0"],
+ default_team: "trendy_team_android_telemetry_client_infra",
}
cc_defaults {
@@ -28,6 +28,7 @@
cc_library {
name: "libexpresslog",
+ host_supported: true,
defaults: ["expresslog_defaults"],
cflags: [
"-DNAMESPACE_FOR_HASH_FUNCTIONS=farmhash",
@@ -74,6 +75,7 @@
cc_library_static {
name: "libstatslog_express",
+ host_supported: true,
generated_sources: ["statslog_express.cpp"],
generated_headers: ["statslog_express.h"],
export_generated_headers: ["statslog_express.h"],
@@ -119,5 +121,5 @@
],
shared_libs: [
"libstatssocket",
- ]
+ ],
}
diff --git a/libstats/pull_rust/Android.bp b/libstats/pull_rust/Android.bp
index 6902026..2a8939e 100644
--- a/libstats/pull_rust/Android.bp
+++ b/libstats/pull_rust/Android.bp
@@ -61,7 +61,6 @@
srcs: ["stats_pull.rs"],
rustlibs: [
"liblog_rust",
- "libonce_cell",
"libstatslog_rust_header",
"libstatspull_bindgen",
],
diff --git a/libstats/pull_rust/stats_pull.rs b/libstats/pull_rust/stats_pull.rs
index b2bebcc..03929e3 100644
--- a/libstats/pull_rust/stats_pull.rs
+++ b/libstats/pull_rust/stats_pull.rs
@@ -14,13 +14,12 @@
//! A Rust interface for the StatsD pull API.
-use once_cell::sync::Lazy;
use statslog_rust_header::{Atoms, Stat, StatsError};
use statspull_bindgen::*;
use std::collections::HashMap;
use std::convert::TryInto;
use std::os::raw::c_void;
-use std::sync::Mutex;
+use std::sync::{LazyLock, Mutex};
/// The return value of callbacks.
pub type StatsPullResult = Vec<Box<dyn Stat>>;
@@ -107,8 +106,8 @@
}
}
-static COOKIES: Lazy<Mutex<HashMap<i32, fn() -> StatsPullResult>>> =
- Lazy::new(|| Mutex::new(HashMap::new()));
+static COOKIES: LazyLock<Mutex<HashMap<i32, fn() -> StatsPullResult>>> =
+ LazyLock::new(|| Mutex::new(HashMap::new()));
/// # Safety
///
diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp
index d8d75ac..111d46a 100644
--- a/libutils/Threads.cpp
+++ b/libutils/Threads.cpp
@@ -313,11 +313,6 @@
int androidSetThreadPriority(pid_t tid, int pri)
{
int rc = 0;
- int curr_pri = getpriority(PRIO_PROCESS, tid);
-
- if (curr_pri == pri) {
- return rc;
- }
if (setpriority(PRIO_PROCESS, tid, pri) < 0) {
rc = INVALID_OPERATION;
diff --git a/libvendorsupport/include_llndk/android/llndk-versioning.h b/libvendorsupport/include_llndk/android/llndk-versioning.h
index cf82fb7..0402c28 100644
--- a/libvendorsupport/include_llndk/android/llndk-versioning.h
+++ b/libvendorsupport/include_llndk/android/llndk-versioning.h
@@ -25,7 +25,7 @@
__attribute__((annotate("introduced_in_llndk=" #vendor_api_level)))
#endif
-#if defined(__ANDROID_VENDOR__)
+#if defined(__ANDROID_VNDK__)
// Use this macro as an `if` statement to call an API that are available to both NDK and LLNDK.
// This returns true for the vendor modules if the vendor_api_level is less than or equal to the
@@ -33,7 +33,7 @@
#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) \
constexpr(__ANDROID_VENDOR_API__ >= vendor_api_level)
-#else // __ANDROID_VENDOR__
+#else // __ANDROID_VNDK__
// For non-vendor modules, API_LEVEL_AT_LEAST is replaced with __builtin_available(sdk_api_level) to
// guard the API for __INTRODUCED_IN.
@@ -42,4 +42,4 @@
(__builtin_available(android sdk_api_level, *))
#endif
-#endif // __ANDROID_VENDOR__
+#endif // __ANDROID_VNDK__
diff --git a/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp b/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp
index a484441..bed4a73 100644
--- a/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp
+++ b/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp
@@ -729,7 +729,6 @@
{"sys.ims.QMI_DAEMON_STATUS", "u:object_r:qcom_ims_prop:s0"},
{"sys.listeners.registered", "u:object_r:qseecomtee_prop:s0"},
{"sys.logbootcomplete", "u:object_r:system_prop:s0"},
- {"sys.oem_unlock_allowed", "u:object_r:system_prop:s0"},
{"sys.qcom.devup", "u:object_r:system_prop:s0"},
{"sys.sysctl.extra_free_kbytes", "u:object_r:system_prop:s0"},
{"sys.usb.config", "u:object_r:system_radio_prop:s0"},
diff --git a/rootdir/init.rc b/rootdir/init.rc
index d80416d..1acd637 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -567,7 +567,7 @@
trigger post-fs-data
# Should be before netd, but after apex, properties and logging is available.
- trigger load_bpf_programs
+ trigger load-bpf-programs
trigger bpf-progs-loaded
# Now we can start zygote.
@@ -1110,6 +1110,19 @@
on property:vold.checkpoint_committed=1
trigger post-fs-data-checkpointed
+# It is important that we start bpfloader after:
+# - /sys/fs/bpf is already mounted,
+# - apex (incl. rollback) is initialized (so that we can load bpf
+# programs shipped as part of apex mainline modules)
+# - logd is ready for us to log stuff
+#
+# At the same time we want to be as early as possible to reduce races and thus
+# failures (before memory is fragmented, and cpu is busy running tons of other
+# stuff) and we absolutely want to be before netd and the system boot slot is
+# considered to have booted successfully.
+on load-bpf-programs
+ exec_start bpfloader
+
on bpf-progs-loaded
start netd
@@ -1280,7 +1293,7 @@
# controlling access. On older kernels, the paranoid value is the only means of
# controlling access. It is normally 3 (allow only root), but the shell user
# can lower it to 1 (allowing thread-scoped pofiling) via security.perf_harden.
-on load_bpf_programs && property:sys.init.perf_lsm_hooks=1
+on load-bpf-programs && property:sys.init.perf_lsm_hooks=1
write /proc/sys/kernel/perf_event_paranoid -1
on property:security.perf_harden=0 && property:sys.init.perf_lsm_hooks=""
write /proc/sys/kernel/perf_event_paranoid 1
diff --git a/trusty/metrics/include/trusty/metrics/tipc.h b/trusty/metrics/include/trusty/metrics/tipc.h
index b4428d5..4c4d37d 100644
--- a/trusty/metrics/include/trusty/metrics/tipc.h
+++ b/trusty/metrics/include/trusty/metrics/tipc.h
@@ -43,6 +43,8 @@
#define UUID_STR_SIZE (37)
+#define HASH_SIZE_BYTES 64
+
/**
* enum metrics_cmd - command identifiers for metrics interface
* @METRICS_CMD_RESP_BIT: message is a response
@@ -112,10 +114,22 @@
* "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
* @crash_reason: architecture-specific code representing the reason for the
* crash
+ * @far: Fault Address Register corresponding to the crash. It is set to 0 and
+ * not always revealed
+ * @far_hash: Fault Address Register obfuscated, always revealed
+ * @elr: Exception Link Register corresponding to the crash. It is set to 0 and
+ * not always revealed
+ * @elr_hash: Exception Link Register obfuscated, always revealed
+ * @is_hash: Boolean value indicating whether far and elr have been ob
*/
struct metrics_report_crash_req {
char app_id[UUID_STR_SIZE];
uint32_t crash_reason;
+ uint64_t far;
+ uint8_t far_hash[HASH_SIZE_BYTES];
+ uint64_t elr;
+ uint8_t elr_hash[HASH_SIZE_BYTES];
+ bool is_hash;
} __attribute__((__packed__));
enum TrustyStorageErrorType {
diff --git a/trusty/storage/interface/Android.bp b/trusty/storage/interface/Android.bp
index d031b0c..769f53d 100644
--- a/trusty/storage/interface/Android.bp
+++ b/trusty/storage/interface/Android.bp
@@ -20,6 +20,7 @@
cc_library_static {
name: "libtrustystorageinterface",
- vendor: true,
+ vendor_available: true,
+ system_ext_specific: true,
export_include_dirs: ["include"],
}
diff --git a/trusty/storage/proxy/Android.bp b/trusty/storage/proxy/Android.bp
index e362b8b..f32188a 100644
--- a/trusty/storage/proxy/Android.bp
+++ b/trusty/storage/proxy/Android.bp
@@ -18,10 +18,8 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
-cc_binary {
- name: "storageproxyd",
- vendor: true,
-
+cc_defaults {
+ name: "storageproxyd.defaults",
srcs: [
"checkpoint_handling.cpp",
"ipc.c",
@@ -47,9 +45,22 @@
"libtrustystorageinterface",
"libtrusty",
],
-
cflags: [
"-Wall",
"-Werror",
],
}
+
+cc_binary {
+ name: "storageproxyd",
+ defaults: ["storageproxyd.defaults"],
+ vendor: true,
+ // vendor variant requires this flag
+ cflags: ["-DVENDOR_FS_READY_PROPERTY"],
+}
+
+cc_binary {
+ name: "storageproxyd.system",
+ defaults: ["storageproxyd.defaults"],
+ system_ext_specific: true,
+}
diff --git a/trusty/storage/proxy/storage.c b/trusty/storage/proxy/storage.c
index ca39f6a..72c4e93 100644
--- a/trusty/storage/proxy/storage.c
+++ b/trusty/storage/proxy/storage.c
@@ -54,6 +54,8 @@
/* List head for storage mapping, elements added at init, and never removed */
static struct storage_mapping_node* storage_mapping_head;
+#ifdef VENDOR_FS_READY_PROPERTY
+
/*
* Properties set to 1 after we have opened a file under ssdir_name. The backing
* files for both TD and TDP are currently located under /data/vendor/ss and can
@@ -75,16 +77,6 @@
static bool fs_ready_set = false;
static bool fs_ready_rw_set = false;
-static enum sync_state fs_state;
-static enum sync_state fd_state[FD_TBL_SIZE];
-
-static bool alternate_mode;
-
-static struct {
- struct storage_file_read_resp hdr;
- uint8_t data[MAX_READ_SIZE];
-} read_rsp;
-
static bool property_set_helper(const char* prop) {
int rc = property_set(prop, "1");
if (rc == 0) {
@@ -96,6 +88,18 @@
return rc == 0;
}
+#endif // #ifdef VENDOR_FS_READY_PROPERTY
+
+static enum sync_state fs_state;
+static enum sync_state fd_state[FD_TBL_SIZE];
+
+static bool alternate_mode;
+
+static struct {
+ struct storage_file_read_resp hdr;
+ uint8_t data[MAX_READ_SIZE];
+} read_rsp;
+
static uint32_t insert_fd(int open_flags, int fd, struct storage_mapping_node* node) {
uint32_t handle = fd;
@@ -535,6 +539,7 @@
free(path);
path = NULL;
+#ifdef VENDOR_FS_READY_PROPERTY
/* a backing file has been opened, notify any waiting init steps */
if (!fs_ready_set || !fs_ready_rw_set) {
bool is_checkpoint_active = false;
@@ -552,6 +557,7 @@
}
}
}
+#endif // #ifdef VENDOR_FS_READY_PROPERTY
return ipc_respond(msg, &resp, sizeof(resp));
diff --git a/trusty/trusty-storage-cf.mk b/trusty/trusty-storage-cf.mk
new file mode 100644
index 0000000..3b46445
--- /dev/null
+++ b/trusty/trusty-storage-cf.mk
@@ -0,0 +1,25 @@
+#
+# Copyright (C) 2024 The Android Open-Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# This makefile should be included by the cuttlefish device
+# when enabling the Trusty VM to pull in the baseline set
+# of storage specific modules
+
+PRODUCT_PACKAGES += \
+ storageproxyd.system \
+ rpmb_dev.system \
+
diff --git a/trusty/utils/rpmb_dev/Android.bp b/trusty/utils/rpmb_dev/Android.bp
index 603a1a8..13f151d 100644
--- a/trusty/utils/rpmb_dev/Android.bp
+++ b/trusty/utils/rpmb_dev/Android.bp
@@ -15,11 +15,8 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
-cc_binary {
- name: "rpmb_dev",
- vendor: true,
- host_supported: true,
-
+cc_defaults {
+ name: "rpmb_dev.cc_defaults",
srcs: [
"rpmb_dev.c",
],
@@ -32,7 +29,23 @@
"-Wall",
"-Werror",
],
+}
+
+cc_binary {
+ name: "rpmb_dev",
+ defaults: ["rpmb_dev.cc_defaults"],
+ vendor: true,
+ host_supported: true,
init_rc: [
"rpmb_dev.rc",
],
}
+
+cc_binary {
+ name: "rpmb_dev.system",
+ defaults: ["rpmb_dev.cc_defaults"],
+ system_ext_specific: true,
+ init_rc: [
+ "rpmb_dev.system.rc",
+ ],
+}
diff --git a/trusty/utils/rpmb_dev/rpmb_dev.system.rc b/trusty/utils/rpmb_dev/rpmb_dev.system.rc
new file mode 100644
index 0000000..b78c4e2
--- /dev/null
+++ b/trusty/utils/rpmb_dev/rpmb_dev.system.rc
@@ -0,0 +1,64 @@
+service storageproxyd_system /system_ext/bin/storageproxyd.system \
+ -d ${storageproxyd_system.trusty_ipc_dev:-/dev/trusty-ipc-dev0} \
+ -r /dev/socket/rpmb_mock_system \
+ -p /data/secure_storage_system \
+ -t sock
+ disabled
+ user system
+ group system
+
+service rpmb_mock_init_system /system_ext/bin/rpmb_dev.system \
+ --dev /mnt/secure_storage_rpmb_system/persist/RPMB_DATA --init --size 2048
+ disabled
+ user system
+ group system
+ oneshot
+
+service rpmb_mock_system /system_ext/bin/rpmb_dev.system \
+ --dev /mnt/secure_storage_rpmb_system/persist/RPMB_DATA \
+ --sock rpmb_mock_system
+ disabled
+ user system
+ group system
+ socket rpmb_mock_system stream 660 system system
+
+# storageproxyd
+on late-fs && \
+ property:trusty_vm_system_nonsecure.ready=1 && \
+ property:storageproxyd_system.trusty_ipc_dev=*
+ wait /dev/socket/rpmb_mock_system
+ start storageproxyd_system
+
+
+# RPMB Mock
+on post-fs && \
+ property:trusty_vm_system_nonsecure.ready=1 && \
+ property:trusty_vm_system.vm_cid=*
+ # Create a persistent location for the RPMB data
+ # (work around lack of RPMb block device on CF).
+ # file contexts secure_storage_rpmb_system_file
+ # (only used on Cuttlefish as this is non secure)
+ mkdir /metadata/secure_storage_rpmb_system 0770 system system
+ mkdir /mnt/secure_storage_rpmb_system 0770 system system
+ symlink /metadata/secure_storage_rpmb_system \
+ /mnt/secure_storage_rpmb_system/persist
+ # Create a system persist directory in /metadata
+ # (work around lack of dedicated system persist partition).
+ # file contexts secure_storage_persist_system_file
+ mkdir /metadata/secure_storage_persist_system 0770 system system
+ mkdir /mnt/secure_storage_persist_system 0770 system system
+ symlink /metadata/secure_storage_persist_system \
+ /mnt/secure_storage_persist_system/persist
+ setprop storageproxyd_system.trusty_ipc_dev VSOCK:${trusty_vm_system.vm_cid}:1
+ exec_start rpmb_mock_init_system
+ start rpmb_mock_system
+
+on post-fs-data && \
+ property:trusty_vm_system_nonsecure.ready=1 && \
+ property:storageproxyd_system.trusty_ipc_dev=*
+ # file contexts secure_storage_system_file
+ mkdir /data/secure_storage_system 0770 root system
+ symlink /mnt/secure_storage_persist_system/persist \
+ /data/secure_storage_system/persist
+ chown root system /data/secure_storage_system/persist
+ restart storageproxyd_system
diff --git a/trusty/utils/trusty-ut-ctrl/Android.bp b/trusty/utils/trusty-ut-ctrl/Android.bp
index 6fc2a48..c255614 100644
--- a/trusty/utils/trusty-ut-ctrl/Android.bp
+++ b/trusty/utils/trusty-ut-ctrl/Android.bp
@@ -16,9 +16,8 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
-cc_binary {
- name: "trusty-ut-ctrl",
- vendor: true,
+cc_defaults {
+ name: "trusty-ut-ctrl.defaults",
srcs: ["ut-ctrl.c"],
shared_libs: [
@@ -33,3 +32,15 @@
"-Werror",
],
}
+
+cc_binary {
+ name: "trusty-ut-ctrl",
+ defaults: ["trusty-ut-ctrl.defaults"],
+ vendor: true,
+}
+
+cc_binary {
+ name: "trusty-ut-ctrl.system",
+ defaults: ["trusty-ut-ctrl.defaults"],
+ system_ext_specific: true,
+}