edk2/0023-UefiCpuPkg-BaseXApicX2ApicLib-fix-CPUID_V2_EXTENDED_.patch
2023-10-11 10:34:03 +02:00

53 lines
2.1 KiB
Diff

From 35c6cfd69232e8eb271a48c9c0b2ad4ffe05978e Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 11 Oct 2023 10:20:41 +0200
Subject: [PATCH 23/23] UefiCpuPkg/BaseXApicX2ApicLib: fix
CPUID_V2_EXTENDED_TOPOLOGY detection
Checking the max cpuid leaf is not enough to figure whenever
CPUID_V2_EXTENDED_TOPOLOGY is supported. Quoting a comment for
CPUID_EXTENDED_TOPOLOGY in GetProcessorLocationByApicId():
// If CPUID.(EAX=0BH, ECX=0H):EBX returns zero and maximum input value for
// basic CPUID information is greater than 0BH, then CPUID.0BH leaf is not
// supported on that processor.
Add a similar check for CPUID_V2_EXTENDED_TOPOLOGY to
GetProcessorLocation2ByApicId(). Without this fix OVMF triggers
an ASSERT when running in a kvm guest on latest (12th gen) intel
processors.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2241388
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
index b27fbd71b620..716e60352645 100644
--- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
@@ -1431,6 +1431,7 @@ GetProcessorLocation2ByApicId (
)
{
CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax;
+ CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx;
CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx;
UINT32 MaxStandardCpuIdIndex;
UINT32 Index;
@@ -1447,6 +1448,11 @@ GetProcessorLocation2ByApicId (
//
AsmCpuid (CPUID_SIGNATURE, &MaxStandardCpuIdIndex, NULL, NULL, NULL);
if (MaxStandardCpuIdIndex < CPUID_V2_EXTENDED_TOPOLOGY) {
+ ExtendedTopologyEbx.Uint32 = 0;
+ } else {
+ AsmCpuidEx (CPUID_V2_EXTENDED_TOPOLOGY, 0, NULL, &ExtendedTopologyEbx.Uint32, NULL, NULL);
+ }
+ if (ExtendedTopologyEbx.Uint32 == 0) {
if (Die != NULL) {
*Die = 0;
}
--
2.41.0