Merge changes Ifd923a38,Iab706340

* changes:
  Add benchmark of Microdroid boot time with multiple vCPUs
  Measure Microdroid boot time in non-debug mode
diff --git a/pvmfw/avb/src/verify.rs b/pvmfw/avb/src/verify.rs
index d5f7283..b6db601 100644
--- a/pvmfw/avb/src/verify.rs
+++ b/pvmfw/avb/src/verify.rs
@@ -393,10 +393,12 @@
 mod tests {
     use super::*;
     use anyhow::Result;
-    use std::fs;
+    use avb_bindgen::AvbFooter;
+    use std::{fs, mem::size_of};
 
     const PUBLIC_KEY_RSA2048_PATH: &str = "data/testkey_rsa2048_pub.bin";
     const PUBLIC_KEY_RSA4096_PATH: &str = "data/testkey_rsa4096_pub.bin";
+    const RANDOM_FOOTER_POS: usize = 30;
 
     /// This test uses the Microdroid payload compiled on the fly to check that
     /// the latest payload can be verified successfully.
@@ -457,6 +459,19 @@
         )
     }
 
+    #[test]
+    fn tampered_kernel_footer_fails_verification() -> Result<()> {
+        let mut kernel = load_latest_signed_kernel()?;
+        let avb_footer_index = kernel.len() - size_of::<AvbFooter>() + RANDOM_FOOTER_POS;
+        kernel[avb_footer_index] = !kernel[avb_footer_index];
+
+        assert_payload_verification_fails(
+            &kernel,
+            &fs::read(PUBLIC_KEY_RSA4096_PATH)?,
+            AvbImageVerifyError::InvalidMetadata,
+        )
+    }
+
     fn assert_payload_verification_fails(
         kernel: &[u8],
         trusted_public_key: &[u8],
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 0d8d2b4..9cfac4e 100644
--- a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
+++ b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
@@ -81,10 +81,11 @@
     private Instrumentation mInstrumentation;
 
     @Before
-    public void setup() {
+    public void setup() throws IOException {
         grantPermission(VirtualMachine.MANAGE_VIRTUAL_MACHINE_PERMISSION);
         grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
         prepareTestSetup(mProtectedVm);
+        setMaxPerformanceTaskProfile();
         mInstrumentation = getInstrumentation();
     }
 
diff --git a/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java b/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java
index 536f663..d762310 100644
--- a/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java
+++ b/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java
@@ -24,6 +24,7 @@
 import android.content.Context;
 import android.os.ParcelFileDescriptor;
 import android.os.SystemProperties;
+import android.system.Os;
 import android.system.virtualmachine.VirtualMachine;
 import android.system.virtualmachine.VirtualMachineCallback;
 import android.system.virtualmachine.VirtualMachineConfig;
@@ -50,6 +51,8 @@
 import java.util.concurrent.TimeUnit;
 
 public abstract class MicrodroidDeviceTestBase {
+    private final String MAX_PERFORMANCE_TASK_PROFILE = "CPUSET_SP_TOP_APP";
+
     public static boolean isCuttlefish() {
         return DeviceProperties.create(SystemProperties::get).isCuttlefish();
     }
@@ -73,6 +76,17 @@
                 permission);
     }
 
+    protected final void setMaxPerformanceTaskProfile() throws IOException {
+        Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
+        UiAutomation uiAutomation = instrumentation.getUiAutomation();
+        String cmd = "settaskprofile " + Os.gettid() + " " + MAX_PERFORMANCE_TASK_PROFILE;
+        String out = runInShell("MicrodroidDeviceTestBase", uiAutomation, cmd).trim();
+        String expect = "Profile " + MAX_PERFORMANCE_TASK_PROFILE + " is applied successfully!";
+        if (!expect.equals(out)) {
+            throw new IOException("Could not apply max performance task profile: " + out);
+        }
+    }
+
     private Context mCtx;
     private boolean mProtectedVm;