From 731f0809a34de077008ae666bb895f32f412e69a Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Thu, 2 Sep 2021 10:02:32 -0700 Subject: [PATCH] x86_64: pass kernel command line to bios This enables the bios to read kernel command line parameters from crosvm and pass them to the kernel that it loads. BUG=b:195323844 TEST=pass --params through uboot to Linux Change-Id: I306bb16421393583edc8b0dbdb3198a5b3cc0377 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3140277 Tested-by: kokoro Commit-Queue: Tom Cherry Reviewed-by: Daniel Verkamp --- x86_64/src/lib.rs | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs index 7988d1db1e..20ee02b278 100644 --- a/x86_64/src/lib.rs +++ b/x86_64/src/lib.rs @@ -482,22 +482,31 @@ impl arch::LinuxArch for X8664arch { // TODO (tjeznach) Write RSDP to bootconfig before writing to memory acpi::create_acpi_tables(&mem, vcpu_count as u8, X86_64_SCI_IRQ, acpi_dev_resource); + let mut cmdline = Self::get_base_linux_cmdline(); + + if noirq { + cmdline.insert_str("acpi=noirq").unwrap(); + } + + get_serial_cmdline(&mut cmdline, serial_parameters, "io") + .map_err(Error::GetSerialCmdline)?; + + for param in components.extra_kernel_params { + cmdline.insert_str(¶m).map_err(Error::Cmdline)?; + } + match components.vm_image { - VmImage::Bios(ref mut bios) => Self::load_bios(&mem, bios)?, + VmImage::Bios(ref mut bios) => { + // Allow a bios to hardcode CMDLINE_OFFSET and read the kernel command line from it. + kernel_loader::load_cmdline( + &mem, + GuestAddress(CMDLINE_OFFSET), + &CString::new(cmdline).unwrap(), + ) + .map_err(Error::LoadCmdline)?; + Self::load_bios(&mem, bios)? + } VmImage::Kernel(ref mut kernel_image) => { - let mut cmdline = Self::get_base_linux_cmdline(); - - if noirq { - cmdline.insert_str("acpi=noirq").unwrap(); - } - - get_serial_cmdline(&mut cmdline, serial_parameters, "io") - .map_err(Error::GetSerialCmdline)?; - - for param in components.extra_kernel_params { - cmdline.insert_str(¶m).map_err(Error::Cmdline)?; - } - if let Some(ramoops_region) = ramoops_region { arch::pstore::add_ramoops_kernel_cmdline(&mut cmdline, &ramoops_region) .map_err(Error::Cmdline)?;