hypervisor: Optional vCPU MSR configuration update in vcpu constructor

When applying a CPU profile we need a way to change the configuration of
each vCPU to respect the requirements of the CPU profile.

This means that we need to set the feature MSRs in accordance with the
CPU profile upon configuring the vCPU and also ensuring that we do not
attempt to restore any MSRs that are not compatible with the profile
upon snapshot/restore.

The first step is to update `Vm::create_vcpu` to take an extra
parameter describing the necessary update.

In the case of KVM we modify the internal MSR state buffer when
constructing the vCPU whenever a VcpuMsrConfigUpdate is present.

The feature MSRs contained in the configuration will be treated in
follow up commits.

The changes to the vmm crate that are part of this commit are just
the minimum necessary to make the crate compile. We will update the
vmm crate to take CPU profiles into account in a follow up commit.

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-07-22 18:06:11 +02:00
committed by Rob Bradford
parent 2aff169533
commit 6ea8e8e20e
6 changed files with 65 additions and 18 deletions

View File

@@ -3935,7 +3935,9 @@ mod unit_tests {
mem.write_slice(&code, load_addr)
.expect("Writing code to memory failed");
let mut vcpu = vm.create_vcpu(0, None).expect("new Vcpu failed");
let mut vcpu = vm
.create_vcpu(0, None, Default::default())
.expect("new Vcpu failed");
let mut vcpu_sregs = vcpu.get_sregs().expect("get sregs failed");
vcpu_sregs.cs.base = 0;
@@ -4073,7 +4075,9 @@ pub fn test_vm() {
mem.write_slice(&code, load_addr)
.expect("Writing code to memory failed");
let mut vcpu = vm.create_vcpu(0, None).expect("new Vcpu failed");
let mut vcpu = vm
.create_vcpu(0, None, Default::default())
.expect("new Vcpu failed");
let mut vcpu_sregs = vcpu.get_sregs().expect("get sregs failed");
vcpu_sregs.cs.base = 0;