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=liming.gao@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 9FC32202E60EF for ; Fri, 20 Oct 2017 09:34:03 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 20 Oct 2017 09:37:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,405,1503385200"; d="scan'208";a="911974548" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by FMSMGA003.fm.intel.com with ESMTP; 20 Oct 2017 09:37:42 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 20 Oct 2017 09:37:42 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Sat, 21 Oct 2017 00:37:40 +0800 From: "Gao, Liming" To: Ard Biesheuvel , Laszlo Ersek CC: "edk2-devel@lists.01.org" , Leif Lindholm Thread-Topic: [edk2] [PATCH] ArmPlatformPkg/PrePeiCore: seed temporary stack before entering PEI core Thread-Index: AQHTSZXkOiGGo0HEsUu1+GjDvNUkfqLsLYEAgAAtmwCAAAd6AIAAi+3g Date: Fri, 20 Oct 2017 16:37:39 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E16EABD@SHSMSX104.ccr.corp.intel.com> References: <20171020112325.10814-1-ard.biesheuvel@linaro.org> <20171020130024.l73uww7cxsjnwbsv@bivouac.eciton.net> <51d0ef33-022f-7153-9acd-9bc4a26cdd59@redhat.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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] ArmPlatformPkg/PrePeiCore: seed temporary stack before entering PEI core X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2017 16:34:03 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Ard: This case is to share the same value between PeiCore and SecCore. I also = think it will be better to define one fixed PCD in MdeModulePkg.dec for thi= s value. Could you submit bugzillar to catch this issue first? Thanks Liming > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ar= d Biesheuvel > Sent: Saturday, October 21, 2017 12:10 AM > To: Laszlo Ersek > Cc: edk2-devel@lists.01.org; Leif Lindholm > Subject: Re: [edk2] [PATCH] ArmPlatformPkg/PrePeiCore: seed temporary sta= ck before entering PEI core >=20 > On 20 October 2017 at 16:43, Laszlo Ersek wrote: > > On 10/20/17 15:00, Leif Lindholm wrote: > >> On Fri, Oct 20, 2017 at 12:23:25PM +0100, Ard Biesheuvel wrote: > >>> DEBUG builds of PEI code will print a diagnostic message regarding > >>> the utilization of temporary RAM before switching to permanent RAM. > >>> For example, > >>> > >>> Total temporary memory: 16352 bytes. > >>> temporary memory stack ever used: 4820 bytes. > >>> temporary memory heap used for HobList: 4720 bytes. > >>> > >>> Tracking stack utilization like this requires the stack to be seeded > >>> with a known magic value, and this needs to occur before entering C > >>> code, given that it uses the stack. Currently, only Nt32Pkg appears > >>> to implement this feature, but it is useful nonetheless, so let's > >>> wire it up for PrePeiCore. > >>> > >>> Contributed-under: TianoCore Contribution Agreement 1.1 > >>> Signed-off-by: Ard Biesheuvel > >>> --- > >>> ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S | 7 ++++++= + > >>> ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S | 10 ++++++= ++++ > >>> ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm | 10 ++++++= ++++ > >>> 3 files changed, 27 insertions(+) > >>> > >>> diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S > b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S > >>> index aab5edab0c42..7a33e2754869 100644 > >>> --- a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S > >>> +++ b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S > >>> @@ -13,6 +13,8 @@ > >>> > >>> #include > >>> > >>> +#define INIT_CAR_VALUE 0x5AA55AA55AA55AA5 > >>> + > >>> ASM_FUNC(_ModuleEntryPoint) > >>> // Do early platform specific actions > >>> bl ASM_PFX(ArmPlatformPeiBootAction) > >>> @@ -84,4 +86,9 @@ _PrepareArguments: > >>> > >>> _SetupPrimaryCoreStack: > >>> mov sp, x1 > >>> + MOV64 (x8, FixedPcdGet64(PcdCPUCoresStackBase)) > >>> + MOV64 (x9, INIT_CAR_VALUE) > >>> +0:stp x9, x9, [x8], #16 > >>> + cmp x8, x1 > >>> + b.lt 0b > >>> b _PrepareArguments > >>> diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S b/A= rmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S > >>> index 14344425ad4c..7342e49bea59 100644 > >>> --- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S > >>> +++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S > >>> @@ -13,6 +13,8 @@ > >>> > >>> #include > >>> > >>> +#define INIT_CAR_VALUE 0x5AA55AA5 > >>> + > >> > >> Worth moving to a common header somewhere? > >> > >> Also defined/used in MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c. > > > > Furthermore, open-coded in: > > > > EmulatorPkg/Unix/Host/Host.c: *StackPointer =3D 0x5AA55AA5; > > Nt32Pkg/Sec/SecMain.c: *StackPointer =3D 0x5AA55AA5; > > > > Honestly I think it should be a Fixed-At-Build PCD, in MdeModulePkg.dec= , > > similarly to > > > > gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue > > > > in MdePkg.dec. > > >=20 > Yes. And you both know how the MdeModulePkg maintainers are going to > respond if I propose adding another PCD. >=20 > > I'm unhappy that we have to annoy Ard with a request to "upstream" this > > constant to MdeModulePkg in some form, but we'll need it yet again in > > OVMF... > > >=20 >=20 > >> > >> That file has an explicit comment saying "temporary memory is filled > >> with this initial value during SEC phase". Should this end have a > >> corresponding comment saying "checked for during PEI phase"? > > > > Thanks > > Laszlo > > > >> > >> / > >> Leif > >> > >>> ASM_FUNC(_ModuleEntryPoint) > >>> // Do early platform specific actions > >>> bl ASM_PFX(ArmPlatformPeiBootAction) > >>> @@ -65,6 +67,14 @@ _PrepareArguments: > >>> > >>> _SetupPrimaryCoreStack: > >>> mov sp, r1 > >>> + MOV32 (r8, FixedPcdGet64(PcdCPUCoresStackBase)) > >>> + MOV32 (r9, INIT_CAR_VALUE) > >>> + mov r10, r9 > >>> + mov r11, r9 > >>> + mov r12, r9 > >>> +0:stm r8!, {r9-r12} > >>> + cmp r8, r1 > >>> + blt 0b > >>> b _PrepareArguments > >>> > >>> _NeverReturn: > >>> diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm > b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm > >>> index abea675828df..7455de8aa66e 100644 > >>> --- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm > >>> +++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm > >>> @@ -13,6 +13,8 @@ > >>> > >>> #include > >>> > >>> +#define INIT_CAR_VALUE 0x5AA55AA5 > >>> + > >>> INCLUDE AsmMacroIoLib.inc > >>> > >>> IMPORT CEntryPoint > >>> @@ -79,6 +81,14 @@ _PrepareArguments > >>> > >>> _SetupPrimaryCoreStack > >>> mov sp, r1 > >>> + mov32 r8, FixedPcdGet64(PcdCPUCoresStackBase) > >>> + mov32 r9, INIT_CAR_VALUE > >>> + mov r10, r9 > >>> + mov r11, r9 > >>> + mov r12, r9 > >>> +0:stm r8!, {r9-r12} > >>> + cmp r8, r1 > >>> + blt 0b > >>> b _PrepareArguments > >>> > >>> _NeverReturn > >>> -- > >>> 2.11.0 > >>> > > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel