From 2610f4353dcafa5bb36babb42d0d7e70420cb54d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 22 Aug 2019 11:18:48 +0100 Subject: [PATCH] arch: acpi: Only add ACPI COM1 device if serial is turned on Only add the ACPI PNP device for the COM1 serial port if it is not turned off with "--serial off" Signed-off-by: Rob Bradford --- arch/src/aarch64/mod.rs | 1 + arch/src/x86_64/acpi.rs | 15 ++++++++++----- arch/src/x86_64/mod.rs | 11 ++++++----- vmm/src/vm.rs | 2 ++ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/arch/src/aarch64/mod.rs b/arch/src/aarch64/mod.rs index f1b45e203..3a15d2688 100644 --- a/arch/src/aarch64/mod.rs +++ b/arch/src/aarch64/mod.rs @@ -16,6 +16,7 @@ pub fn configure_system( _cmdline_addr: GuestAddress, _cmdline_size: usize, _num_cpus: u8, + _serial_enabled: bool, ) -> super::Result<()> { Ok(()) } diff --git a/arch/src/x86_64/acpi.rs b/arch/src/x86_64/acpi.rs index 1ec2efab2..a3036fb9f 100644 --- a/arch/src/x86_64/acpi.rs +++ b/arch/src/x86_64/acpi.rs @@ -37,7 +37,7 @@ struct PCIRangeEntry { _reserved: u32 } -pub fn create_dsdt_table() -> SDT { +pub fn create_dsdt_table(serial_enabled: bool) -> SDT { /* The hex tables in this file are generated from the ASL below with: "iasl -tc " @@ -142,18 +142,23 @@ pub fn create_dsdt_table() -> SDT { // DSDT let mut dsdt = SDT::new(*b"DSDT", 36, 6, *b"CLOUDH", *b"CHDSDT ", 1); dsdt.append(pci_dsdt_data); - dsdt.append(com1_dsdt_data); + if serial_enabled { + dsdt.append(com1_dsdt_data); + } dsdt } - -pub fn create_acpi_tables(guest_mem: &GuestMemoryMmap, num_cpus: u8) -> GuestAddress { +pub fn create_acpi_tables( + guest_mem: &GuestMemoryMmap, + num_cpus: u8, + serial_enabled: bool, +) -> GuestAddress { // RSDP is at the EBDA let rsdp_offset = super::EBDA_START; let mut tables: Vec = Vec::new(); // DSDT - let dsdt = create_dsdt_table(); + let dsdt = create_dsdt_table(serial_enabled); let dsdt_offset = rsdp_offset.checked_add(RSDP::len() as u64).unwrap(); guest_mem .write_slice(dsdt.as_slice(), dsdt_offset) diff --git a/arch/src/x86_64/mod.rs b/arch/src/x86_64/mod.rs index 95045fde7..c20d1700e 100644 --- a/arch/src/x86_64/mod.rs +++ b/arch/src/x86_64/mod.rs @@ -127,6 +127,7 @@ pub fn configure_system( cmdline_size: usize, num_cpus: u8, setup_hdr: Option, + serial_enabled: bool, ) -> super::Result<()> { const KERNEL_BOOT_FLAG_MAGIC: u16 = 0xaa55; const KERNEL_HDR_MAGIC: u32 = 0x53726448; @@ -182,7 +183,7 @@ pub fn configure_system( } } - let rsdp_addr = acpi::create_acpi_tables(guest_mem, num_cpus); + let rsdp_addr = acpi::create_acpi_tables(guest_mem, num_cpus, serial_enabled); params.0.acpi_rsdp_addr = rsdp_addr.0; let zero_page_addr = layout::ZERO_PAGE_START; @@ -251,7 +252,7 @@ mod tests { fn test_system_configuration() { let no_vcpus = 4; let gm = GuestMemoryMmap::new(&vec![(GuestAddress(0), 0x10000)]).unwrap(); - let config_err = configure_system(&gm, GuestAddress(0), 0, 1, None); + let config_err = configure_system(&gm, GuestAddress(0), 0, 1, None, false); assert!(config_err.is_err()); assert_eq!( config_err.unwrap_err(), @@ -269,7 +270,7 @@ mod tests { .map(|r| (r.0, r.1)) .collect(); let gm = GuestMemoryMmap::new(&ram_regions).unwrap(); - configure_system(&gm, GuestAddress(0), 0, no_vcpus, None).unwrap(); + configure_system(&gm, GuestAddress(0), 0, no_vcpus, None, false).unwrap(); // Now assigning some memory that is equal to the start of the 32bit memory hole. let mem_size = 3328 << 20; @@ -280,7 +281,7 @@ mod tests { .map(|r| (r.0, r.1)) .collect(); let gm = GuestMemoryMmap::new(&ram_regions).unwrap(); - configure_system(&gm, GuestAddress(0), 0, no_vcpus, None).unwrap(); + configure_system(&gm, GuestAddress(0), 0, no_vcpus, None, false).unwrap(); // Now assigning some memory that falls after the 32bit memory hole. let mem_size = 3330 << 20; @@ -291,7 +292,7 @@ mod tests { .map(|r| (r.0, r.1)) .collect(); let gm = GuestMemoryMmap::new(&ram_regions).unwrap(); - configure_system(&gm, GuestAddress(0), 0, no_vcpus, None).unwrap(); + configure_system(&gm, GuestAddress(0), 0, no_vcpus, None, false).unwrap(); } #[test] diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 5df39c734..d67665523 100755 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -1634,6 +1634,7 @@ impl<'a> Vm<'a> { cmdline_cstring.to_bytes().len() + 1, vcpu_count, Some(hdr), + self.config.serial.mode != ConsoleOutputMode::Off, ) .map_err(|_| Error::CmdLine)?; @@ -1652,6 +1653,7 @@ impl<'a> Vm<'a> { cmdline_cstring.to_bytes().len() + 1, vcpu_count, None, + self.config.serial.mode != ConsoleOutputMode::Off, ) .map_err(|_| Error::CmdLine)?;