From 171e515c6daaa9a06c0d0ffc7d2a4de0c48b2fe3 Mon Sep 17 00:00:00 2001 From: Ken Lautner Date: Wed, 5 Jun 2024 16:56:23 -0700 Subject: [PATCH 1/4] Changed CpuDeadLoops to panic calls --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 3c5751006d..41f1e0317b 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -1153,7 +1153,7 @@ PiCpuSmmEntry ( Status = GetSmBase (mMaxNumberOfCpus, &mCpuHotPlugData.SmBase); if (Status == EFI_OUT_OF_RESOURCES) { ASSERT (Status != EFI_OUT_OF_RESOURCES); - CpuDeadLoop (); + PANIC ("Not enough space for mCpuHotPlugData.SmBase"); } if (!EFI_ERROR (Status)) { @@ -1165,7 +1165,7 @@ PiCpuSmmEntry ( DEBUG ((DEBUG_ERROR, "The Range of Smbase in SMRAM is not enough -- Required TileSize = 0x%08x, Actual TileSize = 0x%08x\n", TileSize, SIZE_8KB)); FreePool (mCpuHotPlugData.SmBase); FreePool (gSmmCpuPrivate->ProcessorInfo); - CpuDeadLoop (); + PANIC ("TileSize larger than 8KB"); return RETURN_BUFFER_TOO_SMALL; } @@ -1181,7 +1181,7 @@ PiCpuSmmEntry ( mCpuHotPlugData.SmBase = (UINTN *)AllocatePool (sizeof (UINTN) * mMaxNumberOfCpus); if (mCpuHotPlugData.SmBase == NULL) { ASSERT (mCpuHotPlugData.SmBase != NULL); - CpuDeadLoop (); + PANIC ("mCpuHotPlugData.SmBase is NULL"); } // @@ -1195,7 +1195,7 @@ PiCpuSmmEntry ( Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB); if (Buffer == NULL) { DEBUG ((DEBUG_ERROR, "Failed to allocate %Lu pages.\n", (UINT64)BufferPages)); - CpuDeadLoop (); + PANIC ("Failed to allocate buffer for all the tiles"); return EFI_OUT_OF_RESOURCES; } From 8735b1ada884ba84ecfe873fa1524ff8273765b0 Mon Sep 17 00:00:00 2001 From: Ken Lautner Date: Wed, 5 Jun 2024 17:08:43 -0700 Subject: [PATCH 2/4] Added MU_CHANGE comments --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 8 ++++---- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 41f1e0317b..47eb8083d5 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -1153,7 +1153,7 @@ PiCpuSmmEntry ( Status = GetSmBase (mMaxNumberOfCpus, &mCpuHotPlugData.SmBase); if (Status == EFI_OUT_OF_RESOURCES) { ASSERT (Status != EFI_OUT_OF_RESOURCES); - PANIC ("Not enough space for mCpuHotPlugData.SmBase"); + PANIC ("Not enough space for mCpuHotPlugData.SmBase"); // MU_CHANGE } if (!EFI_ERROR (Status)) { @@ -1165,7 +1165,7 @@ PiCpuSmmEntry ( DEBUG ((DEBUG_ERROR, "The Range of Smbase in SMRAM is not enough -- Required TileSize = 0x%08x, Actual TileSize = 0x%08x\n", TileSize, SIZE_8KB)); FreePool (mCpuHotPlugData.SmBase); FreePool (gSmmCpuPrivate->ProcessorInfo); - PANIC ("TileSize larger than 8KB"); + PANIC ("TileSize larger than 8KB"); // MU_CHANGE return RETURN_BUFFER_TOO_SMALL; } @@ -1181,7 +1181,7 @@ PiCpuSmmEntry ( mCpuHotPlugData.SmBase = (UINTN *)AllocatePool (sizeof (UINTN) * mMaxNumberOfCpus); if (mCpuHotPlugData.SmBase == NULL) { ASSERT (mCpuHotPlugData.SmBase != NULL); - PANIC ("mCpuHotPlugData.SmBase is NULL"); + PANIC ("mCpuHotPlugData.SmBase is NULL"); // MU_CHANGE } // @@ -1195,7 +1195,7 @@ PiCpuSmmEntry ( Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB); if (Buffer == NULL) { DEBUG ((DEBUG_ERROR, "Failed to allocate %Lu pages.\n", (UINT64)BufferPages)); - PANIC ("Failed to allocate buffer for all the tiles"); + PANIC ("Failed to allocate buffer for all the tiles"); // MU_CHANGE return EFI_OUT_OF_RESOURCES; } diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h index f5e27bdc09..62b0675f34 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -56,6 +56,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include // MU_CHANGE #include #include From a707875d5769e9e4480e014a6c29b1ed0351ef73 Mon Sep 17 00:00:00 2001 From: Ken Lautner Date: Mon, 17 Jun 2024 14:25:37 -0700 Subject: [PATCH 3/4] Switched one more Deadloop with a Panic call --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 47eb8083d5..b15afb2a20 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -704,7 +704,7 @@ GetSmBase ( ASSERT (NumberOfProcessors == MaxNumberOfCpus); if (NumberOfProcessors != MaxNumberOfCpus) { - CpuDeadLoop (); + PANIC ("Incorrect number of processors!"); // MU_CHANGE } SmBaseHobs = AllocatePool (sizeof (SMM_BASE_HOB_DATA *) * HobCount); From 19826b6d2ee5c0093d75eb93dcb7f9472dfb5e9b Mon Sep 17 00:00:00 2001 From: Ken Lautner Date: Mon, 17 Jun 2024 19:00:05 -0700 Subject: [PATCH 4/4] Added PanicLib to the .inf --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 1 + 1 file changed, 1 insertion(+) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf index f95024d66a..a09e52beba 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf @@ -106,6 +106,7 @@ MmSaveStateLib MmMemoryProtectionHobLib ## MU_CHANGE SmmCpuSyncLib + PanicLib ## MU_CHANGE [Protocols] gEfiSmmAccess2ProtocolGuid ## CONSUMES