From nobody Sat May 18 08:35:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70289+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70289+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1610630020; cv=none; d=zohomail.com; s=zohoarc; b=XXmzzrct1aPCif2BSU/rSvUUR9o9CCqtvsGqVk/1GZps+6P9CgRaU+29nTHlHF2U1J+c82hgbDuUHepgLM8SOst5GMtXhH7vahgKdlYK4Q8gZejS/EHOQp4Kqje1Gc8Fer4DsUacquCQnm4TwNpeXJhZhtqXPWK2gJGM7ch7SJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610630020; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=XVI/V7UnykDvwsZmQEN/FaDNoGVxTNnZ2liJ2k/jjsc=; b=iO/ra+3S9B/g8Fl0Vk4D/TiPMUFHlMygRkP1rVjODDjFKHVBIqIBhAyyixuWQrABcvr3qVOLriXmPqA+Ge1M+6hVtcvmFHqh01WUmeao4jIupWSKW3p+BcKlUEh42C2YcglbMdOx6r/AFadF8ICoLeRhc9Vsl63YGiYp6gDA+rM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70289+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610630020171714.511054600485; Thu, 14 Jan 2021 05:13:40 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3CZ4YY1788612xzNZ9HtlgHh; Thu, 14 Jan 2021 05:13:39 -0800 X-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 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" X-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" X-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: [edk2-devel] [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> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com X-Gm-Message-State: MnLvNS4FDRIrBk3dJWJHJjg3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610630019; bh=2Afcp9/uAo4WmdQEDMMDk7bYFD5hPwbaM20HEnuPMjk=; h=Cc:Date:From:Reply-To:Subject:To; b=LMcc2eFhrAywoR+QOgMswqhaskEzUQdZVNqV5osGHbgzVcLvkzF+xf5nXKczDb2+4vj 87B+F589LYF4eDQj/OOkjTQCG2GRizJ4h10GmH4vvghbbzS0xU5Lg1vIjTxAN+WFlrGEj vxZTW12ZxiuM7Q8u2JuwRBHOgHDl3ZLCR1U= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Eric Dong Reviewed-by: Laszlo Ersek --- 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 CPU PEI Module installs CPU Multiple Processor PPI. =20 - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -532,13 +532,9 @@ InitializeMpExceptionStackSwitchHandlers ( ExceptionNumber =3D FixedPcdGetSize (PcdCpuStackSwitchExceptionList); NewStackSize =3D FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNum= ber; =20 - Status =3D PeiServicesAllocatePool ( - NewStackSize * NumberOfProcessors, - (VOID **)&StackTop - ); + StackTop =3D AllocatePages (EFI_SIZE_TO_PAGES (NewStackSize * NumberOfPr= ocessors)); ASSERT(StackTop !=3D NULL); - if (EFI_ERROR (Status)) { - ASSERT_EFI_ERROR (Status); + if (StackTop =3D=3D NULL) { return; } StackTop +=3D NewStackSize * NumberOfProcessors; 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 Definitions to install Multiple Processor PPI. =20 - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -27,6 +27,7 @@ #include #include #include +#include =20 extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc; =20 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 # CPU driver installs CPU PI Multi-processor PPI. # -# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -45,6 +45,7 @@ [LibraryClasses] MpInitLib BaseMemoryLib CpuLib + MemoryAllocationLib =20 [Guids] gEdkiiMigratedFvInfoGuid ## = SOMETIMES_CONSUMES ## HOB --=20 2.27.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70289): https://edk2.groups.io/g/devel/message/70289 Mute This Topic: https://groups.io/mt/79674591/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-