Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivanshVij committed Apr 29, 2024
1 parent bc33553 commit 149e421
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/cpu_templates/cpu-template-helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ CPU features to a heterogeneous fleet consisting of multiple CPU models.
### MSRs excluded from guest CPU configuration dump

| Register name | Index |
| --------------------------------------- | ----------------------- |
|-----------------------------------------|-------------------------|
| MSR_IA32_TSC | 0x00000010 |
| MSR_ARCH_PERFMON_PERFCTRn | 0x000000c1 - 0x000000d2 |
| MSR_ARCH_PERFMON_EVENTSELn | 0x00000186 - 0x00000197 |
Expand Down
3 changes: 2 additions & 1 deletion src/vmm/src/arch/x86_64/msr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ static SERIALIZABLE_MSR_RANGES: &[MsrRange] = &[
MSR_RANGE!(MSR_K7_HWCR),
MSR_RANGE!(MSR_KVM_POLL_CONTROL),
MSR_RANGE!(MSR_KVM_ASYNC_PF_INT),
MSR_RANGE!(MSR_IA32_TSX_CTRL),
MSR_RANGE!(MSR_PVM_LINEAR_ADDRESS_RANGE),
MSR_RANGE!(MSR_PVM_VCPU_STRUCT),
MSR_RANGE!(MSR_PVM_SUPERVISOR_RSP),
Expand All @@ -254,7 +255,6 @@ static SERIALIZABLE_MSR_RANGES: &[MsrRange] = &[
MSR_RANGE!(MSR_PVM_RETU_RIP),
MSR_RANGE!(MSR_PVM_RETS_RIP),
MSR_RANGE!(MSR_PVM_SWITCH_CR3),
MSR_RANGE!(MSR_IA32_TSX_CTRL),
];

/// Specifies whether a particular MSR should be included in vcpu serialization.
Expand Down Expand Up @@ -379,6 +379,7 @@ const UNDUMPABLE_MSR_RANGES: [MsrRange; 17] = [
MSR_RANGE!(HV_X64_MSR_SYNDBG_OPTIONS),
MSR_RANGE!(HV_X64_MSR_CRASH_P0, 6),
MSR_RANGE!(HV_X64_MSR_REENLIGHTENMENT_CONTROL, 3),
// HV_X64_MSR_TSC_INVARIANT_CONTROL
MSR_RANGE!(HV_X64_MSR_TSC_INVARIANT_CONTROL),
];

Expand Down
32 changes: 32 additions & 0 deletions tests/integration_tests/functional/test_cpu_template_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,35 @@ def test_consecutive_fingerprint_consistency(cpu_template_helper, tmp_path):

# Compare them.
cpu_template_helper.fingerprint_compare(fp1, fp2, None)
# Strip common entries.
cpu_template_helper.template_strip([cpu_config_1, cpu_config_2])

config_1 = json.loads(cpu_config_1.read_text(encoding="utf-8"))
config_2 = json.loads(cpu_config_2.read_text(encoding="utf-8"))

# Check the stripped result is empty.
if PLATFORM == "x86_64":
empty_cpu_config = {
"cpuid_modifiers": [],
"kvm_capabilities": [],
"msr_modifiers": [],
}
elif PLATFORM == "aarch64":
# 0x603000000013df01 -> CNTPCT_EL0
ignore_registers = ["0x603000000013df01"]

config_1["reg_modifiers"] = [
rm for rm in config_1["reg_modifiers"] if rm["addr"] not in ignore_registers
]
config_2["reg_modifiers"] = [
rm for rm in config_2["reg_modifiers"] if rm["addr"] not in ignore_registers
]

empty_cpu_config = {
"kvm_capabilities": [],
"reg_modifiers": [],
"vcpu_features": [],
}

assert config_1 == empty_cpu_config
assert config_2 == empty_cpu_config

0 comments on commit 149e421

Please sign in to comment.