Skip to content

Commit 3a98e88

Browse files
committed
refactor: unify "leaf X missing" error variants
Turn the three error variants that had a cpuid leaf number hardcoded in their name into a single generic LeafMissing(usize) error variant. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
1 parent e51e4cc commit 3a98e88

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/vmm/src/cpu_config/x86_64/cpuid/intel/normalize.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ use crate::cpu_config::x86_64::cpuid::{
1414
pub enum NormalizeCpuidError {
1515
/// Failed to set deterministic cache leaf: {0}
1616
DeterministicCache(#[from] DeterministicCacheError),
17-
/// Leaf 0x6 is missing from CPUID.
18-
MissingLeaf6,
19-
/// Leaf 0x7 / subleaf 0 is missing from CPUID.
20-
MissingLeaf7,
21-
/// Leaf 0xA is missing from CPUID.
22-
MissingLeafA,
17+
/// Leaf {0} is missing from CPUID.
18+
MissingLeaf(usize),
2319
/// Failed to get brand string: {0}
2420
GetBrandString(DefaultBrandStringError),
2521
/// Failed to set brand string: {0}
@@ -164,7 +160,7 @@ impl super::IntelCpuid {
164160
fn update_power_management_entry(&mut self) -> Result<(), NormalizeCpuidError> {
165161
let leaf_6 = self
166162
.get_mut(&CpuidKey::leaf(0x6))
167-
.ok_or(NormalizeCpuidError::MissingLeaf6)?;
163+
.ok_or(NormalizeCpuidError::MissingLeaf(6))?;
168164

169165
// CPUID.06H:EAX[1]
170166
// Intel Turbo Boost Technology available (see description of IA32_MISC_ENABLE[38]).
@@ -184,7 +180,7 @@ impl super::IntelCpuid {
184180
fn update_extended_feature_flags_entry(&mut self) -> Result<(), NormalizeCpuidError> {
185181
let leaf_7_0 = self
186182
.get_mut(&CpuidKey::subleaf(0x7, 0))
187-
.ok_or(NormalizeCpuidError::MissingLeaf7)?;
183+
.ok_or(NormalizeCpuidError::MissingLeaf(7))?;
188184

189185
// Set the following bits as recommended in kernel doc. These bits are reserved in AMD.
190186
// - CPUID.07H:EBX[6] (FDP_EXCPTN_ONLY)
@@ -243,7 +239,7 @@ impl super::IntelCpuid {
243239
fn update_performance_monitoring_entry(&mut self) -> Result<(), NormalizeCpuidError> {
244240
let leaf_a = self
245241
.get_mut(&CpuidKey::leaf(0xA))
246-
.ok_or(NormalizeCpuidError::MissingLeafA)?;
242+
.ok_or(NormalizeCpuidError::MissingLeaf(0xA))?;
247243
leaf_a.result = CpuidRegisters {
248244
eax: 0,
249245
ebx: 0,

0 commit comments

Comments
 (0)