Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5dc01cb
build: Bump crate-ci/typos from 1.33.1 to 1.34.0
dependabot[bot] Jul 1, 2025
b6852af
docs: Fix the chown command in macvtap-bridge.md
liuw Jul 1, 2025
51d16ab
Start manual implementation of CPUID feature flag values
olivereanderson Jul 29, 2025
3b9962f
Add Feature flags with macros
olivereanderson Jul 30, 2025
71bcaad
constructor
olivereanderson Jul 30, 2025
3dd61f6
Intersect feature flags
olivereanderson Jul 30, 2025
659b194
Move CpuProfile into arch/src/lib.rs
olivereanderson Jul 31, 2025
bf5955c
Make it compile with warnings
olivereanderson Jul 31, 2025
f48b1e7
Implement the restriction, improve documentation and some minor cleanup
olivereanderson Jul 31, 2025
bce9f29
Adjust documentation
olivereanderson Jul 31, 2025
199adc3
Fix missing conditional compilation
olivereanderson Jul 31, 2025
cc2e355
Fix name
olivereanderson Aug 1, 2025
4a23b61
Include missing field
olivereanderson Aug 1, 2025
0f75b3e
Shorten macro
olivereanderson Aug 1, 2025
618f169
Simplify macro further
olivereanderson Aug 1, 2025
8218816
Drop guard early
olivereanderson Aug 1, 2025
96ffe84
Make inner value public
olivereanderson Aug 6, 2025
89a7ab3
Rename CpuIdFeatureFlags
olivereanderson Aug 6, 2025
389f5f6
Refactor: Less structs. Use one complete struct with all feature regi…
olivereanderson Aug 7, 2025
1964fbf
Refactoring
olivereanderson Aug 8, 2025
2e50d2c
Add TODO comment for AMD duplicates
olivereanderson Aug 8, 2025
f68a9d9
More associated constants
olivereanderson Aug 8, 2025
5c1ae50
Change macro to be more doc friendly
olivereanderson Aug 11, 2025
b08bcc2
Improve logs and add more comments
olivereanderson Aug 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ jobs:
steps:
- uses: actions/checkout@v4
# Executes "typos ."
- uses: crate-ci/typos@v1.33.1
- uses: crate-ci/typos@v1.34.0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not my doing.

Should fix this before merging.

1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions arch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ hypervisor = { path = "../hypervisor" }
libc = "0.2.167"
linux-loader = { workspace = true, features = ["bzimage", "elf", "pe"] }
log = "0.4.22"
paste = { version = "1"}
serde = { version = "1.0.208", features = ["derive", "rc"] }
thiserror = { workspace = true }
uuid = { workspace = true }
Expand Down
26 changes: 25 additions & 1 deletion arch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
extern crate log;

use std::collections::BTreeMap;
use std::str::FromStr;
use std::sync::Arc;
use std::{fmt, result};

use serde::{Deserialize, Serialize};
use serde::{de::IntoDeserializer, Deserialize, Serialize};
use thiserror::Error;

#[cfg(target_arch = "x86_64")]
Expand Down Expand Up @@ -59,6 +60,29 @@ pub enum Error {
/// Type for returning public functions outcome.
pub type Result<T> = result::Result<T, Error>;

#[cfg(target_arch = "x86_64")]
pub use crate::x86_64::{CpuIdEntryRegister, CpuIdFeatureFlags, CpuProfile};
#[cfg(not(target_arch = "x86_64"))]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum CpuProfile {
Comment thread
olivereanderson marked this conversation as resolved.
#[default]
Host,
}

impl FromStr for CpuProfile {
type Err = serde::de::value::Error;
fn from_str(s: &str) -> result::Result<Self, Self::Err> {
// Should accept both plain strings, and strings surrounded by `"`.
let normalized = s
.strip_prefix('"')
.unwrap_or(s)
.strip_suffix('"')
.unwrap_or(s);
Self::deserialize(normalized.into_deserializer())
}
}

/// Type for memory region types.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub enum RegionType {
Expand Down
93 changes: 93 additions & 0 deletions arch/src/x86_64/cpu_profile/cpuid_feature_flags_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
use crate::x86_64::cpuid_feature_flags::{CpuIdEntryRegister, CpuIdFeatureFlags};

impl CpuIdFeatureFlags {
pub const fn intel_cascadelake_v1() -> Self {
use CpuIdEntryRegister as FF;

Self {
edx_1: FF::VME
.or(FF::SSE2)
.or(FF::SSE)
.or(FF::FXSR)
.or(FF::MMX)
.or(FF::CLFLUSH)
.or(FF::PSE36)
.or(FF::PAT)
.or(FF::CMOV)
.or(FF::MCA)
.or(FF::PGE)
.or(FF::MTRR)
.or(FF::SEP)
.or(FF::APIC)
.or(FF::CX8)
.or(FF::MCE)
.or(FF::PAE)
.or(FF::MSR)
.or(FF::TSC)
.or(FF::PSE)
.or(FF::DE)
.or(FF::FPU),

ecx_1: FF::AVX
.or(FF::XSAVE)
.or(FF::AES)
.or(FF::POPCNT)
.or(FF::X2APIC)
.or(FF::SSE4_2)
.or(FF::SSE4_1)
.or(FF::CX16)
.or(FF::SSSE3)
.or(FF::PCLMULQDQ)
.or(FF::SSE3)
.or(FF::TSC_DEADLINE)
.or(FF::FMA)
.or(FF::MOVBE)
.or(FF::PCID)
.or(FF::F16C)
.or(FF::RDRAND),

edx_8000_0001h: FF::LM
.or(FF::PDPE1GB)
.or(FF::RDTSCP)
.or(FF::NX)
.or(FF::SYSCALL),
ecx_8000_0001h: FF::ABM.or(FF::LAHF_LM).or(FF::PREFETCH_3DNOW),
ebx_7_0: FF::FSGSBASE
.or(FF::BMI1)
.or(FF::HLE)
.or(FF::AVX2)
.or(FF::SMEP)
.or(FF::BMI2)
.or(FF::ERMS)
.or(FF::INVPCID)
.or(FF::RTM)
.or(FF::RDSEED)
.or(FF::ADX)
.or(FF::SMAP)
.or(FF::CLWB)
.or(FF::AVX512F)
.or(FF::AVX512DQ)
.or(FF::AVX512BW)
.or(FF::AVX512CD)
.or(FF::AVX512VL)
.or(FF::CLFLUSHOPT),
ecx_7_0: FF::PKU.or(FF::AVX512VNNI),
edx_7_0: FF::SPEC_CTRL.or(FF::SSBD),
eax_0dh_1: FF::XSAVEOPT.or(FF::XSAVEC).or(FF::XGETBV1),
eax_7_1: FF::NULL,
ecx_7_1: FF::NULL,
edx_7_1: FF::NULL,
edx_7_2: FF::NULL,
ecx_14h: FF::NULL,
ecx_24h_1: FF::NULL,
/*
Caskadelake Server only supports TscInvariant, but this feature cannot be relied upon in the context of migration hence we also leave that turned off.
TODO: Isnt't this feature very useful when the VM is running normally though? (i.e. outside of migrations).
*/
edx_8000_0007h: FF::NULL,
ebx_8000_0008h: FF::NULL,
edx_8000_000ah: FF::NULL,
eax_8000_0021h: FF::NULL,
}
}
}
8 changes: 8 additions & 0 deletions arch/src/x86_64/cpu_profile/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mod cpuid_feature_flags_impl;
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum CpuProfile {
#[default]
Host,
CascadelakeServerV1,
}
Loading
Loading