From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 05439AC0B46 for ; Tue, 2 Jan 2024 09:41:09 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=SBCX1L5I6k3cVh0KyPJiPs9SKNvjucdlhKVpFzPcOi8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704188468; v=1; b=HKKUOeJ9k76s3SY4C1j7u3IBHRe3Zo5OpSet5AQOzRo2BLPLNnKaSW4Ft5z6IfF4MWeRfRHP CGhnX6odyhyM7r9jKGimcLI6nqIWDTjpOgO93Cct6A4PZ44bzLBZDy92Sm63l9pgk+w4EoH/XqH tKSiXlIcIXOOFLwijkl+bwLs= X-Received: by 127.0.0.2 with SMTP id EMeHYY7687511x3nhcX55Lc4; Tue, 02 Jan 2024 01:41:08 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by mx.groups.io with SMTP id smtpd.web11.25720.1704188467791266375 for ; Tue, 02 Jan 2024 01:41:07 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10940"; a="10471729" X-IronPort-AV: E=Sophos;i="6.04,324,1695711600"; d="scan'208";a="10471729" X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2024 01:40:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10940"; a="1110987317" X-IronPort-AV: E=Sophos;i="6.04,324,1695711600"; d="scan'208";a="1110987317" X-Received: from tedkuo1-desk1.gar.corp.intel.com ([10.225.76.14]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2024 01:40:53 -0800 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Sai Chaganty , Chasel Chiu , Nate DeSimone , Eric Dong , Ashraf Ali S , Chinni B Duggapu , Liming Gao Subject: [edk2-devel][edk2-platforms][PATCH v4] MinPlatformPkg: Support SecFspWrapperPlatformSecLib in X64 Date: Tue, 2 Jan 2024 17:40:36 +0800 Message-Id: <588d6f17d0a4ac8ea2353d027829c1993da3dd0a.1704183832.git.ted.kuo@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ted.kuo@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: xXzXwCdBRnhCwiENzgpHFLqFx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=HKKUOeJ9; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io https://bugzilla.tianocore.org/show_bug.cgi?id=3D4623 1.Added PeiCoreEntry.nasm, SecEntry.nasm and Stack.nasm for X64. 2.Made changes in common files to support both IA32 and X64. 3.Added the PCDs below for FSP-T UPD revisions and reset vector in FSP. - PcdFspWrapperBfvforResetVectorInFsp - PcdFsptUpdHeaderRevision - PcdFsptArchUpdRevision Cc: Sai Chaganty Cc: Chasel Chiu Cc: Nate DeSimone Cc: Eric Dong Cc: Ashraf Ali S Cc: Chinni B Duggapu Cc: Liming Gao Signed-off-by: Ted Kuo --- .../SecFspWrapperPlatformSecLib/FsptCoreUpd.h | 25 ++- .../Ia32/SecEntry.nasm | 4 +- .../SecFspWrapperPlatformSecLib.inf | 9 +- ...pWrapperPlatformSecLibResetVectorInFsp.inf | 101 +++++++++ .../SecGetPerformance.c | 11 +- .../SecPlatformInformation.c | 8 +- .../SecRamInitData.c | 73 +++++-- .../X64/PeiCoreEntry.nasm | 202 ++++++++++++++++++ .../X64/SecEntry.nasm | 71 ++++++ .../X64/Stack.nasm | 72 +++++++ .../Ia32 =3D> Include}/Fsp.h | 6 +- .../Intel/MinPlatformPkg/MinPlatformPkg.dec | 17 +- 12 files changed, 565 insertions(+), 34 deletions(-) create mode 100644 Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFsp= WrapperPlatformSecLib/SecFspWrapperPlatformSecLibResetVectorInFsp.inf create mode 100644 Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFsp= WrapperPlatformSecLib/X64/PeiCoreEntry.nasm create mode 100644 Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFsp= WrapperPlatformSecLib/X64/SecEntry.nasm create mode 100644 Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFsp= WrapperPlatformSecLib/X64/Stack.nasm rename Platform/Intel/MinPlatformPkg/{FspWrapper/Library/SecFspWrapperPlat= formSecLib/Ia32 =3D> Include}/Fsp.h (79%) diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/FsptCoreUpd.h b/Platform/Intel/MinPlatformPkg/FspWrapper/Lib= rary/SecFspWrapperPlatformSecLib/FsptCoreUpd.h index 7c0f605b92..24c18f25b8 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/FsptCoreUpd.h +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/FsptCoreUpd.h @@ -1,6 +1,6 @@ /** @file=0D =0D -Copyright (c) 2017, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2017 - 2024, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -10,6 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =0D #pragma pack(1)=0D =0D +#if FixedPcdGet8 (PcdFsptArchUpdRevision) <=3D 1=0D /** Fsp T Core UPD=0D **/=0D typedef struct {=0D @@ -34,6 +35,28 @@ typedef struct { **/=0D UINT8 Reserved[16];=0D } FSPT_CORE_UPD;=0D +#else=0D +/** Fsp T Core UPD=0D +**/=0D +typedef struct {=0D +=0D +/** Offset 0x0040=0D +**/=0D + EFI_PHYSICAL_ADDRESS MicrocodeRegionBase;=0D +=0D +/** Offset 0x0048=0D +**/=0D + UINT64 MicrocodeRegionSize;=0D +=0D +/** Offset 0x0050=0D +**/=0D + EFI_PHYSICAL_ADDRESS CodeRegionBase;=0D +=0D +/** Offset 0x0058=0D +**/=0D + UINT64 CodeRegionSize;=0D +} FSPT_CORE_UPD;=0D +#endif=0D =0D #pragma pack()=0D =0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/Ia32/SecEntry.nasm b/Platform/Intel/MinPlatformPkg/FspWrappe= r/Library/SecFspWrapperPlatformSecLib/Ia32/SecEntry.nasm index 7f6d771e41..0b3f343991 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/Ia32/SecEntry.nasm +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/Ia32/SecEntry.nasm @@ -1,6 +1,6 @@ ;-------------------------------------------------------------------------= -----=0D ;=0D -; Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D +; Copyright (c) 2019 - 2024, Intel Corporation. All rights reserved.
=0D ; SPDX-License-Identifier: BSD-2-Clause-Patent=0D ; Module Name:=0D ;=0D @@ -13,7 +13,7 @@ ;=0D ;-------------------------------------------------------------------------= -----=0D =0D -#include "Fsp.h"=0D +#include =0D =0D SECTION .text=0D =0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/SecFspWrapperPlatformSecLib.inf b/Platform/Intel/MinPlatform= Pkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSec= Lib.inf index 2e0d67eae4..6806e000ce 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecFspWrapperPlatformSecLib.inf +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecFspWrapperPlatformSecLib.inf @@ -1,7 +1,7 @@ ## @file=0D -# Provide FSP wrapper platform sec related function.=0D +# Provide FSP wrapper platform sec related function for IA32.=0D #=0D -# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
= =0D +# Copyright (c) 2017 - 2024, Intel Corporation. All rights reserved.
= =0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -25,7 +25,7 @@ #=0D # The following information is for reference only and not required by the = build tools.=0D #=0D -# VALID_ARCHITECTURES =3D IA32 X64=0D +# VALID_ARCHITECTURES =3D IA32=0D #=0D =0D ##########################################################################= ######=0D @@ -47,7 +47,6 @@ Ia32/SecEntry.nasm=0D Ia32/PeiCoreEntry.nasm=0D Ia32/Stack.nasm=0D - Ia32/Fsp.h=0D =0D ##########################################################################= ######=0D #=0D @@ -96,3 +95,5 @@ gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress ## C= ONSUMES=0D gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection ## C= ONSUMES=0D gMinPlatformPkgTokenSpaceGuid.PcdFspDispatchModeUseFspPeiMain ## C= ONSUMES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFsptUpdHeaderRevision ## C= ONSUMES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFsptArchUpdRevision ## C= ONSUMES=0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/SecFspWrapperPlatformSecLibResetVectorInFsp.inf b/Platform/I= ntel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWr= apperPlatformSecLibResetVectorInFsp.inf new file mode 100644 index 0000000000..ea062cfad1 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecFspWrapperPlatformSecLibResetVectorInFsp.inf @@ -0,0 +1,101 @@ +## @file=0D +# Provide FSP wrapper platform sec related function for X64.=0D +#=0D +# Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +#=0D +##=0D +=0D +##########################################################################= ######=0D +#=0D +# Defines Section - statements that will be processed to create a Makefile= .=0D +#=0D +##########################################################################= ######=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D SecFspWrapperPlatformSecLib=0D + FILE_GUID =3D 94D8AA5C-5BAE-421F-B2C7-DD1A93BB4D3D= =0D + MODULE_TYPE =3D SEC=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D PlatformSecLib=0D +=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +# This library is only supported in X64 when reset vector is in FSP.=0D +#=0D +# VALID_ARCHITECTURES =3D X64=0D +#=0D +=0D +##########################################################################= ######=0D +#=0D +# Sources Section - list of files that are required for the build to succe= ed.=0D +#=0D +##########################################################################= ######=0D +=0D +[Sources]=0D + FspWrapperPlatformSecLib.c=0D + SecRamInitData.c=0D + SecPlatformInformation.c=0D + SecGetPerformance.c=0D + SecTempRamDone.c=0D + PlatformInit.c=0D + FsptCoreUpd.h=0D +=0D +[Sources.X64]=0D + X64/SecEntry.nasm=0D + X64/PeiCoreEntry.nasm=0D + X64/Stack.nasm=0D +=0D +##########################################################################= ######=0D +#=0D +# Package Dependency Section - list of Package files that are required for= =0D +# this module.=0D +#=0D +##########################################################################= ######=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + UefiCpuPkg/UefiCpuPkg.dec=0D + IntelFsp2Pkg/IntelFsp2Pkg.dec=0D + IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec=0D + MinPlatformPkg/MinPlatformPkg.dec=0D +=0D +[LibraryClasses]=0D + LocalApicLib=0D + SerialPortLib=0D + FspWrapperPlatformLib=0D + FspWrapperApiLib=0D + SecBoardInitLib=0D + TestPointCheckLib=0D + PeiServicesTablePointerLib=0D +=0D +[Ppis]=0D + gEfiSecPlatformInformationPpiGuid ## CONSUMES=0D + gPeiSecPerformancePpiGuid ## CONSUMES=0D + gTopOfTemporaryRamPpiGuid ## PRODUCES=0D + gEfiPeiFirmwareVolumeInfoPpiGuid ## PRODUCES=0D + gFspTempRamExitPpiGuid ## CONSUMES=0D + gPlatformInitTempRamExitPpiGuid ## CONSUMES=0D +=0D +[Pcd]=0D + gUefiCpuPkgTokenSpaceGuid.PcdPeiTemporaryRamStackSize ## C= ONSUMES=0D + gIntelFsp2WrapperTokenSpaceGuid.PcdFsptBaseAddress ## C= ONSUMES=0D + gIntelFsp2PkgTokenSpaceGuid.PcdFspTemporaryRamSize ## C= ONSUMES=0D + gMinPlatformPkgTokenSpaceGuid.PcdSecSerialPortDebugEnable ## C= ONSUMES=0D +=0D +[FixedPcd]=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvMicrocodeBase ## C= ONSUMES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFlashFvMicrocodeSize ## C= ONSUMES=0D + gMinPlatformPkgTokenSpaceGuid.PcdMicrocodeOffsetInFv ## C= ONSUMES=0D + gIntelFsp2WrapperTokenSpaceGuid.PcdFlashCodeCacheAddress ## C= ONSUMES=0D + gIntelFsp2WrapperTokenSpaceGuid.PcdFlashCodeCacheSize ## C= ONSUMES=0D + gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress ## C= ONSUMES=0D + gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection ## C= ONSUMES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFspDispatchModeUseFspPeiMain ## C= ONSUMES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFspWrapperBfvforResetVectorInFsp ## C= ONSUMES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFsptUpdHeaderRevision ## C= ONSUMES=0D + gMinPlatformPkgTokenSpaceGuid.PcdFsptArchUpdRevision ## C= ONSUMES=0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/SecGetPerformance.c b/Platform/Intel/MinPlatformPkg/FspWrapp= er/Library/SecFspWrapperPlatformSecLib/SecGetPerformance.c index ac2deeabec..1699bd9710 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecGetPerformance.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecGetPerformance.c @@ -1,7 +1,7 @@ /** @file=0D Sample to provide SecGetPerformance function.=0D =0D -Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2017 - 2024, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -58,6 +58,7 @@ SecGetPerformance ( if (EFI_ERROR (Status)) {=0D return EFI_NOT_FOUND;=0D }=0D +=0D //=0D // |--------------| <- TopOfTemporaryRam - BL=0D // | List Ptr |=0D @@ -77,12 +78,12 @@ SecGetPerformance ( // | TSC[31:00] |=0D // |--------------|=0D //=0D - TopOfTemporaryRam =3D (UINTN) TopOfTemporaryRamPpi - sizeof (UINT32);=0D - TopOfTemporaryRam -=3D sizeof (UINT32) * 2;=0D - Count =3D *(UINT32 *)(TopOfTemporaryRam - sizeof (UINT32));= =0D + TopOfTemporaryRam =3D (UINTN) TopOfTemporaryRamPpi - sizeof (UINTN);=0D + TopOfTemporaryRam -=3D sizeof(UINTN) * 2;=0D + Count =3D *(UINT32 *) (UINTN) (TopOfTemporaryRam - sizeof (U= INT32));=0D Size =3D Count * sizeof (UINT32);=0D =0D - Ticker =3D *(UINT64 *) (TopOfTemporaryRam - sizeof (UINT32) - Size - siz= eof (UINT32) * 2);=0D + Ticker =3D *(UINT64 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32) - Si= ze - sizeof (UINT64));=0D Performance->ResetEnd =3D GetTimeInNanoSecond (Ticker);=0D =0D return EFI_SUCCESS;=0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/SecPlatformInformation.c b/Platform/Intel/MinPlatformPkg/Fsp= Wrapper/Library/SecFspWrapperPlatformSecLib/SecPlatformInformation.c index 24d55ed838..4cbde95c2d 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecPlatformInformation.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecPlatformInformation.c @@ -1,7 +1,7 @@ /** @file=0D Provide SecPlatformInformation function.=0D =0D -Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2017 - 2024, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -59,9 +59,9 @@ SecPlatformInformation ( // This routine copies the BIST information to the buffer pointed by=0D // PlatformInformationRecord for output.=0D //=0D - TopOfTemporaryRam =3D (UINTN) TopOfTemporaryRamPpi - sizeof (UINT32);=0D - TopOfTemporaryRam -=3D sizeof (UINT32) * 2;=0D - Count =3D *((UINT32 *)(TopOfTemporaryRam - sizeof (UINT32)))= ;=0D + TopOfTemporaryRam =3D (UINTN) TopOfTemporaryRamPpi - sizeof (UINTN);=0D + TopOfTemporaryRam -=3D sizeof (UINTN) * 2;=0D + Count =3D *((UINT32 *)(UINTN) (TopOfTemporaryRam - sizeof (U= INT32)));=0D Size =3D Count * sizeof (IA32_HANDOFF_STATUS);=0D =0D if ((*StructureSize) < (UINT64) Size) {=0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/SecRamInitData.c b/Platform/Intel/MinPlatformPkg/FspWrapper/= Library/SecFspWrapperPlatformSecLib/SecRamInitData.c index 355d1e6509..49d5302a7b 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecRamInitData.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecRamInitData.c @@ -1,7 +1,7 @@ /** @file=0D Provide TempRamInitParams data.=0D =0D -Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2017 - 2024, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -12,25 +12,70 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =0D typedef struct {=0D FSP_UPD_HEADER FspUpdHeader;=0D +#if FixedPcdGet8 (PcdFsptArchUpdRevision) =3D=3D 1=0D + FSPT_ARCH_UPD FsptArchUpd;=0D +#elif FixedPcdGet8 (PcdFsptArchUpdRevision) =3D=3D 2=0D + FSPT_ARCH2_UPD FsptArchUpd;=0D +#endif=0D FSPT_CORE_UPD FsptCoreUpd;=0D -} FSPT_UPD_CORE_DATA;=0D + UINT16 UpdTerminator;=0D +} FSPT_UPD_DATA;=0D =0D -GLOBAL_REMOVE_IF_UNREFERENCED CONST FSPT_UPD_CORE_DATA FsptUpdDataPtr =3D = {=0D +GLOBAL_REMOVE_IF_UNREFERENCED CONST FSPT_UPD_DATA FsptUpdDataPtr =3D {=0D {=0D - 0x4450555F54505346,=0D - 0x00,=0D - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,=0D - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00=0D + 0x4450555F54505346, // FSP-T= UPD Header Signature - FSPT_UPD=0D + FixedPcdGet8 (PcdFsptUpdHeaderRevision), // FSP-T= UPD Header Revision=0D + { // Reser= ved[23]=0D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,=0D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,=0D + 0x00, 0x00, 0x00=0D }=0D },=0D +#if FixedPcdGet8 (PcdFsptArchUpdRevision) =3D=3D 1=0D {=0D - FixedPcdGet32 (PcdFlashFvMicrocodeBase) + FixedPcdGet32 (PcdMicrocodeO= ffsetInFv),=0D - FixedPcdGet32 (PcdFlashFvMicrocodeSize) - FixedPcdGet32 (PcdMicrocodeO= ffsetInFv),=0D - 0, // Set CodeRegionBase as 0, so that caching will be 4GB-(C= odeRegionSize > LLCSize ? LLCSize : CodeRegionSize) will be used.=0D - FixedPcdGet32 (PcdFlashCodeCacheSize),=0D - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,=0D + 0x01, // FSP-T= ARCH UPD Revision=0D + { // Reser= ved[3]=0D + 0x00, 0x00, 0x00=0D + },=0D + 0x00000020, // Lengt= h of FSP-T ARCH UPD=0D + 0, // FspDe= bugHandler=0D + { // Reser= ved1[20]=0D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,=0D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00=0D + }=0D + },=0D +#elif FixedPcdGet8 (PcdFsptArchUpdRevision) =3D=3D 2=0D + {=0D + 0x02, // FSP-T= ARCH2 UPD Revision=0D + { // Reser= ved[3]=0D + 0x00, 0x00, 0x00=0D + },=0D + 0x00000020, // Lengt= h of FSP-T ARCH2 UPD=0D + 0, // FspDe= bugHandler=0D + { // Reser= ved1[16]=0D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,=0D 0x00, 0x00, 0x00, 0x00, 0x00, 0x00=0D }=0D - }=0D + },=0D +#endif=0D +#if FixedPcdGet8 (PcdFsptArchUpdRevision) <=3D 1=0D + {=0D + FixedPcdGet32 (PcdFlashFvMicrocodeBase) + FixedPcdGet32 (PcdMicrocodeO= ffsetInFv), // MicrocodeRegionBase=0D + FixedPcdGet32 (PcdFlashFvMicrocodeSize) - FixedPcdGet32 (PcdMicrocodeO= ffsetInFv), // MicrocodeRegionSize=0D + 0, // Set CodeRegionBase as 0, so that caching will be 4GB-(CodeRegion= Size > LLCSize ? LLCSize : CodeRegionSize) will be used.=0D + FixedPcdGet32 (PcdFlashCodeCacheSize), = // CodeRegionSize=0D + { = // Reserved[16]=0D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,=0D + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00=0D + }=0D + },=0D +#else=0D + {=0D + FixedPcdGet32 (PcdFlashFvMicrocodeBase) + FixedPcdGet32 (PcdMicrocodeO= ffsetInFv), // MicrocodeRegionBase=0D + FixedPcdGet32 (PcdFlashFvMicrocodeSize) - FixedPcdGet32 (PcdMicrocodeO= ffsetInFv), // MicrocodeRegionSize=0D + 0, // Set CodeRegionBase as 0, so that caching will be 4GB-(CodeRegion= Size > LLCSize ? LLCSize : CodeRegionSize) will be used.=0D + FixedPcdGet32 (PcdFlashCodeCacheSize) = // CodeRegionSize=0D + },=0D +#endif=0D + 0x55AA=0D };=0D -=0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/X64/PeiCoreEntry.nasm b/Platform/Intel/MinPlatformPkg/FspWra= pper/Library/SecFspWrapperPlatformSecLib/X64/PeiCoreEntry.nasm new file mode 100644 index 0000000000..af3affcf7f --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/X64/PeiCoreEntry.nasm @@ -0,0 +1,202 @@ +;-------------------------------------------------------------------------= -----=0D +;=0D +; Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D +; SPDX-License-Identifier: BSD-2-Clause-Patent=0D +;=0D +; Module Name:=0D +;=0D +; PeiCoreEntry.nasm=0D +;=0D +; Abstract:=0D +;=0D +; Find and call SecStartup=0D +;=0D +;-------------------------------------------------------------------------= -----=0D +=0D +SECTION .text=0D +=0D +extern ASM_PFX(SecStartup)=0D +extern ASM_PFX(PlatformInit)=0D +extern ASM_PFX(PcdGet64 (PcdFspWrapperBfvforResetVectorInFsp))=0D +=0D +;-------------------------------------------------------------------------= ----=0D +; Macro: PUSHA_64=0D +;=0D +; Description: Saves all registers on stack=0D +;=0D +; Input: None=0D +;=0D +; Output: None=0D +;-------------------------------------------------------------------------= ----=0D +%macro PUSHA_64 0=0D + push r8=0D + push r9=0D + push r10=0D + push r11=0D + push r12=0D + push r13=0D + push r14=0D + push r15=0D + push rax=0D + push rcx=0D + push rdx=0D + push rbx=0D + push rsp=0D + push rbp=0D + push rsi=0D + push rdi=0D +%endmacro=0D +=0D +;-------------------------------------------------------------------------= ----=0D +; Macro: POPA_64=0D +;=0D +; Description: Restores all registers from stack=0D +;=0D +; Input: None=0D +;=0D +; Output: None=0D +;-------------------------------------------------------------------------= ----=0D +%macro POPA_64 0=0D + pop rdi=0D + pop rsi=0D + pop rbp=0D + pop rsp=0D + pop rbx=0D + pop rdx=0D + pop rcx=0D + pop rax=0D + pop r15=0D + pop r14=0D + pop r13=0D + pop r12=0D + pop r11=0D + pop r10=0D + pop r9=0D + pop r8=0D +%endmacro=0D +=0D +global ASM_PFX(CallPeiCoreEntryPoint)=0D +ASM_PFX(CallPeiCoreEntryPoint):=0D + ;=0D + ; Per X64 calling convention, make sure RSP is 16-byte aligned.=0D + ;=0D + mov rax, rsp=0D + and rax, 0fh=0D + sub rsp, rax=0D +=0D + ;=0D + ; Platform init=0D + ;=0D + PUSHA_64=0D + sub rsp, 20h=0D + call ASM_PFX(PlatformInit)=0D + add rsp, 20h=0D + POPA_64=0D +=0D + ;=0D + ; Set stack top pointer=0D + ;=0D + mov rsp, r8=0D +=0D + ;=0D + ; Push the hob list pointer=0D + ;=0D + push rcx=0D +=0D + ;=0D + ; RBP holds start of BFV passed from Vtf0. Save it to r10.=0D + ;=0D + mov r10, rbp=0D +=0D + ;=0D + ; Save the value=0D + ; RDX: start of range=0D + ; r8: end of range=0D + ;=0D + mov rbp, rsp=0D + push rdx=0D + push r8=0D + mov r14, rdx=0D + mov r15, r8=0D +=0D + ;=0D + ; Push processor count to stack first, then BIST status (AP then BSP)=0D + ;=0D + mov eax, 1=0D + cpuid=0D + shr ebx, 16=0D + and ebx, 0000000FFh=0D + cmp bl, 1=0D + jae PushProcessorCount=0D +=0D + ;=0D + ; Some processors report 0 logical processors. Effectively 0 =3D 1.=0D + ; So we fix up the processor count=0D + ;=0D + inc ebx=0D +=0D +PushProcessorCount:=0D + sub rsp, 4=0D + mov rdi, rsp=0D + mov DWORD [rdi], ebx=0D +=0D + ;=0D + ; We need to implement a long-term solution for BIST capture. For now, = we just copy BSP BIST=0D + ; for all processor threads=0D + ;=0D + xor ecx, ecx=0D + mov cl, bl=0D +PushBist:=0D + sub rsp, 4=0D + mov rdi, rsp=0D + movd eax, mm0=0D + mov DWORD [rdi], eax=0D + loop PushBist=0D +=0D + ;=0D + ; FSP saves the timestamp of the beginning of firmware execution in mm5.= =0D + ; Get the timestamp from mm5 and then push to stack.=0D + ;=0D + movq rax, mm5=0D + push rax=0D +=0D + ;=0D + ; Per X64 calling convention, make sure RSP is 16-byte aligned.=0D + ;=0D + mov rax, rsp=0D + and rax, 0fh=0D + sub rsp, rax=0D +=0D + ;=0D + ; Pass entry point of the PEI core=0D + ;=0D + mov rdi, 0FFFFFFE0h=0D + mov edi, DWORD [rdi]=0D + mov r9, rdi=0D +=0D + ;=0D + ; Pass BFV into the PEI Core=0D + ;=0D + ; Reset Vector and initial SEC core (to initialize Temp Ram) is part of = FSP-O.=0D + ; Default UefiCpuPkg Reset Vector locates FSP-O as BFV. However the actu= al=0D + ; SEC core that launches PEI is part of another FV. We need to pass that= FV=0D + ; as BFV to PEI core.=0D + ;=0D + mov r8, ASM_PFX (PcdGet64 (PcdFspWrapperBfvforResetVectorInFsp))=0D + mov rcx, QWORD[r8]=0D + mov r8, rcx=0D +=0D + ;=0D + ; Pass stack size into the PEI Core=0D + ;=0D + mov rcx, r15 ; Start of TempRam=0D + mov rdx, r14 ; End of TempRam=0D +=0D + sub rcx, rdx ; Size of TempRam=0D +=0D + ;=0D + ; Pass Control into the PEI Core=0D + ;=0D + sub rsp, 20h=0D + call ASM_PFX(SecStartup)=0D +=0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/X64/SecEntry.nasm b/Platform/Intel/MinPlatformPkg/FspWrapper= /Library/SecFspWrapperPlatformSecLib/X64/SecEntry.nasm new file mode 100644 index 0000000000..de8ba83d52 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/X64/SecEntry.nasm @@ -0,0 +1,71 @@ +;-------------------------------------------------------------------------= -----=0D +;=0D +; Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D +; SPDX-License-Identifier: BSD-2-Clause-Patent=0D +; Module Name:=0D +;=0D +; SecEntry.nasm=0D +;=0D +; Abstract:=0D +;=0D +; This is the code that passes control to PEI core.=0D +;=0D +;-------------------------------------------------------------------------= -----=0D +=0D +#include =0D +=0D +SECTION .text=0D +=0D +extern ASM_PFX(CallPeiCoreEntryPoint)=0D +extern ASM_PFX(FsptUpdDataPtr)=0D +; Pcds=0D +extern ASM_PFX(PcdGet32 (PcdFspTemporaryRamSize))=0D +=0D +;-------------------------------------------------------------------------= ---=0D +;=0D +; Procedure: _ModuleEntryPoint=0D +;=0D +; Input: None=0D +;=0D +; Output: None=0D +;=0D +; Destroys: Assume all registers=0D +;=0D +; Description:=0D +;=0D +; After TempRamInit done, pass control to PEI core.=0D +;=0D +; Return: None=0D +;=0D +; MMX Usage:=0D +; MM0 =3D BIST State=0D +;=0D +;-------------------------------------------------------------------------= ---=0D +=0D +BITS 64=0D +align 16=0D +global ASM_PFX(_ModuleEntryPoint)=0D +ASM_PFX(_ModuleEntryPoint):=0D + push rax=0D + mov rax, ASM_PFX(FsptUpdDataPtr) ; This is dummy code to include Te= mpRamInitParams in SecCore for FSP-O.=0D +#if FixedPcdGet8(PcdFspModeSelection) =3D=3D 1=0D + mov rax, ASM_PFX(PcdGet32 (PcdFspTemporaryRamSize))=0D + sub edx, dword [rax] ; TemporaryRam for FSP=0D +#endif=0D + pop rax=0D +=0D + mov r8, rdx=0D + mov rdx, rcx=0D + xor ecx, ecx ; zero - no Hob List Yet=0D + mov rsp, r8=0D +=0D + ;=0D + ; Per X64 calling convention, make sure RSP is 16-byte aligned.=0D + ;=0D + mov rax, rsp=0D + and rax, 0fh=0D + sub rsp, rax=0D +=0D + call ASM_PFX(CallPeiCoreEntryPoint)=0D +=0D + jmp $=0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/X64/Stack.nasm b/Platform/Intel/MinPlatformPkg/FspWrapper/Li= brary/SecFspWrapperPlatformSecLib/X64/Stack.nasm new file mode 100644 index 0000000000..21010bf4ef --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/X64/Stack.nasm @@ -0,0 +1,72 @@ +;-------------------------------------------------------------------------= -----=0D +;=0D +; Copyright (c) 2024, Intel Corporation. All rights reserved.
=0D +; SPDX-License-Identifier: BSD-2-Clause-Patent=0D +; Abstract:=0D +;=0D +; Switch the stack from temporary memory to permanent memory.=0D +;=0D +;-------------------------------------------------------------------------= -----=0D +=0D + SECTION .text=0D +=0D +;-------------------------------------------------------------------------= -----=0D +; VOID=0D +; EFIAPI=0D +; SecSwitchStack (=0D +; UINT32 TemporaryMemoryBase,=0D +; UINT32 PermanentMemoryBase=0D +; );=0D +;-------------------------------------------------------------------------= -----=0D +global ASM_PFX(SecSwitchStack)=0D +ASM_PFX(SecSwitchStack):=0D + ;=0D + ; Save four register: rax, rbx, rcx, rdx=0D + ;=0D + push rax=0D + push rbx=0D + push rcx=0D + push rdx=0D +=0D + ;=0D + ; !!CAUTION!! this function address's is pushed into stack after=0D + ; migration of whole temporary memory, so need save it to permanent=0D + ; memory at first!=0D + ;=0D +=0D + mov rbx, rcx ; Save the first parameter=0D + mov rcx, rdx ; Save the second parameter=0D +=0D + ;=0D + ; Save this function's return address into permanent memory at first.= =0D + ; Then, Fixup the esp point to permanent memory=0D + ;=0D + mov rax, rsp=0D + sub rax, rbx=0D + add rax, rcx=0D + mov rdx, qword [rsp] ; copy pushed register's value to perma= nent memory=0D + mov qword [rax], rdx=0D + mov rdx, qword [rsp + 8]=0D + mov qword [rax + 8], rdx=0D + mov rdx, qword [rsp + 16]=0D + mov qword [rax + 16], rdx=0D + mov rdx, qword [rsp + 24]=0D + mov qword [rax + 24], rdx=0D + mov rdx, qword [rsp + 32] ; Update this function's return address= into permanent memory=0D + mov qword [rax + 32], rdx=0D + mov rsp, rax ; From now, rsp is pointed to permanent= memory=0D +=0D + ;=0D + ; Fixup the rbp point to permanent memory=0D + ;=0D + mov rax, rbp=0D + sub rax, rbx=0D + add rax, rcx=0D + mov rbp, rax ; From now, rbp is pointed to permanent= memory=0D +=0D + pop rdx=0D + pop rcx=0D + pop rbx=0D + pop rax=0D + ret=0D +=0D diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/Ia32/Fsp.h b/Platform/Intel/MinPlatformPkg/Include/Fsp.h similarity index 79% rename from Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperP= latformSecLib/Ia32/Fsp.h rename to Platform/Intel/MinPlatformPkg/Include/Fsp.h index 9f6cdcf476..319e1e3372 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/Ia32/Fsp.h +++ b/Platform/Intel/MinPlatformPkg/Include/Fsp.h @@ -1,7 +1,7 @@ /** @file=0D Fsp related definitions=0D =0D -Copyright (c) 2017, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2017 - 2024, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -36,7 +36,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //=0D // Fsp Header=0D //=0D -#define FSP_HEADER_IMAGEBASE_OFFSET 0x1C=0D -#define FSP_HEADER_TEMPRAMINIT_OFFSET 0x30=0D +#define FSP_HEADER_IMAGEBASE_OFFSET 0x1C=0D +#define FSP_HEADER_TEMPRAMINIT_OFFSET 0x30=0D =0D #endif=0D diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec b/Platform/In= tel/MinPlatformPkg/MinPlatformPkg.dec index a14c6b2db5..12f86585ad 100644 --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec @@ -6,7 +6,7 @@ # INF files to generate AutoGen.c and AutoGen.h files=0D # for the build infrastructure.=0D #=0D -# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2017 - 2024, Intel Corporation. All rights reserved.
=0D # Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
= =0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -393,6 +393,21 @@ #=0D gMinPlatformPkgTokenSpaceGuid.PcdFspDispatchModeUseFspPeiMain|TRUE|BOOLE= AN|0xF00000A8=0D =0D + ## BFV Location for Reset Vector in FSP=0D + # The default of BFV Location for Reset Vector in FSP is 0x00000000FFFF0= 000.=0D + #=0D + gMinPlatformPkgTokenSpaceGuid.PcdFspWrapperBfvforResetVectorInFsp|0x0000= 0000FFFF0000|UINT64|0xF00000A9=0D +=0D + ## FSP-T UPD Header Revision=0D + # The default of FSP-T UPD Header Revision is 0.=0D + #=0D + gMinPlatformPkgTokenSpaceGuid.PcdFsptUpdHeaderRevision|0x0|UINT8|0xF0000= 0AA=0D +=0D + ## FSP-T ARCH UPD Revision=0D + # The default of FSP-T ARCH UPD Revision is 0.=0D + #=0D + gMinPlatformPkgTokenSpaceGuid.PcdFsptArchUpdRevision|0x0|UINT8|0xF00000A= C=0D +=0D [PcdsFeatureFlag]=0D =0D gMinPlatformPkgTokenSpaceGuid.PcdStopAfterDebugInit |FALSE|BOOLEAN|0= xF00000A1=0D --=20 2.40.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113032): https://edk2.groups.io/g/devel/message/113032 Mute This Topic: https://groups.io/mt/103478590/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-