Skip to content

Comments

WIP: Make CPU profiles MSR aware#70

Draft
olivereanderson wants to merge 16 commits intocyberus-technology:gardenlinuxfrom
olivereanderson:cpu-profiles-msr
Draft

WIP: Make CPU profiles MSR aware#70
olivereanderson wants to merge 16 commits intocyberus-technology:gardenlinuxfrom
olivereanderson:cpu-profiles-msr

Conversation

@olivereanderson
Copy link

@olivereanderson olivereanderson commented Jan 26, 2026

WIP: Do not review

TODO:

  • Understand differences between us and QEMU
  • Test on real hardware
  • Nice PR description :)

@olivereanderson olivereanderson force-pushed the cpu-profiles-msr branch 7 times, most recently from 7a0c713 to abe10dd Compare February 3, 2026 15:17
@olivereanderson olivereanderson force-pushed the cpu-profiles-msr branch 5 times, most recently from 324135c to b8fa2a0 Compare February 9, 2026 19:21
@olivereanderson olivereanderson force-pushed the cpu-profiles-msr branch 6 times, most recently from b85447c to 1463253 Compare February 13, 2026 23:21
@olivereanderson olivereanderson force-pushed the cpu-profiles-msr branch 5 times, most recently from 7d80ea0 to b348d8a Compare February 23, 2026 17:00
In order to apply CPU profiles we need to modify the MSR-based features
according to the profile. The first step is to obtain these MSR-based
features from the hypervisor as introduced in this commit.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We want to deny MSRs that are not available, or should not be available
for a given CPU profile, but in order to do that we must also have
some means to see which MSRs are supported by the host.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We realized that we only need a method for obtaining supported MSR
indices and the buffer can be built from that in the `CpuManager`'s
constructor.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
In order to ensure that MSRs that are not compatible with a given
CPU profile do no get accessed by the guests we need to introduce
functionality to deny such MSRs via filters.

The implementation introduced here is mostly a temporary workaround
until rust-vmm/kvm#359 gets integrated in
CHV.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
In preparation for making CPU profiles MSR aware we prepare for having
two pieces of data associated with a CPU profile: CPUID and MSR
adjustments. We thus rename the pre-existing CpuProfileData struct
to CpuIdProfileData and adapt the CPU profile generation tool
accordingly.

We also make the CPU profile generation tool write directly to file
and automatically introduce the required license file as well. This
makes the profile generation process more convenient.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
Introduce convenience methods for looking up CPUID value definitions.

We will later use these methods to assert certain policies at compile
time in order to stay consistent with MSR policies we introduce.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
In order to generate CPU profiles we also need definitions and policies
for MSR-based features, as some CPU features are exposed through MSRs
rather than CPUID.

This commit introduces the MSR analogues of the data structures we
previously introduced for CPUID definitions.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We introduce MSR-based feature definitions for Intel CPUs that will be
utilized by the upcoming CPU profile generation tool.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
In order for live migrations to be safe it is necessary to ensure that
the destination VM exposes MSR-based features compatible with those
of the source VM. These checks have been omitted from CHV thus far,
but we introduce them here for Intel CPUs.

Our checks provide logs at the error level and debug level. The
former aims to provide the minimal amount of information required to
investigate the problem further, while the debug logs provide (much)
more convenience when debugging.

We will also incorporate these checks in the context of CPU profiles in
a later commit.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
This list will be used to help us detect unknown MSRs when generating
CPU profiles. It serves no other purpose beyond that.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We include a list of non-architectural MSRS. This list will only be
used to help the CPU profile generation tool rule out MSRs that it
does not know how to handle.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We include a list of MSRS defined by KVM that may be approved by
CPU profiles and another list of those that may not be approved by
CPU profiles. These lists will later be used by the CPU profile
generation tool.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We introduce functionality related to adjusting MSR-based features
according to the CPU profile.

The functionality introduced here will be utilized in a follow up
commit.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We record the necessary MSR-based feature modifications that need to be
set in the `CpuManager` and make sure to set these MSR values upon
vCPU configuration.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We adapt the CPU profile generation tool to also take the MSR-based
features into account.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
We regenerate the CPU profiles and include the MSR-related data.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant