From 58dbf07453c45aefa0c1069e5acf7040fe9c6ce3 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Fri, 15 Jul 2022 16:57:46 +0000 Subject: [PATCH] hypervisor: x86: drop get/set Xcrs from Vcpu trait Signed-off-by: Wei Liu --- hypervisor/src/cpu.rs | 12 +----------- hypervisor/src/kvm/mod.rs | 36 ++++++++++++++++++------------------ hypervisor/src/mshv/mod.rs | 36 ++++++++++++++++++------------------ 3 files changed, 37 insertions(+), 47 deletions(-) diff --git a/hypervisor/src/cpu.rs b/hypervisor/src/cpu.rs index 2c27b62f0..af1ea99f1 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::{ExtendedControlRegisters, MsrEntries, VcpuEvents}; +use crate::x86_64::{MsrEntries, VcpuEvents}; use crate::CpuState; #[cfg(target_arch = "aarch64")] use crate::DeviceAttr; @@ -351,16 +351,6 @@ pub trait Vcpu: Send + Sync { fn set_mp_state(&self, mp_state: MpState) -> Result<()>; #[cfg(target_arch = "x86_64")] /// - /// X86 specific call that returns the vcpu's current "xcrs". - /// - fn get_xcrs(&self) -> Result; - #[cfg(target_arch = "x86_64")] - /// - /// X86 specific call that sets the vcpu's current "xcrs". - /// - fn set_xcrs(&self, xcrs: &ExtendedControlRegisters) -> Result<()>; - #[cfg(target_arch = "x86_64")] - /// /// Returns currently pending exceptions, interrupts, and NMIs as well as related /// states of the vcpu. /// diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 4129d4b68..51fc2556b 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -1426,24 +1426,6 @@ impl cpu::Vcpu for KvmVcpu { } #[cfg(target_arch = "x86_64")] /// - /// X86 specific call that returns the vcpu's current "xcrs". - /// - fn get_xcrs(&self) -> cpu::Result { - self.fd - .get_xcrs() - .map_err(|e| cpu::HypervisorCpuError::GetXcsr(e.into())) - } - #[cfg(target_arch = "x86_64")] - /// - /// X86 specific call that sets the vcpu's current "xcrs". - /// - fn set_xcrs(&self, xcrs: &ExtendedControlRegisters) -> cpu::Result<()> { - self.fd - .set_xcrs(xcrs) - .map_err(|e| cpu::HypervisorCpuError::SetXcsr(e.into())) - } - #[cfg(target_arch = "x86_64")] - /// /// Translates guest virtual address to guest physical address using the `KVM_TRANSLATE` ioctl. /// fn translate_gva(&self, gva: u64, _flags: u64) -> cpu::Result<(u64, u32)> { @@ -2106,6 +2088,24 @@ impl KvmVcpu { .set_xsave(xsave) .map_err(|e| cpu::HypervisorCpuError::SetXsaveState(e.into())) } + #[cfg(target_arch = "x86_64")] + /// + /// X86 specific call that returns the vcpu's current "xcrs". + /// + fn get_xcrs(&self) -> cpu::Result { + self.fd + .get_xcrs() + .map_err(|e| cpu::HypervisorCpuError::GetXcsr(e.into())) + } + #[cfg(target_arch = "x86_64")] + /// + /// X86 specific call that sets the vcpu's current "xcrs". + /// + fn set_xcrs(&self, xcrs: &ExtendedControlRegisters) -> cpu::Result<()> { + self.fd + .set_xcrs(xcrs) + .map_err(|e| cpu::HypervisorCpuError::SetXcsr(e.into())) + } } /// Device struct for KVM diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index 83ee51dfc..c25c8ef1b 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -354,24 +354,6 @@ impl cpu::Vcpu for MshvVcpu { .map_err(|e| cpu::HypervisorCpuError::SetMsrEntries(e.into())) } - #[cfg(target_arch = "x86_64")] - /// - /// X86 specific call that returns the vcpu's current "xcrs". - /// - fn get_xcrs(&self) -> cpu::Result { - self.fd - .get_xcrs() - .map_err(|e| cpu::HypervisorCpuError::GetXcsr(e.into())) - } - #[cfg(target_arch = "x86_64")] - /// - /// X86 specific call that sets the vcpu's current "xcrs". - /// - fn set_xcrs(&self, xcrs: &ExtendedControlRegisters) -> cpu::Result<()> { - self.fd - .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 @@ -725,6 +707,24 @@ impl MshvVcpu { .set_xsave(xsave) .map_err(|e| cpu::HypervisorCpuError::SetXsaveState(e.into())) } + #[cfg(target_arch = "x86_64")] + /// + /// X86 specific call that returns the vcpu's current "xcrs". + /// + fn get_xcrs(&self) -> cpu::Result { + self.fd + .get_xcrs() + .map_err(|e| cpu::HypervisorCpuError::GetXcsr(e.into())) + } + #[cfg(target_arch = "x86_64")] + /// + /// X86 specific call that sets the vcpu's current "xcrs". + /// + fn set_xcrs(&self, xcrs: &ExtendedControlRegisters) -> cpu::Result<()> { + self.fd + .set_xcrs(xcrs) + .map_err(|e| cpu::HypervisorCpuError::SetXcsr(e.into())) + } } /// Device struct for MSHV