Skip to content

Commit ddd31fe

Browse files
committed
fix(x86_64): specify IA32_MTRRdefType MSR on boot
The IA32_MTRRdefType MSR describes the default memory type used for physical addresses which are outside of any configured memory ranges, as well as whether MTRRs and fixed ranges are enabled. Without enabling this MSR, guest kernel is not able to change memory types for memory ranges outside main memory. This was causing pmem region to be marked as `uncached-minus` which instructed the cpu to skip all caches (L1, L2, L3) when reading/writing to that memory region. To fix this set IA32_MTRRdefType set to 0x806: - bit 11 enables MTRR - bits 0..7 specify the memory type used by default - value 6 represents `write-back` type Now guest can correctly set pmem memory region to `write-back` memory type. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent fa2627a commit ddd31fe

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,15 @@ pub fn create_boot_msr_entries() -> Vec<kvm_msr_entry> {
419419
data: u64::from(MSR_IA32_MISC_ENABLE_FAST_STRING),
420420
..Default::default()
421421
},
422+
// set default memory type for physical memory outside configured
423+
// memory ranges to write-back by setting MTRR enable bit and
424+
// setting memory type to write-back (value 6).
425+
// https://wiki.osdev.org/MTRR
426+
kvm_msr_entry {
427+
index: MSR_MTRRdefType,
428+
data: 0x806,
429+
..Default::default()
430+
},
422431
]
423432
}
424433

0 commit comments

Comments
 (0)