From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 3D501208F7A37 for ; Thu, 21 Dec 2017 21:30:23 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Dec 2017 21:35:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,439,1508828400"; d="scan'208";a="189183947" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 21 Dec 2017 21:35:13 -0800 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 21 Dec 2017 21:35:12 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 21 Dec 2017 21:35:12 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Fri, 22 Dec 2017 13:35:10 +0800 From: "Wang, Jian J" To: "Yao, Jiewen" , "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: AQHTefr35N1D5hjqNEuJ0x1uCkzFQqNOxfoQ//+JlICAAIlXAA== Date: Fri, 22 Dec 2017 05:35:10 +0000 Message-ID: References: <20171221012712.3480-1-jian.j.wang@intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AA57407@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503AA57407@SHSMSX104.ccr.corp.intel.com> Accept-Language: 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:30:24 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable You're right. It will be updated to use more accurate wording. Thanks for c= atching it. Regards, Jian > -----Original Message----- > From: Yao, Jiewen > Sent: Friday, December 22, 2017 1:22 PM > To: Wang, Jian J ; edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Dong, Eric > Subject: RE: [edk2] [PATCH] UefiCpuPkg/MpInitLib: Fix incorrect Guard pag= e > setup for APs >=20 > 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 > for APs. >=20 > With commit message update, reviewed-by: Jiewen.yao@intel.com >=20 >=20 > > -----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 p= age > > setup for APs > > > > Hi, > > > > Anyone has any comments on this? > > > > Regards, > > Jian > > > > > > > -----Original Message----- > > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf O= f > 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 pag= e > setup > > > for APs > > > > > > AP has its own stack for code execution. If PcdCpuStackGuard is enabl= ed, > > > 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= page. > > > + // > > > + 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 BootSer= vices, > > > // so we will allocate reserved data for AP loop code. We also nee= d to > > > -- > > > 2.15.1.windows.2 > > > > > > _______________________________________________ > > > edk2-devel mailing list > > > edk2-devel@lists.01.org > > > https://lists.01.org/mailman/listinfo/edk2-devel