mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
hypervisor: Add api to retrieve CPUID leaf
Add necessary API to retrieve cpuid leaf on MSHV. This API is used to update cpuid information during the parsing of the igvm file. Microsoft hypervisor does not provide common CpuID like KVM. That's why we need to call this API during the IGVM parsing. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
@@ -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!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1077,6 +1077,23 @@ impl cpu::Vcpu for MshvVcpu {
|
||||
fn get_cpuid2(&self, _num_entries: usize) -> cpu::Result<Vec<CpuIdEntry>> {
|
||||
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).
|
||||
|
||||
Reference in New Issue
Block a user