Merge "Treat APK path change as compatible" into main
diff --git a/pvmfw/README.md b/pvmfw/README.md
index 795bb05..d7884fb 100644
--- a/pvmfw/README.md
+++ b/pvmfw/README.md
@@ -214,17 +214,19 @@
   that if matching properties are present in the VM device tree they contain the
   correct values.
 
-  One use case for this mechanism is passing the [public key of the
-  Secretkeeper][secretkeeper_key] HAL implementation to each VM.
+  Use-cases of VM reference DT include:
 
-<!--
-  TODO(b/319192461): Attach link explaining about Microdroid vendor partition
--->
+  - Passing the [public key of the Secretkeeper][secretkeeper_key] HAL
+    implementation to each VM.
+
+  - Passing the [vendor hashtree digest][vendor_hashtree_digest] to run
+    Microdroid with verified vendor image.
 
 [header]: src/config.rs
 [DTBO]: https://android.googlesource.com/platform/external/dtc/+/refs/heads/main/Documentation/dt-object-internal.txt
 [debug_policy]: ../docs/debug/README.md#debug-policy
 [secretkeeper_key]: https://android.googlesource.com/platform/system/secretkeeper/+/refs/heads/main/README.md#secretkeeper-public-key
+[vendor_hashtree_digest]: ../microdroid/README.md#verification-of-vendor-image
 
 #### Virtual Platform Boot Certificate Chain Handover
 
diff --git a/tests/benchmark/assets/vm_config.json b/tests/benchmark/assets/microdroid/vm_config.json
similarity index 100%
rename from tests/benchmark/assets/vm_config.json
rename to tests/benchmark/assets/microdroid/vm_config.json
diff --git a/tests/benchmark/assets/vm_config_io.json b/tests/benchmark/assets/microdroid/vm_config_io.json
similarity index 100%
rename from tests/benchmark/assets/vm_config_io.json
rename to tests/benchmark/assets/microdroid/vm_config_io.json
diff --git a/tests/benchmark/assets/vm_config_gki-android14-6.1.json b/tests/benchmark/assets/microdroid_gki-android14-6.1/vm_config.json
similarity index 100%
rename from tests/benchmark/assets/vm_config_gki-android14-6.1.json
rename to tests/benchmark/assets/microdroid_gki-android14-6.1/vm_config.json
diff --git a/tests/benchmark/assets/microdroid_gki-android14-6.1/vm_config_io.json b/tests/benchmark/assets/microdroid_gki-android14-6.1/vm_config_io.json
new file mode 100644
index 0000000..34c204e
--- /dev/null
+++ b/tests/benchmark/assets/microdroid_gki-android14-6.1/vm_config_io.json
@@ -0,0 +1,15 @@
+{
+  "os": {
+    "name": "microdroid_gki-android14-6.1"
+  },
+  "task": {
+    "type": "microdroid_launcher",
+    "command": "MicrodroidBenchmarkNativeLib.so"
+  },
+  "apexes": [
+    {
+      "name": "com.android.virt"
+    }
+  ],
+  "export_tombstones": true
+}
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 e406172..e0de9b3 100644
--- a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
+++ b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
@@ -66,6 +66,7 @@
 import java.io.Writer;
 import java.nio.file.Files;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -91,12 +92,23 @@
     private static final String MICRODROID_IMG_PREFIX = "microdroid_";
     private static final String MICRODROID_IMG_SUFFIX = ".img";
 
-    @Parameterized.Parameters(name = "protectedVm={0}")
-    public static Object[] protectedVmConfigs() {
-        return new Object[] {false, true};
+    @Parameterized.Parameters(name = "protectedVm={0},gki={1}")
+    public static Collection<Object[]> params() {
+        List<Object[]> ret = new ArrayList<>();
+        ret.add(new Object[] {true /* protectedVm */, null /* use microdroid kernel */});
+        ret.add(new Object[] {false /* protectedVm */, null /* use microdroid kernel */});
+        for (String gki : SUPPORTED_GKI_VERSIONS) {
+            ret.add(new Object[] {true /* protectedVm */, gki});
+            ret.add(new Object[] {false /* protectedVm */, gki});
+        }
+        return ret;
     }
 
-    @Parameterized.Parameter public boolean mProtectedVm;
+    @Parameterized.Parameter(0)
+    public boolean mProtectedVm;
+
+    @Parameterized.Parameter(1)
+    public String mGki;
 
     private final MetricsProcessor mMetricsProcessor = new MetricsProcessor(METRIC_NAME_PREFIX);
 
@@ -119,7 +131,7 @@
     public void setup() throws IOException {
         grantPermission(VirtualMachine.MANAGE_VIRTUAL_MACHINE_PERMISSION);
         grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
-        prepareTestSetup(mProtectedVm, null /* gki */);
+        prepareTestSetup(mProtectedVm, mGki);
         setMaxPerformanceTaskProfile();
         mInstrumentation = getInstrumentation();
     }
@@ -240,62 +252,31 @@
             throws VirtualMachineException, InterruptedException, IOException {
         runBootTimeTest(
                 "test_vm_boot_time",
-                "assets/vm_config.json",
+                "assets/" + os() + "/vm_config.json",
                 /* fullDebug */ false,
                 (builder) -> builder.setCpuTopology(CPU_TOPOLOGY_ONE_CPU));
     }
-
-    @Test
-    public void testMicrodroidGkiBootTime()
-            throws VirtualMachineException, InterruptedException, IOException {
-        runBootTimeTest(
-                "test_vm_boot_time",
-                "assets/vm_config_gki-android14-6.1.json",
-                /* reportDetailed */ false,
-                (builder) -> builder.setCpuTopology(CPU_TOPOLOGY_ONE_CPU));
-    }
-
     @Test
     public void testMicrodroidHostCpuTopologyBootTime()
             throws VirtualMachineException, InterruptedException, IOException {
         runBootTimeTest(
                 "test_vm_boot_time_host_topology",
-                "assets/vm_config.json",
+                "assets/" + os() + "/vm_config.json",
                 /* fullDebug */ false,
                 (builder) -> builder.setCpuTopology(CPU_TOPOLOGY_MATCH_HOST));
     }
 
     @Test
-    public void testMicrodroidGkiHostCpuTopologyBootTime()
-            throws VirtualMachineException, InterruptedException, IOException {
-        runBootTimeTest(
-                "test_vm_boot_time_host_topology",
-                "assets/vm_config_gki-android14-6.1.json",
-                /* reportDetailed */ false,
-                (builder) -> builder.setCpuTopology(CPU_TOPOLOGY_MATCH_HOST));
-    }
-
-    @Test
     public void testMicrodroidDebugBootTime()
             throws VirtualMachineException, InterruptedException, IOException {
         runBootTimeTest(
                 "test_vm_boot_time_debug",
-                "assets/vm_config.json",
+                "assets/" + os() + "/vm_config.json",
                 /* fullDebug */ true,
                 (builder) -> builder);
     }
 
     @Test
-    public void testMicrodroidGkiDebugBootTime()
-            throws VirtualMachineException, InterruptedException, IOException {
-        runBootTimeTest(
-                "test_vm_boot_time_debug",
-                "assets/vm_config_gki-android14-6.1.json",
-                /* reportDetailed */ true,
-                (builder) -> builder);
-    }
-
-    @Test
     public void testMicrodroidDebugBootTime_withVendorPartition() throws Exception {
         assume().withMessage(
                         "Cuttlefish doesn't support device tree under"
@@ -318,7 +299,7 @@
                 new File("/data/local/tmp/microdroid-bench/microdroid_vendor_image.img");
         runBootTimeTest(
                 "test_vm_boot_time_debug_with_vendor_partition",
-                "assets/vm_config.json",
+                "assets/" + os() + "/vm_config.json",
                 /* fullDebug */ true,
                 (builder) -> builder.setVendorDiskImage(vendorDiskImage));
     }
@@ -347,7 +328,7 @@
     @Test
     public void testVsockTransferFromHostToVM() throws Exception {
         VirtualMachineConfig config =
-                newVmConfigBuilderWithPayloadConfig("assets/vm_config_io.json")
+                newVmConfigBuilderWithPayloadConfig("assets/" + os() + "/vm_config_io.json")
                         .setDebugLevel(DEBUG_LEVEL_NONE)
                         .build();
         List<Double> transferRates = new ArrayList<>(IO_TEST_TRIAL_COUNT);
@@ -373,7 +354,7 @@
 
     private void testVirtioBlkReadRate(boolean isRand) throws Exception {
         VirtualMachineConfig config =
-                newVmConfigBuilderWithPayloadConfig("assets/vm_config_io.json")
+                newVmConfigBuilderWithPayloadConfig("assets/" + os() + "/vm_config_io.json")
                         .setDebugLevel(DEBUG_LEVEL_NONE)
                         .build();
         List<Double> readRates = new ArrayList<>(IO_TEST_TRIAL_COUNT);
@@ -519,7 +500,7 @@
     public void testMemoryUsage() throws Exception {
         final String vmName = "test_vm_mem_usage";
         VirtualMachineConfig config =
-                newVmConfigBuilderWithPayloadConfig("assets/vm_config_io.json")
+                newVmConfigBuilderWithPayloadConfig("assets/" + os() + "/vm_config_io.json")
                         .setDebugLevel(DEBUG_LEVEL_NONE)
                         .setMemoryBytes(256 * ONE_MEBI)
                         .build();
@@ -605,7 +586,7 @@
     public void testMemoryReclaim() throws Exception {
         final String vmName = "test_vm_mem_reclaim";
         VirtualMachineConfig config =
-                newVmConfigBuilderWithPayloadConfig("assets/vm_config_io.json")
+                newVmConfigBuilderWithPayloadConfig("assets/" + os() + "/vm_config_io.json")
                         .setDebugLevel(DEBUG_LEVEL_NONE)
                         .setMemoryBytes(256 * ONE_MEBI)
                         .build();
@@ -830,7 +811,7 @@
     @Test
     public void testVmKillTime() throws Exception {
         VirtualMachineConfig config =
-                newVmConfigBuilderWithPayloadConfig("assets/vm_config_io.json")
+                newVmConfigBuilderWithPayloadConfig("assets/" + os() + "/vm_config_io.json")
                         .setDebugLevel(DEBUG_LEVEL_NONE)
                         .build();
         List<Double> vmKillTime = new ArrayList<>(TEST_TRIAL_COUNT);