diff --git a/hypervisor/src/cpu.rs b/hypervisor/src/cpu.rs index af1ea99f1..dca8d271e 100644 --- a/hypervisor/src/cpu.rs +++ b/hypervisor/src/cpu.rs @@ -19,7 +19,7 @@ use crate::kvm::{TdxExitDetails, TdxExitStatus}; #[cfg(target_arch = "x86_64")] use crate::x86_64::LapicState; #[cfg(target_arch = "x86_64")] -use crate::x86_64::{MsrEntries, VcpuEvents}; +use crate::x86_64::MsrEntries; use crate::CpuState; #[cfg(target_arch = "aarch64")] use crate::DeviceAttr; @@ -349,18 +349,6 @@ pub trait Vcpu: Send + Sync { /// Sets the vcpu's current "multiprocessing state". /// fn set_mp_state(&self, mp_state: MpState) -> Result<()>; - #[cfg(target_arch = "x86_64")] - /// - /// Returns currently pending exceptions, interrupts, and NMIs as well as related - /// states of the vcpu. - /// - fn get_vcpu_events(&self) -> Result; - #[cfg(target_arch = "x86_64")] - /// - /// Sets pending exceptions, interrupts, and NMIs as well as related states - /// of the vcpu. - /// - fn set_vcpu_events(&self, events: &VcpuEvents) -> Result<()>; #[cfg(all(feature = "kvm", target_arch = "x86_64"))] /// /// Let the guest know that it has been paused, which prevents from diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 51fc2556b..0c1581f20 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -1535,26 +1535,6 @@ impl cpu::Vcpu for KvmVcpu { } #[cfg(target_arch = "x86_64")] /// - /// Returns currently pending exceptions, interrupts, and NMIs as well as related - /// states of the vcpu. - /// - fn get_vcpu_events(&self) -> cpu::Result { - self.fd - .get_vcpu_events() - .map_err(|e| cpu::HypervisorCpuError::GetVcpuEvents(e.into())) - } - #[cfg(target_arch = "x86_64")] - /// - /// Sets pending exceptions, interrupts, and NMIs as well as related states - /// of the vcpu. - /// - fn set_vcpu_events(&self, events: &VcpuEvents) -> cpu::Result<()> { - self.fd - .set_vcpu_events(events) - .map_err(|e| cpu::HypervisorCpuError::SetVcpuEvents(e.into())) - } - #[cfg(target_arch = "x86_64")] - /// /// Let the guest know that it has been paused, which prevents from /// potential soft lockups when being resumed. /// @@ -2106,6 +2086,26 @@ impl KvmVcpu { .set_xcrs(xcrs) .map_err(|e| cpu::HypervisorCpuError::SetXcsr(e.into())) } + #[cfg(target_arch = "x86_64")] + /// + /// Returns currently pending exceptions, interrupts, and NMIs as well as related + /// states of the vcpu. + /// + fn get_vcpu_events(&self) -> cpu::Result { + self.fd + .get_vcpu_events() + .map_err(|e| cpu::HypervisorCpuError::GetVcpuEvents(e.into())) + } + #[cfg(target_arch = "x86_64")] + /// + /// Sets pending exceptions, interrupts, and NMIs as well as related states + /// of the vcpu. + /// + fn set_vcpu_events(&self, events: &VcpuEvents) -> cpu::Result<()> { + self.fd + .set_vcpu_events(events) + .map_err(|e| cpu::HypervisorCpuError::SetVcpuEvents(e.into())) + } } /// Device struct for KVM diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index c25c8ef1b..c6dfbb116 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -354,26 +354,6 @@ impl cpu::Vcpu for MshvVcpu { .map_err(|e| cpu::HypervisorCpuError::SetMsrEntries(e.into())) } - #[cfg(target_arch = "x86_64")] - /// - /// Returns currently pending exceptions, interrupts, and NMIs as well as related - /// states of the vcpu. - /// - fn get_vcpu_events(&self) -> cpu::Result { - self.fd - .get_vcpu_events() - .map_err(|e| cpu::HypervisorCpuError::GetVcpuEvents(e.into())) - } - #[cfg(target_arch = "x86_64")] - /// - /// Sets pending exceptions, interrupts, and NMIs as well as related states - /// of the vcpu. - /// - fn set_vcpu_events(&self, events: &VcpuEvents) -> cpu::Result<()> { - self.fd - .set_vcpu_events(events) - .map_err(|e| cpu::HypervisorCpuError::SetVcpuEvents(e.into())) - } #[cfg(target_arch = "x86_64")] /// /// X86 specific call to enable HyperV SynIC @@ -725,6 +705,26 @@ impl MshvVcpu { .set_xcrs(xcrs) .map_err(|e| cpu::HypervisorCpuError::SetXcsr(e.into())) } + #[cfg(target_arch = "x86_64")] + /// + /// Returns currently pending exceptions, interrupts, and NMIs as well as related + /// states of the vcpu. + /// + fn get_vcpu_events(&self) -> cpu::Result { + self.fd + .get_vcpu_events() + .map_err(|e| cpu::HypervisorCpuError::GetVcpuEvents(e.into())) + } + #[cfg(target_arch = "x86_64")] + /// + /// Sets pending exceptions, interrupts, and NMIs as well as related states + /// of the vcpu. + /// + fn set_vcpu_events(&self, events: &VcpuEvents) -> cpu::Result<()> { + self.fd + .set_vcpu_events(events) + .map_err(|e| cpu::HypervisorCpuError::SetVcpuEvents(e.into())) + } } /// Device struct for MSHV