acpi: allocate sci_irq instead of use fixed number

sci_irq can be allocated so not to use the fixed number 9.
Actually this irq is not used for injecting any event but
the Linux guest OS requires to see meaning value from the
FADP table. So just fill it to satisfy.

BUG=chromium:1018674
TEST=None

Change-Id: If3ea3bb2844fc7fc1c24a577b7098d2a3e6f1c7f
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035352
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
This commit is contained in:
Chuanxiao Dong 2019-11-01 15:50:58 +08:00 committed by Commit Bot
parent 7eae7735ee
commit 05d30607bc

View file

@ -66,6 +66,7 @@ use sys_util::{Clock, EventFd, GuestAddress, GuestMemory, GuestMemoryError};
#[sorted]
#[derive(Debug)]
pub enum Error {
AllocateIrq,
CloneEventFd(sys_util::Error),
Cmdline(kernel_cmdline::Error),
ConfigureSystem,
@ -112,6 +113,7 @@ impl Display for Error {
#[sorted]
match self {
AllocateIrq => write!(f, "error allocating a single irq"),
CloneEventFd(e) => write!(f, "unable to clone an EventFd: {}", e),
Cmdline(e) => write!(f, "the given kernel command line was invalid: {}", e),
ConfigureSystem => write!(f, "error configuring the system"),
@ -192,6 +194,7 @@ fn configure_system(
setup_data: Option<GuestAddress>,
initrd: Option<(GuestAddress, usize)>,
mut params: boot_params,
sci_irq: u32,
) -> Result<()> {
const EBDA_START: u64 = 0x0009fc00;
const KERNEL_BOOT_FLAG_MAGIC: u16 = 0xaa55;
@ -255,7 +258,7 @@ fn configure_system(
.write_obj_at_addr(params, zero_page_addr)
.map_err(|_| Error::ZeroPageSetup)?;
let rsdp_addr = acpi::create_acpi_tables(guest_mem, num_cpus, 9);
let rsdp_addr = acpi::create_acpi_tables(guest_mem, num_cpus, sci_irq);
params.acpi_rsdp_addr = rsdp_addr.0;
Ok(())
@ -368,6 +371,8 @@ impl arch::LinuxArch for X8664arch {
// Event used to notify crosvm that guest OS is trying to suspend.
let suspend_evt = EventFd::new().map_err(Error::CreateEventFd)?;
// allocate sci_irq to fill the ACPI FACP table
let sci_irq = resources.allocate_irq().ok_or(Error::AllocateIrq)?;
let mut io_bus = Self::setup_io_bus(
&mut vm,
@ -430,6 +435,7 @@ impl arch::LinuxArch for X8664arch {
components.android_fstab,
kernel_end,
params,
sci_irq,
)?;
}
}
@ -514,6 +520,7 @@ impl X8664arch {
android_fstab: Option<File>,
kernel_end: u64,
params: boot_params,
sci_irq: u32,
) -> Result<()> {
kernel_loader::load_cmdline(mem, GuestAddress(CMDLINE_OFFSET), cmdline)
.map_err(Error::LoadCmdline)?;
@ -575,6 +582,7 @@ impl X8664arch {
setup_data,
initrd,
params,
sci_irq,
)?;
Ok(())
}