UefiCpuPkg: Gate AP exception stacks on PcdCpuStackGuard

Commit e67f405713 ("UefiCpuPkg/CpuDxe: Initialize stack switch for MP")
always runs InitializeMpExceptionStackSwitchHandlers(), which copies the
current GDT, appends a TSS, and reloads GDTR/TR via ArchSetupExceptionStack().

Platforms with PcdCpuStackGuard set to FALSE (including UefiPayloadPkg
defaults) do not enable stack guard and should not rewrite the GDT during
CpuDxe MP init. On payload platforms this unconditional path faults during
early CpuDxe and can cause repeated resets before DXE finishes loading.

Restore gating on PcdCpuStackGuard in CpuDxe and CpuMpPei, and consume
the PCD again from CpuDxe.inf.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
Matt DeVillier 2026-08-05 16:04:05 -05:00
parent d98a39d4ce
commit 2f11273007
3 changed files with 8 additions and 1 deletions

View file

@ -89,6 +89,7 @@
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask ## CONSUMES

View file

@ -763,7 +763,9 @@ InitializeMpExceptionHandlers (
//
// Setup stack switch for Stack Guard feature and separate AP GDTs.
//
InitializeMpExceptionStackSwitchHandlers ();
if (PcdGetBool (PcdCpuStackGuard)) {
InitializeMpExceptionStackSwitchHandlers ();
}
}
/**

View file

@ -89,6 +89,10 @@ InitializeMpExceptionStackSwitchHandlers (
EFI_STATUS Status;
UINT8 *Buffer;
if (!PcdGetBool (PcdCpuStackGuard)) {
return;
}
Status = MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL);
ASSERT_EFI_ERROR (Status);