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());