From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.1141.1610630019135029854 for ; Thu, 14 Jan 2021 05:13:39 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: ray.ni@intel.com) IronPort-SDR: tkas2HOTGKddG8U7Kw1AqnDeqMKfh/Lk+rSnog3z+kOZYIPicynQt1e5nbNVFUmQ3X/67xoRoD ftU3DcV9wLrA== X-IronPort-AV: E=McAfee;i="6000,8403,9863"; a="197013741" X-IronPort-AV: E=Sophos;i="5.79,347,1602572400"; d="scan'208";a="197013741" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2021 05:13:37 -0800 IronPort-SDR: CObhj41mEqWXtsjVzNI4+OXQ3+DWKaDvda4zq7zY5E7ZTxUo4dcFsWXEJfyyBRz9wc67FEKLCV 0gPVVZvwbpmA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,347,1602572400"; d="scan'208";a="353895260" Received: from ray-dev.ccr.corp.intel.com ([10.239.158.87]) by fmsmga008.fm.intel.com with ESMTP; 14 Jan 2021 05:13:36 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Laszlo Ersek , Rahul Kumar Subject: [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu Date: Thu, 14 Jan 2021 21:12:00 +0800 Message-Id: <20210114131200.1659-1-ray.ni@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable When StackGuard is enabled, the CpuMp driver allocates known good stacks for all CPUs for DF# and PF# exceptions. It uses AllocatePool to do so. The size needed equals to 64KB =3D StackSize (2K) * ExceptionNumber (2) * NumberOfProcessors (16) However, AllocatePool max allocation size is less than 64K. To fix the issue, AllocatePages() is used. Signed-off-by: Ray Ni Cc: Eric Dong Cc: Laszlo Ersek Cc: Rahul Kumar --- UefiCpuPkg/CpuMpPei/CpuMpPei.c | 10 +++------- UefiCpuPkg/CpuMpPei/CpuMpPei.h | 3 ++- UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 3 ++- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index d07540cf74..40729a09b9 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -1,7 +1,7 @@ /** @file=0D CPU PEI Module installs CPU Multiple Processor PPI.=0D =0D - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -532,13 +532,9 @@ InitializeMpExceptionStackSwitchHandlers ( ExceptionNumber =3D FixedPcdGetSize (PcdCpuStackSwitchExceptionList);=0D NewStackSize =3D FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNum= ber;=0D =0D - Status =3D PeiServicesAllocatePool (=0D - NewStackSize * NumberOfProcessors,=0D - (VOID **)&StackTop=0D - );=0D + StackTop =3D AllocatePages (EFI_SIZE_TO_PAGES (NewStackSize * NumberOfPr= ocessors));=0D ASSERT(StackTop !=3D NULL);=0D - if (EFI_ERROR (Status)) {=0D - ASSERT_EFI_ERROR (Status);=0D + if (StackTop =3D=3D NULL) {=0D return;=0D }=0D StackTop +=3D NewStackSize * NumberOfProcessors;=0D diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h index 6a481a84dc..c6870656ca 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h @@ -1,7 +1,7 @@ /** @file=0D Definitions to install Multiple Processor PPI.=0D =0D - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -27,6 +27,7 @@ #include =0D #include =0D #include =0D +#include =0D =0D extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc;=0D =0D diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPe= i.inf index 7e511325d8..ba829d816e 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf @@ -1,7 +1,7 @@ ## @file=0D # CPU driver installs CPU PI Multi-processor PPI.=0D #=0D -# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
= =0D +# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
= =0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -45,6 +45,7 @@ [LibraryClasses] MpInitLib=0D BaseMemoryLib=0D CpuLib=0D + MemoryAllocationLib=0D =0D [Guids]=0D gEdkiiMigratedFvInfoGuid ## = SOMETIMES_CONSUMES ## HOB=0D --=20 2.27.0.windows.1