Skip to content

Commit

Permalink
[CHERRY-PICK] UefiCpuPkg/MpInitLib: Use AsmCpuidEx() for CPUID_EXTEND…
Browse files Browse the repository at this point in the history
…ED_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: d4d7c9a ("UefiCpuPkg/MpInitLib: use BSP to do extended ...")
Signed-off-by: Tom Lendacky <[email protected]>
Reviewed-by: Ray Ni <[email protected]>
  • Loading branch information
tlendacky authored and kenlautner committed May 21, 2024
1 parent 94c9ad0 commit 20f68f4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion UefiCpuPkg/Library/MpInitLib/AmdSev.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,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;
}
}
Expand Down

0 comments on commit 20f68f4

Please sign in to comment.