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.115; helo=mga14.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 BD99F222A54C3 for ; Tue, 2 Jan 2018 23:00:36 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2018 23:05:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,500,1508828400"; d="scan'208";a="189140639" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 02 Jan 2018 23:05:38 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 Jan 2018 23:05:38 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 Jan 2018 23:05:38 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by shsmsx102.ccr.corp.intel.com ([169.254.2.189]) with mapi id 14.03.0319.002; Wed, 3 Jan 2018 15:05:36 +0800 From: "Wang, Jian J" To: "Yao, Jiewen" CC: Laszlo Ersek , "Dong, Eric" , "Wang, Jian J" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH] UefiCpuPkg/MpInitLib: fix wrong base address set as Stack Guard Thread-Index: AQHTgIBBAhUXNh3QfEei4ASfd+cM3KNhwREg Date: Wed, 3 Jan 2018 07:05:36 +0000 Message-ID: References: <20171229083631.16652-1-jian.j.wang@intel.com> In-Reply-To: <20171229083631.16652-1-jian.j.wang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTI4NjNmOTMtOWI4MS00M2IxLWJiMmMtMjZlN2Y4NDE5NGViIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJtMm1FOEVsZkN2c2pEM3FIOEE2cVFtNjgxU0trRHRySmZHcCt3eDlPaWhuVFwvcVk3R1R0M3d5RFZaXC9EOHBBdEIifQ== x-ctpclassification: CTP_NT 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 wrong base address set as Stack Guard 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: Wed, 03 Jan 2018 07:00:37 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Jiewen, Please take a look at this patch. Regards, Jian > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ji= an J > Wang > Sent: Friday, December 29, 2017 4:37 PM > To: edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Yao, Jiewen ; > Dong, Eric > Subject: [edk2] [PATCH] UefiCpuPkg/MpInitLib: fix wrong base address set = as > Stack Guard >=20 > The reason is that DXE part initialization will reuse the stack allocated > at PEI phase, if MP was initialized before. Some code added to check this > situation and use stack base address saved in HOB passed from PEI. >=20 > 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/DxeMpLib.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > index 40c1bf407a..05484c9ff3 100644 > --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > @@ -295,6 +295,7 @@ InitMpGlobalData ( > UINTN Index; > EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc; > UINTN StackBase; > + CPU_INFO_IN_HOB *CpuInfoInHob; >=20 > SaveCpuMpData (CpuMpData); >=20 > @@ -314,9 +315,18 @@ InitMpGlobalData ( > ASSERT (FALSE); > } >=20 > - for (Index =3D 0; Index < CpuMpData->CpuCount; ++Index) { > - StackBase =3D CpuMpData->Buffer + Index * CpuMpData->CpuApStackSiz= e; > + // > + // DXE will reuse stack allocated for APs at PEI phase if it's avail= able. > + // Let's check it here. > + // > + CpuInfoInHob =3D (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob; > + if (CpuInfoInHob !=3D NULL && CpuInfoInHob->ApTopOfStack !=3D 0) { > + StackBase =3D CpuInfoInHob->ApTopOfStack; > + } else { > + StackBase =3D CpuMpData->Buffer; > + } >=20 > + for (Index =3D 0; Index < CpuMpData->CpuCount; ++Index) { > Status =3D gDS->GetMemorySpaceDescriptor (StackBase, &MemDesc); > ASSERT_EFI_ERROR (Status); >=20 > @@ -326,6 +336,9 @@ InitMpGlobalData ( > MemDesc.Attributes | EFI_MEMORY_RP > ); > ASSERT_EFI_ERROR (Status); > + > + DEBUG ((DEBUG_VERBOSE, "Stack Guard set at %x [cpu%d]!\n", StackBa= se, > Index)); > + StackBase +=3D CpuMpData->CpuApStackSize; > } > } >=20 > -- > 2.15.1.windows.2 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel