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=liming.gao@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 3A1462034AB1B for ; Sun, 5 Nov 2017 20:21:30 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Nov 2017 20:25:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,351,1505804400"; d="scan'208";a="146305843" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 05 Nov 2017 20:25:19 -0800 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 5 Nov 2017 20:25:19 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 5 Nov 2017 20:25:18 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Mon, 6 Nov 2017 12:25:17 +0800 From: "Gao, Liming" To: Ard Biesheuvel , "edk2-devel@lists.01.org" , "leif.lindholm@linaro.org" , "lersek@redhat.com" Thread-Topic: [PATCH v2] ArmPlatformPkg/PrePeiCore: seed temporary stack before entering PEI core Thread-Index: AQHTVJeox4mpyxYBXkSLC39TR+IWiaMGxUtw Date: Mon, 6 Nov 2017 04:25:16 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1789B5@SHSMSX104.ccr.corp.intel.com> References: <20171103113352.8604-1-ard.biesheuvel@linaro.org> In-Reply-To: <20171103113352.8604-1-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] 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: Mon, 06 Nov 2017 04:21:31 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] >Sent: Friday, November 03, 2017 7:34 PM >To: edk2-devel@lists.01.org; leif.lindholm@linaro.org; lersek@redhat.com; >Gao, Liming >Cc: Ard Biesheuvel >Subject: [PATCH v2] ArmPlatformPkg/PrePeiCore: seed temporary stack >before entering PEI core > >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 as well. > >Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D748 >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Ard Biesheuvel >--- >v2: switch to newly introduced PCD > > ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S | 6 ++++++ > ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S | 8 ++++++++ > ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm | 8 ++++++++ > ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf | 2 ++ > ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf | 2 ++ > 5 files changed, 26 insertions(+) > >diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S >b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S >index aab5edab0c42..0950fd0c0cdb 100644 >--- a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S >+++ b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S >@@ -84,4 +84,10 @@ _PrepareArguments: > > _SetupPrimaryCoreStack: > mov sp, x1 >+ MOV64 (x8, FixedPcdGet64 (PcdCPUCoresStackBase)) >+ MOV64 (x9, FixedPcdGet32 (PcdInitValueInTempStack) |\ >+ FixedPcdGet32 (PcdInitValueInTempStack) << 32) >+0:stp x9, x9, [x8], #16 >+ cmp x8, x1 >+ b.lt 0b > b _PrepareArguments >diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S >b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S >index 14344425ad4c..a491af30a048 100644 >--- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S >+++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S >@@ -65,6 +65,14 @@ _PrepareArguments: > > _SetupPrimaryCoreStack: > mov sp, r1 >+ MOV32 (r8, FixedPcdGet64 (PcdCPUCoresStackBase)) >+ MOV32 (r9, FixedPcdGet32 (PcdInitValueInTempStack)) >+ 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..dc1ad8144492 100644 >--- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm >+++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm >@@ -79,6 +79,14 @@ _PrepareArguments > > _SetupPrimaryCoreStack > mov sp, r1 >+ mov32 r8, FixedPcdGet64 (PcdCPUCoresStackBase) >+ mov32 r9, FixedPcdGet32 (PcdInitValueInTempStack) >+ 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/PrePeiCoreMPCore.inf >b/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf >index ecdbccb8d620..8e0456f8dc2a 100644 >--- a/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf >+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf >@@ -75,3 +75,5 @@ [FixedPcd] > gArmTokenSpaceGuid.PcdGicDistributorBase > gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase > gArmTokenSpaceGuid.PcdGicSgiIntId >+ >+ gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack >diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf >b/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf >index b5d4e389b2a4..ec83cec2d879 100644 >--- a/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf >+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf >@@ -69,3 +69,5 @@ [FixedPcd] > gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase > gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize > gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize >+ >+ gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack >-- >2.11.0