diff options
author | Jian J Wang <jian.j.wang@intel.com> | 2018-01-08 13:30:38 +0800 |
---|---|---|
committer | Eric Dong <eric.dong@intel.com> | 2018-01-10 08:25:12 +0800 |
commit | 523152618d20a58c9ad55203fa6e5b8bebe938f0 (patch) | |
tree | e980a672e0ba41850ef93aaf1bdecbe23a1a53af | |
parent | f2655dcf28c4dbece5bdf6433a2624e68ea7aeb4 (diff) | |
download | edk2-523152618d20a58c9ad55203fa6e5b8bebe938f0.tar.gz edk2-523152618d20a58c9ad55203fa6e5b8bebe938f0.tar.bz2 edk2-523152618d20a58c9ad55203fa6e5b8bebe938f0.zip |
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>
-rw-r--r-- | UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c index 40c1bf407a..e832c16eca 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));
}
}
|