mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
device_manager: AArch64: add a field to set/get GIC device entity
In AArch64 systems, the state of GIC device can only be retrieved from `KVM_GET_DEVICE_ATTR` ioctl. Therefore to implement saving/restoring the GIC states, we need to make sure that the GIC object (either the file descriptor or the device itself) can be extracted after the VM is started. This commit refactors the code of GIC creation by adding a new field `gic_device_entity` in device manager and methods to set/get this field. The GIC object can be therefore saved in the device manager after calling `arch::configure_system`. Signed-off-by: Henry Wang <Henry.Wang@arm.com>
This commit is contained in:
@@ -26,7 +26,7 @@ pub enum Error {
|
||||
}
|
||||
type Result<T> = result::Result<T, Error>;
|
||||
|
||||
pub trait GICDevice {
|
||||
pub trait GICDevice: Send {
|
||||
/// Returns the hypervisor agnostic Device of the GIC device
|
||||
fn device(&self) -> &Arc<dyn hypervisor::Device>;
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ pub mod regs;
|
||||
pub use self::fdt::DeviceInfoForFDT;
|
||||
use crate::DeviceType;
|
||||
use crate::RegionType;
|
||||
use aarch64::gic::GICDevice;
|
||||
use hypervisor::kvm::kvm_bindings;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::CStr;
|
||||
@@ -146,7 +147,7 @@ pub fn configure_system<T: DeviceInfoForFDT + Clone + Debug, S: ::std::hash::Bui
|
||||
device_info: &HashMap<(DeviceType, String), T, S>,
|
||||
initrd: &Option<super::InitramfsConfig>,
|
||||
pci_space_address: &Option<(u64, u64)>,
|
||||
) -> super::Result<()> {
|
||||
) -> super::Result<Box<dyn GICDevice>> {
|
||||
// If pci_space_address is present, it means PCI devices are used ("pci" feature enabled).
|
||||
// Then GITv3-ITS is required for MSI messaging.
|
||||
// Otherwise ("mmio" feature enabled), any version of GIC is OK.
|
||||
@@ -164,7 +165,7 @@ pub fn configure_system<T: DeviceInfoForFDT + Clone + Debug, S: ::std::hash::Bui
|
||||
)
|
||||
.map_err(Error::SetupFDT)?;
|
||||
|
||||
Ok(())
|
||||
Ok(gic_device)
|
||||
}
|
||||
|
||||
/// Returns the memory address where the initramfs could be loaded.
|
||||
|
||||
Reference in New Issue
Block a user