Allocate pVM firmware memory consistently.

Allocate the same way as the rest of RAM, whether in
unprotected-with-firmware mode or actually protected mode.

TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: Ic0ebc0d90e91bd450af55f3252039ddab8d26443
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3827215
Commit-Queue: Andrew Walbran <qwandor@google.com>
Tested-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Andrew Walbran 2022-05-04 16:10:45 +01:00 committed by crosvm LUCI
parent 3fcf6e68eb
commit 379dd2dfec
2 changed files with 5 additions and 6 deletions

View file

@ -251,7 +251,10 @@ impl arch::LinuxArch for AArch64 {
vec![(GuestAddress(AARCH64_PHYS_MEM_START), components.memory_size)];
// Allocate memory for the pVM firmware.
if components.protected_vm == ProtectionType::UnprotectedWithFirmware {
if matches!(
components.protected_vm,
ProtectionType::Protected | ProtectionType::UnprotectedWithFirmware
) {
memory_regions.push((
GuestAddress(AARCH64_PROTECTED_VM_FW_START),
AARCH64_PROTECTED_VM_FW_MAX_SIZE,
@ -373,7 +376,7 @@ impl arch::LinuxArch for AArch64 {
match components.protected_vm {
ProtectionType::Protected => {
// Allocate memory for the pVM firmware and tell the hypervisor to load it.
// Tell the hypervisor to load the pVM firmware.
vm.load_protected_vm_firmware(
GuestAddress(AARCH64_PROTECTED_VM_FW_START),
AARCH64_PROTECTED_VM_FW_MAX_SIZE,

View file

@ -197,10 +197,6 @@ impl VmAArch64 for KvmVm {
if info.firmware_size > fw_max_size {
return Err(Error::new(ENOMEM));
}
let mem = MemoryMappingBuilder::new(info.firmware_size as usize)
.build()
.map_err(|_| Error::new(EINVAL))?;
self.add_memory_region(fw_addr, Box::new(mem), false, false)?;
self.set_protected_vm_firmware_ipa(fw_addr)
}
}