From 1e31359279581679d837816fbab980e82145671d Mon Sep 17 00:00:00 2001 From: Takahiro Itazuri Date: Sun, 16 Apr 2023 16:42:54 +0000 Subject: [PATCH] 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 --- src/vmm/src/guest_config/templates/x86_64.rs | 2 +- src/vmm/src/guest_config/x86_64/mod.rs | 21 +- .../x86_64/static_cpu_templates/c3.rs | 776 ++----------- .../x86_64/static_cpu_templates/t2.rs | 784 ++----------- .../x86_64/static_cpu_templates/t2a.rs | 1023 ++--------------- .../x86_64/static_cpu_templates/t2cl.rs | 822 ++----------- .../x86_64/static_cpu_templates/t2s.rs | 806 ++----------- .../x86_64/static_cpu_templates_new/c3.rs | 120 -- .../x86_64/static_cpu_templates_new/mod.rs | 13 - .../x86_64/static_cpu_templates_new/t2.rs | 132 --- .../x86_64/static_cpu_templates_new/t2a.rs | 132 --- .../x86_64/static_cpu_templates_new/t2cl.rs | 139 --- .../x86_64/static_cpu_templates_new/t2s.rs | 139 --- 13 files changed, 584 insertions(+), 4325 deletions(-) delete mode 100644 src/vmm/src/guest_config/x86_64/static_cpu_templates_new/c3.rs delete mode 100644 src/vmm/src/guest_config/x86_64/static_cpu_templates_new/mod.rs delete mode 100644 src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2.rs delete mode 100644 src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2a.rs delete mode 100644 src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2cl.rs delete mode 100644 src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2s.rs diff --git a/src/vmm/src/guest_config/templates/x86_64.rs b/src/vmm/src/guest_config/templates/x86_64.rs index f2342bff5083..a05e49d10ef8 100644 --- a/src/vmm/src/guest_config/templates/x86_64.rs +++ b/src/vmm/src/guest_config/templates/x86_64.rs @@ -14,7 +14,7 @@ use super::{CpuTemplateType, GetCpuTemplate, GetCpuTemplateError, StaticCpuTempl use crate::guest_config::cpuid::common::get_vendor_id_from_host; use crate::guest_config::cpuid::cpuid_ffi::KvmCpuidFlags; use crate::guest_config::cpuid::{VENDOR_ID_AMD, VENDOR_ID_INTEL}; -use crate::guest_config::x86_64::static_cpu_templates_new::{c3, t2, t2a, t2cl, t2s}; +use crate::guest_config::x86_64::static_cpu_templates::{c3, t2, t2a, t2cl, t2s}; impl GetCpuTemplate for Option { fn get_cpu_template(&self) -> Result, GetCpuTemplateError> { diff --git a/src/vmm/src/guest_config/x86_64/mod.rs b/src/vmm/src/guest_config/x86_64/mod.rs index 12f6d61f59dc..04680ad0beae 100644 --- a/src/vmm/src/guest_config/x86_64/mod.rs +++ b/src/vmm/src/guest_config/x86_64/mod.rs @@ -1,11 +1,8 @@ // Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -/// Module with CPU templates for x86_64 -pub mod static_cpu_templates; - /// Module for static CPU templates for x86_64 -pub mod static_cpu_templates_new; +pub mod static_cpu_templates; use std::collections::HashMap; @@ -115,7 +112,7 @@ mod tests { use kvm_bindings::KVM_CPUID_FLAG_STATEFUL_FUNC; use super::*; - use crate::guest_config::cpuid::{IntelCpuid, KvmCpuidFlags}; + use crate::guest_config::cpuid::{CpuidEntry, IntelCpuid, KvmCpuidFlags}; use crate::guest_config::templates::x86_64::{ CpuidLeafModifier, CpuidRegisterModifier, RegisterModifier, RegisterValueFilter, }; @@ -176,6 +173,16 @@ mod tests { } } + fn build_supported_cpuid() -> Cpuid { + Cpuid::Intel(IntelCpuid(BTreeMap::from([( + CpuidKey { + leaf: 0x3, + subleaf: 0x0, + }, + CpuidEntry::default(), + )]))) + } + fn empty_cpu_config() -> CpuConfiguration { CpuConfiguration { cpuid: Cpuid::Intel(IntelCpuid(BTreeMap::new())), @@ -185,14 +192,14 @@ mod tests { fn supported_cpu_config() -> CpuConfiguration { CpuConfiguration { - cpuid: static_cpu_templates::t2::t2(), + cpuid: build_supported_cpuid(), msrs: HashMap::from([(0x8000, 0b1000), (0x9999, 0b1010)]), } } fn unsupported_cpu_config() -> CpuConfiguration { CpuConfiguration { - cpuid: static_cpu_templates::t2::t2(), + cpuid: build_supported_cpuid(), msrs: HashMap::from([(0x8000, 0b1000), (0x8001, 0b1010)]), } } diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates/c3.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates/c3.rs index 4361fdca0eed..6375c26c3bf0 100644 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates/c3.rs +++ b/src/vmm/src/guest_config/x86_64/static_cpu_templates/c3.rs @@ -1,690 +1,120 @@ // Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -use crate::guest_config::cpuid::cpuid_ffi::KvmCpuidFlags; -use crate::guest_config::cpuid::{Cpuid, CpuidEntry, CpuidKey, CpuidRegisters, IntelCpuid}; +use crate::guest_config::cpuid::KvmCpuidFlags; +use crate::guest_config::templates::x86_64::{ + CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterValueFilter, +}; +use crate::guest_config::templates::CustomCpuTemplate; -/// This is translated from `cpuid -r` within a C3 guest microVM on an ec2 m5.metal instance: +/// C3 CPU template. /// -/// ```text -/// CPU 0: -/// 0x00000000 0x00: eax=0x00000016 ebx=0x756e6547 ecx=0x6c65746e edx=0x49656e69 -/// 0x00000001 0x00: eax=0x000306e4 ebx=0x00020800 ecx=0xffba2203 edx=0x178bfbff -/// 0x00000002 0x00: eax=0x76036301 ebx=0x00f0b5ff ecx=0x00000000 edx=0x00c30000 -/// 0x00000003 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000004 0x00: eax=0x04000121 ebx=0x01c0003f ecx=0x0000003f edx=0x00000000 -/// 0x00000004 0x01: eax=0x04000122 ebx=0x01c0003f ecx=0x0000003f edx=0x00000000 -/// 0x00000004 0x02: eax=0x04000143 ebx=0x03c0003f ecx=0x000003ff edx=0x00000000 -/// 0x00000004 0x03: eax=0x04004163 ebx=0x0280003f ecx=0x0000bfff edx=0x00000004 -/// 0x00000005 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000006 0x00: eax=0x00000004 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000007 0x00: eax=0x00000000 ebx=0x00100283 ecx=0x00000000 edx=0xac000400 -/// 0x00000008 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000009 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000a 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000b 0x00: eax=0x00000000 ebx=0x00000001 ecx=0x00000100 edx=0x00000000 -/// 0x0000000b 0x01: eax=0x00000007 ebx=0x00000002 ecx=0x00000201 edx=0x00000000 -/// 0x0000000c 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000d 0x00: eax=0x00000007 ebx=0x00000340 ecx=0x00000a88 edx=0x00000000 -/// 0x0000000d 0x01: eax=0x00000001 ebx=0x00000a08 ecx=0x00000000 edx=0x00000000 -/// 0x0000000d 0x02: eax=0x00000100 ebx=0x00000240 ecx=0x00000000 edx=0x00000000 -/// 0x0000000e 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000f 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000010 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000011 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000012 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000013 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000014 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000015 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000016 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x40000000 0x00: eax=0x40000001 ebx=0x4b4d564b ecx=0x564b4d56 edx=0x0000004d -/// 0x40000001 0x00: eax=0x01007efb ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000000 0x00: eax=0x80000008 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000001 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000001 edx=0x28100800 -/// 0x80000002 0x00: eax=0x65746e49 ebx=0x2952286c ecx=0x6f655820 edx=0x2952286e -/// 0x80000003 0x00: eax=0x6f725020 ebx=0x73736563 ecx=0x4020726f edx=0x352e3220 -/// 0x80000004 0x00: eax=0x7a484730 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000005 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000006 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x01006040 edx=0x00000000 -/// 0x80000007 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000100 -/// 0x80000008 0x00: eax=0x0000302e ebx=0x0100d000 ecx=0x00000000 edx=0x00000000 -/// 0x80860000 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0xc0000000 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// ``` -#[allow(clippy::too_many_lines)] -pub fn c3() -> Cpuid { - Cpuid::Intel(IntelCpuid({ - let mut map = std::collections::BTreeMap::new(); - map.insert( - CpuidKey { - leaf: 0x0, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x16, - ebx: 0x756e6547, - ecx: 0x6c65746e, - edx: 0x49656e69, - }, - }, - ); - map.insert( - CpuidKey { +/// Mask CPUID to make exposed CPU features as close as possbile to AWS C3 instance. +pub fn c3() -> CustomCpuTemplate { + CustomCpuTemplate { + cpuid_modifiers: vec![ + CpuidLeafModifier { leaf: 0x1, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x306e4, - ebx: 0x20800, - ecx: 0xffba2203, - edx: 0x178bfbff, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x2, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x76036301, - ebx: 0xf0b5ff, - ecx: 0x0, - edx: 0xc30000, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x3, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000121, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000122, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000143, - ebx: 0x3c0003f, - ecx: 0x3ff, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x3, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4004163, - ebx: 0x280003f, - ecx: 0xbfff, - edx: 0x4, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x5, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x6, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x4, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(0), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00001111111111110011111111111111, + value: 0b00000000000000110000011011100100, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b00000000010000001101110100111100, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b10101000011001000001000010000000, + value: 0b00000000000000000001000010000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0x7, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x100283, - ecx: 0x0, - edx: 0xac000400, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x9, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xa, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xb, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x1, - ecx: 0x100, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xb, - subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x7, - ebx: 0x2, - ecx: 0x201, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(1), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Ebx, + bitmap: RegisterValueFilter { + filter: 0b11111111101011111101110101111100, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b01000000010000010100100000011110, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000000001100, + value: 0b00000000000000000000000000000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0xd, subleaf: 0x0, + flags: KvmCpuidFlags(1), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000001011111000, + value: 0b00000000000000000000000000000000, + }, + }], }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x7, - ebx: 0x340, - ecx: 0xa88, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + CpuidLeafModifier { leaf: 0xd, subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x1, - ebx: 0xa08, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xd, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x100, - ebx: 0x240, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xe, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xf, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x10, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x11, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x12, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x13, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x14, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x15, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x16, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x40000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x40000001, - ebx: 0x4b4d564b, - ecx: 0x564b4d56, - edx: 0x4d, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x40000001, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x1007efb, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x80000008, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(1), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000000001110, + value: 0b00000000000000000000000000000000, + }, + }], + }, + CpuidLeafModifier { leaf: 0x80000001, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x1, - edx: 0x28100800, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000002, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x65746e49, - ebx: 0x2952286c, - ecx: 0x6f655820, - edx: 0x2952286e, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000003, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x6f725020, - ebx: 0x73736563, - ecx: 0x4020726f, - edx: 0x352e3220, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000004, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x7a484730, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000005, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000006, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x1006040, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000007, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x100, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000008, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x302e, - ebx: 0x100d000, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80860000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc0000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map - })) + flags: KvmCpuidFlags(0), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000100100000, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b00000100000000000000000000000000, + value: 0b00000000000000000000000000000000, + }, + }, + ], + }, + ], + msr_modifiers: vec![], + } } diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2.rs index ed0f35ef6b21..299187218ab9 100644 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2.rs +++ b/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2.rs @@ -1,690 +1,132 @@ // Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -use crate::guest_config::cpuid::cpuid_ffi::KvmCpuidFlags; -use crate::guest_config::cpuid::{Cpuid, CpuidEntry, CpuidKey, CpuidRegisters, IntelCpuid}; +use crate::guest_config::cpuid::KvmCpuidFlags; +use crate::guest_config::templates::x86_64::{ + CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterValueFilter, +}; +use crate::guest_config::templates::CustomCpuTemplate; -/// This is translated from `cpuid -r` within a T2 guest microVM on an ec2 m5.metal instance: +/// T2 template /// -/// ```text -/// CPU 0: -/// 0x00000000 0x00: eax=0x00000016 ebx=0x756e6547 ecx=0x6c65746e edx=0x49656e69 -/// 0x00000001 0x00: eax=0x000306f2 ebx=0x00020800 ecx=0xfffa3203 edx=0x178bfbff -/// 0x00000002 0x00: eax=0x76036301 ebx=0x00f0b5ff ecx=0x00000000 edx=0x00c30000 -/// 0x00000003 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000004 0x00: eax=0x04000121 ebx=0x01c0003f ecx=0x0000003f edx=0x00000000 -/// 0x00000004 0x01: eax=0x04000122 ebx=0x01c0003f ecx=0x0000003f edx=0x00000000 -/// 0x00000004 0x02: eax=0x04000143 ebx=0x03c0003f ecx=0x000003ff edx=0x00000000 -/// 0x00000004 0x03: eax=0x04004163 ebx=0x0280003f ecx=0x0000bfff edx=0x00000004 -/// 0x00000005 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000006 0x00: eax=0x00000004 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000007 0x00: eax=0x00000000 ebx=0x001007ab ecx=0x00000000 edx=0xac000400 -/// 0x00000008 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000009 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000a 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000b 0x00: eax=0x00000000 ebx=0x00000001 ecx=0x00000100 edx=0x00000000 -/// 0x0000000b 0x01: eax=0x00000007 ebx=0x00000002 ecx=0x00000201 edx=0x00000000 -/// 0x0000000c 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000d 0x00: eax=0x00000007 ebx=0x00000340 ecx=0x00000a88 edx=0x00000000 -/// 0x0000000d 0x01: eax=0x00000001 ebx=0x00000a08 ecx=0x00000000 edx=0x00000000 -/// 0x0000000d 0x02: eax=0x00000100 ebx=0x00000240 ecx=0x00000000 edx=0x00000000 -/// 0x0000000e 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000f 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000010 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000011 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000012 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000013 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000014 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000015 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000016 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x40000000 0x00: eax=0x40000001 ebx=0x4b4d564b ecx=0x564b4d56 edx=0x0000004d -/// 0x40000001 0x00: eax=0x01007efb ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000000 0x00: eax=0x80000008 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000001 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000021 edx=0x28100800 -/// 0x80000002 0x00: eax=0x65746e49 ebx=0x2952286c ecx=0x6f655820 edx=0x2952286e -/// 0x80000003 0x00: eax=0x6f725020 ebx=0x73736563 ecx=0x4020726f edx=0x352e3220 -/// 0x80000004 0x00: eax=0x7a484730 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000005 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000006 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x01006040 edx=0x00000000 -/// 0x80000007 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000100 -/// 0x80000008 0x00: eax=0x0000302e ebx=0x0100d000 ecx=0x00000000 edx=0x00000000 -/// 0x80860000 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0xc0000000 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// ``` -#[allow(clippy::too_many_lines)] -pub fn t2() -> Cpuid { - Cpuid::Intel(IntelCpuid({ - let mut map = std::collections::BTreeMap::new(); - map.insert( - CpuidKey { - leaf: 0x0, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x16, - ebx: 0x756e6547, - ecx: 0x6c65746e, - edx: 0x49656e69, - }, - }, - ); - map.insert( - CpuidKey { +/// Mask CPUID to make exposed CPU features as close as possbile to AWS T2 instance. +pub fn t2() -> CustomCpuTemplate { + CustomCpuTemplate { + cpuid_modifiers: vec![ + CpuidLeafModifier { leaf: 0x1, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x306f2, - ebx: 0x20800, - ecx: 0xfffa3203, - edx: 0x178bfbff, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x2, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x76036301, - ebx: 0xf0b5ff, - ecx: 0x0, - edx: 0xc30000, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x3, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000121, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000122, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000143, - ebx: 0x3c0003f, - ecx: 0x3ff, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x3, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4004163, - ebx: 0x280003f, - ecx: 0xbfff, - edx: 0x4, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x5, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x6, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x4, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(0), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00001111111111110011111111111111, + value: 0b00000000000000110000011011110010, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b00000000000001001100110111111100, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b11101000011001000001000010000000, + value: 0b00000000000000000001000010000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0x7, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x1007ab, - ecx: 0x0, - edx: 0xac000400, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x9, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xa, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xb, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x1, - ecx: 0x100, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xb, - subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x7, - ebx: 0x2, - ecx: 0x201, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(1), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Ebx, + bitmap: RegisterValueFilter { + filter: 0b11111111111011111111101001010100, + value: 0b00000000000000000000001000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b01000000010000010101111101011110, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000100011100, + value: 0b00000000000000000000000000000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0xd, subleaf: 0x0, + flags: KvmCpuidFlags(1), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000001011111000, + value: 0b00000000000000000000000000000000, + }, + }], }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x7, - ebx: 0x0340, - ecx: 0xa88, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + CpuidLeafModifier { leaf: 0xd, subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x1, - ebx: 0xa08, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xd, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x100, - ebx: 0x240, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xe, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xf, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x10, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x11, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x12, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x13, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x14, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x15, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x16, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x40000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x40000001, - ebx: 0x4b4d564b, - ecx: 0x564b4d56, - edx: 0x4d, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x40000001, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x1007efb, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x80000008, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(1), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000000001110, + value: 0b00000000000000000000000000000000, + }, + }], + }, + CpuidLeafModifier { leaf: 0x80000001, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x21, - edx: 0x28100800, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000002, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x65746e49, - ebx: 0x2952286c, - ecx: 0x6f655820, - edx: 0x2952286e, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000003, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x6f725020, - ebx: 0x73736563, - ecx: 0x4020726f, - edx: 0x352e3220, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000004, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x7a484730, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000005, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000006, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x1006040, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000007, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x100, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(0), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b00100000000000000000000100000000, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b00000100000000000000000000000000, + value: 0b00000000000000000000000000000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0x80000008, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x302e, - ebx: 0x100d000, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80860000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc0000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map - })) + flags: KvmCpuidFlags(0), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Ebx, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000001000000000, + value: 0b00000000000000000000000000000000, + }, + }], + }, + ], + msr_modifiers: vec![], + } } diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2a.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2a.rs index cdb60778cd04..851ab5ae0e10 100644 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2a.rs +++ b/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2a.rs @@ -1,929 +1,132 @@ // Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -use crate::guest_config::cpuid::cpuid_ffi::KvmCpuidFlags; -use crate::guest_config::cpuid::{AmdCpuid, Cpuid, CpuidEntry, CpuidKey, CpuidRegisters}; +use crate::guest_config::cpuid::KvmCpuidFlags; +use crate::guest_config::templates::x86_64::{ + CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterValueFilter, +}; +use crate::guest_config::templates::CustomCpuTemplate; -/// This is translated from `cpuid -r` within a T2A guest microVM on an ec2 m6a.metal instance: +/// T2A template /// -/// ```text -/// CPU 0: -/// 0x00000000 0x00: eax=0x00000010 ebx=0x68747541 ecx=0x444d4163 edx=0x69746e65 -/// 0x00000001 0x00: eax=0x000306f2 ebx=0x00020800 ecx=0xfffa3203 edx=0x178bfbff -/// 0x00000002 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000003 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000005 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000006 0x00: eax=0x00000004 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000007 0x00: eax=0x00000000 ebx=0x001007ab ecx=0x00000000 edx=0x8c000000 -/// 0x00000008 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000009 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000a 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000c 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000d 0x00: eax=0x00000007 ebx=0x00000340 ecx=0x00000988 edx=0x00000000 -/// 0x0000000d 0x01: eax=0x00000001 ebx=0x00000348 ecx=0x00000000 edx=0x00000000 -/// 0x0000000d 0x02: eax=0x00000100 ebx=0x00000240 ecx=0x00000000 edx=0x00000000 -/// 0x0000000e 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000f 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000010 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x40000000 0x00: eax=0x40000001 ebx=0x4b4d564b ecx=0x564b4d56 edx=0x0000004d -/// 0x40000001 0x00: eax=0x01007efb ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000000 0x00: eax=0x8000001f ebx=0x68747541 ecx=0x444d4163 edx=0x69746e65 -/// 0x80000001 0x00: eax=0x00a00f11 ebx=0x40000000 ecx=0x00c00237 edx=0x2813fbff -/// 0x80000002 0x00: eax=0x20444d41 ebx=0x43595045 ecx=0x00000000 edx=0x00000000 -/// 0x80000003 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000004 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000005 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000006 0x00: eax=0x48002200 ebx=0x68004200 ecx=0x02006140 edx=0x06009140 -/// 0x80000007 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000100 -/// 0x80000008 0x00: eax=0x00003030 ebx=0x030ed000 ecx=0x00007001 edx=0x00000000 -/// 0x80000009 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x8000000a 0x00: eax=0x00000001 ebx=0x00000008 ecx=0x00000000 edx=0x00000009 -/// 0x8000000b 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x8000000c 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x8000000d 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x8000000e 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x8000000f 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000010 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000011 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000012 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000013 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000014 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000015 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000016 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000017 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000018 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000019 0x00: eax=0xf040f040 ebx=0xf0400000 ecx=0x00000000 edx=0x00000000 -/// 0x8000001a 0x00: eax=0x00000006 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x8000001b 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x8000001c 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x8000001d 0x00: eax=0x00000121 ebx=0x01c0003f ecx=0x0000003f edx=0x00000000 -/// 0x8000001d 0x01: eax=0x00000122 ebx=0x01c0003f ecx=0x0000003f edx=0x00000000 -/// 0x8000001d 0x02: eax=0x00000143 ebx=0x01c0003f ecx=0x000003ff edx=0x00000002 -/// 0x8000001d 0x03: eax=0x00004163 ebx=0x03c0003f ecx=0x00007fff edx=0x00000001 -/// 0x8000001e 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x8000001f 0x00: eax=0x0101fd3f ebx=0x00004173 ecx=0x000001fd edx=0x000001fe -/// 0x80860000 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0xc0000000 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// ``` -#[allow(clippy::too_many_lines)] -pub fn t2a() -> Cpuid { - Cpuid::Amd(AmdCpuid({ - let mut map = std::collections::BTreeMap::new(); - map.insert( - CpuidKey { - leaf: 0x0, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x10, - ebx: 0x68747541, - ecx: 0x444d4163, - edx: 0x69746e65, - }, - }, - ); - map.insert( - CpuidKey { +/// Provide instruction set feature partity with Intel Cascade Lake or later using T2CL template. +pub fn t2a() -> CustomCpuTemplate { + CustomCpuTemplate { + cpuid_modifiers: vec![ + CpuidLeafModifier { leaf: 0x1, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x306f2, - ebx: 0x20800, - ecx: 0xfffa3203, - edx: 0x178bfbff, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x2, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x3, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x5, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x6, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x4, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(0), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00001111111111110011111111111111, + value: 0b00000000000000110000011011110010, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b00000000000001001100110111111100, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b11101000011001000001000010000000, + value: 0b00000000000000000001000010000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0x7, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x1007ab, - ecx: 0x0, - edx: 0x8c000000, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x9, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xa, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(1), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Ebx, + bitmap: RegisterValueFilter { + filter: 0b11111111111011111111101001010100, + value: 0b00000000000000000000001000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b01000000010000010101111101011110, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000100011100, + value: 0b00000000000000000000000000000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0xd, subleaf: 0x0, + flags: KvmCpuidFlags(1), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000001011111000, + value: 0b00000000000000000000000000000000, + }, + }], }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x7, - ebx: 0x340, - ecx: 0x988, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + CpuidLeafModifier { leaf: 0xd, subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x1, - ebx: 0x348, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xd, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x100, - ebx: 0x240, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xe, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xf, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x10, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x40000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x40000001, - ebx: 0x4b4d564b, - ecx: 0x564b4d56, - edx: 0x4d, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x40000001, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x01007efb, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x8000001f, - ebx: 0x68747541, - ecx: 0x444d4163, - edx: 0x69746e65, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(1), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000000001110, + value: 0b00000000000000000000000000000000, + }, + }], + }, + CpuidLeafModifier { leaf: 0x80000001, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0xa00f11, - ebx: 0x40000000, - ecx: 0xc00237, - edx: 0x2813fbff, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000002, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x20444d41, - ebx: 0x43595045, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000003, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000004, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000005, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000006, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x48002200, - ebx: 0x68004200, - ecx: 0x2006140, - edx: 0x6009140, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000007, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x100, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(0), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b00100000000000000000000111000000, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b00000111110000000000000000000000, + value: 0b00000000000000000000000000000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0x80000008, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x3030, - ebx: 0x30ed000, - ecx: 0x7001, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000009, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc000000a, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x1, - ebx: 0x8, - ecx: 0x0, - edx: 0x9, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000000b, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000000c, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000000d, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000000e, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000000f, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000010, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000011, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000012, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000013, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000014, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000015, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000016, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000017, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000018, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000019, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0xf040f040, - ebx: 0xf0400000, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000001a, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x6, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000001b, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x6, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000001c, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x6, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000001d, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x121, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000001d, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x121, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000001d, - subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x122, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000001d, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x143, - ebx: 0x1c0003f, - ecx: 0x3ff, - edx: 0x2, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000001d, - subleaf: 0x3, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4163, - ebx: 0x3c0003f, - ecx: 0x7fff, - edx: 0x1, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000001e, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8000001f, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x101fd3f, - ebx: 0x4173, - ecx: 0x1fd, - edx: 0x1fe, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80860000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc0000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map - })) + flags: KvmCpuidFlags(0), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Ebx, + bitmap: RegisterValueFilter { + filter: 0b00000000000011000000001000000101, + value: 0b00000000000011000000000000000000, + }, + }], + }, + ], + msr_modifiers: vec![], + } } diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2cl.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2cl.rs index 2673617347a8..2091fc302718 100644 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2cl.rs +++ b/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2cl.rs @@ -1,721 +1,139 @@ // Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -use std::collections::HashMap; +use crate::guest_config::cpuid::KvmCpuidFlags; +use crate::guest_config::templates::x86_64::{ + CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterModifier, RegisterValueFilter, +}; +use crate::guest_config::templates::CustomCpuTemplate; -use crate::arch::x86_64::msr::ArchCapaMSRFlags; -use crate::arch_gen::x86::msr_index::MSR_IA32_ARCH_CAPABILITIES; -use crate::guest_config::cpuid::cpuid_ffi::KvmCpuidFlags; -use crate::guest_config::cpuid::{Cpuid, CpuidEntry, CpuidKey, CpuidRegisters, IntelCpuid}; - -/// Add the MSR entries specific to this T2S template. -#[inline] -pub fn update_t2cl_msr_entries(msr_entries: &mut HashMap) { - let capabilities = ArchCapaMSRFlags::RDCL_NO - | ArchCapaMSRFlags::IBRS_ALL - | ArchCapaMSRFlags::SKIP_L1DFL_VMENTRY - | ArchCapaMSRFlags::MDS_NO - | ArchCapaMSRFlags::IF_PSCHANGE_MC_NO - | ArchCapaMSRFlags::TSX_CTRL; - msr_entries.insert(MSR_IA32_ARCH_CAPABILITIES, capabilities.bits()); -} - -/// This is translated from `cpuid -r` within a T2CL guest microVM on an ec2 m5.metal instance: +/// T2CL template /// -/// ```text -/// CPU 0: -/// 0x00000000 0x00: eax=0x00000016 ebx=0x756e6547 ecx=0x6c65746e edx=0x49656e69 -/// 0x00000001 0x00: eax=0x000306f2 ebx=0x00020800 ecx=0xfffa3203 edx=0x178bfbff -/// 0x00000002 0x00: eax=0x76036301 ebx=0x00f0b5ff ecx=0x00000000 edx=0x00c30000 -/// 0x00000003 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000004 0x00: eax=0x04000121 ebx=0x01c0003f ecx=0x0000003f edx=0x00000000 -/// 0x00000004 0x01: eax=0x04000122 ebx=0x01c0003f ecx=0x0000003f edx=0x00000000 -/// 0x00000004 0x02: eax=0x04000143 ebx=0x03c0003f ecx=0x000003ff edx=0x00000000 -/// 0x00000004 0x03: eax=0x04004163 ebx=0x0280003f ecx=0x0000bfff edx=0x00000004 -/// 0x00000005 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000006 0x00: eax=0x00000004 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000007 0x00: eax=0x00000000 ebx=0x001007ab ecx=0x00000000 edx=0xac000400 -/// 0x00000008 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000009 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000a 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000b 0x00: eax=0x00000000 ebx=0x00000001 ecx=0x00000100 edx=0x00000000 -/// 0x0000000b 0x01: eax=0x00000007 ebx=0x00000002 ecx=0x00000201 edx=0x00000000 -/// 0x0000000c 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000d 0x00: eax=0x00000007 ebx=0x00000340 ecx=0x00000a88 edx=0x00000000 -/// 0x0000000d 0x01: eax=0x00000001 ebx=0x00000a08 ecx=0x00000000 edx=0x00000000 -/// 0x0000000d 0x02: eax=0x00000100 ebx=0x00000240 ecx=0x00000000 edx=0x00000000 -/// 0x0000000e 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000f 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000010 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000011 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000012 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000013 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000014 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000015 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000016 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x40000000 0x00: eax=0x40000001 ebx=0x4b4d564b ecx=0x564b4d56 edx=0x0000004d -/// 0x40000001 0x00: eax=0x01007efb ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000000 0x00: eax=0x80000008 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000001 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000021 edx=0x28100800 -/// 0x80000002 0x00: eax=0x65746e49 ebx=0x2952286c ecx=0x6f655820 edx=0x2952286e -/// 0x80000003 0x00: eax=0x6f725020 ebx=0x73736563 ecx=0x4020726f edx=0x352e3220 -/// 0x80000004 0x00: eax=0x7a484730 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000005 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000006 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x01006040 edx=0x00000000 -/// 0x80000007 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000100 -/// 0x80000008 0x00: eax=0x0000302e ebx=0x0100d000 ecx=0x00000000 edx=0x00000000 -/// 0x80860000 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0xc0000000 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// ``` -#[allow(clippy::too_many_lines)] -pub fn t2cl() -> Cpuid { - Cpuid::Intel(IntelCpuid({ - let mut map = std::collections::BTreeMap::new(); - map.insert( - CpuidKey { - leaf: 0x0, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0xd, - ebx: 0x756e6547, - ecx: 0x6c65746e, - edx: 0x49656e69, - }, - }, - ); - map.insert( - CpuidKey { +/// Mask CPUID to make exposed CPU features as close as possbile to Intel Cascade Lake and provide +/// instruction set feature partity with AMD Milan using T2A template. +pub fn t2cl() -> CustomCpuTemplate { + CustomCpuTemplate { + cpuid_modifiers: vec![ + CpuidLeafModifier { leaf: 0x1, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x306f2, - ebx: 0x20800, - ecx: 0xfffa3203, - edx: 0x178bfbff, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x2, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x76036301, - ebx: 0xf0b5ff, - ecx: 0x0, - edx: 0xc30000, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x3, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000121, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000122, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000143, - ebx: 0x3c0003f, - ecx: 0x3ff, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x3, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4004163, - ebx: 0x280003f, - ecx: 0xbfff, - edx: 0x4, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x5, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x6, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x4, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(0), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00001111111111110011111111111111, + value: 0b00000000000000110000011011110010, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b00000000000001001100110111111100, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b11101000011001000001000010000000, + value: 0b00000000000000000001000010000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0x7, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x1007ab, - ecx: 0x0, - edx: 0xac000400, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x9, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xa, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xb, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x1, - ecx: 0x100, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xb, - subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x7, - ebx: 0x2, - ecx: 0x201, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xb, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x2, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(1), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Ebx, + bitmap: RegisterValueFilter { + filter: 0b11111111111011111111101001010100, + value: 0b00000000000000000000001000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b01000000010000010101111101011110, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000100011100, + value: 0b00000000000000000000000000000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0xd, subleaf: 0x0, + flags: KvmCpuidFlags(1), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000001011111000, + value: 0b00000000000000000000000000000000, + }, + }], }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x7, - ebx: 0x340, - ecx: 0xa88, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + CpuidLeafModifier { leaf: 0xd, subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x1, - ebx: 0xa08, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xd, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x100, - ebx: 0x240, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xe, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xf, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x10, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x11, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x12, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x13, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x14, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x15, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x16, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x40000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x40000001, - ebx: 0x4b4d564b, - ecx: 0x564b4d56, - edx: 0x4d, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x40000001, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x1007efb, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x80000008, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(1), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000000001110, + value: 0b00000000000000000000000000000000, + }, + }], + }, + CpuidLeafModifier { leaf: 0x80000001, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x21, - edx: 0x28100800, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000002, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x65746e49, - ebx: 0x2952286c, - ecx: 0x6f655820, - edx: 0x2952286e, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000003, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x6f725020, - ebx: 0x73736563, - ecx: 0x4020726f, - edx: 0x352e3220, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000004, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x7a484730, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000005, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000006, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x1006040, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000007, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x100, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(0), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b00100000000000000000000111000000, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b00000111110000000000000000000000, + value: 0b00000000000000000000000000000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0x80000008, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x302e, - ebx: 0x100d000, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80860000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc0000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map - })) + flags: KvmCpuidFlags(0), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Ebx, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000001000000000, + value: 0b00000000000000000000000000000000, + }, + }], + }, + ], + msr_modifiers: vec![RegisterModifier { + addr: 0x10a, + bitmap: RegisterValueFilter { + filter: 0b1111111111111111111111111111111111111111111111111111111111111111, + value: 0b0000000000000000000000000000000000000000000000000000000011101011, + }, + }], + } } diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2s.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2s.rs index a18fbba4b52e..eaf596ab2f69 100644 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2s.rs +++ b/src/vmm/src/guest_config/x86_64/static_cpu_templates/t2s.rs @@ -1,705 +1,139 @@ // Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -use std::collections::HashMap; +use crate::guest_config::cpuid::KvmCpuidFlags; +use crate::guest_config::templates::x86_64::{ + CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterModifier, RegisterValueFilter, +}; +use crate::guest_config::templates::CustomCpuTemplate; -use crate::arch::x86_64::msr::ArchCapaMSRFlags; -use crate::arch_gen::x86::msr_index::MSR_IA32_ARCH_CAPABILITIES; -use crate::guest_config::cpuid::cpuid_ffi::KvmCpuidFlags; -use crate::guest_config::cpuid::{Cpuid, CpuidEntry, CpuidKey, CpuidRegisters, IntelCpuid}; - -/// Add the MSR entries specific to this T2S template. -#[inline] -pub fn update_t2s_msr_entries(msr_entries: &mut HashMap) { - let capabilities = ArchCapaMSRFlags::RSBA - | ArchCapaMSRFlags::SKIP_L1DFL_VMENTRY - | ArchCapaMSRFlags::IF_PSCHANGE_MC_NO - | ArchCapaMSRFlags::MISC_PACKAGE_CTRLS - | ArchCapaMSRFlags::ENERGY_FILTERING_CTL; - msr_entries.insert(MSR_IA32_ARCH_CAPABILITIES, capabilities.bits()); -} - -/// This is translated from `cpuid -r` within a T2S guest microVM on an ec2 m5.metal instance: +/// T2S template /// -/// ```text -/// CPU 0: -/// 0x00000000 0x00: eax=0x00000016 ebx=0x756e6547 ecx=0x6c65746e edx=0x49656e69 -/// 0x00000001 0x00: eax=0x000306f2 ebx=0x00020800 ecx=0xfffa3203 edx=0x178bfbff -/// 0x00000002 0x00: eax=0x76036301 ebx=0x00f0b5ff ecx=0x00000000 edx=0x00c30000 -/// 0x00000003 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000004 0x00: eax=0x04000121 ebx=0x01c0003f ecx=0x0000003f edx=0x00000000 -/// 0x00000004 0x01: eax=0x04000122 ebx=0x01c0003f ecx=0x0000003f edx=0x00000000 -/// 0x00000004 0x02: eax=0x04000143 ebx=0x03c0003f ecx=0x000003ff edx=0x00000000 -/// 0x00000004 0x03: eax=0x04004163 ebx=0x0280003f ecx=0x0000bfff edx=0x00000004 -/// 0x00000005 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000006 0x00: eax=0x00000004 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000007 0x00: eax=0x00000000 ebx=0x001007ab ecx=0x00000000 edx=0xac000400 -/// 0x00000008 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000009 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000a 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000b 0x00: eax=0x00000000 ebx=0x00000001 ecx=0x00000100 edx=0x00000000 -/// 0x0000000b 0x01: eax=0x00000007 ebx=0x00000002 ecx=0x00000201 edx=0x00000000 -/// 0x0000000c 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000d 0x00: eax=0x00000007 ebx=0x00000340 ecx=0x00000a88 edx=0x00000000 -/// 0x0000000d 0x01: eax=0x00000001 ebx=0x00000a08 ecx=0x00000000 edx=0x00000000 -/// 0x0000000d 0x02: eax=0x00000100 ebx=0x00000240 ecx=0x00000000 edx=0x00000000 -/// 0x0000000e 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x0000000f 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000010 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000011 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000012 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000013 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000014 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000015 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x00000016 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x40000000 0x00: eax=0x40000001 ebx=0x4b4d564b ecx=0x564b4d56 edx=0x0000004d -/// 0x40000001 0x00: eax=0x01007efb ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000000 0x00: eax=0x80000008 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000001 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000021 edx=0x28100800 -/// 0x80000002 0x00: eax=0x65746e49 ebx=0x2952286c ecx=0x6f655820 edx=0x2952286e -/// 0x80000003 0x00: eax=0x6f725020 ebx=0x73736563 ecx=0x4020726f edx=0x352e3220 -/// 0x80000004 0x00: eax=0x7a484730 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000005 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0x80000006 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x01006040 edx=0x00000000 -/// 0x80000007 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000100 -/// 0x80000008 0x00: eax=0x0000302e ebx=0x0100d000 ecx=0x00000000 edx=0x00000000 -/// 0x80860000 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// 0xc0000000 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000 -/// ``` -#[allow(clippy::too_many_lines)] -pub fn t2s() -> Cpuid { - Cpuid::Intel(IntelCpuid({ - let mut map = std::collections::BTreeMap::new(); - map.insert( - CpuidKey { - leaf: 0x0, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x16, - ebx: 0x756e6547, - ecx: 0x6c65746e, - edx: 0x49656e69, - }, - }, - ); - map.insert( - CpuidKey { +/// Mask CPUID to make exposed CPU features as close as possbile to AWS T2 instance and allow +/// migrating snapshots between hosts with Intel Skylake and Cascade Lake securely. +pub fn t2s() -> CustomCpuTemplate { + CustomCpuTemplate { + cpuid_modifiers: vec![ + CpuidLeafModifier { leaf: 0x1, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x306f2, - ebx: 0x20800, - ecx: 0xf7fa3203, - edx: 0x178bfbff, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x2, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x76036301, - ebx: 0xf0b5ff, - ecx: 0x0, - edx: 0xc30000, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x3, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000121, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000122, - ebx: 0x1c0003f, - ecx: 0x3f, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4000143, - ebx: 0x3c0003f, - ecx: 0x3ff, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x4, - subleaf: 0x3, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x4004163, - ebx: 0x280003f, - ecx: 0xbfff, - edx: 0x4, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x5, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x6, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x4, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(0), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00001111111111110011111111111111, + value: 0b00000000000000110000011011110010, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b00000000000001001100110111111100, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b11101000011001000001000010000000, + value: 0b00000000000000000001000010000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0x7, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x1007ab, - ecx: 0x0, - edx: 0xac000400, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x8, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x9, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xa, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xb, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x1, - ecx: 0x100, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xb, - subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x7, - ebx: 0x2, - ecx: 0x201, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(1), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Ebx, + bitmap: RegisterValueFilter { + filter: 0b11111111111011111111101001010100, + value: 0b00000000000000000000001000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b01000000010000010101111101011110, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000100011100, + value: 0b00000000000000000000000000000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0xd, subleaf: 0x0, + flags: KvmCpuidFlags(1), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000001011111000, + value: 0b00000000000000000000000000000000, + }, + }], }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x7, - ebx: 0x340, - ecx: 0xa88, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + CpuidLeafModifier { leaf: 0xd, subleaf: 0x1, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x1, - ebx: 0xa08, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xd, - subleaf: 0x2, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x100, - ebx: 0x240, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xe, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xf, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x10, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x11, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x12, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x13, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x14, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x1), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x15, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x16, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x40000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x40000001, - ebx: 0x4b4d564b, - ecx: 0x564b4d56, - edx: 0x4d, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x40000001, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x1007efb, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x80000008, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(1), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Eax, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000000000001110, + value: 0b00000000000000000000000000000000, + }, + }], + }, + CpuidLeafModifier { leaf: 0x80000001, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x21, - edx: 0x28100800, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000002, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x65746e49, - ebx: 0x2952286c, - ecx: 0x6f655820, - edx: 0x2952286e, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000003, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x6f725020, - ebx: 0x73736563, - ecx: 0x4020726f, - edx: 0x302e3320, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000004, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x7a484730, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000005, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000006, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x1006040, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80000007, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x100, - }, - }, - ); - map.insert( - CpuidKey { + flags: KvmCpuidFlags(0), + modifiers: vec![ + CpuidRegisterModifier { + register: CpuidRegister::Ecx, + bitmap: RegisterValueFilter { + filter: 0b00100000000000000000000100000000, + value: 0b00000000000000000000000000000000, + }, + }, + CpuidRegisterModifier { + register: CpuidRegister::Edx, + bitmap: RegisterValueFilter { + filter: 0b00000100000000000000000000000000, + value: 0b00000000000000000000000000000000, + }, + }, + ], + }, + CpuidLeafModifier { leaf: 0x80000008, subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x302e, - ebx: 0x100d000, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0x80860000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map.insert( - CpuidKey { - leaf: 0xc0000000, - subleaf: 0x0, - }, - CpuidEntry { - flags: KvmCpuidFlags(0x0), - result: CpuidRegisters { - eax: 0x0, - ebx: 0x0, - ecx: 0x0, - edx: 0x0, - }, - }, - ); - map - })) + flags: KvmCpuidFlags(0), + modifiers: vec![CpuidRegisterModifier { + register: CpuidRegister::Ebx, + bitmap: RegisterValueFilter { + filter: 0b00000000000000000000001000000000, + value: 0b00000000000000000000000000000000, + }, + }], + }, + ], + msr_modifiers: vec![RegisterModifier { + addr: 0x10a, + bitmap: RegisterValueFilter { + filter: 0b1111111111111111111111111111111111111111111111111111111111111111, + value: 0b0000000000000000000000000000000000000000000000000000110001001100, + }, + }], + } } diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/c3.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/c3.rs deleted file mode 100644 index 6375c26c3bf0..000000000000 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/c3.rs +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -use crate::guest_config::cpuid::KvmCpuidFlags; -use crate::guest_config::templates::x86_64::{ - CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterValueFilter, -}; -use crate::guest_config::templates::CustomCpuTemplate; - -/// C3 CPU template. -/// -/// Mask CPUID to make exposed CPU features as close as possbile to AWS C3 instance. -pub fn c3() -> CustomCpuTemplate { - CustomCpuTemplate { - cpuid_modifiers: vec![ - CpuidLeafModifier { - leaf: 0x1, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00001111111111110011111111111111, - value: 0b00000000000000110000011011100100, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b00000000010000001101110100111100, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b10101000011001000001000010000000, - value: 0b00000000000000000001000010000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0x7, - subleaf: 0x0, - flags: KvmCpuidFlags(1), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Ebx, - bitmap: RegisterValueFilter { - filter: 0b11111111101011111101110101111100, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b01000000010000010100100000011110, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000000001100, - value: 0b00000000000000000000000000000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0xd, - subleaf: 0x0, - flags: KvmCpuidFlags(1), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000001011111000, - value: 0b00000000000000000000000000000000, - }, - }], - }, - CpuidLeafModifier { - leaf: 0xd, - subleaf: 0x1, - flags: KvmCpuidFlags(1), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000000001110, - value: 0b00000000000000000000000000000000, - }, - }], - }, - CpuidLeafModifier { - leaf: 0x80000001, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000100100000, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b00000100000000000000000000000000, - value: 0b00000000000000000000000000000000, - }, - }, - ], - }, - ], - msr_modifiers: vec![], - } -} diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/mod.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/mod.rs deleted file mode 100644 index 62ad4ef7b0fd..000000000000 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -/// Module with C3 CPU template for x86_64 -pub mod c3; -/// Module with T2 CPU template for x86_64 -pub mod t2; -/// Module with T2A CPU template for x86_64 -pub mod t2a; -/// Module with T2CL CPU template for x86_64 -pub mod t2cl; -/// Module with T2S CPU template for x86_64 -pub mod t2s; diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2.rs deleted file mode 100644 index 299187218ab9..000000000000 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2.rs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -use crate::guest_config::cpuid::KvmCpuidFlags; -use crate::guest_config::templates::x86_64::{ - CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterValueFilter, -}; -use crate::guest_config::templates::CustomCpuTemplate; - -/// T2 template -/// -/// Mask CPUID to make exposed CPU features as close as possbile to AWS T2 instance. -pub fn t2() -> CustomCpuTemplate { - CustomCpuTemplate { - cpuid_modifiers: vec![ - CpuidLeafModifier { - leaf: 0x1, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00001111111111110011111111111111, - value: 0b00000000000000110000011011110010, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b00000000000001001100110111111100, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b11101000011001000001000010000000, - value: 0b00000000000000000001000010000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0x7, - subleaf: 0x0, - flags: KvmCpuidFlags(1), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Ebx, - bitmap: RegisterValueFilter { - filter: 0b11111111111011111111101001010100, - value: 0b00000000000000000000001000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b01000000010000010101111101011110, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000100011100, - value: 0b00000000000000000000000000000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0xd, - subleaf: 0x0, - flags: KvmCpuidFlags(1), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000001011111000, - value: 0b00000000000000000000000000000000, - }, - }], - }, - CpuidLeafModifier { - leaf: 0xd, - subleaf: 0x1, - flags: KvmCpuidFlags(1), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000000001110, - value: 0b00000000000000000000000000000000, - }, - }], - }, - CpuidLeafModifier { - leaf: 0x80000001, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b00100000000000000000000100000000, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b00000100000000000000000000000000, - value: 0b00000000000000000000000000000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0x80000008, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Ebx, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000001000000000, - value: 0b00000000000000000000000000000000, - }, - }], - }, - ], - msr_modifiers: vec![], - } -} diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2a.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2a.rs deleted file mode 100644 index 851ab5ae0e10..000000000000 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2a.rs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -use crate::guest_config::cpuid::KvmCpuidFlags; -use crate::guest_config::templates::x86_64::{ - CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterValueFilter, -}; -use crate::guest_config::templates::CustomCpuTemplate; - -/// T2A template -/// -/// Provide instruction set feature partity with Intel Cascade Lake or later using T2CL template. -pub fn t2a() -> CustomCpuTemplate { - CustomCpuTemplate { - cpuid_modifiers: vec![ - CpuidLeafModifier { - leaf: 0x1, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00001111111111110011111111111111, - value: 0b00000000000000110000011011110010, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b00000000000001001100110111111100, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b11101000011001000001000010000000, - value: 0b00000000000000000001000010000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0x7, - subleaf: 0x0, - flags: KvmCpuidFlags(1), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Ebx, - bitmap: RegisterValueFilter { - filter: 0b11111111111011111111101001010100, - value: 0b00000000000000000000001000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b01000000010000010101111101011110, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000100011100, - value: 0b00000000000000000000000000000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0xd, - subleaf: 0x0, - flags: KvmCpuidFlags(1), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000001011111000, - value: 0b00000000000000000000000000000000, - }, - }], - }, - CpuidLeafModifier { - leaf: 0xd, - subleaf: 0x1, - flags: KvmCpuidFlags(1), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000000001110, - value: 0b00000000000000000000000000000000, - }, - }], - }, - CpuidLeafModifier { - leaf: 0x80000001, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b00100000000000000000000111000000, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b00000111110000000000000000000000, - value: 0b00000000000000000000000000000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0x80000008, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Ebx, - bitmap: RegisterValueFilter { - filter: 0b00000000000011000000001000000101, - value: 0b00000000000011000000000000000000, - }, - }], - }, - ], - msr_modifiers: vec![], - } -} diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2cl.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2cl.rs deleted file mode 100644 index 2091fc302718..000000000000 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2cl.rs +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -use crate::guest_config::cpuid::KvmCpuidFlags; -use crate::guest_config::templates::x86_64::{ - CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterModifier, RegisterValueFilter, -}; -use crate::guest_config::templates::CustomCpuTemplate; - -/// T2CL template -/// -/// Mask CPUID to make exposed CPU features as close as possbile to Intel Cascade Lake and provide -/// instruction set feature partity with AMD Milan using T2A template. -pub fn t2cl() -> CustomCpuTemplate { - CustomCpuTemplate { - cpuid_modifiers: vec![ - CpuidLeafModifier { - leaf: 0x1, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00001111111111110011111111111111, - value: 0b00000000000000110000011011110010, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b00000000000001001100110111111100, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b11101000011001000001000010000000, - value: 0b00000000000000000001000010000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0x7, - subleaf: 0x0, - flags: KvmCpuidFlags(1), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Ebx, - bitmap: RegisterValueFilter { - filter: 0b11111111111011111111101001010100, - value: 0b00000000000000000000001000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b01000000010000010101111101011110, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000100011100, - value: 0b00000000000000000000000000000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0xd, - subleaf: 0x0, - flags: KvmCpuidFlags(1), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000001011111000, - value: 0b00000000000000000000000000000000, - }, - }], - }, - CpuidLeafModifier { - leaf: 0xd, - subleaf: 0x1, - flags: KvmCpuidFlags(1), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000000001110, - value: 0b00000000000000000000000000000000, - }, - }], - }, - CpuidLeafModifier { - leaf: 0x80000001, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b00100000000000000000000111000000, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b00000111110000000000000000000000, - value: 0b00000000000000000000000000000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0x80000008, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Ebx, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000001000000000, - value: 0b00000000000000000000000000000000, - }, - }], - }, - ], - msr_modifiers: vec![RegisterModifier { - addr: 0x10a, - bitmap: RegisterValueFilter { - filter: 0b1111111111111111111111111111111111111111111111111111111111111111, - value: 0b0000000000000000000000000000000000000000000000000000000011101011, - }, - }], - } -} diff --git a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2s.rs b/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2s.rs deleted file mode 100644 index eaf596ab2f69..000000000000 --- a/src/vmm/src/guest_config/x86_64/static_cpu_templates_new/t2s.rs +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -use crate::guest_config::cpuid::KvmCpuidFlags; -use crate::guest_config::templates::x86_64::{ - CpuidLeafModifier, CpuidRegister, CpuidRegisterModifier, RegisterModifier, RegisterValueFilter, -}; -use crate::guest_config::templates::CustomCpuTemplate; - -/// T2S template -/// -/// Mask CPUID to make exposed CPU features as close as possbile to AWS T2 instance and allow -/// migrating snapshots between hosts with Intel Skylake and Cascade Lake securely. -pub fn t2s() -> CustomCpuTemplate { - CustomCpuTemplate { - cpuid_modifiers: vec![ - CpuidLeafModifier { - leaf: 0x1, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00001111111111110011111111111111, - value: 0b00000000000000110000011011110010, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b00000000000001001100110111111100, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b11101000011001000001000010000000, - value: 0b00000000000000000001000010000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0x7, - subleaf: 0x0, - flags: KvmCpuidFlags(1), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Ebx, - bitmap: RegisterValueFilter { - filter: 0b11111111111011111111101001010100, - value: 0b00000000000000000000001000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b01000000010000010101111101011110, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000100011100, - value: 0b00000000000000000000000000000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0xd, - subleaf: 0x0, - flags: KvmCpuidFlags(1), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000001011111000, - value: 0b00000000000000000000000000000000, - }, - }], - }, - CpuidLeafModifier { - leaf: 0xd, - subleaf: 0x1, - flags: KvmCpuidFlags(1), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Eax, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000000000001110, - value: 0b00000000000000000000000000000000, - }, - }], - }, - CpuidLeafModifier { - leaf: 0x80000001, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![ - CpuidRegisterModifier { - register: CpuidRegister::Ecx, - bitmap: RegisterValueFilter { - filter: 0b00100000000000000000000100000000, - value: 0b00000000000000000000000000000000, - }, - }, - CpuidRegisterModifier { - register: CpuidRegister::Edx, - bitmap: RegisterValueFilter { - filter: 0b00000100000000000000000000000000, - value: 0b00000000000000000000000000000000, - }, - }, - ], - }, - CpuidLeafModifier { - leaf: 0x80000008, - subleaf: 0x0, - flags: KvmCpuidFlags(0), - modifiers: vec![CpuidRegisterModifier { - register: CpuidRegister::Ebx, - bitmap: RegisterValueFilter { - filter: 0b00000000000000000000001000000000, - value: 0b00000000000000000000000000000000, - }, - }], - }, - ], - msr_modifiers: vec![RegisterModifier { - addr: 0x10a, - bitmap: RegisterValueFilter { - filter: 0b1111111111111111111111111111111111111111111111111111111111111111, - value: 0b0000000000000000000000000000000000000000000000000000110001001100, - }, - }], - } -}