mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 21:55:20 +00:00
arch: vmm: Move ACPI tables creation to vmm crate
Remove ACPI table creation from arch crate to the vmm crate simplifying arch::configure_system() GuestAddress(0) is used to mean no RSDP table rather than adding complexity with a conditional argument or an Option type as it will evaluate to a zero value which would be the default anyway. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
c3eaa41b77
commit
0319a4a09a
@ -5,7 +5,6 @@ authors = ["The Chromium OS Authors"]
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
acpi = ["acpi_tables"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
byteorder = "1.3.2"
|
byteorder = "1.3.2"
|
||||||
|
@ -16,8 +16,7 @@ pub fn configure_system(
|
|||||||
_cmdline_addr: GuestAddress,
|
_cmdline_addr: GuestAddress,
|
||||||
_cmdline_size: usize,
|
_cmdline_size: usize,
|
||||||
_num_cpus: u8,
|
_num_cpus: u8,
|
||||||
_serial_enabled: bool,
|
_rsdp_addr: Option<GuestAddress>,
|
||||||
_virt_iommu: Option<(u32, &[u32])>,
|
|
||||||
) -> super::Result<()> {
|
) -> super::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE-BSD-3-Clause file.
|
// found in the LICENSE-BSD-3-Clause file.
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
|
||||||
mod acpi;
|
|
||||||
|
|
||||||
mod gdt;
|
mod gdt;
|
||||||
pub mod interrupts;
|
pub mod interrupts;
|
||||||
pub mod layout;
|
pub mod layout;
|
||||||
@ -111,9 +108,7 @@ pub fn configure_system(
|
|||||||
cmdline_size: usize,
|
cmdline_size: usize,
|
||||||
num_cpus: u8,
|
num_cpus: u8,
|
||||||
setup_hdr: Option<setup_header>,
|
setup_hdr: Option<setup_header>,
|
||||||
_serial_enabled: bool,
|
rsdp_addr: Option<GuestAddress>,
|
||||||
_end_of_range: GuestAddress,
|
|
||||||
_virt_iommu: Option<(u32, &[u32])>,
|
|
||||||
) -> super::Result<()> {
|
) -> super::Result<()> {
|
||||||
const KERNEL_BOOT_FLAG_MAGIC: u16 = 0xaa55;
|
const KERNEL_BOOT_FLAG_MAGIC: u16 = 0xaa55;
|
||||||
const KERNEL_HDR_MAGIC: u32 = 0x53726448;
|
const KERNEL_HDR_MAGIC: u32 = 0x53726448;
|
||||||
@ -172,21 +167,7 @@ pub fn configure_system(
|
|||||||
E820_RESERVED,
|
E820_RESERVED,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
if let Some(rsdp_addr) = rsdp_addr {
|
||||||
{
|
|
||||||
let start_of_device_area = if mem_end < layout::MEM_32BIT_RESERVED_START {
|
|
||||||
layout::RAM_64BIT_START
|
|
||||||
} else {
|
|
||||||
guest_mem.end_addr().unchecked_add(1)
|
|
||||||
};
|
|
||||||
let rsdp_addr = acpi::create_acpi_tables(
|
|
||||||
guest_mem,
|
|
||||||
num_cpus,
|
|
||||||
_serial_enabled,
|
|
||||||
start_of_device_area,
|
|
||||||
_end_of_range,
|
|
||||||
_virt_iommu,
|
|
||||||
);
|
|
||||||
params.0.acpi_rsdp_addr = rsdp_addr.0;
|
params.0.acpi_rsdp_addr = rsdp_addr.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,16 +227,7 @@ mod tests {
|
|||||||
fn test_system_configuration() {
|
fn test_system_configuration() {
|
||||||
let no_vcpus = 4;
|
let no_vcpus = 4;
|
||||||
let gm = GuestMemoryMmap::new(&vec![(GuestAddress(0), 0x10000)]).unwrap();
|
let gm = GuestMemoryMmap::new(&vec![(GuestAddress(0), 0x10000)]).unwrap();
|
||||||
let config_err = configure_system(
|
let config_err = configure_system(&gm, GuestAddress(0), 0, 1, None, None);
|
||||||
&gm,
|
|
||||||
GuestAddress(0),
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
None,
|
|
||||||
false,
|
|
||||||
GuestAddress((1 << 36) - 1),
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
assert!(config_err.is_err());
|
assert!(config_err.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
config_err.unwrap_err(),
|
config_err.unwrap_err(),
|
||||||
@ -273,17 +245,7 @@ mod tests {
|
|||||||
.map(|r| (r.0, r.1))
|
.map(|r| (r.0, r.1))
|
||||||
.collect();
|
.collect();
|
||||||
let gm = GuestMemoryMmap::new(&ram_regions).unwrap();
|
let gm = GuestMemoryMmap::new(&ram_regions).unwrap();
|
||||||
configure_system(
|
configure_system(&gm, GuestAddress(0), 0, no_vcpus, None, None).unwrap();
|
||||||
&gm,
|
|
||||||
GuestAddress(0),
|
|
||||||
0,
|
|
||||||
no_vcpus,
|
|
||||||
None,
|
|
||||||
false,
|
|
||||||
GuestAddress((1 << 36) - 1),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Now assigning some memory that is equal to the start of the 32bit memory hole.
|
// Now assigning some memory that is equal to the start of the 32bit memory hole.
|
||||||
let mem_size = 3328 << 20;
|
let mem_size = 3328 << 20;
|
||||||
@ -294,17 +256,7 @@ mod tests {
|
|||||||
.map(|r| (r.0, r.1))
|
.map(|r| (r.0, r.1))
|
||||||
.collect();
|
.collect();
|
||||||
let gm = GuestMemoryMmap::new(&ram_regions).unwrap();
|
let gm = GuestMemoryMmap::new(&ram_regions).unwrap();
|
||||||
configure_system(
|
configure_system(&gm, GuestAddress(0), 0, no_vcpus, None, None).unwrap();
|
||||||
&gm,
|
|
||||||
GuestAddress(0),
|
|
||||||
0,
|
|
||||||
no_vcpus,
|
|
||||||
None,
|
|
||||||
false,
|
|
||||||
GuestAddress((1 << 36) - 1),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Now assigning some memory that falls after the 32bit memory hole.
|
// Now assigning some memory that falls after the 32bit memory hole.
|
||||||
let mem_size = 3330 << 20;
|
let mem_size = 3330 << 20;
|
||||||
@ -315,17 +267,7 @@ mod tests {
|
|||||||
.map(|r| (r.0, r.1))
|
.map(|r| (r.0, r.1))
|
||||||
.collect();
|
.collect();
|
||||||
let gm = GuestMemoryMmap::new(&ram_regions).unwrap();
|
let gm = GuestMemoryMmap::new(&ram_regions).unwrap();
|
||||||
configure_system(
|
configure_system(&gm, GuestAddress(0), 0, no_vcpus, None, None).unwrap();
|
||||||
&gm,
|
|
||||||
GuestAddress(0),
|
|
||||||
0,
|
|
||||||
no_vcpus,
|
|
||||||
None,
|
|
||||||
false,
|
|
||||||
GuestAddress((1 << 36) - 1),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
acpi = ["acpi_tables","devices/acpi", "arch/acpi"]
|
acpi = ["acpi_tables","devices/acpi"]
|
||||||
pci_support = ["pci", "vfio", "vm-virtio/pci_support"]
|
pci_support = ["pci", "vfio", "vm-virtio/pci_support"]
|
||||||
mmio_support = ["vm-virtio/mmio_support"]
|
mmio_support = ["vm-virtio/mmio_support"]
|
||||||
cmos = ["devices/cmos"]
|
cmos = ["devices/cmos"]
|
||||||
|
@ -14,7 +14,7 @@ use vm_memory::{Address, ByteValued, Bytes};
|
|||||||
|
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use super::layout;
|
use arch::layout;
|
||||||
|
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
struct LocalAPIC {
|
struct LocalAPIC {
|
@ -30,6 +30,9 @@ pub mod config;
|
|||||||
pub mod device_manager;
|
pub mod device_manager;
|
||||||
pub mod vm;
|
pub mod vm;
|
||||||
|
|
||||||
|
#[cfg(feature = "acpi")]
|
||||||
|
mod acpi;
|
||||||
|
|
||||||
/// Errors associated with VMM management
|
/// Errors associated with VMM management
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
|
@ -23,7 +23,7 @@ extern crate vm_allocator;
|
|||||||
extern crate vm_memory;
|
extern crate vm_memory;
|
||||||
extern crate vm_virtio;
|
extern crate vm_virtio;
|
||||||
|
|
||||||
use crate::config::{ConsoleOutputMode, VmConfig};
|
use crate::config::VmConfig;
|
||||||
use crate::device_manager::{get_win_size, Console, DeviceManager, DeviceManagerError};
|
use crate::device_manager::{get_win_size, Console, DeviceManager, DeviceManagerError};
|
||||||
use arch::RegionType;
|
use arch::RegionType;
|
||||||
use devices::ioapic;
|
use devices::ioapic;
|
||||||
@ -768,7 +768,34 @@ impl Vm {
|
|||||||
)
|
)
|
||||||
.map_err(|_| Error::CmdLine)?;
|
.map_err(|_| Error::CmdLine)?;
|
||||||
let vcpu_count = self.config.cpus.cpu_count;
|
let vcpu_count = self.config.cpus.cpu_count;
|
||||||
let end_of_range = GuestAddress((1 << get_host_cpu_phys_bits()) - 1);
|
|
||||||
|
#[allow(unused_mut, unused_assignments)]
|
||||||
|
let mut rsdp_addr: Option<GuestAddress> = None;
|
||||||
|
|
||||||
|
#[cfg(feature = "acpi")]
|
||||||
|
{
|
||||||
|
rsdp_addr = Some({
|
||||||
|
let end_of_range = GuestAddress((1 << get_host_cpu_phys_bits()) - 1);
|
||||||
|
|
||||||
|
let mem_end = mem.end_addr();
|
||||||
|
let start_of_device_area = if mem_end < arch::layout::MEM_32BIT_RESERVED_START {
|
||||||
|
arch::layout::RAM_64BIT_START
|
||||||
|
} else {
|
||||||
|
mem_end.unchecked_add(1)
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::config::ConsoleOutputMode;
|
||||||
|
crate::acpi::create_acpi_tables(
|
||||||
|
&mem,
|
||||||
|
vcpu_count,
|
||||||
|
self.config.serial.mode != ConsoleOutputMode::Off,
|
||||||
|
start_of_device_area,
|
||||||
|
end_of_range,
|
||||||
|
self.devices.virt_iommu(),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
match entry_addr.setup_header {
|
match entry_addr.setup_header {
|
||||||
Some(hdr) => {
|
Some(hdr) => {
|
||||||
arch::configure_system(
|
arch::configure_system(
|
||||||
@ -777,9 +804,7 @@ impl Vm {
|
|||||||
cmdline_cstring.to_bytes().len() + 1,
|
cmdline_cstring.to_bytes().len() + 1,
|
||||||
vcpu_count,
|
vcpu_count,
|
||||||
Some(hdr),
|
Some(hdr),
|
||||||
self.config.serial.mode != ConsoleOutputMode::Off,
|
rsdp_addr,
|
||||||
end_of_range,
|
|
||||||
self.devices.virt_iommu(),
|
|
||||||
)
|
)
|
||||||
.map_err(|_| Error::CmdLine)?;
|
.map_err(|_| Error::CmdLine)?;
|
||||||
|
|
||||||
@ -798,9 +823,7 @@ impl Vm {
|
|||||||
cmdline_cstring.to_bytes().len() + 1,
|
cmdline_cstring.to_bytes().len() + 1,
|
||||||
vcpu_count,
|
vcpu_count,
|
||||||
None,
|
None,
|
||||||
self.config.serial.mode != ConsoleOutputMode::Off,
|
rsdp_addr,
|
||||||
end_of_range,
|
|
||||||
self.devices.virt_iommu(),
|
|
||||||
)
|
)
|
||||||
.map_err(|_| Error::CmdLine)?;
|
.map_err(|_| Error::CmdLine)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user