From 9ac82420cb501cc16e4431f3fc767877a9964bd0 Mon Sep 17 00:00:00 2001 From: Matt Gilbride Date: Tue, 20 Aug 2024 21:23:22 +0000 Subject: [PATCH] Support vendor partition in non-debuggable pVMs Use the existence of /proc/device-tree/avf/vendor_hashtree_descriptor_root_digest (rather than kernel param androidboot.microdroid.mount_vendor=1) to know if the vendor partition is requested. Bug: 340506965 Test: TH Change-Id: I0ac1c773e44454fd9c52559d833dc8eca211889c --- init/first_stage_mount.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp index ece430b70..c26b31e93 100644 --- a/init/first_stage_mount.cpp +++ b/init/first_stage_mount.cpp @@ -156,6 +156,13 @@ static Result ReadFirstStageFstabAndroid() { 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 @@ -166,7 +173,7 @@ static Result ReadFirstStageFstabMicrodroid(const std::string& cmdline) { if (!ReadDefaultFstab(&fstab)) { return Error() << "failed to read fstab"; } - if (cmdline.find("androidboot.microdroid.mount_vendor=1") == std::string::npos) { + if (!IsRequestingMicrodroidVendorPartition(cmdline)) { // 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());