update debug patch, add proper fix for bz2241388

This commit is contained in:
Gerd Hoffmann 2023-10-11 10:34:03 +02:00
parent cfa1bfa2a7
commit 0441730028
4 changed files with 126 additions and 77 deletions

View File

@ -0,0 +1,72 @@
From 25c2ee86021a5080c6b4c156a89469ab21e4f7e3 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Tue, 10 Oct 2023 12:54:58 +0200
Subject: [PATCH 22/23] [debug] add logging for cpuid topology
https://bugzilla.redhat.com/show_bug.cgi?id=2241388
---
.../BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
index aa4eb11181f6..b27fbd71b620 100644
--- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
@@ -1264,6 +1264,7 @@ GetProcessorLocationByApicId (
*Package = 0;
}
+ DEBUG ((DEBUG_INFO, "%a: no hyperthreading\n", __func__));
return;
}
@@ -1300,6 +1301,7 @@ GetProcessorLocationByApicId (
//
if (ExtendedTopologyEbx.Uint32 != 0) {
TopologyLeafSupported = TRUE;
+ DEBUG ((DEBUG_INFO, "%a: ExtendedTopology, v1\n", __func__));
//
// Sub-leaf index 0 (ECX= 0 as input) provides enumeration parameters to extract
@@ -1393,6 +1395,11 @@ GetProcessorLocationByApicId (
if (Package != NULL) {
*Package = (InitialApicId >> (ThreadBits + CoreBits));
}
+
+ if (*Thread && *Core && *Package) {
+ DEBUG ((DEBUG_INFO, "%a: apic id %d -> package %d / core %d / thread %d\n",
+ __func__, InitialApicId, *Package, *Core, *Thread));
+ }
}
/**
@@ -1460,6 +1467,7 @@ GetProcessorLocation2ByApicId (
// If the V2 extended topology enumeration leaf is available, it
// is the preferred mechanism for enumerating topology.
//
+ DEBUG ((DEBUG_INFO, "%a: ExtendedTopology, v2\n", __func__));
for (Index = 0; ; Index++) {
AsmCpuidEx (
CPUID_V2_EXTENDED_TOPOLOGY,
@@ -1471,6 +1479,9 @@ GetProcessorLocation2ByApicId (
);
LevelType = ExtendedTopologyEcx.Bits.LevelType;
+ DEBUG ((DEBUG_INFO, "%a: %d: type %x, shift %x\n", __func__, Index,
+ ExtendedTopologyEcx.Bits.LevelType,
+ ExtendedTopologyEax.Bits.ApicIdShift));
//
// first level reported should be SMT.
@@ -1521,4 +1532,8 @@ GetProcessorLocation2ByApicId (
*Location[LevelType] &= (1 << (Bits[LevelType] - Bits[LevelType - 1])) - 1;
}
}
+ if (*Thread && *Core && *Module && *Tile && *Die && *Package) {
+ DEBUG ((DEBUG_INFO, "%a: apic id %d -> package %d / die %d / tile %d / module &d / core %d / thread %d\n",
+ __func__, InitialApicId, *Package, *Die, *Tile, *Module, *Core, *Thread));
+ }
}
--
2.41.0

View File

@ -1,76 +0,0 @@
From bb0be5e283a5c995990846b6dad998ba1de235f2 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Tue, 10 Oct 2023 12:54:58 +0200
Subject: [PATCH 22/22] [debug] add logging, try handle extended topology v2
failure
https://bugzilla.redhat.com/show_bug.cgi?id=2241388
---
.../Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
index aa4eb11181f6..1867c3e236a8 100644
--- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
@@ -1264,6 +1264,7 @@ GetProcessorLocationByApicId (
*Package = 0;
}
+ DEBUG ((DEBUG_INFO, "%a: no SMP\n", __func__));
return;
}
@@ -1300,6 +1301,7 @@ GetProcessorLocationByApicId (
//
if (ExtendedTopologyEbx.Uint32 != 0) {
TopologyLeafSupported = TRUE;
+ DEBUG ((DEBUG_INFO, "%a: ExtendedTopology, v1\n", __func__));
//
// Sub-leaf index 0 (ECX= 0 as input) provides enumeration parameters to extract
@@ -1351,6 +1353,7 @@ GetProcessorLocationByApicId (
//
if (StandardSignatureIsAuthenticAMD ()) {
if (MaxExtendedCpuIdIndex >= CPUID_AMD_PROCESSOR_TOPOLOGY) {
+ DEBUG ((DEBUG_INFO, "%a: AMD Topology\n", __func__));
AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, &AmdExtendedCpuSigEcx.Uint32, NULL);
if (AmdExtendedCpuSigEcx.Bits.TopologyExtensions != 0) {
//
@@ -1440,6 +1443,7 @@ GetProcessorLocation2ByApicId (
//
AsmCpuid (CPUID_SIGNATURE, &MaxStandardCpuIdIndex, NULL, NULL, NULL);
if (MaxStandardCpuIdIndex < CPUID_V2_EXTENDED_TOPOLOGY) {
+ fallback_v1:
if (Die != NULL) {
*Die = 0;
}
@@ -1460,6 +1464,7 @@ GetProcessorLocation2ByApicId (
// If the V2 extended topology enumeration leaf is available, it
// is the preferred mechanism for enumerating topology.
//
+ DEBUG ((DEBUG_INFO, "%a: ExtendedTopology, v2\n", __func__));
for (Index = 0; ; Index++) {
AsmCpuidEx (
CPUID_V2_EXTENDED_TOPOLOGY,
@@ -1471,10 +1476,17 @@ GetProcessorLocation2ByApicId (
);
LevelType = ExtendedTopologyEcx.Bits.LevelType;
+ DEBUG ((DEBUG_INFO, "%a: %d: type %x, shift %x\n", __func__, Index,
+ ExtendedTopologyEcx.Bits.LevelType,
+ ExtendedTopologyEax.Bits.ApicIdShift));
//
// first level reported should be SMT.
//
+ if (!((Index != 0) || (LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT))) {
+ DEBUG ((DEBUG_INFO, "%a: ASSERT hack\n", __func__));
+ goto fallback_v1;
+ }
ASSERT ((Index != 0) || (LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_SMT));
if (LevelType == CPUID_EXTENDED_TOPOLOGY_LEVEL_TYPE_INVALID) {
break;
--
2.41.0

View File

@ -0,0 +1,52 @@
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

View File

@ -117,7 +117,8 @@ Patch0018: 0018-OvmfPkg-Disable-PcdFirstTimeWakeUpAPsBySipi.patch
Patch0019: 0019-OvmfPkg-AmdSev-Disable-PcdFirstTimeWakeUpAPsBySipi.patch
Patch0020: 0020-OvmfPkg-AmdSev-fix-BdsPlatform.c-assertion-failure-d.patch
Patch0021: 0021-OvmfPkg-set-PcdVariableStoreSize-PcdMaxVolatileVaria.patch
Patch0022: 0022-debug-add-logging-try-handle-extended-topology-v2-fa.patch
Patch0022: 0022-debug-add-logging-for-cpuid-topology.patch
Patch0023: 0023-UefiCpuPkg-BaseXApicX2ApicLib-fix-CPUID_V2_EXTENDED_.patch
# python3-devel and libuuid-devel are required for building tools.