>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. - 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
This program and the accompanying materials @@ -731,6 +731,25 @@ SecCoreStartupWithStack ( UINT32 Index; volatile UINT8 *Table; + // + // 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 = (UINTN)TopOfCurrentStack - JumpBuffer.Esp; +#elif defined (MDE_CPU_X64) + StackUsed = (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-init of // the BaseExtractGuidedSectionLib. Since this is before library contructors 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 BSD License @@ -71,6 +71,7 @@ gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd + gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire -- 2.15.0