Snap for 11920703 from 82567462f32ca92e8ccad00c58530b50d61bc564 to 24Q3-release
Change-Id: Ib8a97d55b0e4b2aa16c22729f0e9536fd62118a2
diff --git a/compos/common/compos_client.rs b/compos/common/compos_client.rs
index 6914380..107f8d0 100644
--- a/compos/common/compos_client.rs
+++ b/compos/common/compos_client.rs
@@ -36,7 +36,6 @@
use glob::glob;
use log::{info, warn};
use platformproperties::hypervisorproperties;
-use rustutils::system_properties;
use std::fs::File;
use std::path::{Path, PathBuf};
use vmclient::{DeathReason, ErrorCode, VmInstance, VmWaitError};
@@ -80,7 +79,11 @@
idsig_manifest_ext_apk: &Path,
parameters: &VmParameters,
) -> Result<Self> {
- let protected_vm = want_protected_vm()?;
+ let have_protected_vm =
+ hypervisorproperties::hypervisor_protected_vm_supported()?.unwrap_or(false);
+ if !have_protected_vm {
+ bail!("Protected VM not supported, unable to start VM");
+ }
let instance_fd = ParcelFileDescriptor::new(instance_image);
@@ -133,7 +136,7 @@
payload: Payload::ConfigPath(config_path),
debugLevel: debug_level,
extraIdsigs: extra_idsigs,
- protectedVm: protected_vm,
+ protectedVm: true,
memoryMib: parameters.memory_mib.unwrap_or(0), // 0 means use the default
cpuTopology: cpu_topology,
customConfig: custom_config,
@@ -236,28 +239,6 @@
Ok(idsig_fd)
}
-fn want_protected_vm() -> Result<bool> {
- let have_protected_vm =
- hypervisorproperties::hypervisor_protected_vm_supported()?.unwrap_or(false);
- if have_protected_vm {
- info!("Starting protected VM");
- return Ok(true);
- }
-
- let is_debug_build = system_properties::read("ro.debuggable")?.as_deref().unwrap_or("0") == "1";
- if !is_debug_build {
- bail!("Protected VM not supported, unable to start VM");
- }
-
- let have_non_protected_vm = hypervisorproperties::hypervisor_vm_supported()?.unwrap_or(false);
- if have_non_protected_vm {
- warn!("Protected VM not supported, falling back to non-protected on debuggable build");
- return Ok(false);
- }
-
- bail!("No VM support available")
-}
-
struct Callback {}
impl vmclient::VmCallback for Callback {
fn on_payload_started(&self, cid: i32) {
diff --git a/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java b/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java
index c6b2499..46df011 100644
--- a/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java
+++ b/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java
@@ -282,4 +282,8 @@
.map(os -> os.replaceFirst("^microdroid_gki-", ""))
.collect(Collectors.toList());
}
+
+ protected boolean isPkvmHypervisor() throws DeviceNotAvailableException {
+ return getDevice().getProperty("ro.boot.hypervisor.version").equals("kvm.arm-protected");
+ }
}
diff --git a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
index eb456f2..9d0b04b 100644
--- a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
@@ -809,8 +809,10 @@
// Check VmCreationRequested atom
AtomsProto.VmCreationRequested atomVmCreationRequested =
data.get(0).getAtom().getVmCreationRequested();
- assertThat(atomVmCreationRequested.getHypervisor())
- .isEqualTo(AtomsProto.VmCreationRequested.Hypervisor.PKVM);
+ if (isPkvmHypervisor()) {
+ assertThat(atomVmCreationRequested.getHypervisor())
+ .isEqualTo(AtomsProto.VmCreationRequested.Hypervisor.PKVM);
+ }
assertThat(atomVmCreationRequested.getIsProtected()).isEqualTo(mProtectedVm);
assertThat(atomVmCreationRequested.getCreationSucceeded()).isTrue();
assertThat(atomVmCreationRequested.getBinderExceptionCode()).isEqualTo(0);
@@ -832,7 +834,11 @@
assertThat(atomVmExited.getDeathReason()).isEqualTo(AtomsProto.VmExited.DeathReason.KILLED);
assertThat(atomVmExited.getExitSignal()).isEqualTo(9);
// In CPU & memory related fields, check whether positive values are collected or not.
- assertThat(atomVmExited.getGuestTimeMillis()).isGreaterThan(0);
+ if (isPkvmHypervisor()) {
+ // Guest Time may not be updated on other hypervisors.
+ // Checking only if the hypervisor is PKVM.
+ assertThat(atomVmExited.getGuestTimeMillis()).isGreaterThan(0);
+ }
assertThat(atomVmExited.getRssVmKb()).isGreaterThan(0);
assertThat(atomVmExited.getRssCrosvmKb()).isGreaterThan(0);