@@ -61,16 +61,14 @@ pub enum GetMaxCpusPerPackageError {
6161#[ rustfmt:: skip]
6262#[ derive( Debug , thiserror:: Error , displaydoc:: Display , Eq , PartialEq ) ]
6363pub enum ExtendedTopologyError {
64- /// Failed to set `Number of bits to shift right on x2APIC ID to get a unique topology ID of the next level type`: {0}
65- ApicId ( CheckedAssignError ) ,
66- /// Failed to set `Number of logical processors at this level type`: {0}
67- LogicalProcessors ( CheckedAssignError ) ,
68- /// Failed to set `Domain Type`: {0}
69- DomainType ( CheckedAssignError ) ,
70- /// Failed to set `Input ECX`: {0}
71- InputEcx ( CheckedAssignError ) ,
72- /// Failed to set all leaves, as more than `u32::MAX` sub-leaves are present: {0}
73- Overflow ( <u32 as TryFrom < usize > >:: Error ) ,
64+ /// Failed to set domain type (CPUID.(EAX=0xB,ECX={0}):ECX[15:8]): {1}
65+ DomainType ( u32 , CheckedAssignError ) ,
66+ /// Failed to set input ECX (CPUID.(EAX=0xB,ECX={0}):ECX[7:0]): {1}
67+ InputEcx ( u32 , CheckedAssignError ) ,
68+ /// Failed to set number of logical processors (CPUID.(EAX=0xB,ECX={0}):EBX[15:0]): {1}
69+ NumLogicalProcs ( u32 , CheckedAssignError ) ,
70+ /// Failed to set right-shift bits (CPUID.(EAX=0xB,ECX={0}):EAX[4:0]): {1}
71+ RightShiftBits ( u32 , CheckedAssignError ) ,
7472 /// Unexpected subleaf: {0}
7573 UnexpectedSubleaf ( u32 )
7674}
@@ -348,18 +346,18 @@ impl super::Cpuid {
348346 // To get the next level APIC ID, shift right with at most 1 because we have
349347 // maximum 2 logical procerssors per core that can be represented by 1 bit.
350348 set_range ( & mut subleaf. result . eax , 0 ..5 , u32:: from ( cpu_bits) )
351- . map_err ( ExtendedTopologyError :: ApicId ) ?;
349+ . map_err ( |err| ExtendedTopologyError :: RightShiftBits ( index , err ) ) ?;
352350
353351 // When cpu_count == 1 or HT is disabled, there is 1 logical core at this
354352 // domain; otherwise there are 2
355353 set_range ( & mut subleaf. result . ebx , 0 ..16 , u32:: from ( cpus_per_core) )
356- . map_err ( ExtendedTopologyError :: LogicalProcessors ) ?;
354+ . map_err ( |err| ExtendedTopologyError :: NumLogicalProcs ( index , err ) ) ?;
357355
358356 // Skip setting 0 to ECX[7:0] since it's already reset to 0.
359357
360358 // Set the domain type identification value for logical processor,
361359 set_range ( & mut subleaf. result . ecx , 8 ..16 , 1 )
362- . map_err ( ExtendedTopologyError :: DomainType ) ?;
360+ . map_err ( |err| ExtendedTopologyError :: DomainType ( index , err ) ) ?;
363361 }
364362 // Core domain
365363 1 => {
@@ -373,17 +371,17 @@ impl super::Cpuid {
373371 0 ..5 ,
374372 MAX_SUPPORTED_VCPUS . next_power_of_two ( ) . ilog2 ( ) ,
375373 )
376- . map_err ( ExtendedTopologyError :: ApicId ) ?;
374+ . map_err ( |err| ExtendedTopologyError :: RightShiftBits ( index , err ) ) ?;
377375 set_range ( & mut subleaf. result . ebx , 0 ..16 , u32:: from ( cpu_count) )
378- . map_err ( ExtendedTopologyError :: LogicalProcessors ) ?;
376+ . map_err ( |err| ExtendedTopologyError :: NumLogicalProcs ( index , err ) ) ?;
379377
380378 // Setting the input ECX value (i.e. `index`)
381379 set_range ( & mut subleaf. result . ecx , 0 ..8 , index)
382- . map_err ( ExtendedTopologyError :: InputEcx ) ?;
380+ . map_err ( |err| ExtendedTopologyError :: InputEcx ( index , err ) ) ?;
383381
384382 // Set the domain type identification value for core.
385383 set_range ( & mut subleaf. result . ecx , 8 ..16 , 2 )
386- . map_err ( ExtendedTopologyError :: DomainType ) ?;
384+ . map_err ( |err| ExtendedTopologyError :: DomainType ( index , err ) ) ?;
387385 }
388386 _ => {
389387 // KVM no longer returns any subleaf numbers greater than 0. The patch was
0 commit comments