From 45c4d1a06e41d521866e06537443355e8a660ae4 Mon Sep 17 00:00:00 2001 From: Michael Zhao Date: Thu, 24 Jun 2021 09:57:01 +0800 Subject: [PATCH] aarch64: Reduce UEFI space size to 4 MiB UEFI need to be loaded to a flash area at the beginning of guest memory address space. To simulate the flash, we take a piece of RAM and hide it to the guest. As this is a temporary solution, the hiden RAM for UEFI should be as little as possible. The size was 64 MiB, that's too much, 4 MiB is enough. The down side of such simulation is that there is a gap (4 MiB) between the memory size in VMM's view and that in guest's view. This is to be fixed by implementing a flash device in future. Signed-off-by: Michael Zhao --- arch/src/aarch64/layout.rs | 5 +++-- arch/src/aarch64/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/src/aarch64/layout.rs b/arch/src/aarch64/layout.rs index da029cbda..02792b7fc 100644 --- a/arch/src/aarch64/layout.rs +++ b/arch/src/aarch64/layout.rs @@ -46,10 +46,11 @@ use vm_memory::GuestAddress; -/// 0x0 ~ 0x400_0000 is reserved to uefi +/// 0x0 ~ 0x40_0000 (4 MiB) is reserved to UEFI +/// UEFI binary size is required less than 3 MiB, reserving 4 MiB is enough. pub const UEFI_START: u64 = 0x0; pub const MEM_UEFI_START: GuestAddress = GuestAddress(0); -pub const UEFI_SIZE: u64 = 0x0400_0000; +pub const UEFI_SIZE: u64 = 0x040_0000; /// Below this address will reside the GIC, above this address will reside the MMIO devices. pub const MAPPED_IO_START: u64 = 0x0900_0000; diff --git a/arch/src/aarch64/mod.rs b/arch/src/aarch64/mod.rs index 01fe78ced..52a326194 100644 --- a/arch/src/aarch64/mod.rs +++ b/arch/src/aarch64/mod.rs @@ -88,7 +88,7 @@ pub fn configure_vcpu( pub fn arch_memory_regions(size: GuestUsize) -> Vec<(GuestAddress, usize, RegionType)> { // Normally UEFI should be loaded to a flash area at the beginning of memory. // But now flash memory type is not supported. - // As a workaround, we take 64 MiB memory from the main RAM for UEFI. + // As a workaround, we take 4 MiB memory from the main RAM for UEFI. // As a result, the RAM that the guest can see is less than what has been // assigned in command line, when ACPI and UEFI is enabled. let ram_deduction = if cfg!(feature = "acpi") { @@ -98,7 +98,7 @@ pub fn arch_memory_regions(size: GuestUsize) -> Vec<(GuestAddress, usize, Region }; vec![ - // 0 ~ 64 MiB: Reserved for UEFI space + // 0 ~ 4 MiB: Reserved for UEFI space #[cfg(feature = "acpi")] (GuestAddress(0), layout::UEFI_SIZE as usize, RegionType::Ram), #[cfg(not(feature = "acpi"))] @@ -107,7 +107,7 @@ pub fn arch_memory_regions(size: GuestUsize) -> Vec<(GuestAddress, usize, Region layout::UEFI_SIZE as usize, RegionType::Reserved, ), - // 64 MiB ~ 256 MiB: Gic and legacy devices + // 4 MiB ~ 256 MiB: Gic and legacy devices ( GuestAddress(layout::UEFI_SIZE), (layout::MEM_32BIT_DEVICES_START.0 - layout::UEFI_SIZE) as usize,