From bb8d19bbd6284d3b8faf52d52603d464f6e8570a Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 11 May 2020 16:55:38 +0100 Subject: [PATCH] arch: Check RSDP address does not go past memory The setup_mptables() call which is not used on ACPI builds has a side effect of testing whether there was enough RAM which one of the unit tests was relying on. Add a similar check for the RSDP address. Signed-off-by: Rob Bradford --- arch/src/lib.rs | 2 ++ arch/src/x86_64/mod.rs | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/src/lib.rs b/arch/src/lib.rs index d442bfd97..e20550f65 100644 --- a/arch/src/lib.rs +++ b/arch/src/lib.rs @@ -45,6 +45,8 @@ pub enum Error { InitramfsAddress, /// Error writing module entry to guest memory. ModlistSetup(vm_memory::GuestMemoryError), + /// RSDP Beyond Guest Memory + RSDPPastRamEnd, } pub type Result = result::Result; diff --git a/arch/src/x86_64/mod.rs b/arch/src/x86_64/mod.rs index 579ad423c..1986886d0 100644 --- a/arch/src/x86_64/mod.rs +++ b/arch/src/x86_64/mod.rs @@ -169,6 +169,13 @@ pub fn configure_system( // Note that this puts the mptable at the last 1k of Linux's 640k base RAM mptable::setup_mptable(guest_mem, num_cpus).map_err(Error::MpTableSetup)?; + // Check that the RAM is not smaller than the RSDP start address + if let Some(rsdp_addr) = rsdp_addr { + if rsdp_addr.0 > guest_mem.last_addr().0 { + return Err(super::Error::RSDPPastRamEnd); + } + } + match boot_prot { BootProtocol::PvhBoot => { configure_pvh(guest_mem, cmdline_addr, initramfs, rsdp_addr)?; @@ -481,7 +488,7 @@ mod tests { &None, 1, None, - None, + Some(layout::RSDP_POINTER), BootProtocol::LinuxBoot, ); assert!(config_err.is_err());