Jiewen, Please take a look at this patch.
Regards, Jian > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jian J > Wang > Sent: Friday, December 29, 2017 4:37 PM > To: edk2-devel@lists.01.org > Cc: Laszlo Ersek <ler...@redhat.com>; Yao, Jiewen <jiewen....@intel.com>; > Dong, Eric <eric.d...@intel.com> > Subject: [edk2] [PATCH] UefiCpuPkg/MpInitLib: fix wrong base address set as > Stack Guard > > 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....@intel.com> > Cc: Eric Dong <eric.d...@intel.com> > Cc: Laszlo Ersek <ler...@redhat.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jian J Wang <jian.j.w...@intel.com> > --- > UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > index 40c1bf407a..05484c9ff3 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,9 +315,18 @@ InitMpGlobalData ( > ASSERT (FALSE); > } > > - for (Index = 0; Index < CpuMpData->CpuCount; ++Index) { > - StackBase = CpuMpData->Buffer + Index * CpuMpData->CpuApStackSize; > + // > + // DXE will reuse stack allocated for APs at PEI phase if it's available. > + // Let's check it here. > + // > + CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob; > + if (CpuInfoInHob != NULL && CpuInfoInHob->ApTopOfStack != 0) { > + StackBase = CpuInfoInHob->ApTopOfStack; > + } else { > + StackBase = CpuMpData->Buffer; > + } > > + for (Index = 0; Index < CpuMpData->CpuCount; ++Index) { > Status = gDS->GetMemorySpaceDescriptor (StackBase, &MemDesc); > ASSERT_EFI_ERROR (Status); > > @@ -326,6 +336,9 @@ InitMpGlobalData ( > MemDesc.Attributes | EFI_MEMORY_RP > ); > ASSERT_EFI_ERROR (Status); > + > + DEBUG ((DEBUG_VERBOSE, "Stack Guard set at %x [cpu%d]!\n", StackBase, > Index)); > + StackBase += CpuMpData->CpuApStackSize; > } > } > > -- > 2.15.1.windows.2 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel