From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.11639.1611065936584238363 for ; Tue, 19 Jan 2021 06:18:56 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=jKd1A6X7; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: eric.dong@intel.com) IronPort-SDR: Dgfi5y3KxzNmN5DcLsJpU7kZxxiwlBaD1OUJNEX1BQrZO8RNNPiAOnGfhbOWNfEBVbfWMJFo6S y+Xnn/JXVjXQ== X-IronPort-AV: E=McAfee;i="6000,8403,9868"; a="243001003" X-IronPort-AV: E=Sophos;i="5.79,359,1602572400"; d="scan'208";a="243001003" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2021 06:18:54 -0800 IronPort-SDR: UY0Nt3SzlkNptkY5Mzuq7rlbjcE66K932+Gjfq94Btrm6C2NQ/6PyiXb+BDG08EpC6VKwNSVLy 0YtVRClkXtzg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,359,1602572400"; d="scan'208";a="391108617" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga007.jf.intel.com with ESMTP; 19 Jan 2021 06:18:54 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 19 Jan 2021 06:18:54 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 19 Jan 2021 06:18:54 -0800 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.169) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Tue, 19 Jan 2021 06:18:54 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kR2mJ/gIp7UckYNJH759CBl330vqxO8FKgYHQfFsQwo2bD+kxCaY4FvyByEukMAbEbbDjaBta4fN+jcjSJScO3DYF8UNdad1mSzNHQ0oOBsZkkIHfrfi7yBFAx/dhp4FW40HaYz7+UWU4U7BA6vX2ZpBMHVSRjh9peepXIHdBmcIFZ0aKiSzBK6w8KndpegTuXB3qNHpqOGzh8Naazd4lRvF8ov7wgiT71nuvl+vgBeIUcGF894zKFiFKUapr9zDlUp/09Pyrx559LjGV3063UL5ovYIEP/yohibllvE2iFHSTN2TxhAqdj+WeGMMiXHpw5YJFFybIubKiqbubVVdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ywpNHgml66W/L6EEW0W1hzqqiWFgcx4v+kRFMyKvnWE=; b=iT85hJtCRIvpQ1BKF6ABkzVGwMpC/Pa6RmPlWisfD6o180mZr9LLKwyjKtXc5ICN5J9G4CXp4d4mgaTgNW8dFP/PQg/vfp02Mmgs05x2tZh4UKrVrv3j76uHWw/om5CBBeW57PnOjIzm95jNZ407UxCmYseSwGit4bI9uTrNHucRUuyJ9a6yuv0yPfYcgTAPPA16mUCtOJ5qBUbG9RMVFfvdtxoapi3jDRSudPbxPrUxbs7oatFpH91wc4Bj068qZebEG3cTkLVscUjWbEr8ZNrkYSZd6wWVoHf8IRcXXBs7fe9N7JIE3Tg16+tgtwRlXFUl7SAEW7D9UtEOR0ImPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ywpNHgml66W/L6EEW0W1hzqqiWFgcx4v+kRFMyKvnWE=; b=jKd1A6X7QVfSNmP9vRi7RLCgIMyY+mcfcXmrFRcDcN7R8Uw5Xt69ZClTy7aLZdRKYZCwxUCwOOS5y9srHNs0l7/64WNVXwvJqiUIZVAqudNQDwuRLsTtPllQZ2qm6D5aBUoQNm6k065ayp0LzTeC08kqESOb2IIEQKyg5X3Zu3o= Received: from CY4PR11MB1272.namprd11.prod.outlook.com (2603:10b6:903:29::9) by CY4PR11MB1973.namprd11.prod.outlook.com (2603:10b6:903:123::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10; Tue, 19 Jan 2021 14:18:52 +0000 Received: from CY4PR11MB1272.namprd11.prod.outlook.com ([fe80::59b2:5d29:472d:1d36]) by CY4PR11MB1272.namprd11.prod.outlook.com ([fe80::59b2:5d29:472d:1d36%5]) with mapi id 15.20.3763.014; Tue, 19 Jan 2021 14:18:51 +0000 From: "Dong, Eric" To: "Ni, Ray" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Kumar, Rahul1" Subject: Re: [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu Thread-Topic: [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu Thread-Index: AQHW6nclsc/yh//Qu0eTV7FFMEPjxaovBveQ Date: Tue, 19 Jan 2021 14:18:51 +0000 Message-ID: References: <20210114131200.1659-1-ray.ni@intel.com> In-Reply-To: <20210114131200.1659-1-ray.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.213] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2e3eff6c-50a7-4d01-9509-08d8bc852580 x-ms-traffictypediagnostic: CY4PR11MB1973: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7RCGGWS4sBFSzgJT5OOaZbT1lDqyF3mwWtrcs2cFRZd2Capf1MnsMQZT8au0/4Y+RBeiKQjbcrWdY5w8ZTMzFounW0+4u5yntDjie/ue19CmD1tIcW41NLwUVWCf+utxV/8tLYdeL6bbJDa/eyxG6S3lQRAVeaa5Nmtgwd1mpQlBhPZkmv/LKrIMZG8pZisMiu6SC13HmK8gznsFF2LfjO/AJ9QCQo/g6kPAu0CYPvD/lVjUkf82iBKkhRc5HdpL7LKhkjEmZ2cdi+Kxp/q7rmvPSFt7pP+graVyekTX2d4+s3sHfjD+zfGFL4M0SSJlci+zLDgbBxCch6jPMYrjapSUAan1DIZThSz/BCRBGVCnHse/OKv5rnk9Dk2I8j+DPiuynfeknQFNIKIKQnBb5Q== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1272.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(366004)(39860400002)(136003)(396003)(376002)(110136005)(52536014)(71200400001)(33656002)(76116006)(7696005)(316002)(186003)(83380400001)(8676002)(107886003)(9686003)(55016002)(64756008)(66946007)(4326008)(66556008)(26005)(54906003)(6506007)(86362001)(8936002)(5660300002)(66476007)(2906002)(53546011)(478600001)(66446008);DIR:OUT;SFP:1102; x-ms-exchange-ant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w1+AWz+Q6bWYl/OkM2u1hDDKg/Y1sNZdJRAiJY?= =?us-ascii?Q?l/KtUo4SoGWPXc5ip0aB3WKzoFM0ypuEXtuLUeEa14XjrTCNLlJW9AW0MGhR?= =?us-ascii?Q?0USkVTq5VYUfqK/bbdM5L/4ER3LXVxJr6lgFTza+4sTRC6qyjz+eD5eBpNf4?= =?us-ascii?Q?OJzGAvIZeRQAkLcJvJ+7nW5jJ4oBwHyr1NrhnhxwzwOg0WTUTT95oCp76qPq?= =?us-ascii?Q?tqCzNUob?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1272.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e3eff6c-50a7-4d01-9509-08d8bc852580 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jan 2021 14:18:51.7511 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GV7rg6y15lt3wf3hQSrS4hTGNkV8Qe8oCtU5ihLAky91/RvgqS5it6FGJ0/uV/e5BbPmcdR6Vc6zIVDbsNj1dw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1973 Return-Path: eric.dong@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong -----Original Message----- From: Ni, Ray =20 Sent: Thursday, January 14, 2021 9:12 PM To: devel@edk2.groups.io Cc: Dong, Eric ; Laszlo Ersek ; Kum= ar, Rahul1 Subject: [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 1= 6-core cpu 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 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