From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.21258.1574326765547073654 for ; Thu, 21 Nov 2019 00:59:26 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: nathaniel.l.desimone@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Nov 2019 00:59:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,224,1571727600"; d="scan'208";a="210033075" Received: from nldesimo-desk1.amr.corp.intel.com ([10.7.159.63]) by orsmga006.jf.intel.com with ESMTP; 21 Nov 2019 00:59:21 -0800 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Michael Kubacki , Chasel Chiu , Liming Gao Subject: [edk2-platforms] [PATCH V2 14/14] MinPlatformPkg: Remove BoardInitLib dependency from PlatformSecLib Date: Thu, 21 Nov 2019 00:58:53 -0800 Message-Id: <20191121085853.2626-15-nathaniel.l.desimone@intel.com> X-Mailer: git-send-email 2.24.0.windows.2 In-Reply-To: <20191121085853.2626-1-nathaniel.l.desimone@intel.com> References: <20191121085853.2626-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable SecFspWrapperPlatformSecLib contains the implementation of SecPlatformDisableTemporaryMemory(), which SecMain in UefiCpuPkg will call as part of its implementation of EFI_PEI_TEMPORARY_RAM_DONE_PPI. For platforms that use FSP, the implementation of SecPlatformDisableTemporaryMemory() can be made generic since the chipset specifics will be contained in FspTempRamExit(). The Minimum Platform Specification provides the BoardPkg two interface hook points, BoardInitBeforeTempRamExit() and BoardInitAfterTempRamExit() which must be called during SecPlatformDisableTemporaryMemory(). Due to EFI_PEI_TEMPORARY_RAM_DONE_PPI being a special case of a PPI that is implemented in SEC, these two functions are the only ones in BoardInitLib that need to be called by SEC. Linking BoardInitLib with SEC places many restrictions on the implementation of that library. The features available to SEC phase code are very minimal. Since this code runs during PEI phase, these restrictions are not actually required. Instead of directly linking with BoardInitLib, SecPlatformDisableTemporaryMemory() shall call BoardInitLib indirectly through a PPI (PLATFORM_INIT_TEMP_RAM_EXIT_PPI.) This PPI is produced by PlatformInitPreMem, which implements the other BoardInitLib calls already, so this change should also slightly reduce the size of the final binary image since less PE/COFF images will need to link with BoardInitLib. Cc: Michael Kubacki Cc: Chasel Chiu Cc: Liming Gao Signed-off-by: Nate DeSimone --- .../SecFspWrapperPlatformSecLib.inf | 2 +- .../SecTempRamDone.c | 36 +++++++-- .../Include/Ppi/PlatformInitTempRamExitPpi.h | 55 ++++++++++++++ .../Intel/MinPlatformPkg/MinPlatformPkg.dec | 2 + .../PlatformInitPei/PlatformInitPreMem.c | 76 ++++++++++++++++++- .../PlatformInitPei/PlatformInitPreMem.inf | 1 + 6 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 Platform/Intel/MinPlatformPkg/Include/Ppi/PlatformInitT= empRamExitPpi.h diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/SecFspWrapperPlatformSecLib.inf b/Platform/Intel/MinPlatform= Pkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSec= Lib.inf index 02c720c73d..4f3fa9fa34 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecFspWrapperPlatformSecLib.inf +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecFspWrapperPlatformSecLib.inf @@ -69,7 +69,6 @@ SerialPortLib=0D FspWrapperPlatformLib=0D FspWrapperApiLib=0D - BoardInitLib=0D SecBoardInitLib=0D TestPointCheckLib=0D PeiServicesTablePointerLib=0D @@ -80,6 +79,7 @@ gTopOfTemporaryRamPpiGuid ## PRODUCES=0D gEfiPeiFirmwareVolumeInfoPpiGuid ## PRODUCES=0D gFspTempRamExitPpiGuid ## CONSUMES=0D + gPlatformInitTempRamExitPpiGuid ## CONSUMES=0D =0D [Pcd]=0D gUefiCpuPkgTokenSpaceGuid.PcdPeiTemporaryRamStackSize ## C= ONSUMES=0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/SecTempRamDone.c b/Platform/Intel/MinPlatformPkg/FspWrapper/= Library/SecFspWrapperPlatformSecLib/SecTempRamDone.c index 922e4ec204..b22cf57d6c 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecTempRamDone.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecTempRamDone.c @@ -10,6 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =0D #include =0D #include =0D +#include =0D =0D #include =0D #include =0D @@ -17,7 +18,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D #include =0D #include =0D -#include =0D #include =0D =0D /**=0D @@ -29,14 +29,35 @@ SecPlatformDisableTemporaryMemory ( VOID=0D )=0D {=0D - EFI_STATUS Status;=0D - VOID *TempRamExitParam;=0D - CONST EFI_PEI_SERVICES **PeiServices;=0D - FSP_TEMP_RAM_EXIT_PPI *TempRamExitPpi;=0D + EFI_STATUS Status;=0D + VOID *TempRamExitParam;=0D + CONST EFI_PEI_SERVICES **PeiServices;=0D + FSP_TEMP_RAM_EXIT_PPI *TempRamExitPpi;=0D + PLATFORM_INIT_TEMP_RAM_EXIT_PPI *PlatformInitTempRamExitPpi;=0D =0D DEBUG ((DEBUG_INFO, "SecPlatformDisableTemporaryMemory enter\n"));=0D + PeiServices =3D GetPeiServicesTablePointer ();=0D + ASSERT (PeiServices !=3D NULL);=0D + if (PeiServices =3D=3D NULL) {=0D + return;=0D + }=0D + ASSERT ((*PeiServices) !=3D NULL);=0D + if ((*PeiServices) =3D=3D NULL) {=0D + return;=0D + }=0D + Status =3D (*PeiServices)->LocatePpi (=0D + PeiServices,=0D + &gPlatformInitTempRamExitPpiGuid,=0D + 0,=0D + NULL,=0D + (VOID **) &PlatformInitTempRamExitPpi=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D + if (EFI_ERROR (Status)) {=0D + return;=0D + }=0D =0D - Status =3D BoardInitBeforeTempRamExit ();=0D + Status =3D PlatformInitTempRamExitPpi->PlatformInitBeforeTempRamExit ();= =0D ASSERT_EFI_ERROR (Status);=0D =0D if (PcdGet8 (PcdFspModeSelection) =3D=3D 1) {=0D @@ -51,7 +72,6 @@ SecPlatformDisableTemporaryMemory ( //=0D // FSP Dispatch mode=0D //=0D - PeiServices =3D GetPeiServicesTablePointer ();=0D Status =3D (*PeiServices)->LocatePpi (=0D PeiServices,=0D &gFspTempRamExitPpiGuid,=0D @@ -66,7 +86,7 @@ SecPlatformDisableTemporaryMemory ( TempRamExitPpi->TempRamExit (NULL);=0D }=0D =0D - Status =3D BoardInitAfterTempRamExit ();=0D + Status =3D PlatformInitTempRamExitPpi->PlatformInitAfterTempRamExit ();= =0D ASSERT_EFI_ERROR (Status);=0D =0D return ;=0D diff --git a/Platform/Intel/MinPlatformPkg/Include/Ppi/PlatformInitTempRamE= xitPpi.h b/Platform/Intel/MinPlatformPkg/Include/Ppi/PlatformInitTempRamExi= tPpi.h new file mode 100644 index 0000000000..590647738c --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Include/Ppi/PlatformInitTempRamExitPpi.h @@ -0,0 +1,55 @@ +/** @file=0D + This file defines the PPI for notifying PlatformInitPreMem=0D + of temporary memory being disabled.=0D +=0D +Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef _PLATFORM_INIT_TEMP_RAM_EXIT_PPI_H_=0D +#define _PLATFORM_INIT_TEMP_RAM_EXIT_PPI_H_=0D +=0D +#include =0D +=0D +//=0D +// Forward declaration for the PLATFORM_INIT_TEMP_RAM_EXIT_PPI.=0D +//=0D +typedef struct _PLATFORM_INIT_TEMP_RAM_EXIT_PPI PLATFORM_INIT_TEMP_RAM_EXI= T_PPI;=0D +=0D +/**=0D + A hook for platform-specific initialization prior to disabling temporary= RAM.=0D +=0D + @retval EFI_SUCCESS The platform initialization was successful.=0D + @retval EFI_NOT_READY The platform has not been detected yet.=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *PLATFORM_INIT_BEFORE_TEMP_RAM_EXIT) (=0D + VOID=0D + );=0D +=0D +/**=0D + A hook for platform-specific initialization after disabling temporary RA= M.=0D +=0D + @retval EFI_SUCCESS The platform initialization was successful.=0D + @retval EFI_NOT_READY The platform has not been detected yet.=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *PLATFORM_INIT_AFTER_TEMP_RAM_EXIT) (=0D + VOID=0D + );=0D +=0D +///=0D +/// This PPI provides functions for notifying PlatformInitPreMem=0D +/// of temporary memory being disabled.=0D +///=0D +struct _PLATFORM_INIT_TEMP_RAM_EXIT_PPI {=0D + PLATFORM_INIT_BEFORE_TEMP_RAM_EXIT PlatformInitBeforeTempRamExit;=0D + PLATFORM_INIT_AFTER_TEMP_RAM_EXIT PlatformInitAfterTempRamExit;=0D +};=0D +=0D +extern EFI_GUID gPlatformInitTempRamExitPpiGuid;=0D +=0D +#endif // _PLATFORM_INIT_TEMP_RAM_EXIT_PPI_H_=0D diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec b/Platform/In= tel/MinPlatformPkg/MinPlatformPkg.dec index 6ef0219129..6a765d689d 100644 --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec @@ -28,6 +28,8 @@ gPeiBaseMemoryTestPpiGuid =3D {0xb6ec423c, 0x21d2, 0x490d, {0x85= , 0xc6, 0xdd, 0x58, 0x64, 0xea, 0xa6, 0x74}}=0D gPeiPlatformMemorySizePpiGuid =3D {0x9a7ef41e, 0xc140, 0x4bd1, {0xb8= , 0x84, 0x1e, 0x11, 0x24, 0x0b, 0x4c, 0xe6}}=0D =0D + gPlatformInitTempRamExitPpiGuid =3D {0xbae23646, 0xbd60, 0x4f8b, {0xb3= , 0xf9, 0xf3, 0x91, 0xee, 0x7e, 0xe6, 0xc8}}=0D +=0D [Guids]=0D gMinPlatformPkgTokenSpaceGuid =3D {0x69d13bf0, 0xaf91, 0x4d96, {0xaa= , 0x9f, 0x21, 0x84, 0xc5, 0xce, 0x3b, 0xc0}}=0D =0D diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/Pla= tformInitPreMem.c b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInit= Pei/PlatformInitPreMem.c index c579ff008e..efdeb6a91c 100644 --- a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformIn= itPreMem.c +++ b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformIn= itPreMem.c @@ -29,6 +29,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D #include =0D #include =0D +#include =0D =0D EFI_STATUS=0D EFIAPI=0D @@ -72,7 +73,31 @@ BaseMemoryTest ( OUT EFI_PHYSICAL_ADDRESS *ErrorAddress=0D );=0D =0D -static EFI_PEI_NOTIFY_DESCRIPTOR mMemDiscoveredNotifyList =3D {=0D +/**=0D + A hook for platform-specific initialization prior to disabling temporary= RAM.=0D +=0D + @retval EFI_SUCCESS The platform initialization was successful.=0D + @retval EFI_NOT_READY The platform has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +PlatformInitBeforeTempRamExit (=0D + VOID=0D + );=0D +=0D +/**=0D + A hook for platform-specific initialization after disabling temporary RA= M.=0D +=0D + @retval EFI_SUCCESS The platform initialization was successful.=0D + @retval EFI_NOT_READY The platform has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +PlatformInitAfterTempRamExit (=0D + VOID=0D + );=0D +=0D +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_NOTIFY_DESCRIPTOR mMemDiscoveredNoti= fyList =3D {=0D (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINA= TE_LIST),=0D &gEfiPeiMemoryDiscoveredPpiGuid,=0D (EFI_PEIM_NOTIFY_ENTRY_POINT) MemoryDiscoveredPpiNotifyCallback=0D @@ -90,11 +115,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR m= PpiBootMode =3D { NULL=0D };=0D =0D -static PEI_BASE_MEMORY_TEST_PPI mPeiBaseMemoryTestPpi =3D { BaseMemory= Test };=0D +GLOBAL_REMOVE_IF_UNREFERENCED PEI_BASE_MEMORY_TEST_PPI mPeiBaseMemoryT= estPpi =3D { BaseMemoryTest };=0D =0D -static PEI_PLATFORM_MEMORY_SIZE_PPI mMemoryMemorySizePpi =3D { GetPlatfor= mMemorySize };=0D +GLOBAL_REMOVE_IF_UNREFERENCED PEI_PLATFORM_MEMORY_SIZE_PPI mMemoryMemorySi= zePpi =3D { GetPlatformMemorySize };=0D =0D -static EFI_PEI_PPI_DESCRIPTOR mMemPpiList[] =3D {=0D +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR mMemPpiList[] = =3D {=0D {=0D EFI_PEI_PPI_DESCRIPTOR_PPI,=0D &gPeiBaseMemoryTestPpiGuid,=0D @@ -107,6 +132,17 @@ static EFI_PEI_PPI_DESCRIPTOR mMemPpiList[] =3D { },=0D };=0D =0D +GLOBAL_REMOVE_IF_UNREFERENCED PLATFORM_INIT_TEMP_RAM_EXIT_PPI mPlatformIni= tTempRamExitPpi =3D {=0D + PlatformInitBeforeTempRamExit,=0D + PlatformInitAfterTempRamExit=0D +};=0D +=0D +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR mPlatformInitTempRamE= xitPpiDesc =3D {=0D + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),=0D + &gPlatformInitTempRamExitPpiGuid,=0D + &mPlatformInitTempRamExitPpi=0D +};=0D +=0D ///=0D /// Memory Reserved should be between 125% to 150% of the Current required= memory=0D /// otherwise BdsMisc.c would do a reset to make it 125% to avoid s4 resum= e issues.=0D @@ -391,6 +427,35 @@ MemoryDiscoveredPpiNotifyCallback ( return Status;=0D }=0D =0D +/**=0D + A hook for platform-specific initialization prior to disabling temporary= RAM.=0D +=0D + @retval EFI_SUCCESS The platform initialization was successful.=0D + @retval EFI_NOT_READY The platform has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +PlatformInitBeforeTempRamExit (=0D + VOID=0D + )=0D +{=0D + return BoardInitBeforeTempRamExit ();=0D +}=0D +=0D +/**=0D + A hook for platform-specific initialization after disabling temporary RA= M.=0D +=0D + @retval EFI_SUCCESS The platform initialization was successful.=0D + @retval EFI_NOT_READY The platform has not been detected yet.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +PlatformInitAfterTempRamExit (=0D + VOID=0D + )=0D +{=0D + return BoardInitAfterTempRamExit ();=0D +}=0D =0D /**=0D This function handles PlatformInit task after PeiReadOnlyVariable2 PPI p= roduced=0D @@ -446,6 +511,9 @@ PlatformInitPreMem ( Status =3D BoardInitBeforeMemoryInit ();=0D ASSERT_EFI_ERROR (Status);=0D =0D + Status =3D PeiServicesInstallPpi (&mPlatformInitTempRamExitPpiDesc);=0D + ASSERT_EFI_ERROR (Status);=0D +=0D return Status;=0D }=0D =0D diff --git a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/Pla= tformInitPreMem.inf b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformIn= itPei/PlatformInitPreMem.inf index af5dbe8772..7ee18eb6d5 100644 --- a/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformIn= itPreMem.inf +++ b/Platform/Intel/MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformIn= itPreMem.inf @@ -53,6 +53,7 @@ gEfiPeiMemoryDiscoveredPpiGuid=0D gEfiPeiMasterBootModePpiGuid ## PRODUCES=0D gEfiPeiBootInRecoveryModePpiGuid ## PRODUCES=0D + gPlatformInitTempRamExitPpiGuid ## PRODUCES=0D gEfiPeiReadOnlyVariable2PpiGuid=0D gPeiBaseMemoryTestPpiGuid=0D gPeiPlatformMemorySizePpiGuid=0D --=20 2.24.0.windows.2