summaryrefslogtreecommitdiff
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorJian J Wang <jian.j.wang@intel.com>2018-01-08 13:30:38 +0800
committerEric Dong <eric.dong@intel.com>2018-01-10 08:25:12 +0800
commit523152618d20a58c9ad55203fa6e5b8bebe938f0 (patch)
treee980a672e0ba41850ef93aaf1bdecbe23a1a53af /UefiCpuPkg
parentf2655dcf28c4dbece5bdf6433a2624e68ea7aeb4 (diff)
downloadedk2-523152618d20a58c9ad55203fa6e5b8bebe938f0.zip
edk2-523152618d20a58c9ad55203fa6e5b8bebe938f0.tar.gz
edk2-523152618d20a58c9ad55203fa6e5b8bebe938f0.tar.bz2
UefiCpuPkg/MpInitLib: fix wrong address set as Stack Guard for APs
The reason is that DXE part initialization will reuse the stack allocated at PEI phase, if MP was initialized before. Some code added to check this situation and use stack base address saved in HOB passed from PEI. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Dong <eric.dong@intel.com>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/Library/MpInitLib/DxeMpLib.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 40c1bf4..e832c16 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -295,6 +295,7 @@ InitMpGlobalData (
UINTN Index;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc;
UINTN StackBase;
+ CPU_INFO_IN_HOB *CpuInfoInHob;
SaveCpuMpData (CpuMpData);
@@ -314,8 +315,21 @@ InitMpGlobalData (
ASSERT (FALSE);
}
+ //
+ // DXE will reuse stack allocated for APs at PEI phase if it's available.
+ // Let's check it here.
+ //
+ // Note: BSP's stack guard is set at DxeIpl phase. But for the sake of
+ // BSP/AP exchange, stack guard for ApTopOfStack of cpu 0 will still be
+ // set here.
+ //
+ CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
for (Index = 0; Index < CpuMpData->CpuCount; ++Index) {
- StackBase = CpuMpData->Buffer + Index * CpuMpData->CpuApStackSize;
+ if (CpuInfoInHob != NULL && CpuInfoInHob[Index].ApTopOfStack != 0) {
+ StackBase = CpuInfoInHob[Index].ApTopOfStack - CpuMpData->CpuApStackSize;
+ } else {
+ StackBase = CpuMpData->Buffer + Index * CpuMpData->CpuApStackSize;
+ }
Status = gDS->GetMemorySpaceDescriptor (StackBase, &MemDesc);
ASSERT_EFI_ERROR (Status);
@@ -326,6 +340,9 @@ InitMpGlobalData (
MemDesc.Attributes | EFI_MEMORY_RP
);
ASSERT_EFI_ERROR (Status);
+
+ DEBUG ((DEBUG_INFO, "Stack Guard set at %lx [cpu%lu]!\n",
+ (UINT64)StackBase, (UINT64)Index));
}
}