summaryrefslogtreecommitdiff
path: root/UefiCpuPkg/Library
diff options
context:
space:
mode:
authorJian J Wang <jian.j.wang@intel.com>2018-09-03 10:47:54 +0800
committerJian J Wang <jian.j.wang@intel.com>2018-09-10 09:28:27 +0800
commite09b6b5953db38db87b84c80a2e95a82a1c91020 (patch)
tree62cac89b1d5da9661dddb41dcc6d73ce5972eaec /UefiCpuPkg/Library
parentfc0e7fd5e8aad193fcc3479634d5c69996f6460a (diff)
downloadedk2-e09b6b5953db38db87b84c80a2e95a82a1c91020.zip
edk2-e09b6b5953db38db87b84c80a2e95a82a1c91020.tar.gz
edk2-e09b6b5953db38db87b84c80a2e95a82a1c91020.tar.bz2
UefiCpuPkg/MpInitLib: fix register restore issue in AP wakeup
The conflict issues are introduced by Stack Guard feature enabled for PEI. The first is CR0 which should be restored after CR3 and CR4. Another is TR which should not be passed from BSP to AP during init phase. Cc: Eric Dong <eric.dong@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: "Ware, Ryan R" <ryan.r.ware@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Dong <eric.dong@intel.com>
Diffstat (limited to 'UefiCpuPkg/Library')
-rw-r--r--UefiCpuPkg/Library/MpInitLib/MpLib.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 5c562d4..85ca4a2 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -217,9 +217,9 @@ RestoreVolatileRegisters (
CPUID_VERSION_INFO_EDX VersionInfoEdx;
IA32_TSS_DESCRIPTOR *Tss;
- AsmWriteCr0 (VolatileRegisters->Cr0);
AsmWriteCr3 (VolatileRegisters->Cr3);
AsmWriteCr4 (VolatileRegisters->Cr4);
+ AsmWriteCr0 (VolatileRegisters->Cr0);
if (IsRestoreDr) {
AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32);
@@ -1558,7 +1558,7 @@ MpInitLibInitialize (
ApLoopMode = GetApLoopMode (&MonitorFilterSize);
//
- // Save BSP's Control registers for APs
+ // Save BSP's Control registers for APs.
//
SaveVolatileRegisters (&VolatileRegisters);
@@ -1656,6 +1656,10 @@ MpInitLibInitialize (
//
CopyMem ((VOID *)ApIdtBase, (VOID *)VolatileRegisters.Idtr.Base, VolatileRegisters.Idtr.Limit + 1);
VolatileRegisters.Idtr.Base = ApIdtBase;
+ //
+ // Don't pass BSP's TR to APs to avoid AP init failure.
+ //
+ VolatileRegisters.Tr = 0;
CopyMem (&CpuMpData->CpuData[0].VolatileRegisters, &VolatileRegisters, sizeof (VolatileRegisters));
//
// Set BSP basic information