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 <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-05-11 16:55:38 +01:00
parent 1c44e917f9
commit bb8d19bbd6
2 changed files with 10 additions and 1 deletions

View File

@ -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<T> = result::Result<T, Error>;

View File

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