From: Yao, Jiewen Date: Sun, 2 Aug 2015 04:02:37 +0000 (+0000) Subject: Add Dual-FSP support (MemoryInitUpd/SiliconInitUpd) X-Git-Tag: edk2-stable201903~9158 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=b23441875c34bd15badb76e8d0b001ebd5d7010d Add Dual-FSP support (MemoryInitUpd/SiliconInitUpd) Add FspUpdSignatureCheck() API in FspSecPlatformLib, so that FspSecCore can check if UPD data is valid in FSP API. Add Set/GetFspMemoryInitUpdDataPointer() and Set/GetFspSiliconInitUpdDataPointer() API in FspCommonLib, so that core can set this UdpDataPointer and platform code may get UpdDataPointer easily. Add UpdateMemSiUpdInitOffsetValue function in GenCfgOpt.py tool, so that the MemoryInitUpdOffset and SiUpdInitOffset is recorded. Add missing EMBED comment in GenCfgOptUserManual.docx Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Yao, Jiewen" Reviewed-by: "Mudusuru, Giri P" git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18123 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/IntelFspPkg/FspSecCore/SecFsp.c b/IntelFspPkg/FspSecCore/SecFsp.c index a9aba7108e..07aed1c1c0 100644 --- a/IntelFspPkg/FspSecCore/SecFsp.c +++ b/IntelFspPkg/FspSecCore/SecFsp.c @@ -265,7 +265,7 @@ FspApiCallingCheck ( // if ((UINT32)FspData != 0xFFFFFFFF) { Status = EFI_UNSUPPORTED; - } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % EFI_PAGE_SIZE) != 0)) { + } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % EFI_PAGE_SIZE) != 0) || (EFI_ERROR(FspUpdSignatureCheck(ApiIdx, ApiParam)))) { Status = EFI_INVALID_PARAMETER; } } else if (ApiIdx == 2) { @@ -285,7 +285,7 @@ FspApiCallingCheck ( // if ((UINT32)FspData != 0xFFFFFFFF) { Status = EFI_UNSUPPORTED; - } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % EFI_PAGE_SIZE) != 0)) { + } else if ((FspRtBuffer == NULL) || ((FspRtBuffer->BootLoaderTolumSize % EFI_PAGE_SIZE) != 0) || (EFI_ERROR(FspUpdSignatureCheck(ApiIdx, ApiParam)))) { Status = EFI_INVALID_PARAMETER; } } else if (ApiIdx == 4) { @@ -308,6 +308,8 @@ FspApiCallingCheck ( } else { if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) { Status = EFI_UNSUPPORTED; + } else if (EFI_ERROR(FspUpdSignatureCheck(ApiIdx, ApiParam))) { + Status = EFI_INVALID_PARAMETER; } } } else { diff --git a/IntelFspPkg/FspSecCore/SecFsp.h b/IntelFspPkg/FspSecCore/SecFsp.h index 3e4e2a4b5c..4dceebc31b 100644 --- a/IntelFspPkg/FspSecCore/SecFsp.h +++ b/IntelFspPkg/FspSecCore/SecFsp.h @@ -15,14 +15,14 @@ #define _SEC_FSPE_H_ #include +#include #include #include #include #include #include #include - -#include +#include #define FSP_MCUD_SIGNATURE SIGNATURE_32 ('M', 'C', 'U', 'D') #define FSP_PER0_SIGNATURE SIGNATURE_32 ('P', 'E', 'R', '0') diff --git a/IntelFspPkg/Include/Library/FspCommonLib.h b/IntelFspPkg/Include/Library/FspCommonLib.h index eddebba1ea..fa2f81c088 100644 --- a/IntelFspPkg/Include/Library/FspCommonLib.h +++ b/IntelFspPkg/Include/Library/FspCommonLib.h @@ -157,6 +157,50 @@ GetFspUpdDataPointer ( VOID ); +/** + This function sets the memory init UPD data pointer. + + @param[in] MemoryInitUpdPtr memory init UPD data pointer. +**/ +VOID +EFIAPI +SetFspMemoryInitUpdDataPointer ( + IN VOID *MemoryInitUpdPtr + ); + +/** + This function gets the memory init UPD data pointer. + + @return memory init UPD data pointer. +**/ +VOID * +EFIAPI +GetFspMemoryInitUpdDataPointer ( + VOID + ); + +/** + This function sets the silicon init UPD data pointer. + + @param[in] SiliconInitUpdPtr silicon init UPD data pointer. +**/ +VOID +EFIAPI +SetFspSiliconInitUpdDataPointer ( + IN VOID *SiliconInitUpdPtr + ); + +/** + This function gets the silicon init UPD data pointer. + + @return silicon init UPD data pointer. +**/ +VOID * +EFIAPI +GetFspSiliconInitUpdDataPointer ( + VOID + ); + /** Set FSP measurement point timestamp. diff --git a/IntelFspPkg/Include/Library/FspSecPlatformLib.h b/IntelFspPkg/Include/Library/FspSecPlatformLib.h index c6ed43001d..d5c7e77930 100644 --- a/IntelFspPkg/Include/Library/FspSecPlatformLib.h +++ b/IntelFspPkg/Include/Library/FspSecPlatformLib.h @@ -71,4 +71,18 @@ SecCarInit ( IN FSP_TEMP_RAM_INIT_PARAMS *TempRamInitParamPtr ); +/** + This function check the signture of UPD. + + @param[in] ApiIdx Internal index of the FSP API. + @param[in] ApiParam Parameter of the FSP API. + +**/ +EFI_STATUS +EFIAPI +FspUpdSignatureCheck ( + IN UINT32 ApiIdx, + IN VOID *ApiParam + ); + #endif diff --git a/IntelFspPkg/Include/Private/FspGlobalData.h b/IntelFspPkg/Include/Private/FspGlobalData.h index f50255fa7f..be33e89c17 100644 --- a/IntelFspPkg/Include/Private/FspGlobalData.h +++ b/IntelFspPkg/Include/Private/FspGlobalData.h @@ -34,6 +34,8 @@ typedef struct { FSP_PLAT_DATA PlatformData; FSP_INFO_HEADER *FspInfoHeader; VOID *UpdDataRgnPtr; + VOID *MemoryInitUpdPtr; + VOID *SiliconInitUpdPtr; UINT8 ApiMode; UINT8 Reserved[3]; UINT32 PerfIdx; diff --git a/IntelFspPkg/Library/BaseFspCommonLib/FspCommonLib.c b/IntelFspPkg/Library/BaseFspCommonLib/FspCommonLib.c index 7de84a0a7e..a31d16bb70 100644 --- a/IntelFspPkg/Library/BaseFspCommonLib/FspCommonLib.c +++ b/IntelFspPkg/Library/BaseFspCommonLib/FspCommonLib.c @@ -289,6 +289,91 @@ GetFspUpdDataPointer ( return FspData->UpdDataRgnPtr; } + +/** + This function sets the memory init UPD data pointer. + + @param[in] MemoryInitUpdPtr memory init UPD data pointer. +**/ +VOID +EFIAPI +SetFspMemoryInitUpdDataPointer ( + IN VOID *MemoryInitUpdPtr + ) +{ + FSP_GLOBAL_DATA *FspData; + + // + // Get the Fsp Global Data Pointer + // + FspData = GetFspGlobalDataPointer (); + + // + // Set the memory init UPD pointer. + // + FspData->MemoryInitUpdPtr = MemoryInitUpdPtr; +} + +/** + This function gets the memory init UPD data pointer. + + @return memory init UPD data pointer. +**/ +VOID * +EFIAPI +GetFspMemoryInitUpdDataPointer ( + VOID + ) +{ + FSP_GLOBAL_DATA *FspData; + + FspData = GetFspGlobalDataPointer (); + return FspData->MemoryInitUpdPtr; +} + + +/** + This function sets the silicon init UPD data pointer. + + @param[in] SiliconInitUpdPtr silicon init UPD data pointer. +**/ +VOID +EFIAPI +SetFspSiliconInitUpdDataPointer ( + IN VOID *SiliconInitUpdPtr + ) +{ + FSP_GLOBAL_DATA *FspData; + + // + // Get the Fsp Global Data Pointer + // + FspData = GetFspGlobalDataPointer (); + + // + // Set the silicon init UPD data pointer. + // + FspData->SiliconInitUpdPtr = SiliconInitUpdPtr; +} + +/** + This function gets the silicon init UPD data pointer. + + @return silicon init UPD data pointer. +**/ +VOID * +EFIAPI +GetFspSiliconInitUpdDataPointer ( + VOID + ) +{ + FSP_GLOBAL_DATA *FspData; + + FspData = GetFspGlobalDataPointer (); + return FspData->SiliconInitUpdPtr; +} + + /** Set FSP measurement point timestamp. diff --git a/IntelFspPkg/Library/BaseFspPlatformLib/FspPlatformMemory.c b/IntelFspPkg/Library/BaseFspPlatformLib/FspPlatformMemory.c index 97cae9ad9d..ed5db933f1 100644 --- a/IntelFspPkg/Library/BaseFspPlatformLib/FspPlatformMemory.c +++ b/IntelFspPkg/Library/BaseFspPlatformLib/FspPlatformMemory.c @@ -86,7 +86,9 @@ FspMigrateTemporaryMemory ( FSP_INIT_PARAMS *FspInitParams; UINT32 *NewStackTop; VOID *BootLoaderTempRamHob; - VOID *UpdDataRgnPtr; + UINT32 UpdDataRgnPtr; + UINT32 MemoryInitUpdPtr; + UINT32 SiliconInitUpdPtr; VOID *PlatformDataPtr; UINT8 ApiMode; @@ -105,7 +107,7 @@ FspMigrateTemporaryMemory ( if (ApiMode == 0) { BootLoaderTempRamHob = BuildGuidHob (&gFspBootLoaderTemporaryMemoryGuid, BootLoaderTempRamSize); } else { - BootLoaderTempRamHob = (VOID *)AllocatePool (BootLoaderTempRamSize); + BootLoaderTempRamHob = (VOID *)AllocatePages (EFI_SIZE_TO_PAGES (BootLoaderTempRamSize)); } ASSERT(BootLoaderTempRamHob != NULL); @@ -150,9 +152,20 @@ FspMigrateTemporaryMemory ( // // Update UPD pointer in FSP Global Data // - UpdDataRgnPtr = ((FSP_INIT_RT_COMMON_BUFFER *)FspInitParams->RtBufferPtr)->UpdDataRgnPtr; - if (UpdDataRgnPtr != NULL) { - SetFspUpdDataPointer (UpdDataRgnPtr); + if (ApiMode == 0) { + UpdDataRgnPtr = (UINT32)((UINT32 *)GetFspUpdDataPointer ()); + if (UpdDataRgnPtr >= BootLoaderTempRamStart && UpdDataRgnPtr < BootLoaderTempRamEnd) { + MemoryInitUpdPtr = (UINT32)((UINT32 *)GetFspMemoryInitUpdDataPointer ()); + SiliconInitUpdPtr = (UINT32)((UINT32 *)GetFspSiliconInitUpdDataPointer ()); + SetFspUpdDataPointer ((VOID *)(UpdDataRgnPtr + OffsetGap)); + SetFspMemoryInitUpdDataPointer ((VOID *)(MemoryInitUpdPtr + OffsetGap)); + SetFspSiliconInitUpdDataPointer ((VOID *)(SiliconInitUpdPtr + OffsetGap)); + } + } else { + MemoryInitUpdPtr = (UINT32)((UINT32 *)GetFspMemoryInitUpdDataPointer ()); + if (MemoryInitUpdPtr >= BootLoaderTempRamStart && MemoryInitUpdPtr < BootLoaderTempRamEnd) { + SetFspMemoryInitUpdDataPointer ((VOID *)(MemoryInitUpdPtr + OffsetGap)); + } } // diff --git a/IntelFspPkg/Library/SecFspSecPlatformLibNull/PlatformSecLibNull.c b/IntelFspPkg/Library/SecFspSecPlatformLibNull/PlatformSecLibNull.c index 4de2a1d755..d72d05f2e2 100644 --- a/IntelFspPkg/Library/SecFspSecPlatformLibNull/PlatformSecLibNull.c +++ b/IntelFspPkg/Library/SecFspSecPlatformLibNull/PlatformSecLibNull.c @@ -14,4 +14,21 @@ #include +/** + This function check the signture of UPD. + + @param[in] ApiIdx Internal index of the FSP API. + @param[in] ApiParam Parameter of the FSP API. + +**/ +EFI_STATUS +EFIAPI +FspUpdSignatureCheck ( + IN UINT32 ApiIdx, + IN VOID *ApiParam + ) +{ + return EFI_SUCCESS; +} + diff --git a/IntelFspPkg/Tools/GenCfgOpt.py b/IntelFspPkg/Tools/GenCfgOpt.py index 77eaf6481f..a38da70212 100644 --- a/IntelFspPkg/Tools/GenCfgOpt.py +++ b/IntelFspPkg/Tools/GenCfgOpt.py @@ -88,6 +88,48 @@ are permitted provided that the following conditions are met: **/ """ +def UpdateMemSiUpdInitOffsetValue (DscFile): + DscFd = open(DscFile, "r") + DscLines = DscFd.readlines() + DscFd.close() + + DscContent = [] + MemUpdInitOffset = 0 + SiUpdInitOffset = 0 + MemUpdInitOffsetValue = 0 + SiUpdInitOffsetValue = 0 + + while len(DscLines): + DscLine = DscLines.pop(0) + DscContent.append(DscLine) + DscLine = DscLine.strip() + Match = re.match("^([_a-zA-Z0-9]+).(MemoryInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine) + if Match: + MemUpdInitOffsetValue = int(Match.group(5), 0) + Match = re.match("^\s*([_a-zA-Z0-9]+).(SiliconInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine) + if Match: + SiUpdInitOffsetValue = int(Match.group(5), 0) + Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(0x244450554D454D24)",DscLine) + if Match: + MemUpdInitOffset = int(Match.group(3), 0) + Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(0x244450555F495324)",DscLine) + if Match: + SiUpdInitOffset = int(Match.group(3), 0) + + if MemUpdInitOffsetValue != MemUpdInitOffset or SiUpdInitOffsetValue != SiUpdInitOffset: + MemUpdInitOffsetStr = "0x%08X" % MemUpdInitOffset + SiUpdInitOffsetStr = "0x%08X" % SiUpdInitOffset + DscFd = open(DscFile,"w") + for DscLine in DscContent: + Match = re.match("^\s*([_a-zA-Z0-9]+).(MemoryInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine) + if Match: + DscLine = re.sub(r'(?:[^\s]+\s*$)', MemUpdInitOffsetStr + '\n', DscLine) + Match = re.match("^\s*([_a-zA-Z0-9]+).(SiliconInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine) + if Match: + DscLine = re.sub(r'(?:[^\s]+\s*$)', SiUpdInitOffsetStr + '\n', line) + DscFd.writelines(DscLine) + DscFd.close() + class CLogicalExpression: def __init__(self): self.index = 0 @@ -889,6 +931,22 @@ EndList return 256 TxtBody = [] + for Item in self._CfgItemList: + if str(Item['cname']) == 'Signature' and Item['length'] == 8: + Value = int(Item['value'], 16) + Chars = [] + while Value != 0x0: + Chars.append(chr(Value & 0xFF)) + Value = Value >> 8 + SignatureStr = ''.join(Chars) + if int(Item['offset']) == 0: + TxtBody.append("#define FSP_UPD_SIGNATURE %s /* '%s' */\n" % (Item['value'], SignatureStr)) + elif 'MEM' in SignatureStr: + TxtBody.append("#define FSP_MEMORY_INIT_UPD_SIGNATURE %s /* '%s' */\n" % (Item['value'], SignatureStr)) + else: + TxtBody.append("#define FSP_SILICON_INIT_UPD_SIGNATURE %s /* '%s' */\n" % (Item['value'], SignatureStr)) + TxtBody.append("\n") + for Region in ['UPD', 'VPD']: # Write PcdVpdRegionSign and PcdImageRevision @@ -1176,6 +1234,8 @@ def Main(): print "ERROR: Cannot open DSC file '%s' !" % DscFile return 2 + UpdateMemSiUpdInitOffsetValue(DscFile) + OutFile = '' if argc > 4: if sys.argv[4][0] == '-': diff --git a/IntelFspPkg/Tools/UserManuals/GenCfgOptUserManual.docx b/IntelFspPkg/Tools/UserManuals/GenCfgOptUserManual.docx index e4da8e057b..1cbc459eba 100644 Binary files a/IntelFspPkg/Tools/UserManuals/GenCfgOptUserManual.docx and b/IntelFspPkg/Tools/UserManuals/GenCfgOptUserManual.docx differ