From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CD92222198F49 for ; Thu, 21 Dec 2017 21:17:23 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Dec 2017 21:22:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,439,1508828400"; d="scan'208";a="14359617" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 21 Dec 2017 21:22:12 -0800 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 21 Dec 2017 21:22:12 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 21 Dec 2017 21:22:11 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Fri, 22 Dec 2017 13:22:10 +0800 From: "Yao, Jiewen" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: Laszlo Ersek , "Dong, Eric" Thread-Topic: [edk2] [PATCH] UefiCpuPkg/MpInitLib: Fix incorrect Guard page setup for APs Thread-Index: AQHTefrolXuofxYa3kCRMdvgm1ukwKNOQACAgACVWxA= Date: Fri, 22 Dec 2017 05:22:09 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AA57407@SHSMSX104.ccr.corp.intel.com> References: <20171221012712.3480-1-jian.j.wang@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGQ3ZjBhODItOTUwNS00YmZjLWI0NzctOWEyZDcyZGI2NGIzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJmeWRpaE9JYU5CYzhvWDFoZDZ0NWFCeGxlWjdLRXFiVmVCa0R1OXJ3RkM2ZXJmdHdyM1lJXC9LQjRLSlVHYjZQWSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] UefiCpuPkg/MpInitLib: Fix incorrect Guard page setup for APs X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Dec 2017 05:17:24 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I do not think we have AP guard page before, right? So I suggest we change commit message to be: Add missing Guard page setup f= or APs. With commit message update, reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Wang, Jian J > Sent: Friday, December 22, 2017 12:26 PM > To: Wang, Jian J ; edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Yao, Jiewen ; > Dong, Eric > Subject: RE: [edk2] [PATCH] UefiCpuPkg/MpInitLib: Fix incorrect Guard pag= e > setup for APs >=20 > Hi, >=20 > Anyone has any comments on this? >=20 > Regards, > Jian >=20 >=20 > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of = Jian > J > > Wang > > Sent: Thursday, December 21, 2017 9:27 AM > > To: edk2-devel@lists.01.org > > Cc: Laszlo Ersek ; Yao, Jiewen ; > > Dong, Eric > > Subject: [edk2] [PATCH] UefiCpuPkg/MpInitLib: Fix incorrect Guard page = setup > > for APs > > > > AP has its own stack for code execution. If PcdCpuStackGuard is enabled= , > > the page at the bottom of stack of AP will be disabled (NOT PRESENT) to > > monitor the stack overflow issue. This requires PcdCpuApStackSize to be > > set with value more than one page of memory. > > > > Cc: Jiewen Yao > > Cc: Eric Dong > > Cc: Laszlo Ersek > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Jian J Wang > > --- > > UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 1 + > > UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 34 > > ++++++++++++++++++++++++--- > > 2 files changed, 32 insertions(+), 3 deletions(-) > > > > diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf > > b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf > > index 805641b516..e7b9eb4462 100644 > > --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf > > +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf > > @@ -73,4 +73,5 @@ > > gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize > ## > > CONSUMES > > gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode > ## CONSUMES > > gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate > ## > > SOMETIMES_CONSUMES > > + gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard > ## > > CONSUMES > > > > diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > > b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > > index 479f8189f6..40c1bf407a 100644 > > --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > > +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > > > @@ -288,9 +289,12 @@ InitMpGlobalData ( > > IN CPU_MP_DATA *CpuMpData > > ) > > { > > - EFI_STATUS Status; > > - EFI_PHYSICAL_ADDRESS Address; > > - UINTN ApSafeBufferSize; > > + EFI_STATUS Status; > > + EFI_PHYSICAL_ADDRESS Address; > > + UINTN ApSafeBufferSize; > > + UINTN Index; > > + EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc; > > + UINTN StackBase; > > > > SaveCpuMpData (CpuMpData); > > > > @@ -301,6 +305,30 @@ InitMpGlobalData ( > > return; > > } > > > > + if (PcdGetBool (PcdCpuStackGuard)) { > > + // > > + // One extra page at the bottom of the stack is needed for Guard p= age. > > + // > > + if (CpuMpData->CpuApStackSize <=3D EFI_PAGE_SIZE) { > > + DEBUG ((DEBUG_ERROR, "PcdCpuApStackSize is not big enough for > Stack > > Guard!\n")); > > + ASSERT (FALSE); > > + } > > + > > + for (Index =3D 0; Index < CpuMpData->CpuCount; ++Index) { > > + StackBase =3D CpuMpData->Buffer + Index * > CpuMpData->CpuApStackSize; > > + > > + Status =3D gDS->GetMemorySpaceDescriptor (StackBase, &MemDesc); > > + ASSERT_EFI_ERROR (Status); > > + > > + Status =3D gDS->SetMemorySpaceAttributes ( > > + StackBase, > > + EFI_PAGES_TO_SIZE (1), > > + MemDesc.Attributes | EFI_MEMORY_RP > > + ); > > + ASSERT_EFI_ERROR (Status); > > + } > > + } > > + > > // > > // Avoid APs access invalid buffer data which allocated by BootServi= ces, > > // so we will allocate reserved data for AP loop code. We also need = to > > -- > > 2.15.1.windows.2 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel