Use /proc/device-tree for reading AVF DT
Although /proc/device-tree is symlink to /sys/firmware/devicetree/base,
/proc/device-tree is the stable API but the absolute path may be
changed in the future.
Bug: 322465386
Test: atest CustomPvmfwHostTestCases
Change-Id: I0d55918b6ec4563135c596649ccfd4bd84284963
diff --git a/microdroid/fstab.microdroid b/microdroid/fstab.microdroid
index 2742757..3209442 100644
--- a/microdroid/fstab.microdroid
+++ b/microdroid/fstab.microdroid
@@ -2,4 +2,4 @@
# This is a temporary solution to unblock other devs that depend on /vendor partition in Microdroid
# The /vendor partition will only be mounted if the kernel cmdline contains
# androidboot.microdroid.mount_vendor=1.
-/dev/block/by-name/microdroid-vendor /vendor ext4 noatime,ro,errors=panic wait,first_stage_mount,avb_hashtree_digest=/sys/firmware/devicetree/base/avf/vendor_hashtree_descriptor_root_digest
+/dev/block/by-name/microdroid-vendor /vendor ext4 noatime,ro,errors=panic wait,first_stage_mount,avb_hashtree_digest=/proc/device-tree/avf/vendor_hashtree_descriptor_root_digest
diff --git a/microdroid/init_debug_policy/src/init_debug_policy.rs b/microdroid/init_debug_policy/src/init_debug_policy.rs
index 6c80926..90d04ac 100644
--- a/microdroid/init_debug_policy/src/init_debug_policy.rs
+++ b/microdroid/init_debug_policy/src/init_debug_policy.rs
@@ -29,11 +29,10 @@
}
fn main() -> Result<(), PropertyWatcherError> {
- // If VM is debuggable or debug policy says so, send logs to outside ot the VM via the serial console.
- // Otherwise logs are internally consumed at /dev/null
+ // If VM is debuggable or debug policy says so, send logs to outside ot the VM via the serial
+ // console. Otherwise logs are internally consumed at /dev/null
let log_path = if system_properties::read_bool("ro.boot.microdroid.debuggable", false)?
- || get_debug_policy_bool("/sys/firmware/devicetree/base/avf/guest/common/log")
- .unwrap_or_default()
+ || get_debug_policy_bool("/proc/device-tree/avf/guest/common/log").unwrap_or_default()
{
"/dev/hvc2"
} else {
@@ -42,8 +41,7 @@
system_properties::write("ro.log.file_logger.path", log_path)?;
let (adbd_enabled, debuggable) = if system_properties::read_bool("ro.boot.adb.enabled", false)?
- || get_debug_policy_bool("/sys/firmware/devicetree/base/avf/guest/microdroid/adb")
- .unwrap_or_default()
+ || get_debug_policy_bool("/proc/device-tree/avf/guest/microdroid/adb").unwrap_or_default()
{
// debuggable is required for adb root and bypassing adb authorization.
("1", "1")
diff --git a/microdroid_manager/src/main.rs b/microdroid_manager/src/main.rs
index 8888feb..aa712c6 100644
--- a/microdroid_manager/src/main.rs
+++ b/microdroid_manager/src/main.rs
@@ -68,11 +68,11 @@
use vm_secret::VmSecret;
const WAIT_TIMEOUT: Duration = Duration::from_secs(10);
-const AVF_STRICT_BOOT: &str = "/sys/firmware/devicetree/base/chosen/avf,strict-boot";
-const AVF_NEW_INSTANCE: &str = "/sys/firmware/devicetree/base/chosen/avf,new-instance";
-const AVF_DEBUG_POLICY_RAMDUMP: &str = "/sys/firmware/devicetree/base/avf/guest/common/ramdump";
+const AVF_STRICT_BOOT: &str = "/proc/device-tree/chosen/avf,strict-boot";
+const AVF_NEW_INSTANCE: &str = "/proc/device-tree/chosen/avf,new-instance";
+const AVF_DEBUG_POLICY_RAMDUMP: &str = "/proc/device-tree/avf/guest/common/ramdump";
const DEBUG_MICRODROID_NO_VERIFIED_BOOT: &str =
- "/sys/firmware/devicetree/base/virtualization/guest/debug-microdroid,no-verified-boot";
+ "/proc/device-tree/virtualization/guest/debug-microdroid,no-verified-boot";
const ENCRYPTEDSTORE_BIN: &str = "/system/bin/encryptedstore";
const ZIPFUSE_BIN: &str = "/system/bin/zipfuse";
diff --git a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
index e0de9b3..b9faa85 100644
--- a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
+++ b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
@@ -278,9 +278,7 @@
@Test
public void testMicrodroidDebugBootTime_withVendorPartition() throws Exception {
- assume().withMessage(
- "Cuttlefish doesn't support device tree under"
- + " /sys/firmware/devicetree/base")
+ assume().withMessage("Cuttlefish doesn't support device tree under" + " /proc/device-tree")
.that(isCuttlefish())
.isFalse();
// TODO(b/317567210): Boots fails with vendor partition in HWASAN enabled microdroid
diff --git a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
index 1739eab..7a5d69b 100644
--- a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
@@ -938,7 +938,7 @@
assumeFalse("Unlocked devices may have AVF debug policy", lockProp.equals("orange"));
// Test that AVF debug policy doesn't exist.
- boolean hasDebugPolicy = device.doesFileExist("/sys/firmware/devicetree/base/avf");
+ boolean hasDebugPolicy = device.doesFileExist("/proc/device-tree/avf");
assertThat(hasDebugPolicy).isFalse();
}
diff --git a/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java b/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
index 33d41ab..3d83f40 100644
--- a/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
+++ b/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
@@ -2105,8 +2105,7 @@
public void configuringVendorDiskImageRequiresCustomPermission() throws Exception {
assumeSupportedDevice();
assumeFalse(
- "Cuttlefish doesn't support device tree under /sys/firmware/devicetree/base",
- isCuttlefish());
+ "Cuttlefish doesn't support device tree under /proc/device-tree", isCuttlefish());
// TODO(b/317567210): Boots fails with vendor partition in HWASAN enabled microdroid
// after introducing verification based on DT and fstab in microdroid vendor partition.
assumeFalse(
@@ -2136,8 +2135,7 @@
public void bootsWithVendorPartition() throws Exception {
assumeSupportedDevice();
assumeFalse(
- "Cuttlefish doesn't support device tree under /sys/firmware/devicetree/base",
- isCuttlefish());
+ "Cuttlefish doesn't support device tree under /proc/device-tree", isCuttlefish());
// TODO(b/317567210): Boots fails with vendor partition in HWASAN enabled microdroid
// after introducing verification based on DT and fstab in microdroid vendor partition.
assumeFalse(
@@ -2177,8 +2175,7 @@
public void creationFailsWithUnsignedVendorPartition() throws Exception {
assumeSupportedDevice();
assumeFalse(
- "Cuttlefish doesn't support device tree under /sys/firmware/devicetree/base",
- isCuttlefish());
+ "Cuttlefish doesn't support device tree under /proc/device-tree", isCuttlefish());
// TODO(b/317567210): Boots fails with vendor partition in HWASAN enabled microdroid
// after introducing verification based on DT and fstab in microdroid vendor partition.
assumeFalse(
diff --git a/virtualizationmanager/src/debug_config.rs b/virtualizationmanager/src/debug_config.rs
index 003a7d4..e2b657a 100644
--- a/virtualizationmanager/src/debug_config.rs
+++ b/virtualizationmanager/src/debug_config.rs
@@ -45,7 +45,7 @@
// unwrap() is safe for to_str() because node_path and prop_name were &str.
PathBuf::from(
[
- "/sys/firmware/devicetree/base",
+ "/proc/device-tree",
self.node_path.to_str().unwrap(),
"/",
self.prop_name.to_str().unwrap(),