The CPUID_EXTENDED_TOPOLOGY CPUID leaf takes a subleaf as input when
returning CPUID information. However, the AsmCpuid() function does not
zero out ECX before the CPUID instruction, so the input leaf is used as
the sub-leaf for the CPUID request and returns erroneous/invalid CPUID
data, since the intent of the request was to get data related to sub-leaf
0. Instead, use AsmCpuidEx() for the CPUID_EXTENDED_TOPOLOGY leaf.
Fixes: d4d7c9ad5fe5 ("UefiCpuPkg/MpInitLib: use BSP to do extended ...")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
UefiCpuPkg/Library/MpInitLib/AmdSev.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/UefiCpuPkg/Library/MpInitLib/AmdSev.c b/UefiCpuPkg/Library/MpInitLib/AmdSev.c
index bda4960f6fd3..d34f9513e002 100644
--- a/UefiCpuPkg/Library/MpInitLib/AmdSev.c
+++ b/UefiCpuPkg/Library/MpInitLib/AmdSev.c
@@ -256,7 +256,14 @@ FillExchangeInfoDataSevEs (
if (StdRangeMax >= CPUID_EXTENDED_TOPOLOGY) {
CPUID_EXTENDED_TOPOLOGY_EBX ExtTopoEbx;
- AsmCpuid (CPUID_EXTENDED_TOPOLOGY, NULL, &ExtTopoEbx.Uint32, NULL, NULL);
+ AsmCpuidEx (
+ CPUID_EXTENDED_TOPOLOGY,
+ 0,
+ NULL,
+ &ExtTopoEbx.Uint32,
+ NULL,
+ NULL
+ );
ExchangeInfo->ExtTopoAvail = !!ExtTopoEbx.Bits.LogicalProcessors;
}
}
--
2.42.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110767): https://edk2.groups.io/g/devel/message/110767
Mute This Topic: https://groups.io/mt/102432043/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: Ray Ni <ray.ni@intel.com>
Thanks,
Ray
> -----Original Message-----
> From: Tom Lendacky <thomas.lendacky@amd.com>
> Sent: Tuesday, November 7, 2023 6:46 AM
> To: devel@edk2.groups.io
> Cc: Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Kumar,
> Rahul R <rahul.r.kumar@intel.com>; Gerd Hoffmann <kraxel@redhat.com>;
> Ard Biesheuvel <ardb+tianocore@kernel.org>; Michael Roth
> <michael.roth@amd.com>
> Subject: [PATCH 1/2] UefiCpuPkg/MpInitLib: Use AsmCpuidEx() for
> CPUID_EXTENDED_TOPOLOGY leaf
>
> The CPUID_EXTENDED_TOPOLOGY CPUID leaf takes a subleaf as input when
> returning CPUID information. However, the AsmCpuid() function does not
> zero out ECX before the CPUID instruction, so the input leaf is used as
> the sub-leaf for the CPUID request and returns erroneous/invalid CPUID
> data, since the intent of the request was to get data related to sub-leaf
> 0. Instead, use AsmCpuidEx() for the CPUID_EXTENDED_TOPOLOGY leaf.
>
> Fixes: d4d7c9ad5fe5 ("UefiCpuPkg/MpInitLib: use BSP to do extended ...")
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> UefiCpuPkg/Library/MpInitLib/AmdSev.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/UefiCpuPkg/Library/MpInitLib/AmdSev.c
> b/UefiCpuPkg/Library/MpInitLib/AmdSev.c
> index bda4960f6fd3..d34f9513e002 100644
> --- a/UefiCpuPkg/Library/MpInitLib/AmdSev.c
> +++ b/UefiCpuPkg/Library/MpInitLib/AmdSev.c
> @@ -256,7 +256,14 @@ FillExchangeInfoDataSevEs (
> if (StdRangeMax >= CPUID_EXTENDED_TOPOLOGY) {
> CPUID_EXTENDED_TOPOLOGY_EBX ExtTopoEbx;
>
> - AsmCpuid (CPUID_EXTENDED_TOPOLOGY, NULL, &ExtTopoEbx.Uint32,
> NULL, NULL);
> + AsmCpuidEx (
> + CPUID_EXTENDED_TOPOLOGY,
> + 0,
> + NULL,
> + &ExtTopoEbx.Uint32,
> + NULL,
> + NULL
> + );
> ExchangeInfo->ExtTopoAvail = !!ExtTopoEbx.Bits.LogicalProcessors;
> }
> }
> --
> 2.42.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111805): https://edk2.groups.io/g/devel/message/111805
Mute This Topic: https://groups.io/mt/102432043/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2026 Red Hat, Inc.