Skip to content

Commit f6b8659

Browse files
committed
refactor(vmm): replace static CPU templates for x86_64
Replace the static CPU templates introduced in PR firecracker-microvm#3076 with ones that are introduced in PR firecracker-microvm#3598, are compatibile with main branch and are defined using `CustomCpuTemplate`. Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent 72ff948 commit f6b8659

File tree

13 files changed

+584
-4325
lines changed

13 files changed

+584
-4325
lines changed

src/vmm/src/guest_config/templates/x86_64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::{CpuTemplateType, GetCpuTemplate, GetCpuTemplateError, StaticCpuTempl
1414
use crate::guest_config::cpuid::common::get_vendor_id_from_host;
1515
use crate::guest_config::cpuid::cpuid_ffi::KvmCpuidFlags;
1616
use crate::guest_config::cpuid::{VENDOR_ID_AMD, VENDOR_ID_INTEL};
17-
use crate::guest_config::x86_64::static_cpu_templates_new::{c3, t2, t2a, t2cl, t2s};
17+
use crate::guest_config::x86_64::static_cpu_templates::{c3, t2, t2a, t2cl, t2s};
1818

1919
impl GetCpuTemplate for Option<CpuTemplateType> {
2020
fn get_cpu_template(&self) -> Result<Cow<CustomCpuTemplate>, GetCpuTemplateError> {

src/vmm/src/guest_config/x86_64/mod.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
/// Module with CPU templates for x86_64
5-
pub mod static_cpu_templates;
6-
74
/// Module for static CPU templates for x86_64
8-
pub mod static_cpu_templates_new;
5+
pub mod static_cpu_templates;
96

107
use std::collections::HashMap;
118

@@ -128,7 +125,7 @@ mod tests {
128125
use kvm_bindings::KVM_CPUID_FLAG_STATEFUL_FUNC;
129126

130127
use super::*;
131-
use crate::guest_config::cpuid::{IntelCpuid, KvmCpuidFlags};
128+
use crate::guest_config::cpuid::{CpuidEntry, IntelCpuid, KvmCpuidFlags};
132129
use crate::guest_config::templates::x86_64::{
133130
CpuidLeafModifier, CpuidRegisterModifier, RegisterModifier, RegisterValueFilter,
134131
};
@@ -189,6 +186,16 @@ mod tests {
189186
}
190187
}
191188

189+
fn build_supported_cpuid() -> Cpuid {
190+
Cpuid::Intel(IntelCpuid(BTreeMap::from([(
191+
CpuidKey {
192+
leaf: 0x3,
193+
subleaf: 0x0,
194+
},
195+
CpuidEntry::default(),
196+
)])))
197+
}
198+
192199
fn empty_cpu_config() -> CpuConfiguration {
193200
CpuConfiguration {
194201
cpuid: Cpuid::Intel(IntelCpuid(BTreeMap::new())),
@@ -198,14 +205,14 @@ mod tests {
198205

199206
fn supported_cpu_config() -> CpuConfiguration {
200207
CpuConfiguration {
201-
cpuid: static_cpu_templates::t2::t2(),
208+
cpuid: build_supported_cpuid(),
202209
msrs: HashMap::from([(0x8000, 0b1000), (0x9999, 0b1010)]),
203210
}
204211
}
205212

206213
fn unsupported_cpu_config() -> CpuConfiguration {
207214
CpuConfiguration {
208-
cpuid: static_cpu_templates::t2::t2(),
215+
cpuid: build_supported_cpuid(),
209216
msrs: HashMap::from([(0x8000, 0b1000), (0x8001, 0b1010)]),
210217
}
211218
}

0 commit comments

Comments
 (0)