arch: Introduce MSR CPU profile data

We introduce a type describing MSR adjustments associated with a
CPU profile.

The upcoming CPU profile generation tool will serialize instances of
this struct when generating a CPU profile.

A follow up PR will take care of filling out the currently stubbed
`msr_data` method.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
This commit is contained in:
Oliver Anderson
2026-06-08 15:50:08 +02:00
committed by Rob Bradford
parent 26305445b6
commit 67c758b1ac
2 changed files with 24 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ use hypervisor::arch::x86::CpuIdEntry;
use crate::x86_64::cpu_profile::cpuid_adjustments::{ use crate::x86_64::cpu_profile::cpuid_adjustments::{
CpuidOutputRegisterAdjustments, CpuidProfileData, MissingCpuidEntriesError, CpuidOutputRegisterAdjustments, CpuidProfileData, MissingCpuidEntriesError,
}; };
use crate::x86_64::cpu_profile::msr_adjustments::MsrProfileData;
use crate::x86_64::{AMX_TILECFG_BIT, AMX_TILEDATA_BIT, CpuidReg}; use crate::x86_64::{AMX_TILECFG_BIT, AMX_TILEDATA_BIT, CpuidReg};
/// Mask indicating availability of the AMX TILECFG state component /// Mask indicating availability of the AMX TILECFG state component
@@ -64,6 +65,13 @@ impl CpuProfile {
CpuProfile::Host => None, CpuProfile::Host => None,
} }
} }
/// Obtain MSR adjustment data related to the given CPU profile.
fn msr_data(&self) -> Option<MsrProfileData> {
match self {
CpuProfile::Host => None,
}
}
} }
/// See [`CpuProfile::adjust_cpuid`](CpuProfile::adjust_cpuid) /// See [`CpuProfile::adjust_cpuid`](CpuProfile::adjust_cpuid)

View File

@@ -89,3 +89,19 @@ impl FeatureMsrAdjustment {
} }
} }
} }
/// Data describing MSR adjustments related to a CPU profile.
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
pub struct MsrProfileData {
/// Describes feature MSR adjustments necessary to become compatible with
/// the desired target.
pub adjustments: Vec<(RegisterAddress, FeatureMsrAdjustment)>,
/// List of the MSRs that the CPU profile requires.
///
/// When applying a CPU profile then the union of the sets of MSRs obtained
/// from `Hypervisor::get_feature_msrs` and `Hypervisor::get_msr_index_list`
/// must necessarily contain all MSRs listed here. Otherwise the host is
/// considered incompatible with the CPU profile. Exceptions are made for
/// missing Hyper-V MSRs when `kvm_hyperv=off`.
pub required_msrs: Vec<RegisterAddress>,
}