hypervisor, vmm: introduce trait functions for aarch64 PMU

The original code uses kvm_device_attr directly outside of the
hyeprvisor crate. That leaks hypervisor details.

No functional change intended.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu
2022-07-20 11:42:24 +00:00
committed by Liu Wei
parent b5d10eb28b
commit f84ddedb1a
3 changed files with 49 additions and 30 deletions

View File

@@ -236,6 +236,12 @@ pub enum HypervisorCpuError {
#[cfg(feature = "tdx")]
#[error("Unknown TDX VM call")]
UnknownTdxVmCall,
#[cfg(target_arch = "aarch64")]
///
/// Failed to intialize PMU
///
#[error("Failed to initialize PMU")]
InitializePmu,
}
#[derive(Debug)]
@@ -400,6 +406,16 @@ pub trait Vcpu: Send + Sync {
#[cfg(target_arch = "aarch64")]
fn setup_regs(&self, cpu_id: u8, boot_ip: u64, fdt_start: u64) -> Result<()>;
///
/// Check if the CPU supports PMU
///
#[cfg(target_arch = "aarch64")]
fn has_pmu_support(&self) -> bool;
///
/// Initialize PMU
///
#[cfg(target_arch = "aarch64")]
fn init_pmu(&self, irq: u32) -> Result<()>;
///
/// Retrieve the vCPU state.
/// This function is necessary to snapshot the VM
///