mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
hypervisor: Add get_feature_msrs method
KVM defines feature MSRs as MSRs that expose host capabilities and processor features. CPU profiles will describe how to adjust such feature MSRs similarly to how they describe CPUID modifications. We thus introduce a method on the hypervisor trait that queries the hypervisor for the supported feature MSRs. This will later be used to obtain the feature MSRs that need to be adjusted when a CPU profile is applied. The method will also be used by the upcoming CPU profile generation tool which will be introduced in a follow up PR. Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de> On-behalf-of: SAP oliver.anderson@sap.com
This commit is contained in:
committed by
Rob Bradford
parent
ebcf81d6ff
commit
9a2661a9c8
@@ -1825,6 +1825,42 @@ impl hypervisor::Hypervisor for KvmHypervisor {
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn get_feature_msrs(&self) -> hypervisor::Result<Vec<MsrEntry>> {
|
||||
let list = self
|
||||
.kvm
|
||||
.get_msr_feature_index_list()
|
||||
.map_err(|e| hypervisor::HypervisorError::GetFeatureMsrs(e.into()))?;
|
||||
|
||||
let kvm_msrs: Vec<kvm_msr_entry> = list
|
||||
.as_slice()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(|index| kvm_msr_entry {
|
||||
index,
|
||||
..Default::default()
|
||||
})
|
||||
.collect();
|
||||
|
||||
let mut kvm_msrs = MsrEntries::from_entries(&kvm_msrs).unwrap();
|
||||
|
||||
let num_feature_msrs = self
|
||||
.kvm
|
||||
.get_msrs(&mut kvm_msrs)
|
||||
.map_err(|e| hypervisor::HypervisorError::GetFeatureMsrs(e.into()))?;
|
||||
|
||||
if list.as_slice().len() == num_feature_msrs {
|
||||
Ok(kvm_msrs
|
||||
.as_slice()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(MsrEntry::from)
|
||||
.collect())
|
||||
} else {
|
||||
Err(hypervisor::HypervisorError::GetFeatureMsrsPartial)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
///
|
||||
/// Retrieve AArch64 host maximum IPA size supported by KVM.
|
||||
|
||||
Reference in New Issue
Block a user