Skip to content

Commit 9ef25b7

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

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

+1-1
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

+14-7
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

@@ -115,7 +112,7 @@ mod tests {
115112
use kvm_bindings::KVM_CPUID_FLAG_STATEFUL_FUNC;
116113

117114
use super::*;
118-
use crate::guest_config::cpuid::{IntelCpuid, KvmCpuidFlags};
115+
use crate::guest_config::cpuid::{CpuidEntry, IntelCpuid, KvmCpuidFlags};
119116
use crate::guest_config::templates::x86_64::{
120117
CpuidLeafModifier, CpuidRegisterModifier, RegisterModifier, RegisterValueFilter,
121118
};
@@ -176,6 +173,16 @@ mod tests {
176173
}
177174
}
178175

176+
fn build_supported_cpuid() -> Cpuid {
177+
Cpuid::Intel(IntelCpuid(BTreeMap::from([(
178+
CpuidKey {
179+
leaf: 0x3,
180+
subleaf: 0x0,
181+
},
182+
CpuidEntry::default(),
183+
)])))
184+
}
185+
179186
fn empty_cpu_config() -> CpuConfiguration {
180187
CpuConfiguration {
181188
cpuid: Cpuid::Intel(IntelCpuid(BTreeMap::new())),
@@ -185,14 +192,14 @@ mod tests {
185192

186193
fn supported_cpu_config() -> CpuConfiguration {
187194
CpuConfiguration {
188-
cpuid: static_cpu_templates::t2::t2(),
195+
cpuid: build_supported_cpuid(),
189196
msrs: HashMap::from([(0x8000, 0b1000), (0x9999, 0b1010)]),
190197
}
191198
}
192199

193200
fn unsupported_cpu_config() -> CpuConfiguration {
194201
CpuConfiguration {
195-
cpuid: static_cpu_templates::t2::t2(),
202+
cpuid: build_supported_cpuid(),
196203
msrs: HashMap::from([(0x8000, 0b1000), (0x8001, 0b1010)]),
197204
}
198205
}

0 commit comments

Comments
 (0)