From 5e2c70b87f0b0ae44c31c846d03c029156939e03 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 20 Jul 2022 20:33:10 +0000 Subject: [PATCH] hypervisor: aarch64: drop set/has_vcpu_attr This avoids the need for exposing DeviceAttr. Signed-off-by: Wei Liu --- hypervisor/src/cpu.rs | 12 ------------ hypervisor/src/kvm/mod.rs | 28 +++++----------------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/hypervisor/src/cpu.rs b/hypervisor/src/cpu.rs index ad540eda8..d65b5d5f3 100644 --- a/hypervisor/src/cpu.rs +++ b/hypervisor/src/cpu.rs @@ -19,8 +19,6 @@ use crate::arch::x86::{ #[cfg(feature = "tdx")] use crate::kvm::{TdxExitDetails, TdxExitStatus}; use crate::CpuState; -#[cfg(target_arch = "aarch64")] -use crate::DeviceAttr; use crate::MpState; use thiserror::Error; #[cfg(all(feature = "kvm", target_arch = "x86_64"))] @@ -276,16 +274,6 @@ pub trait Vcpu: Send + Sync { /// Returns the vCPU general purpose registers. /// fn get_regs(&self) -> Result; - #[cfg(target_arch = "aarch64")] - /// - /// Sets vcpu attribute - /// - fn set_vcpu_attr(&self, attr: &DeviceAttr) -> Result<()>; - #[cfg(target_arch = "aarch64")] - /// - /// Check if vcpu has attribute. - /// - fn has_vcpu_attr(&self, attr: &DeviceAttr) -> Result<()>; /// /// Sets the vCPU general purpose registers. /// diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index f198f17a0..6f9cb7a41 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -1279,26 +1279,6 @@ impl cpu::Vcpu for KvmVcpu { Ok(()) } - #[cfg(target_arch = "aarch64")] - /// - /// Set attribute for vcpu. - /// - fn set_vcpu_attr(&self, attr: &DeviceAttr) -> cpu::Result<()> { - self.fd - .set_device_attr(attr) - .map_err(|e| cpu::HypervisorCpuError::SetVcpuAttribute(e.into())) - } - - #[cfg(target_arch = "aarch64")] - /// - /// Check if vcpu has a certain attribute. - /// - fn has_vcpu_attr(&self, attr: &DeviceAttr) -> cpu::Result<()> { - self.fd - .has_device_attr(attr) - .map_err(|e| cpu::HypervisorCpuError::HasVcpuAttribute(e.into())) - } - #[cfg(target_arch = "x86_64")] /// /// Returns the vCPU special registers. @@ -2079,7 +2059,7 @@ impl cpu::Vcpu for KvmVcpu { addr: 0x0, flags: 0, }; - self.has_vcpu_attr(&cpu_attr).is_ok() + self.fd.has_device_attr(&cpu_attr).is_ok() } #[cfg(target_arch = "aarch64")] fn init_pmu(&self, irq: u32) -> cpu::Result<()> { @@ -2095,9 +2075,11 @@ impl cpu::Vcpu for KvmVcpu { addr: &irq as *const u32 as u64, flags: 0, }; - self.set_vcpu_attr(&cpu_attr_irq) + self.fd + .set_device_attr(&cpu_attr_irq) .map_err(|_| cpu::HypervisorCpuError::InitializePmu)?; - self.set_vcpu_attr(&cpu_attr) + self.fd + .set_device_attr(&cpu_attr) .map_err(|_| cpu::HypervisorCpuError::InitializePmu) } }