mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
arch: Refactor check_cpuid_compatibility
We make a slightly more general `check_cpuid_compatibility` function that permits the caller to specify something else than "source VM" and "destination VM" when logging an error. This way we can reuse the existing CPUID compatibility checks to ensure that the host VM is compatibile with the user selected CPU profile. In order to avoid a "refactor the world scenario" we keep the old function with its signature and instead refactor it to call the new more general internal function. 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
549f3d6c04
commit
39c27e1312
@@ -509,11 +509,27 @@ impl CpuidFeatureEntry {
|
||||
features
|
||||
}
|
||||
|
||||
// The function returns `Error` (a.k.a. "incompatible"), when the CPUID features from `src_vm_cpuid`
|
||||
// is not a subset of those of the `dest_vm_cpuid`.
|
||||
/// The function returns `Error` (a.k.a. "incompatible"), when the CPUID features from `src_vm_cpuid`
|
||||
/// is not a subset of those of the `dest_vm_cpuid`.
|
||||
pub fn check_cpuid_compatibility(
|
||||
src_vm_cpuid: &[CpuIdEntry],
|
||||
dest_vm_cpuid: &[CpuIdEntry],
|
||||
) -> Result<(), Error> {
|
||||
Self::check_cpuid_compatibility_with_descriptions(
|
||||
src_vm_cpuid,
|
||||
"source VM",
|
||||
dest_vm_cpuid,
|
||||
"destination VM",
|
||||
)
|
||||
}
|
||||
|
||||
/// Similar to `check_cpuid_compatibility`, but with the possibility to change
|
||||
/// the description of the source and destination for logging purposes.
|
||||
fn check_cpuid_compatibility_with_descriptions(
|
||||
src_vm_cpuid: &[CpuIdEntry],
|
||||
src_description: &str,
|
||||
dest_vm_cpuid: &[CpuIdEntry],
|
||||
dest_description: &str,
|
||||
) -> Result<(), Error> {
|
||||
let feature_entry_list = &Self::checked_feature_entry_list();
|
||||
let src_vm_features = Self::get_features_from_cpuid(src_vm_cpuid, feature_entry_list);
|
||||
@@ -540,7 +556,7 @@ impl CpuidFeatureEntry {
|
||||
if !entry_compatible {
|
||||
error!(
|
||||
"Detected incompatible CPUID entry: leaf={:#04x} (subleaf={:#04x}), register='{:?}', \
|
||||
compatible_check='{:?}', source VM feature='{:#04x}', destination VM feature'{:#04x}'.",
|
||||
compatible_check='{:?}', {src_description} feature='{:#04x}', {dest_description} feature='{:#04x}'.",
|
||||
entry.function,
|
||||
entry.index,
|
||||
entry.feature_reg,
|
||||
|
||||
Reference in New Issue
Block a user