Skip to content

Commit 21bc2a7

Browse files
committed
fix(x86_64): serialize full KVM custom MSR range for snapshot
KVM reserves the range 0x4b564d00-0x4b564dff for custom MSRs. The current snapshot implementation only serializes a small subset of these MSRs, which risks missing newly introduced KVM features. Some MSRs are already absent from the list (e.g. MSR_KVM_ASYNC_PF_INT and MSR_KVM_ASYNC_PF_ACK). Replace the individual MSR entries with a single range covering the full KVM custom MSR space so that all KVM-defined MSRs are included during snapshot serialization. Signed-off-by: Zhiheng Tao <junchuan.tzh@antgroup.com>
1 parent dc84e40 commit 21bc2a7

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/vmm/src/arch/x86_64/msr.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,21 @@ const APIC_BASE_MSR: u32 = 0x800;
5050
const APIC_MSR_INDEXES: u32 = 0x400;
5151

5252
/// Custom MSRs fall in the range 0x4b564d00-0x4b564dff
53+
const MSR_KVM_RANGE_START: u32 = 0x4b56_4d00;
54+
const MSR_KVM_RANGE_END: u32 = 0x4b56_4dff;
55+
#[allow(unused)]
5356
const MSR_KVM_WALL_CLOCK_NEW: u32 = 0x4b56_4d00;
57+
#[allow(unused)]
5458
const MSR_KVM_SYSTEM_TIME_NEW: u32 = 0x4b56_4d01;
59+
#[allow(unused)]
5560
const MSR_KVM_ASYNC_PF_EN: u32 = 0x4b56_4d02;
61+
#[allow(unused)]
5662
const MSR_KVM_STEAL_TIME: u32 = 0x4b56_4d03;
63+
#[allow(unused)]
5764
const MSR_KVM_PV_EOI_EN: u32 = 0x4b56_4d04;
65+
#[allow(unused)]
5866
const MSR_KVM_POLL_CONTROL: u32 = 0x4b56_4d05;
67+
#[allow(unused)]
5968
const MSR_KVM_ASYNC_PF_INT: u32 = 0x4b56_4d06;
6069

6170
/// Taken from arch/x86/include/asm/msr-index.h
@@ -218,11 +227,6 @@ static SERIALIZABLE_MSR_RANGES: &[MsrRange] = &[
218227
MSR_RANGE!(MSR_TURBO_ACTIVATION_RATIO),
219228
MSR_RANGE!(MSR_IA32_TSC_DEADLINE),
220229
MSR_RANGE!(APIC_BASE_MSR, APIC_MSR_INDEXES),
221-
MSR_RANGE!(MSR_KVM_WALL_CLOCK_NEW),
222-
MSR_RANGE!(MSR_KVM_SYSTEM_TIME_NEW),
223-
MSR_RANGE!(MSR_KVM_ASYNC_PF_EN),
224-
MSR_RANGE!(MSR_KVM_STEAL_TIME),
225-
MSR_RANGE!(MSR_KVM_PV_EOI_EN),
226230
MSR_RANGE!(MSR_EFER),
227231
MSR_RANGE!(MSR_STAR),
228232
MSR_RANGE!(MSR_LSTAR),
@@ -234,9 +238,11 @@ static SERIALIZABLE_MSR_RANGES: &[MsrRange] = &[
234238
MSR_RANGE!(MSR_TSC_AUX),
235239
MSR_RANGE!(MSR_MISC_FEATURES_ENABLES),
236240
MSR_RANGE!(MSR_K7_HWCR),
237-
MSR_RANGE!(MSR_KVM_POLL_CONTROL),
238-
MSR_RANGE!(MSR_KVM_ASYNC_PF_INT),
239241
MSR_RANGE!(MSR_IA32_TSX_CTRL),
242+
MSR_RANGE!(
243+
MSR_KVM_RANGE_START,
244+
MSR_KVM_RANGE_END - MSR_KVM_RANGE_START + 1
245+
),
240246
];
241247

242248
/// Specifies whether a particular MSR should be included in vcpu serialization.

0 commit comments

Comments
 (0)