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.20; helo=mga02.intel.com; envelope-from=jordan.l.justen@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 5128720359A7C for ; Sat, 11 Nov 2017 14:00:26 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Nov 2017 14:04:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,380,1505804400"; d="scan'208,223";a="172498571" Received: from sacolema-mobl2.amr.corp.intel.com (HELO localhost) ([10.254.117.1]) by orsmga005.jf.intel.com with ESMTP; 11 Nov 2017 14:04:29 -0800 MIME-Version: 1.0 To: Laszlo Ersek , edk2-devel-01 Message-ID: <151043786891.19895.6326436717816766532@jljusten-skl> From: Jordan Justen In-Reply-To: <151043270153.17841.16763408160801933614@jljusten-skl> Cc: Ard Biesheuvel , Ruiyu Ni References: <20171110154908.306-1-lersek@redhat.com> <151043270153.17841.16763408160801933614@jljusten-skl> User-Agent: alot/0.6 Date: Sat, 11 Nov 2017 14:04:29 -0800 Subject: Re: [PATCH 0/4] OvmfPkg: measure temp stack usage, restore temp RAM to 64KB 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: Sat, 11 Nov 2017 22:00:26 -0000 X-Groupsio-MsgNum: 17286 Content-Type: multipart/mixed; boundary="===============5859723414747959530==" --===============5859723414747959530== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 2017-11-11 12:38:21, Jordan Justen wrote: > On 2017-11-10 07:49:04, Laszlo Ersek wrote: > > The first three patches enable the PEI_CORE to report OVMF's temp > > SEC/PEI stack and heap usage. > > = > > - This depends on the new fixed PCD "PcdInitValueInTempStack", > > recently added for > > > > ("INIT_CAR_VALUE should be defined in a central location"). > > = > > - Ard recently implemented the same in ArmPlatformPkg, for > > ("measure te= mp > > SEC/PEI stack usage"). > > = > > The last (fourth) patch adapts OVMF to the larger MtrrLib stack demand > > that originates from commit 2bbd7e2fbd4b ("UefiCpuPkg/MtrrLib: Update > > algorithm to calculate optimal settings", 2017-09-27). OVMF's temp RAM > > size is restored to the historical / original 64KB. > > = > > This work is tracked in > > ("measure temp > > SEC/PEI stack usage; grow temp SEC/PEI RAM"), with links to related > > mailing list discussions. > > = > > Repo: https://github.com/lersek/edk2.git > > Branch: temp_ram_tweaks > > = > > Cc: Ard Biesheuvel > > Cc: Jordan Justen > > Cc: Ruiyu Ni > > = > > Thanks > > Laszlo > > = > > Laszlo Ersek (4): > > OvmfPkg/Sec/Ia32: free up EAX for other uses while setting up the > > stack > > OvmfPkg/Sec/Ia32: seed the temporary RAM with PcdInitValueInTempStack > > OvmfPkg/Sec/X64: seed the temporary RAM with PcdInitValueInTempStack > = > I'd like to try a different option for these 3. Can you hold off a bit > before pushing this series? I think we should use a C based approach instead, like in the attached patch. > > OvmfPkg: restore temporary SEC/PEI RAM size to 64KB This patch is Reviewed-by: Jordan Justen > > = > > OvmfPkg/OvmfPkgIa32.fdf | 2 +- > > OvmfPkg/OvmfPkgIa32X64.fdf | 2 +- > > OvmfPkg/OvmfPkgX64.fdf | 2 +- > > OvmfPkg/Sec/SecMain.inf | 1 + > > OvmfPkg/Sec/Ia32/SecEntry.nasm | 19 ++++++++++++++++--- > > OvmfPkg/Sec/X64/SecEntry.nasm | 15 +++++++++++++++ > > 6 files changed, 35 insertions(+), 6 deletions(-) > > = > > -- = > > 2.14.1.3.gb7cf6e02401b > >=20 --===============5859723414747959530== Content-Type: text/x-diff; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-OvmfPkg-Sec-Fill-most-of-temp-RAM-with-PcdInitValueI.patch" Content-Disposition: attachment; filename="0001-OvmfPkg-Sec-Fill-most-of-temp-RAM-with-PcdInitValueI.patch" >>From 0acb3277e5f7b6ac195c6dbf4fc3ce544e65d9a7 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Sat, 11 Nov 2017 13:25:35 -0800 Subject: [PATCH] OvmfPkg/Sec: Fill most of temp RAM with PcdInitValueInTempStack During a DEBUG build this allows the PEI dispatcher to report the amount of stack used by SEC/PEI. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen --- OvmfPkg/Sec/SecMain.c | 21 ++++++++++++++++++++- OvmfPkg/Sec/SecMain.inf | 3 ++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index f7fec3d8c0..077f7d6563 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -1,7 +1,7 @@ /** @file Main SEC phase code. Transitions to PEI. =20 - Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
=20 This program and the accompanying materials @@ -731,6 +731,25 @@ SecCoreStartupWithStack ( UINT32 Index; volatile UINT8 *Table; =20 + // + // Fill most of temporary RAM with PcdInitValueInTempStack. We stop + // filling at the current stack pointer - 512 bytes. + // + DEBUG_CODE_BEGIN (); + BASE_LIBRARY_JUMP_BUFFER JumpBuffer; + UINTN StackUsed; + + SetJump (&JumpBuffer); +#if defined (MDE_CPU_IA32) + StackUsed =3D (UINTN)TopOfCurrentStack - JumpBuffer.Esp; +#elif defined (MDE_CPU_X64) + StackUsed =3D (UINTN)TopOfCurrentStack - JumpBuffer.Rsp; +#endif + SetMem32 ((VOID*)(UINTN)PcdGet32 (PcdOvmfSecPeiTempRamBase), + PcdGet32 (PcdOvmfSecPeiTempRamSize) - StackUsed - 512, + FixedPcdGet32 (PcdInitValueInTempStack)); + DEBUG_CODE_END (); + // // To ensure SMM can't be compromised on S3 resume, we must force re-ini= t of // the BaseExtractGuidedSectionLib. Since this is before library contruc= tors diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf index 711b595309..c63215393b 100644 --- a/OvmfPkg/Sec/SecMain.inf +++ b/OvmfPkg/Sec/SecMain.inf @@ -1,7 +1,7 @@ ## @file # SEC Driver # -# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -71,6 +71,7 @@ gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd + gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack =20 [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire --=20 2.15.0 --===============5859723414747959530==--