* [PATCH v2 0/2] Dump CPUID.1FH information correctly
@ 2019-04-04 6:03 Ni, Ray
2019-04-04 6:03 ` [PATCH v2 1/2] UefiCpuPkg/Cpuid.h: Remove duplicated struct definition for leaf 1FH Ni, Ray
2019-04-04 6:03 ` [PATCH v2 2/2] UefiCpuPkg/Cpuid: Dump leaf 1FH information correctly Ni, Ray
0 siblings, 2 replies; 5+ messages in thread
From: Ni, Ray @ 2019-04-04 6:03 UTC (permalink / raw)
To: devel
v2: Removes the duplicated structure definitions introduced for leaf
1FH.
Ray Ni (2):
UefiCpuPkg/Cpuid.h: Remove duplicated struct definition for leaf 1FH
UefiCpuPkg/Cpuid: Dump leaf 1FH information correctly
UefiCpuPkg/Application/Cpuid/Cpuid.c | 74 +++++-----------
UefiCpuPkg/Include/Register/Cpuid.h | 126 ++-------------------------
2 files changed, 32 insertions(+), 168 deletions(-)
--
2.21.0.windows.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] UefiCpuPkg/Cpuid.h: Remove duplicated struct definition for leaf 1FH
2019-04-04 6:03 [PATCH v2 0/2] Dump CPUID.1FH information correctly Ni, Ray
@ 2019-04-04 6:03 ` Ni, Ray
2019-04-04 6:23 ` eric.dong
2019-04-04 6:03 ` [PATCH v2 2/2] UefiCpuPkg/Cpuid: Dump leaf 1FH information correctly Ni, Ray
1 sibling, 1 reply; 5+ messages in thread
From: Ni, Ray @ 2019-04-04 6:03 UTC (permalink / raw)
To: devel; +Cc: Eric Dong, Star Zeng, Zhiqiang Qin
Per SDM CPUID.0BH and CPUID.1FH outputs the same format of data in
EAX/EBX/ECX/EDX except CPUID.1FH reports more level types such as
module, tile, die.
The patch removes the unnecessary duplicated structure definitions
for CPUID.1FH because when the structure definitions for CPUID.0BH
can be used for CPUID.1FH.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Zhiqiang Qin <zhiqiang.qin@intel.com>
---
UefiCpuPkg/Application/Cpuid/Cpuid.c | 24 ++---
UefiCpuPkg/Include/Register/Cpuid.h | 126 ++-------------------------
2 files changed, 20 insertions(+), 130 deletions(-)
diff --git a/UefiCpuPkg/Application/Cpuid/Cpuid.c b/UefiCpuPkg/Application/Cpuid/Cpuid.c
index 67cacf2714..d229ac8e7b 100644
--- a/UefiCpuPkg/Application/Cpuid/Cpuid.c
+++ b/UefiCpuPkg/Application/Cpuid/Cpuid.c
@@ -1,7 +1,7 @@
/** @file
UEFI Application to display CPUID leaf information.
- Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1394,26 +1394,26 @@ CpuidV2ExtendedTopologyEnumeration (
VOID
)
{
- CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EAX Eax;
- CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EBX Ebx;
- CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX Ecx;
- UINT32 Edx;
+ CPUID_EXTENDED_TOPOLOGY_EAX Eax;
+ CPUID_EXTENDED_TOPOLOGY_EBX Ebx;
+ CPUID_EXTENDED_TOPOLOGY_ECX Ecx;
+ UINT32 Edx;
- if (CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION > gMaximumBasicFunction) {
+ if (CPUID_V2_EXTENDED_TOPOLOGY > gMaximumBasicFunction) {
return;
}
AsmCpuidEx (
- CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION,
- CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF,
+ CPUID_V2_EXTENDED_TOPOLOGY,
+ 0,
&Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx
);
- Print (L"CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION (Leaf %08x, Sub-Leaf %08x)\n", CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION, CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF);
+ Print (L"CPUID_V2_EXTENDED_TOPOLOGY (Leaf %08x, Sub-Leaf %08x)\n", CPUID_V2_EXTENDED_TOPOLOGY, 0);
Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx);
- PRINT_BIT_FIELD (Eax, BitsNum);
- PRINT_BIT_FIELD (Ebx, ProcessorsNum);
- PRINT_BIT_FIELD (Ecx, LevelNum);
+ PRINT_BIT_FIELD (Eax, ApicIdShift);
+ PRINT_BIT_FIELD (Ebx, LogicalProcessors);
+ PRINT_BIT_FIELD (Ecx, LevelNumber);
PRINT_BIT_FIELD (Ecx, LevelType);
PRINT_VALUE (Edx, x2APICID);
}
diff --git a/UefiCpuPkg/Include/Register/Cpuid.h b/UefiCpuPkg/Include/Register/Cpuid.h
index fab199b6e2..e0f4f968f4 100644
--- a/UefiCpuPkg/Include/Register/Cpuid.h
+++ b/UefiCpuPkg/Include/Register/Cpuid.h
@@ -6,7 +6,7 @@
If a register returned is a single 32-bit value, then a data structure is
not provided for that register.
- Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License which accompanies this distribution.
The full text of the license may be found at
@@ -3620,130 +3620,20 @@ typedef union {
number of logical processors available to BIOS/OS/Applications may be different from the
value of EBX[15:0], depending on software and platform hardware configurations.
- @param EAX CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION (0x1F)
- @param ECX CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF (0x0)
-
-**/
-#define CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION 0x1F
-
-/**
- CPUID V2 Extended Topology Enumeration Leaf
-
- @param EAX CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION (0x1F)
- @param ECX CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF (0x00)
-
- @retval EAX Returns V2 Extended Topology Enumeration Leaf described by
- the type CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EAX.
- @retval EBX Returns V2 Extended Topology Enumeration Leaf described by
- the type CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EBX.
- @retval ECX Returns V2 Extended Topology Enumeration Leaf described by
- the type CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX.
- @retval EDX Returns x2APIC ID the current logical processor.
-
- <b>Example usage</b>
- @code
- CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EAX Eax;
- CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EBX Ebx;
- CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX Ecx;
- UINT32 Edx;
-
- AsmCpuidEx (
- CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION,
- CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF,
- &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx
- );
- @endcode
-**/
-#define CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF 0x00
-
-/**
- CPUID V2 Extended Topology Enumeration Leaf EAX for CPUID leafs.
-**/
-typedef union {
- ///
- /// Individual bit fields
- ///
- struct {
- ///
- /// [Bits 4:0] Number of bits to shift right on x2APIC ID to get a unique
- /// topology ID of the next level type. All logical processors with the
- /// same next level ID share current level.
- ///
- UINT32 BitsNum:5;
- ///
- /// [Bits 31:5] Reserved.
- ///
- UINT32 Reserved:27;
- } Bits;
- ///
- /// All bit fields as a 32-bit value
- ///
- UINT32 Uint32;
-} CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EAX;
-
-/**
- CPUID V2 Extended Topology Enumeration Leaf EBX for CPUID leafs.
-**/
-typedef union {
- ///
- /// Individual bit fields
- ///
- struct {
- ///
- /// [Bits 15:0] Number of logical processors at this level type. The number
- /// reflects configuration as shipped by Intel.
- ///
- UINT32 ProcessorsNum:16;
- ///
- /// [Bits 31:5] Reserved.
- ///
- UINT32 Reserved:16;
- } Bits;
- ///
- /// All bit fields as a 32-bit value
- ///
- UINT32 Uint32;
-} CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EBX;
+ @param EAX CPUID_V2_EXTENDED_TOPOLOGY (0x1F)
+ @param ECX Level number
-/**
- CPUID V2 Extended Topology Enumeration Leaf ECX for CPUID leafs.
**/
-typedef union {
- ///
- /// Individual bit fields
- ///
- struct {
- ///
- /// [Bits 7:0] Level number. Same value in ECX input.
- ///
- UINT32 LevelNum:8;
- ///
- /// [Bits 7:0] Level type.
- ///
- UINT32 LevelType:8;
-
- ///
- /// [Bits 31:5] Reserved.
- ///
- UINT32 Reserved:16;
- } Bits;
- ///
- /// All bit fields as a 32-bit value
- ///
- UINT32 Uint32;
-} CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX;
+#define CPUID_V2_EXTENDED_TOPOLOGY 0x1F
///
-/// @{ Define value for CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX.LevelType
+/// @{ Define value for CPUID_EXTENDED_TOPOLOGY_ECX.LevelType
/// The value of the "level type" field is not related to level numbers in
/// any way, higher "level type" values do not mean higher levels.
///
-#define CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_INVALID 0x00
-#define CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_SMT 0x01
-#define CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_CORE 0x02
-#define CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_MODULE 0x03
-#define CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_TILE 0x04
-#define CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_DIE 0x05
+#define CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_MODULE 0x03
+#define CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_TILE 0x04
+#define CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE 0x05
///
/// @}
///
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] UefiCpuPkg/Cpuid: Dump leaf 1FH information correctly
2019-04-04 6:03 [PATCH v2 0/2] Dump CPUID.1FH information correctly Ni, Ray
2019-04-04 6:03 ` [PATCH v2 1/2] UefiCpuPkg/Cpuid.h: Remove duplicated struct definition for leaf 1FH Ni, Ray
@ 2019-04-04 6:03 ` Ni, Ray
2019-04-04 6:24 ` [edk2-devel] " Dong, Eric
1 sibling, 1 reply; 5+ messages in thread
From: Ni, Ray @ 2019-04-04 6:03 UTC (permalink / raw)
To: devel; +Cc: Eric Dong, Star Zeng, Zhiqiang Qin
Leaf 1FH is very similar to leaf 0BH. Both return the CPU topology
information.
Leaf 0BH returns 3-level (Package/Core/Thread) CPU topology info.
Leaf 1FH returns 6-level (Package/Die/Tile/Module/Core/Thread) CPU
topology info.
The logic to enumerate the topology info is the same.
But today's logic to handle 1FH is completely wrong.
The patch combines them together to fix the 1FH issue.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Zhiqiang Qin <zhiqiang.qin@intel.com>
---
UefiCpuPkg/Application/Cpuid/Cpuid.c | 72 +++++++++-------------------
1 file changed, 23 insertions(+), 49 deletions(-)
diff --git a/UefiCpuPkg/Application/Cpuid/Cpuid.c b/UefiCpuPkg/Application/Cpuid/Cpuid.c
index d229ac8e7b..30d43e9631 100644
--- a/UefiCpuPkg/Application/Cpuid/Cpuid.c
+++ b/UefiCpuPkg/Application/Cpuid/Cpuid.c
@@ -717,7 +717,7 @@ CpuidArchitecturalPerformanceMonitoring (
**/
VOID
CpuidExtendedTopology (
- VOID
+ UINT32 LeafFunction
)
{
CPUID_EXTENDED_TOPOLOGY_EAX Eax;
@@ -726,27 +726,34 @@ CpuidExtendedTopology (
UINT32 Edx;
UINT32 LevelNumber;
- if (CPUID_EXTENDED_TOPOLOGY > gMaximumBasicFunction) {
+ if (LeafFunction > gMaximumBasicFunction) {
+ return;
+ }
+ if ((LeafFunction != CPUID_EXTENDED_TOPOLOGY) && (LeafFunction != CPUID_V2_EXTENDED_TOPOLOGY)) {
return;
}
LevelNumber = 0;
- do {
+ for (LevelNumber = 0; ; LevelNumber++) {
AsmCpuidEx (
- CPUID_EXTENDED_TOPOLOGY, LevelNumber,
+ LeafFunction, LevelNumber,
&Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx
);
- if (Eax.Bits.ApicIdShift != 0) {
- Print (L"CPUID_EXTENDED_TOPOLOGY (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_TOPOLOGY, LevelNumber);
- Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx);
- PRINT_BIT_FIELD (Eax, ApicIdShift);
- PRINT_BIT_FIELD (Ebx, LogicalProcessors);
- PRINT_BIT_FIELD (Ecx, LevelNumber);
- PRINT_BIT_FIELD (Ecx, LevelType);
- PRINT_VALUE (Edx, x2APIC_ID);
+ if (Ecx.Bits.LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID) {
+ break;
}
- LevelNumber++;
- } while (Eax.Bits.ApicIdShift != 0);
+ Print (
+ L"%a (Leaf %08x, Sub-Leaf %08x)\n",
+ LeafFunction == CPUID_EXTENDED_TOPOLOGY ? "CPUID_EXTENDED_TOPOLOGY" : "CPUID_V2_EXTENDED_TOPOLOGY",
+ LeafFunction, LevelNumber
+ );
+ Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx);
+ PRINT_BIT_FIELD (Eax, ApicIdShift);
+ PRINT_BIT_FIELD (Ebx, LogicalProcessors);
+ PRINT_BIT_FIELD (Ecx, LevelNumber);
+ PRINT_BIT_FIELD (Ecx, LevelType);
+ PRINT_VALUE (Edx, x2APIC_ID);
+ }
}
/**
@@ -1385,39 +1392,6 @@ CpuidDeterministicAddressTranslationParameters (
PRINT_BIT_FIELD (Edx, MaximumNum);
}
-/**
- Display CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION main leaf and sub-leafs.
-
-**/
-VOID
-CpuidV2ExtendedTopologyEnumeration (
- VOID
- )
-{
- CPUID_EXTENDED_TOPOLOGY_EAX Eax;
- CPUID_EXTENDED_TOPOLOGY_EBX Ebx;
- CPUID_EXTENDED_TOPOLOGY_ECX Ecx;
- UINT32 Edx;
-
- if (CPUID_V2_EXTENDED_TOPOLOGY > gMaximumBasicFunction) {
- return;
- }
-
- AsmCpuidEx (
- CPUID_V2_EXTENDED_TOPOLOGY,
- 0,
- &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx
- );
- Print (L"CPUID_V2_EXTENDED_TOPOLOGY (Leaf %08x, Sub-Leaf %08x)\n", CPUID_V2_EXTENDED_TOPOLOGY, 0);
- Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx);
-
- PRINT_BIT_FIELD (Eax, ApicIdShift);
- PRINT_BIT_FIELD (Ebx, LogicalProcessors);
- PRINT_BIT_FIELD (Ecx, LevelNumber);
- PRINT_BIT_FIELD (Ecx, LevelType);
- PRINT_VALUE (Edx, x2APICID);
-}
-
/**
Display CPUID_EXTENDED_FUNCTION leaf.
@@ -1619,7 +1593,7 @@ UefiMain (
CpuidStructuredExtendedFeatureFlags ();
CpuidDirectCacheAccessInfo();
CpuidArchitecturalPerformanceMonitoring ();
- CpuidExtendedTopology ();
+ CpuidExtendedTopology (CPUID_EXTENDED_TOPOLOGY);
CpuidExtendedStateMainLeaf ();
CpuidIntelRdtMonitoringEnumerationSubLeaf ();
CpuidIntelRdtMonitoringL3CacheCapabilitySubLeaf ();
@@ -1630,7 +1604,7 @@ UefiMain (
CpuidProcessorFrequency ();
CpuidSocVendor ();
CpuidDeterministicAddressTranslationParameters ();
- CpuidV2ExtendedTopologyEnumeration ();
+ CpuidExtendedTopology (CPUID_V2_EXTENDED_TOPOLOGY);
CpuidExtendedFunction ();
CpuidExtendedCpuSig ();
CpuidProcessorBrandString ();
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] UefiCpuPkg/Cpuid.h: Remove duplicated struct definition for leaf 1FH
2019-04-04 6:03 ` [PATCH v2 1/2] UefiCpuPkg/Cpuid.h: Remove duplicated struct definition for leaf 1FH Ni, Ray
@ 2019-04-04 6:23 ` eric.dong
0 siblings, 0 replies; 5+ messages in thread
From: eric.dong @ 2019-04-04 6:23 UTC (permalink / raw)
To: Ni, Ray, devel@edk2.groups.io; +Cc: Zeng, Star, Qin, Zhiqiang
Reviewed-by: Eric Dong <eric.dong@intel.com>
> -----Original Message-----
> From: Ni, Ray
> Sent: Thursday, April 4, 2019 2:03 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric <eric.dong@intel.com>; Zeng, Star <star.zeng@intel.com>; Qin,
> Zhiqiang <zhiqiang.qin@intel.com>
> Subject: [PATCH v2 1/2] UefiCpuPkg/Cpuid.h: Remove duplicated struct
> definition for leaf 1FH
>
> Per SDM CPUID.0BH and CPUID.1FH outputs the same format of data in
> EAX/EBX/ECX/EDX except CPUID.1FH reports more level types such as
> module, tile, die.
>
> The patch removes the unnecessary duplicated structure definitions for
> CPUID.1FH because when the structure definitions for CPUID.0BH can be
> used for CPUID.1FH.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Zhiqiang Qin <zhiqiang.qin@intel.com>
> ---
> UefiCpuPkg/Application/Cpuid/Cpuid.c | 24 ++---
> UefiCpuPkg/Include/Register/Cpuid.h | 126 ++-------------------------
> 2 files changed, 20 insertions(+), 130 deletions(-)
>
> diff --git a/UefiCpuPkg/Application/Cpuid/Cpuid.c
> b/UefiCpuPkg/Application/Cpuid/Cpuid.c
> index 67cacf2714..d229ac8e7b 100644
> --- a/UefiCpuPkg/Application/Cpuid/Cpuid.c
> +++ b/UefiCpuPkg/Application/Cpuid/Cpuid.c
> @@ -1,7 +1,7 @@
> /** @file
> UEFI Application to display CPUID leaf information.
>
> - Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2016 - 2019, Intel Corporation. All rights
> + reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD
> License
> which accompanies this distribution. The full text of the license may be
> found at @@ -1394,26 +1394,26 @@ CpuidV2ExtendedTopologyEnumeration
> (
> VOID
> )
> {
> - CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EAX Eax;
> - CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EBX Ebx;
> - CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX Ecx;
> - UINT32 Edx;
> + CPUID_EXTENDED_TOPOLOGY_EAX Eax;
> + CPUID_EXTENDED_TOPOLOGY_EBX Ebx;
> + CPUID_EXTENDED_TOPOLOGY_ECX Ecx;
> + UINT32 Edx;
>
> - if (CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION >
> gMaximumBasicFunction) {
> + if (CPUID_V2_EXTENDED_TOPOLOGY > gMaximumBasicFunction) {
> return;
> }
>
> AsmCpuidEx (
> - CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION,
> - CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF,
> + CPUID_V2_EXTENDED_TOPOLOGY,
> + 0,
> &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx
> );
> - Print (L"CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION (Leaf %08x,
> Sub-Leaf %08x)\n", CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION,
> CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF);
> + Print (L"CPUID_V2_EXTENDED_TOPOLOGY (Leaf %08x, Sub-Leaf %08x)\n",
> + CPUID_V2_EXTENDED_TOPOLOGY, 0);
> Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32,
> Ebx.Uint32, Ecx.Uint32, Edx);
>
> - PRINT_BIT_FIELD (Eax, BitsNum);
> - PRINT_BIT_FIELD (Ebx, ProcessorsNum);
> - PRINT_BIT_FIELD (Ecx, LevelNum);
> + PRINT_BIT_FIELD (Eax, ApicIdShift);
> + PRINT_BIT_FIELD (Ebx, LogicalProcessors); PRINT_BIT_FIELD (Ecx,
> + LevelNumber);
> PRINT_BIT_FIELD (Ecx, LevelType);
> PRINT_VALUE (Edx, x2APICID);
> }
> diff --git a/UefiCpuPkg/Include/Register/Cpuid.h
> b/UefiCpuPkg/Include/Register/Cpuid.h
> index fab199b6e2..e0f4f968f4 100644
> --- a/UefiCpuPkg/Include/Register/Cpuid.h
> +++ b/UefiCpuPkg/Include/Register/Cpuid.h
> @@ -6,7 +6,7 @@
> If a register returned is a single 32-bit value, then a data structure is
> not provided for that register.
>
> - Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015 - 2019, Intel Corporation. All rights
> + reserved.<BR>
> This program and the accompanying materials are licensed and made
> available under
> the terms and conditions of the BSD License which accompanies this
> distribution.
> The full text of the license may be found at @@ -3620,130 +3620,20 @@
> typedef union {
> number of logical processors available to BIOS/OS/Applications may be
> different from the
> value of EBX[15:0], depending on software and platform hardware
> configurations.
>
> - @param EAX CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION
> (0x1F)
> - @param ECX
> CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF (0x0)
> -
> -**/
> -#define CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION
> 0x1F
> -
> -/**
> - CPUID V2 Extended Topology Enumeration Leaf
> -
> - @param EAX CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION
> (0x1F)
> - @param ECX
> CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF (0x00)
> -
> - @retval EAX Returns V2 Extended Topology Enumeration Leaf described
> by
> - the type CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EAX.
> - @retval EBX Returns V2 Extended Topology Enumeration Leaf described
> by
> - the type CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EBX.
> - @retval ECX Returns V2 Extended Topology Enumeration Leaf described
> by
> - the type CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX.
> - @retval EDX Returns x2APIC ID the current logical processor.
> -
> - <b>Example usage</b>
> - @code
> - CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EAX Eax;
> - CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EBX Ebx;
> - CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX Ecx;
> - UINT32 Edx;
> -
> - AsmCpuidEx (
> - CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION,
> - CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF,
> - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx
> - );
> - @endcode
> -**/
> -#define CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_MAIN_LEAF
> 0x00
> -
> -/**
> - CPUID V2 Extended Topology Enumeration Leaf EAX for CPUID leafs.
> -**/
> -typedef union {
> - ///
> - /// Individual bit fields
> - ///
> - struct {
> - ///
> - /// [Bits 4:0] Number of bits to shift right on x2APIC ID to get a unique
> - /// topology ID of the next level type. All logical processors with the
> - /// same next level ID share current level.
> - ///
> - UINT32 BitsNum:5;
> - ///
> - /// [Bits 31:5] Reserved.
> - ///
> - UINT32 Reserved:27;
> - } Bits;
> - ///
> - /// All bit fields as a 32-bit value
> - ///
> - UINT32 Uint32;
> -} CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EAX;
> -
> -/**
> - CPUID V2 Extended Topology Enumeration Leaf EBX for CPUID leafs.
> -**/
> -typedef union {
> - ///
> - /// Individual bit fields
> - ///
> - struct {
> - ///
> - /// [Bits 15:0] Number of logical processors at this level type. The number
> - /// reflects configuration as shipped by Intel.
> - ///
> - UINT32 ProcessorsNum:16;
> - ///
> - /// [Bits 31:5] Reserved.
> - ///
> - UINT32 Reserved:16;
> - } Bits;
> - ///
> - /// All bit fields as a 32-bit value
> - ///
> - UINT32 Uint32;
> -} CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_EBX;
> + @param EAX CPUID_V2_EXTENDED_TOPOLOGY (0x1F)
> + @param ECX Level number
>
> -/**
> - CPUID V2 Extended Topology Enumeration Leaf ECX for CPUID leafs.
> **/
> -typedef union {
> - ///
> - /// Individual bit fields
> - ///
> - struct {
> - ///
> - /// [Bits 7:0] Level number. Same value in ECX input.
> - ///
> - UINT32 LevelNum:8;
> - ///
> - /// [Bits 7:0] Level type.
> - ///
> - UINT32 LevelType:8;
> -
> - ///
> - /// [Bits 31:5] Reserved.
> - ///
> - UINT32 Reserved:16;
> - } Bits;
> - ///
> - /// All bit fields as a 32-bit value
> - ///
> - UINT32 Uint32;
> -} CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX;
> +#define CPUID_V2_EXTENDED_TOPOLOGY 0x1F
>
> ///
> -/// @{ Define value for
> CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_ECX.LevelType
> +/// @{ Define value for CPUID_EXTENDED_TOPOLOGY_ECX.LevelType
> /// The value of the "level type" field is not related to level numbers in ///
> any way, higher "level type" values do not mean higher levels.
> ///
> -#define
> CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_INVALID
> 0x00
> -#define
> CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_SMT
> 0x01
> -#define
> CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_CORE
> 0x02
> -#define
> CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_MODULE
> 0x03
> -#define
> CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_TILE
> 0x04
> -#define
> CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION_LEVEL_TYPE_DIE
> 0x05
> +#define CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_MODULE
> 0x03
> +#define CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_TILE
> 0x04
> +#define CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE
> 0x05
> ///
> /// @}
> ///
> --
> 2.21.0.windows.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH v2 2/2] UefiCpuPkg/Cpuid: Dump leaf 1FH information correctly
2019-04-04 6:03 ` [PATCH v2 2/2] UefiCpuPkg/Cpuid: Dump leaf 1FH information correctly Ni, Ray
@ 2019-04-04 6:24 ` Dong, Eric
0 siblings, 0 replies; 5+ messages in thread
From: Dong, Eric @ 2019-04-04 6:24 UTC (permalink / raw)
To: devel@edk2.groups.io, Ni, Ray; +Cc: Zeng, Star, Qin, Zhiqiang
Reviewed-by: Eric Dong <eric.dong@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Ni,
> Ray
> Sent: Thursday, April 4, 2019 2:03 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric <eric.dong@intel.com>; Zeng, Star <star.zeng@intel.com>; Qin,
> Zhiqiang <zhiqiang.qin@intel.com>
> Subject: [edk2-devel] [PATCH v2 2/2] UefiCpuPkg/Cpuid: Dump leaf 1FH
> information correctly
>
> Leaf 1FH is very similar to leaf 0BH. Both return the CPU topology information.
> Leaf 0BH returns 3-level (Package/Core/Thread) CPU topology info.
> Leaf 1FH returns 6-level (Package/Die/Tile/Module/Core/Thread) CPU
> topology info.
> The logic to enumerate the topology info is the same.
>
> But today's logic to handle 1FH is completely wrong.
> The patch combines them together to fix the 1FH issue.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Zhiqiang Qin <zhiqiang.qin@intel.com>
> ---
> UefiCpuPkg/Application/Cpuid/Cpuid.c | 72 +++++++++-------------------
> 1 file changed, 23 insertions(+), 49 deletions(-)
>
> diff --git a/UefiCpuPkg/Application/Cpuid/Cpuid.c
> b/UefiCpuPkg/Application/Cpuid/Cpuid.c
> index d229ac8e7b..30d43e9631 100644
> --- a/UefiCpuPkg/Application/Cpuid/Cpuid.c
> +++ b/UefiCpuPkg/Application/Cpuid/Cpuid.c
> @@ -717,7 +717,7 @@ CpuidArchitecturalPerformanceMonitoring ( **/
> VOID CpuidExtendedTopology (
> - VOID
> + UINT32 LeafFunction
> )
> {
> CPUID_EXTENDED_TOPOLOGY_EAX Eax;
> @@ -726,27 +726,34 @@ CpuidExtendedTopology (
> UINT32 Edx;
> UINT32 LevelNumber;
>
> - if (CPUID_EXTENDED_TOPOLOGY > gMaximumBasicFunction) {
> + if (LeafFunction > gMaximumBasicFunction) {
> + return;
> + }
> + if ((LeafFunction != CPUID_EXTENDED_TOPOLOGY) && (LeafFunction !=
> + CPUID_V2_EXTENDED_TOPOLOGY)) {
> return;
> }
>
> LevelNumber = 0;
> - do {
> + for (LevelNumber = 0; ; LevelNumber++) {
> AsmCpuidEx (
> - CPUID_EXTENDED_TOPOLOGY, LevelNumber,
> + LeafFunction, LevelNumber,
> &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx
> );
> - if (Eax.Bits.ApicIdShift != 0) {
> - Print (L"CPUID_EXTENDED_TOPOLOGY (Leaf %08x, Sub-Leaf %08x)\n",
> CPUID_EXTENDED_TOPOLOGY, LevelNumber);
> - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32,
> Ebx.Uint32, Ecx.Uint32, Edx);
> - PRINT_BIT_FIELD (Eax, ApicIdShift);
> - PRINT_BIT_FIELD (Ebx, LogicalProcessors);
> - PRINT_BIT_FIELD (Ecx, LevelNumber);
> - PRINT_BIT_FIELD (Ecx, LevelType);
> - PRINT_VALUE (Edx, x2APIC_ID);
> + if (Ecx.Bits.LevelType ==
> CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID) {
> + break;
> }
> - LevelNumber++;
> - } while (Eax.Bits.ApicIdShift != 0);
> + Print (
> + L"%a (Leaf %08x, Sub-Leaf %08x)\n",
> + LeafFunction == CPUID_EXTENDED_TOPOLOGY ?
> "CPUID_EXTENDED_TOPOLOGY" : "CPUID_V2_EXTENDED_TOPOLOGY",
> + LeafFunction, LevelNumber
> + );
> + Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32,
> Ebx.Uint32, Ecx.Uint32, Edx);
> + PRINT_BIT_FIELD (Eax, ApicIdShift);
> + PRINT_BIT_FIELD (Ebx, LogicalProcessors);
> + PRINT_BIT_FIELD (Ecx, LevelNumber);
> + PRINT_BIT_FIELD (Ecx, LevelType);
> + PRINT_VALUE (Edx, x2APIC_ID);
> + }
> }
>
> /**
> @@ -1385,39 +1392,6 @@ CpuidDeterministicAddressTranslationParameters
> (
> PRINT_BIT_FIELD (Edx, MaximumNum);
> }
>
> -/**
> - Display CPUID_V2_EXTENDED_TOPOLOGY_ENUMERATION main leaf and
> sub-leafs.
> -
> -**/
> -VOID
> -CpuidV2ExtendedTopologyEnumeration (
> - VOID
> - )
> -{
> - CPUID_EXTENDED_TOPOLOGY_EAX Eax;
> - CPUID_EXTENDED_TOPOLOGY_EBX Ebx;
> - CPUID_EXTENDED_TOPOLOGY_ECX Ecx;
> - UINT32 Edx;
> -
> - if (CPUID_V2_EXTENDED_TOPOLOGY > gMaximumBasicFunction) {
> - return;
> - }
> -
> - AsmCpuidEx (
> - CPUID_V2_EXTENDED_TOPOLOGY,
> - 0,
> - &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx
> - );
> - Print (L"CPUID_V2_EXTENDED_TOPOLOGY (Leaf %08x, Sub-Leaf %08x)\n",
> CPUID_V2_EXTENDED_TOPOLOGY, 0);
> - Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32,
> Ebx.Uint32, Ecx.Uint32, Edx);
> -
> - PRINT_BIT_FIELD (Eax, ApicIdShift);
> - PRINT_BIT_FIELD (Ebx, LogicalProcessors);
> - PRINT_BIT_FIELD (Ecx, LevelNumber);
> - PRINT_BIT_FIELD (Ecx, LevelType);
> - PRINT_VALUE (Edx, x2APICID);
> -}
> -
> /**
> Display CPUID_EXTENDED_FUNCTION leaf.
>
> @@ -1619,7 +1593,7 @@ UefiMain (
> CpuidStructuredExtendedFeatureFlags ();
> CpuidDirectCacheAccessInfo();
> CpuidArchitecturalPerformanceMonitoring ();
> - CpuidExtendedTopology ();
> + CpuidExtendedTopology (CPUID_EXTENDED_TOPOLOGY);
> CpuidExtendedStateMainLeaf ();
> CpuidIntelRdtMonitoringEnumerationSubLeaf ();
> CpuidIntelRdtMonitoringL3CacheCapabilitySubLeaf (); @@ -1630,7 +1604,7
> @@ UefiMain (
> CpuidProcessorFrequency ();
> CpuidSocVendor ();
> CpuidDeterministicAddressTranslationParameters ();
> - CpuidV2ExtendedTopologyEnumeration ();
> + CpuidExtendedTopology (CPUID_V2_EXTENDED_TOPOLOGY);
> CpuidExtendedFunction ();
> CpuidExtendedCpuSig ();
> CpuidProcessorBrandString ();
> --
> 2.21.0.windows.1
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-04-04 6:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-04 6:03 [PATCH v2 0/2] Dump CPUID.1FH information correctly Ni, Ray
2019-04-04 6:03 ` [PATCH v2 1/2] UefiCpuPkg/Cpuid.h: Remove duplicated struct definition for leaf 1FH Ni, Ray
2019-04-04 6:23 ` eric.dong
2019-04-04 6:03 ` [PATCH v2 2/2] UefiCpuPkg/Cpuid: Dump leaf 1FH information correctly Ni, Ray
2019-04-04 6:24 ` [edk2-devel] " Dong, Eric
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox