always add swiotlb size to memory size for protected VMs
This should be a noop when paired with https://crrev.com/c/5637774.
Before that CL, there was an inconsistency in crosvm that essentially
added extra physical memory equivalent to the swiotlb size for
hypervisors requireing static swiotlb allocation (i.e. everything but
pKVM). https://crrev.com/c/5637774 essentially reduces the RAM size by
`swiotlb_size_mib` and then this CL adds `swiotlb_size_mib` back.
Bug: 346770542
Test: launched microdroid and checked --mem argument
Change-Id: I7fa13962abfe7953ceb027cfd8817831a6dec5aa
diff --git a/libs/hypervisor_props/src/lib.rs b/libs/hypervisor_props/src/lib.rs
index 6665bc5..14614fd 100644
--- a/libs/hypervisor_props/src/lib.rs
+++ b/libs/hypervisor_props/src/lib.rs
@@ -37,8 +37,3 @@
pub fn version() -> Result<Option<String>> {
Ok(hypervisorproperties::hypervisor_version()?)
}
-
-/// Returns if the hypervisor is pKVM
-pub fn is_pkvm() -> Result<bool> {
- Ok(version()?.unwrap_or_default().starts_with("kvm") && is_protected_vm_supported()?)
-}
diff --git a/virtualizationmanager/src/crosvm.rs b/virtualizationmanager/src/crosvm.rs
index d9e80e2..ca938f8 100644
--- a/virtualizationmanager/src/crosvm.rs
+++ b/virtualizationmanager/src/crosvm.rs
@@ -941,11 +941,8 @@
let swiotlb_size_mib = 2 * virtio_pci_device_count as u32;
command.arg("--swiotlb").arg(swiotlb_size_mib.to_string());
- // b/346770542 for consistent "usable" memory across protected and non-protected VMs under
- // pKVM.
- if hypervisor_props::is_pkvm()? {
- memory_mib = memory_mib.map(|m| m.saturating_add(swiotlb_size_mib));
- }
+ // b/346770542 for consistent "usable" memory across protected and non-protected VMs.
+ memory_mib = memory_mib.map(|m| m.saturating_add(swiotlb_size_mib));
// Workaround to keep crash_dump from trying to read protected guest memory.
// Context in b/238324526.