Skip to content

Commit 1b645d8

Browse files
authored
Merge branch 'main' into validate-api-swagger
2 parents 93fddc4 + 2b05435 commit 1b645d8

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ and this project adheres to
1919
- [#4028](https://github.com/firecracker-microvm/firecracker/pull/4028):
2020
Firecracker now creates the log and metrics files if they do not exist,
2121
simplifying the launch of Firecracker by removing a manual step.
22+
- [#5526](https://github.com/firecracker-microvm/firecracker/pull/5526): Specify
23+
IA32_MTRRdefType MSR on VM boot to allow it to set page attributes for memory
24+
regions.
2225

2326
### Deprecated
2427

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 (11) 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: (1 << 11) | 0x6,
429+
..Default::default()
430+
},
422431
]
423432
}
424433

src/vmm/src/cpu_config/x86_64/cpuid/common.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
// SPDX-License-Identifier: Apache-2.0
33
#![allow(clippy::restriction)]
44

5+
use crate::arch::x86_64::generated::msr_index::{
6+
MSR_IA32_BNDCFGS, MSR_IA32_CR_PAT, MSR_MTRRdefType, MSR_MTRRfix4K_C0000, MSR_MTRRfix4K_C8000,
7+
MSR_MTRRfix4K_D0000, MSR_MTRRfix4K_D8000, MSR_MTRRfix4K_E0000, MSR_MTRRfix4K_E8000,
8+
MSR_MTRRfix4K_F0000, MSR_MTRRfix4K_F8000, MSR_MTRRfix16K_80000, MSR_MTRRfix16K_A0000,
9+
MSR_MTRRfix64K_00000,
10+
};
11+
512
/// Error type for [`get_cpuid`].
613
#[derive(Debug, thiserror::Error, displaydoc::Display, PartialEq, Eq)]
714
pub enum GetCpuidError {
@@ -93,13 +100,7 @@ pub(crate) fn msrs_to_save_by_cpuid(cpuid: &kvm_bindings::CpuId) -> Vec<u32> {
93100
}
94101

95102
// TODO: Add more dependencies.
96-
cpuid_msr_dep!(
97-
0x7,
98-
0,
99-
ebx,
100-
MPX_BITINDEX,
101-
[crate::arch::x86_64::generated::msr_index::MSR_IA32_BNDCFGS]
102-
);
103+
cpuid_msr_dep!(0x7, 0, ebx, MPX_BITINDEX, [MSR_IA32_BNDCFGS]);
103104

104105
// IA32_MTRR_PHYSBASEn, IA32_MTRR_PHYSMASKn
105106
cpuid_msr_dep!(0x1, 0, edx, MTRR_BITINDEX, 0x200..0x210);
@@ -111,19 +112,19 @@ pub(crate) fn msrs_to_save_by_cpuid(cpuid: &kvm_bindings::CpuId) -> Vec<u32> {
111112
edx,
112113
MTRR_BITINDEX,
113114
[
114-
0x250, // IA32_MTRR_FIX64K_00000
115-
0x258, // IA32_MTRR_FIX16K_80000
116-
0x259, // IA32_MTRR_FIX16K_A0000
117-
0x268, // IA32_MTRR_FIX4K_C0000
118-
0x269, // IA32_MTRR_FIX4K_C8000
119-
0x26a, // IA32_MTRR_FIX4K_D0000
120-
0x26b, // IA32_MTRR_FIX4K_D8000
121-
0x26c, // IA32_MTRR_FIX4K_E0000
122-
0x26d, // IA32_MTRR_FIX4K_E8000
123-
0x26e, // IA32_MTRR_FIX4K_F0000
124-
0x26f, // IA32_MTRR_FIX4K_F8000
125-
0x277, // IA32_PAT
126-
0x2ff // IA32_MTRR_DEF_TYPE
115+
MSR_MTRRfix64K_00000,
116+
MSR_MTRRfix16K_80000,
117+
MSR_MTRRfix16K_A0000,
118+
MSR_MTRRfix4K_C0000,
119+
MSR_MTRRfix4K_C8000,
120+
MSR_MTRRfix4K_D0000,
121+
MSR_MTRRfix4K_D8000,
122+
MSR_MTRRfix4K_E0000,
123+
MSR_MTRRfix4K_E8000,
124+
MSR_MTRRfix4K_F0000,
125+
MSR_MTRRfix4K_F8000,
126+
MSR_IA32_CR_PAT,
127+
MSR_MTRRdefType,
127128
]
128129
);
129130

tests/integration_tests/functional/test_cpu_template_helper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ def build_cpu_config_dict(cpu_config_path):
205205
# features are temporarily disabled. Guest OS disables TILEDATA by default
206206
# using the MSR.
207207
0x1C4,
208+
# IA32_PAT_MSR is R/W MSR for guest OS to control memory page attributes.
209+
0x277,
208210
# MSR_IA32_TSC_DEADLINE specifies the time at which a timer interrupt
209211
# should occur and depends on the elapsed time.
210212
0x6E0,

0 commit comments

Comments
 (0)