From 85aed853282b9796aff6a6b4a883373947443684 Mon Sep 17 00:00:00 2001 From: Takahiro Itazuri Date: Thu, 29 May 2025 07:43:51 +0000 Subject: [PATCH 1/2] Revert "refactor(vmm): Error if subleaf >= 2 given for leaf 0xB" This reverts commit 68e7a4c75018bc8ef9d50de66553500b6aa9f28e. Signed-off-by: Takahiro Itazuri --- src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs b/src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs index f9359036f5f..688d4aeb7d5 100644 --- a/src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs +++ b/src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs @@ -69,8 +69,6 @@ pub enum ExtendedTopologyError { NumLogicalProcs(u32, CheckedAssignError), /// Failed to set right-shift bits (CPUID.(EAX=0xB,ECX={0}):EAX[4:0]): {1} RightShiftBits(u32, CheckedAssignError), - /// Unexpected subleaf: {0} - UnexpectedSubleaf(u32) } /// Error type for setting leaf 0x80000006 of Cpuid::normalize(). @@ -372,11 +370,9 @@ impl super::Cpuid { .map_err(|err| ExtendedTopologyError::DomainType(index, err))?; } _ => { - // KVM no longer returns any subleaf numbers greater than 0. The patch was - // merged in v6.2 and backported to v5.10. Subleaves >= 2 should not be - // included. - // https://github.com/torvalds/linux/commit/45e966fcca03ecdcccac7cb236e16eea38cc18af - return Err(ExtendedTopologyError::UnexpectedSubleaf(index)); + // We expect here as this is an extremely rare case that is unlikely to ever + // occur. + subleaf.result.ecx = index; } } } else { From a60088bf58a8dae28c824fd6f6cb140a0f8c14ab Mon Sep 17 00:00:00 2001 From: Takahiro Itazuri Date: Thu, 29 May 2025 08:00:41 +0000 Subject: [PATCH 2/2] chore(vmm): Warn on unexpected subleaf for CPUID leaf 0xB KVM no longer returns any subleaves greater than 0. The patch was merged in v6.2 and backported to v5.10. So for all our supported kernels, subleaves >= 2 should not be included [1]. However, we intentionally leave Firecracker not fail for unsupported kernels to keep working. Note that we can detect KVM regression thanks to the test that compares a fingerprint with its baseline. So prints a warning message without bailing out. [1]: https://github.com/torvalds/linux/commit/45e966fcca03ecdcccac7cb236e16eea38cc18af Signed-off-by: Takahiro Itazuri --- src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs b/src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs index 688d4aeb7d5..7accc3ecd71 100644 --- a/src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs +++ b/src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs @@ -4,6 +4,7 @@ use crate::cpu_config::x86_64::cpuid::{ CpuidEntry, CpuidKey, CpuidRegisters, CpuidTrait, KvmCpuidFlags, cpuid, }; +use crate::logger::warn; use crate::vmm_config::machine_config::MAX_SUPPORTED_VCPUS; /// Error type for [`super::Cpuid::normalize`]. @@ -370,8 +371,15 @@ impl super::Cpuid { .map_err(|err| ExtendedTopologyError::DomainType(index, err))?; } _ => { - // We expect here as this is an extremely rare case that is unlikely to ever - // occur. + // KVM no longer returns any subleaves greater than 0. The patch was merged + // in v6.2 and backported to v5.10. So for all our supported kernels, + // subleaves >= 2 should not be included. + // https://github.com/torvalds/linux/commit/45e966fcca03ecdcccac7cb236e16eea38cc18af + // + // However, we intentionally leave Firecracker not fail for unsupported + // kernels to keep working. Note that we can detect KVM regression thanks + // to the test that compares a fingerprint with its baseline. + warn!("Subleaf {index} not expected for CPUID leaf 0xB."); subleaf.result.ecx = index; } }