MdeModulePkg/DxeCore: Separate BSP exception stack only for stack guard

Commit cec2c6bbccf7 ("MdeModulePkg: Always Initialize Separate Exception
Stacks") made DxeMain() call InitializeSeparateExceptionStacks()
regardless of PcdCpuStackGuard. This only ever runs on the BSP, and it
loads TR.

This cannot be undone: LTR does not accept a NULL selector, and so the
BSP will hand over control to the OS loader with a non-NULL TR. This
breaks the Windows Server 2016 hypervisor, which is launched by winload
when Credential Guard or virtualization based security is enabled: the
system gets stuck in a reset loop as soon as winload transfers control
to the hypervisor.

So restore the PcdCpuStackGuard check, so that platforms that do not
enable stack guard hand over control to the OS loader with TR in its
reset state, as they did before. This complements the corresponding
change to CpuMpPei and CpuDxe, which load TR on the BSP as well.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 file changed