diff --git a/hypervisor/src/cpu.rs b/hypervisor/src/cpu.rs index a67e2cb50..4820956af 100644 --- a/hypervisor/src/cpu.rs +++ b/hypervisor/src/cpu.rs @@ -267,6 +267,11 @@ pub enum HypervisorCpuError { /// #[error("Failed to write to GPA: {0}")] GpaWrite(#[source] anyhow::Error), + /// + /// Error getting CPUID leaf + /// + #[error("Failed to get CPUID entries: {0}")] + GetCpuidVales(#[source] anyhow::Error), } #[derive(Debug)] @@ -477,4 +482,17 @@ pub trait Vcpu: Send + Sync { fn set_tsc_khz(&self, _freq: u32) -> Result<()> { Ok(()) } + #[cfg(target_arch = "x86_64")] + /// + /// X86 specific call to retrieve cpuid leaf + /// + fn get_cpuid_values( + &self, + _function: u32, + _index: u32, + _xfem: u64, + _xss: u64, + ) -> Result<[u32; 4]> { + unimplemented!() + } } diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index acd20713b..e1419e5e8 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -1077,6 +1077,23 @@ impl cpu::Vcpu for MshvVcpu { fn get_cpuid2(&self, _num_entries: usize) -> cpu::Result> { Ok(self.cpuid.clone()) } + + #[cfg(target_arch = "x86_64")] + /// + /// X86 specific call to retrieve cpuid leaf + /// + fn get_cpuid_values( + &self, + function: u32, + index: u32, + xfem: u64, + xss: u64, + ) -> cpu::Result<[u32; 4]> { + self.fd + .get_cpuid_values(function, index, xfem, xss) + .map_err(|e| cpu::HypervisorCpuError::GetCpuidVales(e.into())) + } + #[cfg(target_arch = "x86_64")] /// /// Returns the state of the LAPIC (Local Advanced Programmable Interrupt Controller).