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 <noreply+kokoro@google.com>
Commit-Queue: Tom Cherry <tomcherry@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Tom Cherry 2021-09-02 10:02:32 -07:00 committed by Commit Bot
parent 2590740b08
commit 731f0809a3

View file

@ -482,22 +482,31 @@ impl arch::LinuxArch for X8664arch {
// TODO (tjeznach) Write RSDP to bootconfig before writing to memory // 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); 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(&param).map_err(Error::Cmdline)?;
}
match components.vm_image { 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) => { 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(&param).map_err(Error::Cmdline)?;
}
if let Some(ramoops_region) = ramoops_region { if let Some(ramoops_region) = ramoops_region {
arch::pstore::add_ramoops_kernel_cmdline(&mut cmdline, &ramoops_region) arch::pstore::add_ramoops_kernel_cmdline(&mut cmdline, &ramoops_region)
.map_err(Error::Cmdline)?; .map_err(Error::Cmdline)?;