From da6504e5ccaa233b0ec051762809905f20ca5859 Mon Sep 17 00:00:00 2001 From: Du Lin Date: Fri, 20 Dec 2024 23:49:19 +0800 Subject: [PATCH 1/2] IntelFsp2WrapperPkg: Save FspHobListPtr right after FspMemoryInit exits Save FspHobList pointer to HOB right after FspMemoryInit exits so that FspHobList pointer is available when performing platform related reset in CallFspWrapperResetSystem(). Some platforms may consume FSP HOBs prior to performing platform related reset. Signed-off-by: Du Lin --- .../FspmWrapperPeim/FspmWrapperPeim.c | 22 ++++++++-------- .../FspWrapperMultiPhaseProcessLib.inf | 5 ++++ .../PeiFspWrapperMultiPhaseProcessLib.c | 26 +++++++++++++++++++ 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c index d9fbb2141752..d88061407643 100644 --- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c +++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c @@ -124,6 +124,17 @@ PeiFspMemoryInit ( TimeStampCounterStart = AsmReadTsc (); Status = CallFspMemoryInit (FspmUpdDataPtr, &FspHobListPtr); + // + // FspHobList is not complete at this moment. + // Save FspHobList pointer to hob, so that it can be got later + // + HobData = BuildGuidHob ( + &gFspHobGuid, + sizeof (VOID *) + ); + ASSERT (HobData != NULL); + CopyMem (HobData, &FspHobListPtr, sizeof (FspHobListPtr)); + // // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status // @@ -167,17 +178,6 @@ PeiFspMemoryInit ( PostFspmHobProcess (FspHobListPtr); - // - // FspHobList is not complete at this moment. - // Save FspHobList pointer to hob, so that it can be got later - // - HobData = BuildGuidHob ( - &gFspHobGuid, - sizeof (VOID *) - ); - ASSERT (HobData != NULL); - CopyMem (HobData, &FspHobListPtr, sizeof (FspHobListPtr)); - return Status; } diff --git a/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/FspWrapperMultiPhaseProcessLib.inf b/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/FspWrapperMultiPhaseProcessLib.inf index e76a7465f2f1..16ad3414067b 100644 --- a/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/FspWrapperMultiPhaseProcessLib.inf +++ b/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/FspWrapperMultiPhaseProcessLib.inf @@ -38,11 +38,16 @@ FspWrapperPlatformLib PeiServicesLib FspWrapperPlatformMultiPhaseLib + BaseMemoryLib + HobLib [Ppis] gEfiPeiReadOnlyVariable2PpiGuid gEdkiiPeiVariablePpiGuid +[Guids] + gFspHobGuid ## CONSUMES + [Pcd] gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress ## CONSUMES gIntelFsp2WrapperTokenSpaceGuid.PcdFspsBaseAddress ## CONSUMES diff --git a/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/PeiFspWrapperMultiPhaseProcessLib.c b/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/PeiFspWrapperMultiPhaseProcessLib.c index 224c24881dd2..68331c701d73 100644 --- a/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/PeiFspWrapperMultiPhaseProcessLib.c +++ b/IntelFsp2WrapperPkg/Library/FspWrapperMultiPhaseProcessLib/PeiFspWrapperMultiPhaseProcessLib.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include /** Execute 32-bit FSP API entry code. @@ -156,6 +158,8 @@ FspWrapperVariableRequestHandler ( EDKII_PEI_VARIABLE_PPI *VariablePpi; BOOLEAN WriteVariableSupport; FSP_MULTI_PHASE_COMPLETE_VARIABLE_REQUEST_PARAMS CompleteVariableRequestParams; + VOID *GuidHob; + VOID *HobData; WriteVariableSupport = TRUE; Status = PeiServicesLocatePpi ( @@ -288,6 +292,16 @@ FspWrapperVariableRequestHandler ( } } + // + // Refresh FspHobList pointer stored in HOB. + // + GuidHob = GetFirstGuidHob (&gFspHobGuid); + ASSERT (GuidHob != NULL); + if (GuidHob != NULL) { + HobData = GET_GUID_HOB_DATA (GuidHob); + CopyMem (HobData, FspHobListPtr, sizeof (*FspHobListPtr)); + } + // // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status // @@ -321,6 +335,8 @@ FspWrapperMultiPhaseHandler ( FSP_MULTI_PHASE_GET_NUMBER_OF_PHASES_PARAMS FspMultiPhaseGetNumber; UINT32 Index; UINT32 NumOfPhases; + VOID *GuidHob; + VOID *HobData; // // Query FSP for the number of phases supported. @@ -352,6 +368,16 @@ FspWrapperMultiPhaseHandler ( FspMultiPhaseParams.MultiPhaseParamPtr = NULL; Status = CallFspMultiPhaseEntry (&FspMultiPhaseParams, FspHobListPtr, ComponentIndex); + // + // Refresh FspHobList pointer stored in HOB. + // + GuidHob = GetFirstGuidHob (&gFspHobGuid); + ASSERT (GuidHob != NULL); + if (GuidHob != NULL) { + HobData = GET_GUID_HOB_DATA (GuidHob); + CopyMem (HobData, FspHobListPtr, sizeof (*FspHobListPtr)); + } + if (Status == FSP_STATUS_VARIABLE_REQUEST) { // // call to Variable request handler From f39b1210660bd8b9a0ec5c6e415673c2ca6dbafd Mon Sep 17 00:00:00 2001 From: Ajan Zhong Date: Tue, 24 Dec 2024 15:58:27 +0800 Subject: [PATCH 2/2] UefiPayloadPkg: Align base address for ACPI region In platform which support ACPI 2.0 only, the base address of ACPI region is not page aligned. This unalinged base address leads to failure at BuildMemoryAllocationHob when parsing ACPI node in FdtParserLib, before building gUniversalPayloadAcpiTableGuid GUID HOB. Align base address of ACPI region down to EFI_PAGE_SIZE to make sure base address always aligned. Signed-off-by: Ajan Zhong --- UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c b/UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c index 372ca0776558..05780a2c19f2 100644 --- a/UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c +++ b/UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c @@ -60,6 +60,8 @@ typedef enum { EFI_PCI_IO_ATTRIBUTE_ISA_IO | \ EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO) +#define UPL_ALIGN_DOWN(Addr) ((UINT64)(Addr) & ~(UINT64)(EFI_PAGE_SIZE - 1)) + extern VOID *mHobList; UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *mPciRootBridgeInfo = NULL; INT32 mNode[0x500] = { 0 }; @@ -289,7 +291,12 @@ ParseReservedMemory ( BuildMemoryAllocationHob (StartAddress, NumberOfBytes, EfiACPIMemoryNVS); } else if (AsciiStrnCmp (TempStr, "acpi", AsciiStrLen ("acpi")) == 0) { DEBUG ((DEBUG_INFO, " acpi, StartAddress:%x, NumberOfBytes:%x\n", StartAddress, NumberOfBytes)); - BuildMemoryAllocationHob (StartAddress, NumberOfBytes, EfiBootServicesData); + + BuildMemoryAllocationHob ( + UPL_ALIGN_DOWN (StartAddress), + ALIGN_VALUE (NumberOfBytes, EFI_PAGE_SIZE), + EfiBootServicesData + ); PlatformAcpiTable = BuildGuidHob (&gUniversalPayloadAcpiTableGuid, sizeof (UNIVERSAL_PAYLOAD_ACPI_TABLE)); if (PlatformAcpiTable != NULL) { DEBUG ((DEBUG_INFO, " build gUniversalPayloadAcpiTableGuid , NumberOfBytes:%x\n", NumberOfBytes));