mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
arch, devices, vmm: Remove "acpi" feature gate
Compile this feature in by default as it's well supported on both aarch64 and x86_64 and we only officially support using it (no non-acpi binaries are available.) Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -19,7 +19,6 @@ use crate::interrupt::kvm::KvmMsiInterruptManager as MsiInterruptManager;
|
||||
#[cfg(feature = "mshv")]
|
||||
use crate::interrupt::mshv::MshvMsiInterruptManager as MsiInterruptManager;
|
||||
use crate::interrupt::LegacyUserspaceInterruptManager;
|
||||
#[cfg(feature = "acpi")]
|
||||
use crate::memory_manager::MEMORY_MANAGER_ACPI_SIZE;
|
||||
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager};
|
||||
use crate::pci_segment::PciSegment;
|
||||
@@ -29,16 +28,13 @@ use crate::sigwinch_listener::start_sigwinch_listener;
|
||||
use crate::GuestRegionMmap;
|
||||
use crate::PciDeviceInfo;
|
||||
use crate::{device_node, DEVICE_MANAGER_SNAPSHOT_ID};
|
||||
#[cfg(feature = "acpi")]
|
||||
use acpi_tables::{aml, aml::Aml};
|
||||
use anyhow::anyhow;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use arch::aarch64::gic::gicv3_its::kvm::KvmGicV3Its;
|
||||
#[cfg(feature = "acpi")]
|
||||
use arch::layout;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use arch::layout::{APIC_START, IOAPIC_SIZE, IOAPIC_START};
|
||||
#[cfg(any(target_arch = "aarch64", feature = "acpi"))]
|
||||
use arch::NumaNodes;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use arch::{DeviceType, MmioDeviceInfo};
|
||||
@@ -480,7 +476,6 @@ pub enum DeviceManagerError {
|
||||
}
|
||||
pub type DeviceManagerResult<T> = result::Result<T, DeviceManagerError>;
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
const DEVICE_MANAGER_ACPI_SIZE: usize = 0x10;
|
||||
|
||||
const TIOCSPTLCK: libc::c_int = 0x4004_5431;
|
||||
@@ -846,7 +841,6 @@ pub struct DeviceManager {
|
||||
cmdline_additions: Vec<String>,
|
||||
|
||||
// ACPI GED notification device
|
||||
#[cfg(feature = "acpi")]
|
||||
ged_notification_device: Option<Arc<Mutex<devices::AcpiGedDevice>>>,
|
||||
|
||||
// VM configuration
|
||||
@@ -910,7 +904,6 @@ pub struct DeviceManager {
|
||||
seccomp_action: SeccompAction,
|
||||
|
||||
// List of guest NUMA nodes.
|
||||
#[cfg(any(target_arch = "aarch64", feature = "acpi"))]
|
||||
numa_nodes: NumaNodes,
|
||||
|
||||
// Possible handle to the virtio-balloon device
|
||||
@@ -920,9 +913,8 @@ pub struct DeviceManager {
|
||||
// activation and thus start the threads from the VMM thread
|
||||
activate_evt: EventFd,
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
acpi_address: GuestAddress,
|
||||
#[cfg(feature = "acpi")]
|
||||
|
||||
selected_segment: usize,
|
||||
|
||||
// Possible handle to the virtio-mem device
|
||||
@@ -951,7 +943,7 @@ impl DeviceManager {
|
||||
exit_evt: &EventFd,
|
||||
reset_evt: &EventFd,
|
||||
seccomp_action: SeccompAction,
|
||||
#[cfg(any(target_arch = "aarch64", feature = "acpi"))] numa_nodes: NumaNodes,
|
||||
numa_nodes: NumaNodes,
|
||||
activate_evt: &EventFd,
|
||||
force_iommu: bool,
|
||||
restoring: bool,
|
||||
@@ -1004,7 +996,6 @@ impl DeviceManager {
|
||||
vm,
|
||||
));
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
let acpi_address = address_manager
|
||||
.allocator
|
||||
.lock()
|
||||
@@ -1038,7 +1029,7 @@ impl DeviceManager {
|
||||
console: Arc::new(Console::default()),
|
||||
interrupt_controller: None,
|
||||
cmdline_additions: Vec::new(),
|
||||
#[cfg(feature = "acpi")]
|
||||
|
||||
ged_notification_device: None,
|
||||
config,
|
||||
memory_manager,
|
||||
@@ -1059,15 +1050,15 @@ impl DeviceManager {
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
id_to_dev_info: HashMap::new(),
|
||||
seccomp_action,
|
||||
#[cfg(any(target_arch = "aarch64", feature = "acpi"))]
|
||||
|
||||
numa_nodes,
|
||||
balloon: None,
|
||||
activate_evt: activate_evt
|
||||
.try_clone()
|
||||
.map_err(DeviceManagerError::EventFd)?,
|
||||
#[cfg(feature = "acpi")]
|
||||
|
||||
acpi_address,
|
||||
#[cfg(feature = "acpi")]
|
||||
|
||||
selected_segment: 0,
|
||||
serial_pty: None,
|
||||
serial_manager: None,
|
||||
@@ -1083,7 +1074,6 @@ impl DeviceManager {
|
||||
|
||||
let device_manager = Arc::new(Mutex::new(device_manager));
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
address_manager
|
||||
.mmio_bus
|
||||
.insert(
|
||||
@@ -1130,7 +1120,6 @@ impl DeviceManager {
|
||||
&interrupt_controller,
|
||||
)));
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
{
|
||||
if let Some(acpi_address) = self.memory_manager.lock().unwrap().acpi_address() {
|
||||
self.address_manager
|
||||
@@ -1154,7 +1143,6 @@ impl DeviceManager {
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
self.add_legacy_devices(&legacy_interrupt_manager)?;
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
{
|
||||
self.ged_notification_device = self.add_acpi_devices(
|
||||
&legacy_interrupt_manager,
|
||||
@@ -1378,7 +1366,6 @@ impl DeviceManager {
|
||||
Ok(interrupt_controller)
|
||||
}
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
fn add_acpi_devices(
|
||||
&mut self,
|
||||
interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = LegacyIrqGroupConfig>>,
|
||||
@@ -2787,9 +2774,6 @@ impl DeviceManager {
|
||||
if let Some(virtio_mem_zone) = memory_zone.virtio_mem_zone() {
|
||||
info!("Creating virtio-mem device: id = {}", memory_zone_id);
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", not(feature = "acpi")))]
|
||||
let node_id: Option<u16> = None;
|
||||
#[cfg(any(target_arch = "aarch64", feature = "acpi"))]
|
||||
let node_id = numa_node_id_from_memory_zone_id(&self.numa_nodes, memory_zone_id)
|
||||
.map(|i| i as u16);
|
||||
|
||||
@@ -3585,7 +3569,6 @@ impl DeviceManager {
|
||||
Arc::clone(self.pci_segments[0].pci_config_io.as_ref().unwrap())
|
||||
}
|
||||
|
||||
#[cfg(any(target_arch = "aarch64", feature = "acpi"))]
|
||||
pub(crate) fn pci_segments(&self) -> &Vec<PciSegment> {
|
||||
&self.pci_segments
|
||||
}
|
||||
@@ -3670,7 +3653,6 @@ impl DeviceManager {
|
||||
&self,
|
||||
_notification_type: AcpiNotificationFlags,
|
||||
) -> DeviceManagerResult<()> {
|
||||
#[cfg(feature = "acpi")]
|
||||
return self
|
||||
.ged_notification_device
|
||||
.as_ref()
|
||||
@@ -3679,8 +3661,6 @@ impl DeviceManager {
|
||||
.unwrap()
|
||||
.notify(_notification_type)
|
||||
.map_err(DeviceManagerError::HotPlugNotification);
|
||||
#[cfg(not(feature = "acpi"))]
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
pub fn add_device(
|
||||
@@ -4113,7 +4093,6 @@ impl DeviceManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub fn notify_power_button(&self) -> DeviceManagerResult<()> {
|
||||
self.ged_notification_device
|
||||
@@ -4127,43 +4106,27 @@ impl DeviceManager {
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub fn notify_power_button(&self) -> DeviceManagerResult<()> {
|
||||
// There are three use cases:
|
||||
// 1. The Cloud Hypervisor is built without feature acpi.
|
||||
// 2. The Cloud Hypervisor is built with feature acpi, but users will
|
||||
// use direct kernel boot with device tree.
|
||||
// 3. The Cloud Hypervisor is built with feature acpi, and users will
|
||||
// use ACPI+UEFI boot.
|
||||
#[cfg(not(feature = "acpi"))]
|
||||
// The `return` here will trigger a GPIO pin 3 event, which will trigger
|
||||
// a power button event for use case 1.
|
||||
return self
|
||||
.gpio_device
|
||||
// There are two use cases:
|
||||
// 1. Users will use direct kernel boot with device tree.
|
||||
// 2. Users will use ACPI+UEFI boot.
|
||||
|
||||
// Trigger a GPIO pin 3 event to satisify use case 1.
|
||||
self.gpio_device
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.trigger_key(3)
|
||||
.map_err(DeviceManagerError::AArch64PowerButtonNotification);
|
||||
#[cfg(feature = "acpi")]
|
||||
{
|
||||
// Trigger a GPIO pin 3 event to satisify use case 2.
|
||||
self.gpio_device
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.trigger_key(3)
|
||||
.map_err(DeviceManagerError::AArch64PowerButtonNotification)?;
|
||||
// Trigger a GED power button event to satisify use case 3.
|
||||
return self
|
||||
.ged_notification_device
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.notify(AcpiNotificationFlags::POWER_BUTTON_CHANGED)
|
||||
.map_err(DeviceManagerError::PowerButtonNotification);
|
||||
}
|
||||
.map_err(DeviceManagerError::AArch64PowerButtonNotification)?;
|
||||
// Trigger a GED power button event to satisify use case 2.
|
||||
return self
|
||||
.ged_notification_device
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap()
|
||||
.notify(AcpiNotificationFlags::POWER_BUTTON_CHANGED)
|
||||
.map_err(DeviceManagerError::PowerButtonNotification);
|
||||
}
|
||||
|
||||
pub fn iommu_attached_devices(&self) -> &Option<(PciBdf, Vec<PciBdf>)> {
|
||||
@@ -4171,7 +4134,6 @@ impl DeviceManager {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_arch = "aarch64", feature = "acpi"))]
|
||||
fn numa_node_id_from_memory_zone_id(numa_nodes: &NumaNodes, memory_zone_id: &str) -> Option<u32> {
|
||||
for (numa_node_id, numa_node) in numa_nodes.iter() {
|
||||
if numa_node.memory_zones.contains(&memory_zone_id.to_owned()) {
|
||||
@@ -4182,7 +4144,6 @@ fn numa_node_id_from_memory_zone_id(numa_nodes: &NumaNodes, memory_zone_id: &str
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
impl Aml for DeviceManager {
|
||||
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
@@ -4490,24 +4451,15 @@ impl Migratable for DeviceManager {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
const PCIU_FIELD_OFFSET: u64 = 0;
|
||||
#[cfg(feature = "acpi")]
|
||||
const PCID_FIELD_OFFSET: u64 = 4;
|
||||
#[cfg(feature = "acpi")]
|
||||
const B0EJ_FIELD_OFFSET: u64 = 8;
|
||||
#[cfg(feature = "acpi")]
|
||||
const PSEG_FIELD_OFFSET: u64 = 12;
|
||||
#[cfg(feature = "acpi")]
|
||||
const PCIU_FIELD_SIZE: usize = 4;
|
||||
#[cfg(feature = "acpi")]
|
||||
const PCID_FIELD_SIZE: usize = 4;
|
||||
#[cfg(feature = "acpi")]
|
||||
const B0EJ_FIELD_SIZE: usize = 4;
|
||||
#[cfg(feature = "acpi")]
|
||||
const PSEG_FIELD_SIZE: usize = 4;
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
impl BusDevice for DeviceManager {
|
||||
fn read(&mut self, base: u64, offset: u64, data: &mut [u8]) {
|
||||
match offset {
|
||||
|
||||
Reference in New Issue
Block a user