Date   

[edk2-platforms: PATCH v4 8/9] WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.

Chiu, Chasel
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3678

Implementation should search FSP_NON_VOLATILE_STORAGE_HOB2 firstly
and only search FSP_NON_VOLATILE_STORAGE_HOB when former one is not found.

Also added PeiGetLargeVariable () to support the scenarios where the
variable data size is bigger than a single variable size limit.

Cc: Isaac Oram <isaac.w.oram@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>
---
Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c =
| 29 +++++++++++++++++++++++------
Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.in=
f | 4 +++-
Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc =
| 1 +
3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3=
NvramSave.c b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S=
3NvramSave.c
index 709c7ad479..01e36cda27 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa=
ve.c
+++ b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa=
ve.c
@@ -7,6 +7,7 @@
**/=0D
=0D
#include "S3NvramSave.h"=0D
+#include <Guid/FspNonVolatileStorageHob2.h>=0D
#include <Library/MemoryAllocationLib.h>=0D
#include <Library/LargeVariableReadLib.h>=0D
#include <Library/LargeVariableWriteLib.h>=0D
@@ -80,21 +81,37 @@ SaveFspNonVolatileStorageHob (
Status =3D EFI_SUCCESS;=0D
=0D
DEBUG ((DEBUG_INFO, "Saving FSP / MRC Training Data\n"));=0D
- GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);=0D
+ //=0D
+ // Firstly check version2 FspNvsHob.=0D
+ //=0D
+ GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHob2Guid);=0D
if (GuidHob !=3D NULL) {=0D
- HobData =3D GET_GUID_HOB_DATA (GuidHob);=0D
- DataSize =3D GET_GUID_HOB_DATA_SIZE (GuidHob);=0D
+ HobData =3D (VOID *) (UINTN) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN=
) GuidHob)->NvsDataPtr;=0D
+ DataSize =3D (UINTN) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHo=
b)->NvsDataLength;=0D
+ } else {=0D
+ //=0D
+ // Fall back to version1 FspNvsHob=0D
+ //=0D
+ GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);=0D
+ if (GuidHob !=3D NULL) {=0D
+ HobData =3D GET_GUID_HOB_DATA (GuidHob);=0D
+ DataSize =3D GET_GUID_HOB_DATA_SIZE (GuidHob);=0D
+ }=0D
+ }=0D
+ if (HobData !=3D NULL) {=0D
+ DEBUG ((DEBUG_INFO, "FspNvsHob.Size: %d\n", DataSize));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataPtr: 0x%x\n", HobData));=0D
if (DataSize > 0) {=0D
=0D
//=0D
// Check if the presently saved data is identical to the data given =
by MRC/FSP=0D
//=0D
- Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorag=
eHobGuid, &FspNvsBufferSize, NULL);=0D
+ Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariable=
Guid, &FspNvsBufferSize, NULL);=0D
if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
if (FspNvsBufferSize =3D=3D DataSize) {=0D
VariableData =3D AllocatePool (FspNvsBufferSize);=0D
if (VariableData !=3D NULL) {=0D
- Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatile=
StorageHobGuid, &FspNvsBufferSize, VariableData);=0D
+ Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVa=
riableGuid, &FspNvsBufferSize, VariableData);=0D
if (!EFI_ERROR (Status) && (FspNvsBufferSize =3D=3D DataSize) =
&& (0 =3D=3D CompareMem (HobData, VariableData, DataSize))) {=0D
DataIsIdentical =3D TRUE;=0D
}=0D
@@ -105,7 +122,7 @@ SaveFspNonVolatileStorageHob (
Status =3D EFI_SUCCESS;=0D
=0D
if (!DataIsIdentical) {=0D
- Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStor=
ageHobGuid, TRUE, DataSize, HobData);=0D
+ Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariab=
leGuid, TRUE, DataSize, HobData);=0D
ASSERT_EFI_ERROR (Status);=0D
DEBUG ((DEBUG_INFO, "Saved size of FSP / MRC Training Data: 0x%x\n=
", DataSize));=0D
} else {=0D
diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3=
NvramSave.inf b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave=
/S3NvramSave.inf
index e62baa24c4..a77125cf44 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa=
ve.inf
+++ b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa=
ve.inf
@@ -43,7 +43,9 @@
LargeVariableWriteLib=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid # CONSUMES=0D
+ gFspNonVolatileStorageHobGuid # CONSUMES=0D
+ gFspNonVolatileStorageHob2Guid # CONSUMES=0D
+ gFspNvsBufferVariableGuid # PRODUCES=0D
=0D
[Pcd]=0D
gEfiCpRcPkgTokenSpaceGuid.PcdPeiSyshostMemorySize=0D
diff --git a/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc b/Platform/=
Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
index dc3dd0e026..87165103bf 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
+++ b/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
@@ -637,6 +637,7 @@
=0D
[LibraryClasses.Common]=0D
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.in=
f=0D
+ PeiLib|MinPlatformPkg/Library/PeiLib/PeiLib.inf=0D
=0D
[Components.IA32]=0D
UefiCpuPkg/SecCore/SecCore.inf=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH v4 9/9] WhitleySiliconPkg: Use same variable name for FspNvsHob.

Chiu, Chasel
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3678

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Isaac Oram <isaac.w.oram@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>
---
Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPl=
atformLib.c | 35 +++++++++--------------------------
Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPl=
atformLib.inf | 3 ++-
2 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/=
FspWrapperPlatformLib.c b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrappe=
rPlatformLib/FspWrapperPlatformLib.c
index a6196a78b0..95a1f2a33c 100644
--- a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrap=
perPlatformLib.c
+++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrap=
perPlatformLib.c
@@ -13,7 +13,7 @@
#include <Library/HobLib.h>=0D
#include <Library/MemoryAllocationLib.h>=0D
#include <Library/LargeVariableReadLib.h>=0D
-=0D
+#include <Library/PeiLib.h>=0D
#include <FspmUpd.h>=0D
#include <Guid/PlatformInfo.h>=0D
#include <Ppi/UpiPolicyPpi.h>=0D
@@ -24,39 +24,22 @@ GetFspNvsBuffer (
)=0D
{=0D
EFI_STATUS Status;=0D
- UINTN FspNvsBufferSize;=0D
- VOID *FspNvsBufferPtr;=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
=0D
FspNvsBufferPtr =3D NULL;=0D
FspNvsBufferSize =3D 0;=0D
- Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageHob=
Guid, &FspNvsBufferSize, NULL);=0D
- if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
- DEBUG ((DEBUG_INFO, "FspNvsBuffer Size =3D %d\n", FspNvsBufferSize));=
=0D
- FspNvsBufferPtr =3D AllocateZeroPool (FspNvsBufferSize);=0D
- if (FspNvsBufferPtr =3D=3D NULL) {=0D
- DEBUG ((DEBUG_ERROR, "Error: Cannot create FspNvsBuffer, out of memo=
ry!\n"));=0D
- ASSERT (FALSE);=0D
- return NULL;=0D
- }=0D
- Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageH=
obGuid, &FspNvsBufferSize, FspNvsBufferPtr);=0D
- if (EFI_ERROR (Status)) {=0D
- DEBUG ((DEBUG_ERROR, "Error: Unable to read FspNvsBuffer UEFI variab=
le Status: %r\n", Status));=0D
- ASSERT_EFI_ERROR (Status);=0D
- return NULL;=0D
- }=0D
-=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
return FspNvsBufferPtr;=0D
-=0D
- } else if (Status =3D=3D EFI_NOT_FOUND) {=0D
- DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does =
not exist (this is likely a first boot)\n"));=0D
} else {=0D
- DEBUG ((DEBUG_ERROR, "Error: Unable to read FspNvsBuffer UEFI variable=
Status: %r\n", Status));=0D
- ASSERT_EFI_ERROR (Status);=0D
- }=0D
-=0D
+ DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does =
not exist (this is likely a first boot)\n"));=0D
return NULL;=0D
}=0D
=0D
+=0D
+}=0D
+=0D
VOID=0D
EFIAPI=0D
UpdateFspmUpdData (=0D
diff --git a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/=
FspWrapperPlatformLib.inf b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrap=
perPlatformLib/FspWrapperPlatformLib.inf
index 3e80ea670c..6ee15ea55f 100644
--- a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrap=
perPlatformLib.inf
+++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrap=
perPlatformLib.inf
@@ -58,11 +58,12 @@
=0D
[Guids]=0D
gEfiPlatformInfoGuid=0D
- gFspNonVolatileStorageHobGuid=0D
+ gFspNvsBufferVariableGuid # CONSUMES=0D
=0D
[LibraryClasses]=0D
PeiServicesLib=0D
LargeVariableReadLib=0D
+ PeiLib=0D
=0D
[Pcd]=0D
gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamBase ## CONSUMES=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH v4 7/9] WhiskeylakeOpenBoardPkg: Use same variable name for FspNvsHob.

Chiu, Chasel
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3678

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>
---
Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicy=
UpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++---=
------------------------------------------------
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSili=
conPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++---=
------------------------------------------------
Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicy=
UpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSili=
conPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 4 ++--
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapInclud=
e.fdf | 18 +++++++++------=
---
5 files changed, 37 insertions(+), 116 deletions(-)

diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiS=
iliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/Whiskeyl=
akeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscU=
pdUpdateLib.c
index a341a58930..ab35bc3f8f 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconP=
olicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconP=
olicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -2,7 +2,7 @@
Implementation of Fsp Misc UPD Initialization.=0D
=0D
=0D
- Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
**/=0D
=0D
@@ -17,11 +17,9 @@
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
=0D
-#include <Library/MemoryAllocationLib.h>=0D
#include <Library/DebugLib.h>=0D
#include <Library/DebugPrintErrorLevelLib.h>=0D
#include <Library/PciLib.h>=0D
-#include <Ppi/ReadOnlyVariable2.h>=0D
#include <Guid/MemoryOverwriteControl.h>=0D
#include <PchAccess.h>=0D
=0D
@@ -44,55 +42,18 @@ PeiFspMiscUpdUpdatePreMem (
)=0D
{=0D
EFI_STATUS Status;=0D
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices;=0D
- UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
-=0D
- Status =3D PeiServicesLocatePpi (=0D
- &gEfiPeiReadOnlyVariable2PpiGuid,=0D
- 0,=0D
- NULL,=0D
- (VOID **) &VariableServices=0D
- );=0D
- if (EFI_ERROR (Status)) {=0D
- ASSERT_EFI_ERROR (Status);=0D
- return Status;=0D
- }=0D
-=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
- MemorySavedData =3D AllocatePool (VariableSize);=0D
- if (MemorySavedData =3D=3D NULL) {=0D
- ASSERT (MemorySavedData !=3D NULL);=0D
- return EFI_OUT_OF_RESOURCES;=0D
- }=0D
-=0D
- DEBUG ((DEBUG_INFO, "VariableSize is 0x%x\n", VariableSize));=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_SUCCESS) {=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
- } else {=0D
- DEBUG ((DEBUG_ERROR, "Fail to retrieve Variable:\"MemoryConfig\" gMe=
moryConfigVariableGuid, Status =3D %r\n", Status));=0D
- ASSERT_EFI_ERROR (Status);=0D
- }=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
+=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
+ } else {=0D
+ DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does =
not exist (this is likely a first boot)\n"));=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D NULL;=0D
}=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
=0D
return EFI_SUCCESS;=0D
}=0D
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Lib=
rary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel=
/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdate=
LibFsp/PeiFspMiscUpdUpdateLib.c
index 145deb5de3..381ef232ea 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/Pe=
iSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/Pe=
iSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -2,7 +2,7 @@
Implementation of Fsp Misc UPD Initialization.=0D
=0D
=0D
- Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
**/=0D
=0D
@@ -18,11 +18,9 @@
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
=0D
-#include <Library/MemoryAllocationLib.h>=0D
#include <Library/DebugLib.h>=0D
#include <Library/DebugPrintErrorLevelLib.h>=0D
#include <Library/PciLib.h>=0D
-#include <Ppi/ReadOnlyVariable2.h>=0D
#include <Guid/MemoryOverwriteControl.h>=0D
#include <PchAccess.h>=0D
#include <Platform.h>=0D
@@ -46,54 +44,17 @@ PeiFspMiscUpdUpdatePreMem (
)=0D
{=0D
EFI_STATUS Status;=0D
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices;=0D
- UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
-=0D
- Status =3D PeiServicesLocatePpi (=0D
- &gEfiPeiReadOnlyVariable2PpiGuid,=0D
- 0,=0D
- NULL,=0D
- (VOID **) &VariableServices=0D
- );=0D
- if (EFI_ERROR (Status)) {=0D
- ASSERT_EFI_ERROR (Status);=0D
- return Status;=0D
- }=0D
-=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
- MemorySavedData =3D AllocatePool (VariableSize);=0D
- if (MemorySavedData =3D=3D NULL) {=0D
- ASSERT (MemorySavedData !=3D NULL);=0D
- return EFI_OUT_OF_RESOURCES;=0D
- }=0D
-=0D
- DEBUG ((DEBUG_INFO, "VariableSize is 0x%x\n", VariableSize));=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_SUCCESS) {=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
- } else {=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D NULL;=0D
- DEBUG ((DEBUG_ERROR, "Fail to retrieve Variable:\"MemoryConfig\" gMe=
moryConfigVariableGuid, Status =3D %r\n", Status));=0D
- ASSERT_EFI_ERROR (Status);=0D
- }=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
+=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
+ } else {=0D
+ DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does =
not exist (this is likely a first boot)\n"));=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D NULL;=0D
}=0D
=0D
FspmUpd->FspmConfig.TsegSize =3D FixedPcdGet32 (PcdTsegSize=
);=0D
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiS=
iliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platform/Intel/=
WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/Pei=
SiliconPolicyUpdateLibFsp.inf
index 2c90d0cb94..362dc2c995 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconP=
olicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconP=
olicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -2,7 +2,7 @@
# Provide FSP wrapper platform related function.=0D
#=0D
#=0D
-# Copyright (c) 2019 - 2020 Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2019 - 2021 Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -82,7 +82,6 @@
PchInfoLib=0D
PchHsioLib=0D
PchPcieRpLib=0D
- MemoryAllocationLib=0D
DebugPrintErrorLevelLib=0D
SiPolicyLib=0D
PchGbeLib=0D
@@ -132,7 +131,7 @@
gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdMrcSpdAddressTable3=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Lib=
rary/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platfo=
rm/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPoli=
cyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index 529c2f1253..1a664b1327 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/Pe=
iSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/Pe=
iSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -2,7 +2,7 @@
# FSP silicon policy updates for the Up Xtreme board.=0D
#=0D
#=0D
-# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>=
=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -136,7 +136,7 @@
gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdBoardBomId=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/Fl=
ashMapInclude.fdf b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include=
/Fdf/FlashMapInclude.fdf
index f7aa730ae7..698efce248 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapI=
nclude.fdf
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapI=
nclude.fdf
@@ -2,7 +2,7 @@
# Flash map for the UpXtreme Board.=0D
#=0D
#=0D
-# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>=
=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -35,16 +35,16 @@ SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize =
=3D 0x00090000
SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset =3D 0x=
00190000 # Flash addr (0xFFAE0000)=0D
SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize =3D 0x=
00190000 #=0D
SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryOffset =3D 0x=
00320000 # Flash addr (0xFFC70000)=0D
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemorySize =3D 0x=
00170000 #=0D
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSOffset =3D 0x=
00490000 # Flash addr (0xFFDE0000)=0D
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemorySize =3D 0x=
00160000 #=0D
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSOffset =3D 0x=
00480000 # Flash addr (0xFFDD0000)=0D
SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSSize =3D 0x=
00070000 #=0D
-SET gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvOffset =3D 0x=
00500000 # Flash addr (0xFFE50000)=0D
+SET gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvOffset =3D 0x=
004F0000 # Flash addr (0xFFE40000)=0D
SET gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize =3D 0x=
00050000 #=0D
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMOffset =3D 0x=
00550000 # Flash addr (0xFFEA0000)=0D
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMOffset =3D 0x=
00540000 # Flash addr (0xFFE90000)=0D
SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMSize =3D 0x=
000EA000 #=0D
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTOffset =3D 0x=
0063A000 # Flash addr (0xFFF8A000)=0D
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTOffset =3D 0x=
0062A000 # Flash addr (0xFFF7A000)=0D
SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTSize =3D 0x=
00006000 #=0D
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedPreMemoryOffset =3D 0x=
00640000 # Flash addr (0xFFF90000)=0D
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedPreMemoryOffset =3D 0x=
00630000 # Flash addr (0xFFF80000)=0D
SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedPreMemorySize =3D 0x=
00010000 #=0D
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemoryOffset =3D 0x=
00650000 # Flash addr (0xFFFA0000)=0D
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemorySize =3D 0x=
00060000 #=0D
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemoryOffset =3D 0x=
00640000 # Flash addr (0xFFF90000)=0D
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemorySize =3D 0x=
00070000 #=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH v4 6/9] TigerlakeOpenBoardPkg: Use same variable name for FspNvsHob.

Chiu, Chasel
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3678

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Sai Chaganty <rangasai.v.chaganty@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Heng Luo <heng.luo@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>
Reviewed-by: Heng Luo <heng.luo@...>
---
Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLi=
b/PeiFspPolicyInitLib.c | 21 ++++++++++++++++++---
Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLi=
b/PeiFspPolicyInitLib.inf | 1 +
2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFsp=
PolicyInitLib/PeiFspPolicyInitLib.c b/Platform/Intel/TigerlakeOpenBoardPkg/=
FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.c
index fc523e93d1..938b74e5d8 100644
--- a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyI=
nitLib/PeiFspPolicyInitLib.c
+++ b/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyI=
nitLib/PeiFspPolicyInitLib.c
@@ -9,7 +9,9 @@
#include <Library/FspWrapperApiLib.h>=0D
#include <Library/BaseMemoryLib.h>=0D
#include <Library/MemoryAllocationLib.h>=0D
+#include <Library/PeiLib.h>=0D
#include <Ppi/FspmArchConfigPpi.h>=0D
+#include <PolicyUpdateMacro.h>=0D
=0D
VOID=0D
EFIAPI=0D
@@ -70,9 +72,11 @@ SiliconPolicyDonePreMem(
)=0D
{=0D
EFI_STATUS Status;=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
#if FixedPcdGet8(PcdFspModeSelection) =3D=3D 0=0D
- FSPM_ARCH_CONFIG_PPI *FspmArchConfigPpi;=0D
- EFI_PEI_PPI_DESCRIPTOR *FspmArchConfigPpiDesc;=0D
+ FSPM_ARCH_CONFIG_PPI *FspmArchConfigPpi;=0D
+ EFI_PEI_PPI_DESCRIPTOR *FspmArchConfigPpiDesc;=0D
=0D
FspmArchConfigPpi =3D (FSPM_ARCH_CONFIG_PPI *) AllocateZeroPool (sizeof =
(FSPM_ARCH_CONFIG_PPI));=0D
if (FspmArchConfigPpi =3D=3D NULL) {=0D
@@ -80,7 +84,6 @@ SiliconPolicyDonePreMem(
return EFI_OUT_OF_RESOURCES;=0D
}=0D
FspmArchConfigPpi->Revision =3D 1;=0D
- FspmArchConfigPpi->NvsBufferPtr =3D NULL;=0D
FspmArchConfigPpi->BootLoaderTolumSize =3D 0;=0D
=0D
FspmArchConfigPpiDesc =3D (EFI_PEI_PPI_DESCRIPTOR *) AllocateZeroPool (s=
izeof (EFI_PEI_PPI_DESCRIPTOR));=0D
@@ -98,6 +101,18 @@ SiliconPolicyDonePreMem(
ASSERT_EFI_ERROR (Status);=0D
#endif=0D
=0D
+ //=0D
+ // Initialize S3 Data variable (S3DataPtr). It may be used for warm and =
fast boot paths.=0D
+ //=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid -=
%r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize));=
=0D
+ UPDATE_POLICY (((FSPM_UPD *) FspmUpd)->FspmArchUpd.NvsBufferPtr, FspmA=
rchConfigPpi->NvsBufferPtr, FspNvsBufferPtr);=0D
+ }=0D
+=0D
//=0D
// Install Policy Ready PPI=0D
// While installed, RC assumes the Policy is ready and finalized. So ple=
ase=0D
diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFsp=
PolicyInitLib/PeiFspPolicyInitLib.inf b/Platform/Intel/TigerlakeOpenBoardPk=
g/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf
index 708fbac08f..0236ae45ae 100644
--- a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyI=
nitLib/PeiFspPolicyInitLib.inf
+++ b/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyI=
nitLib/PeiFspPolicyInitLib.inf
@@ -181,3 +181,4 @@
gTianoLogoGuid ## CONSUMES=0D
gCnviConfigGuid ## CONSUMES=0D
gHdAudioPreMemConfigGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH v4 5/9] KabylakeOpenBoardPkg/KabylakeRvp3: Use same variable name for FspNvsHob.

Chiu, Chasel
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3678

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>
---
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSil=
iconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 25 ++++++++++----=
-----------
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSilicon=
PolicyUpdateLib/PeiSiliconPolicyUpdateLib.c | 23 +++++++++-----=
---------
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSil=
iconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSilicon=
PolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf | 2 +-
4 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Li=
brary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Inte=
l/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpda=
teLibFsp/PeiFspMiscUpdUpdateLib.c
index d8aff1960f..699f4297fa 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -1,7 +1,7 @@
/** @file=0D
Implementation of Fsp Misc UPD Initialization.=0D
=0D
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
=0D
-#include <Library/MemoryAllocationLib.h>=0D
#include <Library/DebugLib.h>=0D
#include <Library/DebugPrintErrorLevelLib.h>=0D
#include <Library/PciLib.h>=0D
@@ -38,25 +37,21 @@ PeiFspMiscUpdUpdatePreMem (
{=0D
EFI_STATUS Status;=0D
UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
+ VOID *FspNvsBufferPtr;=0D
UINT8 MorControl;=0D
VOID *MorControlPtr;=0D
=0D
//=0D
// Initialize S3 Data variable (S3DataPtr). It may be used for warm and =
fast boot paths.=0D
//=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D PeiGetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- &MemorySavedData,=0D
- &VariableSize=0D
- );=0D
- DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid=
- %r\n", Status));=0D
- DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
-=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ VariableSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &VariableSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid -=
%r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", VariableSize));=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
+ }=0D
if (FspmUpd->FspmArchUpd.NvsBufferPtr !=3D NULL) {=0D
//=0D
// Set the DISB bit in PCH (DRAM Initialization Scratchpad Bit - GEN_P=
MCON_A[23]),=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Librar=
y/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c b/Platform/Intel/Ka=
bylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/Pe=
iSiliconPolicyUpdateLib.c
index 2dce9be63c..22aadc0221 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
@@ -398,8 +398,8 @@ SiliconPolicyUpdatePreMem (
SA_MISC_PEI_PREMEM_CONFIG *MiscPeiPreMemConfig;=0D
MEMORY_CONFIG_NO_CRC *MemConfigNoCrc;=0D
VOID *Buffer;=0D
- UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
UINT8 SpdAddressTable[4];=0D
=0D
DEBUG((DEBUG_INFO, "\nUpdating Policy in Pre-Mem\n"));=0D
@@ -430,18 +430,13 @@ SiliconPolicyUpdatePreMem (
// Note: AmberLake FSP does not implement the FSPM_ARCH_CONFIG_PPI a=
dded in FSP 2.1, hence=0D
// the platform specific S3DataPtr must be used instead.=0D
//=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D PeiGetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- &MemorySavedData,=0D
- &VariableSize=0D
- );=0D
- DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHob=
Guid - %r\n", Status));=0D
- DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));=0D
- if (!EFI_ERROR (Status)) {=0D
- MiscPeiPreMemConfig->S3DataPtr =3D MemorySavedData;=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVaria=
bleGuid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGu=
id - %r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize=
));=0D
+ MiscPeiPreMemConfig->S3DataPtr =3D FspNvsBufferPtr;=0D
}=0D
=0D
//=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Li=
brary/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platf=
orm/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPo=
licyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index f8bec0c852..dacec18cd9 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -1,7 +1,7 @@
## @file=0D
# Provide FSP wrapper platform related function.=0D
#=0D
-# Copyright (c) 2017 - 2020 Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2017 - 2021 Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -80,7 +80,6 @@
PchInfoLib=0D
PchHsioLib=0D
PchPcieRpLib=0D
- MemoryAllocationLib=0D
CpuMailboxLib=0D
DebugPrintErrorLevelLib=0D
SiPolicyLib=0D
@@ -141,7 +140,7 @@
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGraphicsVbtGuid=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Librar=
y/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf b/Platform/Intel/=
KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/=
PeiSiliconPolicyUpdateLib.inf
index 5c2da68bf9..4b30ba02ea 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
@@ -50,7 +50,7 @@
gHsioPciePreMemConfigGuid ## CONSUMES=0D
gHsioSataPreMemConfigGuid ## CONSUMES=0D
gSaMiscPeiPreMemConfigGuid ## CONSUMES=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
=0D
[Pcd]=0D
gSiPkgTokenSpaceGuid.PcdPeiMinMemorySize=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH v4 4/9] KabylakeOpenBoardPkg/GalagoPro3: Use same variable name for FspNvsHob.

Chiu, Chasel
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3678

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Jeremy Soller <jeremy@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>
---
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSilic=
onPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 25 +++++++++++-----=
---------
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSilic=
onPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/=
KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLi=
bFsp/PeiFspMiscUpdUpdateLib.c
index 9d6c0176f6..dbc84631ac 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei=
SiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei=
SiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -1,7 +1,7 @@
/** @file=0D
Implementation of Fsp Misc UPD Initialization.=0D
=0D
-Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
=0D
-#include <Library/MemoryAllocationLib.h>=0D
#include <Library/DebugLib.h>=0D
#include <Library/DebugPrintErrorLevelLib.h>=0D
#include <Library/PciLib.h>=0D
@@ -38,24 +37,22 @@ PeiFspMiscUpdUpdatePreMem (
{=0D
EFI_STATUS Status;=0D
UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
+ VOID *FspNvsBufferPtr;=0D
UINT8 MorControl;=0D
VOID *MorControlPtr;=0D
=0D
//=0D
// Initialize S3 Data variable (S3DataPtr). It may be used for warm and =
fast boot paths.=0D
//=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D PeiGetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- &MemorySavedData,=0D
- &VariableSize=0D
- );=0D
- DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid=
- %r\n", Status));=0D
- DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ VariableSize =3D 0;=0D
+=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &VariableSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid -=
%r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", VariableSize));=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
+ }=0D
=0D
if (FspmUpd->FspmArchUpd.NvsBufferPtr !=3D NULL) {=0D
//=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platfor=
m/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicy=
UpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index 463455c90b..ceefe7639e 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei=
SiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei=
SiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -1,7 +1,7 @@
## @file=0D
# FSP wrapper silicon policy update library.=0D
#=0D
-# Copyright (c) 2019 - 2020 Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2019 - 2021 Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -81,7 +81,6 @@
PchInfoLib=0D
PchHsioLib=0D
PchPcieRpLib=0D
- MemoryAllocationLib=0D
CpuMailboxLib=0D
DebugPrintErrorLevelLib=0D
SiPolicyLib=0D
@@ -138,7 +137,7 @@
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGraphicsVbtGuid=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH v4 2/9] CometlakeOpenBoardPkg: Use same variable name for FspNvsHob.

Chiu, Chasel
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3678

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Cc: Deepika Kethi Reddy <deepika.kethi.reddy@...>
Cc: Kathappan Esakkithevar <kathappan.esakkithevar@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>
Reviewed-by: Kathappan Esakkithevar <kathappan.esakkithevar@...>
---
Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUp=
dateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++++------------=
-------------------------------------
Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUp=
dateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
2 files changed, 16 insertions(+), 52 deletions(-)

diff --git a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSil=
iconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/CometlakeO=
penBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUp=
dateLib.c
index 7dbdfa7c16..9e8606ada9 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPol=
icyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPol=
icyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -2,7 +2,7 @@
Implementation of Fsp Misc UPD Initialization.=0D
=0D
=0D
- Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
**/=0D
=0D
@@ -17,7 +17,6 @@
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
=0D
-#include <Library/MemoryAllocationLib.h>=0D
#include <Library/DebugLib.h>=0D
#include <Library/DebugPrintErrorLevelLib.h>=0D
#include <Library/PciLib.h>=0D
@@ -44,55 +43,21 @@ PeiFspMiscUpdUpdatePreMem (
)=0D
{=0D
EFI_STATUS Status;=0D
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices;=0D
- UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
-=0D
- Status =3D PeiServicesLocatePpi (=0D
- &gEfiPeiReadOnlyVariable2PpiGuid,=0D
- 0,=0D
- NULL,=0D
- (VOID **) &VariableServices=0D
- );=0D
- if (EFI_ERROR (Status)) {=0D
- ASSERT_EFI_ERROR (Status);=0D
- return Status;=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
+=0D
+ //=0D
+ // Initialize S3 Data variable (S3DataPtr). It may be used for warm and =
fast boot paths.=0D
+ //=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid -=
%r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize));=
=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
}=0D
=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
- MemorySavedData =3D AllocatePool (VariableSize);=0D
- if (MemorySavedData =3D=3D NULL) {=0D
- ASSERT (MemorySavedData !=3D NULL);=0D
- return EFI_OUT_OF_RESOURCES;=0D
- }=0D
-=0D
- DEBUG ((DEBUG_INFO, "VariableSize is 0x%x\n", VariableSize));=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_SUCCESS) {=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
- } else {=0D
- DEBUG ((DEBUG_ERROR, "Fail to retrieve Variable:\"MemoryConfig\" gMe=
moryConfigVariableGuid, Status =3D %r\n", Status));=0D
- ASSERT_EFI_ERROR (Status);=0D
- }=0D
- }=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
=0D
return EFI_SUCCESS;=0D
}=0D
diff --git a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSil=
iconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platform/Intel/Co=
metlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSili=
conPolicyUpdateLibFsp.inf
index c842b7eef6..94776603c4 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPol=
icyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPol=
icyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -2,7 +2,7 @@
# Provide FSP wrapper platform related function.=0D
#=0D
#=0D
-# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>=
=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -82,7 +82,6 @@
PchInfoLib=0D
PchHsioLib=0D
PchPcieRpLib=0D
- MemoryAllocationLib=0D
DebugPrintErrorLevelLib=0D
SiPolicyLib=0D
PchGbeLib=0D
@@ -132,7 +131,7 @@
gCometlakeOpenBoardPkgTokenSpaceGuid.PcdMrcSpdAddressTable3=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH v4 3/9] KabylakeOpenBoardPkg/AspireVn7Dash572G:Use same variable name for FspNvsHob

Chiu, Chasel
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3678

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Benjamin Doron <benjamin.doron00@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>
---
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 24 +++++++++=
+--------------
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c | 23 +++++++++=
--------------
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 7 ++++---
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf | 2 +-
4 files changed, 24 insertions(+), 32 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapp=
er/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform=
/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSilicon=
PolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
index d8413d284e..a9b7e446c8 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -1,7 +1,7 @@
/** @file=0D
Implementation of Fsp Misc UPD Initialization.=0D
=0D
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -11,7 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DebugLib.h>=0D
#include <Library/PciLib.h>=0D
#include <Library/PeiLib.h>=0D
-=0D
#include <FspEas.h>=0D
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
@@ -34,24 +33,21 @@ PeiFspMiscUpdUpdatePreMem (
{=0D
EFI_STATUS Status;=0D
UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
+ VOID *FspNvsBufferPtr;=0D
UINT8 MorControl;=0D
VOID *MorControlPtr;=0D
=0D
//=0D
// Initialize S3 Data variable (S3DataPtr). It may be used for warm and =
fast boot paths.=0D
//=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D PeiGetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- &MemorySavedData,=0D
- &VariableSize=0D
- );=0D
- DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid=
- %r\n", Status));=0D
- DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ VariableSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &VariableSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid -=
%r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", VariableSize));=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
+ }=0D
=0D
if (FspmUpd->FspmArchUpd.NvsBufferPtr !=3D NULL) {=0D
//=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/L=
ibrary/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c b/Platform/Int=
el/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUp=
dateLib/PeiSiliconPolicyUpdateLib.c
index c9dfb17e0a..3764f7c3ac 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/=
PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/=
PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
@@ -431,8 +431,8 @@ SiliconPolicyUpdatePreMem (
SA_MISC_PEI_PREMEM_CONFIG *MiscPeiPreMemConfig;=0D
MEMORY_CONFIG_NO_CRC *MemConfigNoCrc;=0D
VOID *Buffer;=0D
- UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
UINT8 SpdAddressTable[4];=0D
=0D
DEBUG((DEBUG_INFO, "\nUpdating Policy in Pre-Mem\n"));=0D
@@ -463,18 +463,13 @@ SiliconPolicyUpdatePreMem (
// Note: AmberLake FSP does not implement the FSPM_ARCH_CONFIG_PPI a=
dded in FSP 2.1, hence=0D
// the platform specific S3DataPtr must be used instead.=0D
//=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D PeiGetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- &MemorySavedData,=0D
- &VariableSize=0D
- );=0D
- DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHob=
Guid - %r\n", Status));=0D
- DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));=0D
- if (!EFI_ERROR (Status)) {=0D
- MiscPeiPreMemConfig->S3DataPtr =3D MemorySavedData;=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVaria=
bleGuid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGu=
id - %r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize=
));=0D
+ MiscPeiPreMemConfig->S3DataPtr =3D FspNvsBufferPtr;=0D
}=0D
=0D
//=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapp=
er/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/=
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/Pe=
iSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index e4a657c5f1..eac9344b0a 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -1,7 +1,7 @@
## @file=0D
# Provide FSP wrapper platform related function.=0D
#=0D
-# Copyright (c) 2017 - 2020 Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2017 - 2021 Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -74,7 +74,6 @@
PchInfoLib=0D
PchHsioLib=0D
PchPcieRpLib=0D
- MemoryAllocationLib=0D
SiPolicyLib=0D
PeiLib=0D
=0D
@@ -134,9 +133,11 @@
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdAudioConnector=0D
=0D
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGraphicsVbtGuid=0D
+ gIntelFsp2WrapperTokenSpaceGuid.PcdFspmUpdDataAddress=0D
+ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdRootPort4ClkInfo=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/L=
ibrary/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf b/Platform/I=
ntel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicy=
UpdateLib/PeiSiliconPolicyUpdateLib.inf
index 0a8cf91b07..4dcc000186 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/=
PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/=
PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
@@ -52,7 +52,7 @@
gHsioPciePreMemConfigGuid ## CONSUMES=0D
gHsioSataPreMemConfigGuid ## CONSUMES=0D
gSaMiscPeiPreMemConfigGuid ## CONSUMES=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gIoApicConfigGuid ## CONSUMES=0D
gHpetPreMemConfigGuid ## CONSUMES=0D
gLockDownConfigGuid=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH v4 1/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.

Chiu, Chasel
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3678

Implementation should search FSP_NON_VOLATILE_STORAGE_HOB2 firstly
and only search FSP_NON_VOLATILE_STORAGE_HOB when former one is not found.

Also added PeiGetLargeVariable () to support the scenarios where the
variable data size is bigger than a single variable size limit. (stored
across multiple variables)

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Liming Gao <gaoliming@...>
Cc: Eric Dong <eric.dong@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
---
Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig=
.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++----------------=
---------------------------------------------
Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c =
| 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++++++++++++++----------
Platform/Intel/MinPlatformPkg/Library/PeiVariableReadLib/PeiVariableReadLi=
b.c | 4 ++--
Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig=
.inf | 8 ++++++--
Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc =
| 1 +
Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h =
| 40 +++++++++++++++++++++++++++++++++++-----
Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf =
| 4 +++-
Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec =
| 1 +
8 files changed, 175 insertions(+), 81 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/Save=
MemoryConfig.c b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/=
SaveMemoryConfig.c
index 41ed2550bd..820585f676 100644
--- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC=
onfig.c
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC=
onfig.c
@@ -2,7 +2,7 @@
This is the driver that locates the MemoryConfigurationData HOB, if it=0D
exists, and saves the data to nvRAM.=0D
=0D
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -16,7 +16,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/GlobalVariable.h>=0D
#include <Library/MemoryAllocationLib.h>=0D
#include <Library/BaseMemoryLib.h>=0D
-#include <Protocol/VariableLock.h>=0D
+#include <Library/LargeVariableReadLib.h>=0D
+#include <Library/LargeVariableWriteLib.h>=0D
+#include <Guid/FspNonVolatileStorageHob2.h>=0D
=0D
/**=0D
This is the standard EFI driver point that detects whether there is a=0D
@@ -40,86 +42,71 @@ SaveMemoryConfigEntryPoint (
VOID *VariableData;=0D
UINTN DataSize;=0D
UINTN BufferSize;=0D
- EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;=0D
+ BOOLEAN DataIsIdentical;=0D
=0D
- DataSize =3D 0;=0D
- VariableData =3D NULL;=0D
- GuidHob =3D NULL;=0D
- HobData =3D NULL;=0D
+ DataSize =3D 0;=0D
+ BufferSize =3D 0;=0D
+ VariableData =3D NULL;=0D
+ GuidHob =3D NULL;=0D
+ HobData =3D NULL;=0D
+ DataIsIdentical =3D FALSE;=0D
=0D
//=0D
// Search for the Memory Configuration GUID HOB. If it is not present, =
then=0D
// there's nothing we can do. It may not exist on the update path.=0D
+ // Firstly check version2 FspNvsHob.=0D
//=0D
- GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);=0D
+ GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHob2Guid);=0D
if (GuidHob !=3D NULL) {=0D
- HobData =3D GET_GUID_HOB_DATA (GuidHob);=0D
- DataSize =3D GET_GUID_HOB_DATA_SIZE(GuidHob);=0D
+ HobData =3D (VOID *) (UINTN) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN=
) GuidHob)->NvsDataPtr;=0D
+ DataSize =3D (UINTN) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHo=
b)->NvsDataLength;=0D
+ } else {=0D
+ //=0D
+ // Fall back to version1 FspNvsHob=0D
+ //=0D
+ GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);=0D
+ if (GuidHob !=3D NULL) {=0D
+ HobData =3D GET_GUID_HOB_DATA (GuidHob);=0D
+ DataSize =3D GET_GUID_HOB_DATA_SIZE (GuidHob);=0D
+ }=0D
+ }=0D
+=0D
+ if (HobData !=3D NULL) {=0D
+ DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataLength:%d\n", DataSize));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataPtr : 0x%x\n", HobData));=0D
if (DataSize > 0) {=0D
//=0D
- // Use the HOB to save Memory Configuration Data=0D
+ // Check if the presently saved data is identical to the data given =
by MRC/FSP=0D
//=0D
- BufferSize =3D DataSize;=0D
- VariableData =3D AllocatePool (BufferSize);=0D
- if (VariableData =3D=3D NULL) {=0D
- return EFI_UNSUPPORTED;=0D
- }=0D
- Status =3D gRT->GetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &BufferSize,=0D
- VariableData=0D
- );=0D
-=0D
+ Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariable=
Guid, &BufferSize, NULL);=0D
if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
- FreePool (VariableData);=0D
- VariableData =3D AllocatePool (BufferSize);=0D
- if (VariableData =3D=3D NULL) {=0D
- return EFI_UNSUPPORTED;=0D
+ if (BufferSize =3D=3D DataSize) {=0D
+ VariableData =3D AllocatePool (BufferSize);=0D
+ if (VariableData !=3D NULL) {=0D
+ Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVa=
riableGuid, &BufferSize, VariableData);=0D
+ if (!EFI_ERROR (Status) && (BufferSize =3D=3D DataSize) && (0 =
=3D=3D CompareMem (HobData, VariableData, DataSize))) {=0D
+ DataIsIdentical =3D TRUE;=0D
+ }=0D
+ FreePool (VariableData);=0D
+ }=0D
}=0D
-=0D
- Status =3D gRT->GetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &BufferSize,=0D
- VariableData=0D
- );=0D
}=0D
+ Status =3D EFI_SUCCESS;=0D
=0D
- if ( (EFI_ERROR(Status)) || BufferSize !=3D DataSize || 0 !=3D Compa=
reMem (HobData, VariableData, DataSize)) {=0D
- Status =3D gRT->SetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERV=
ICE_ACCESS),=0D
- DataSize,=0D
- HobData=0D
- );=0D
+ if (!DataIsIdentical) {=0D
+ Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariab=
leGuid, TRUE, DataSize, HobData);=0D
ASSERT_EFI_ERROR (Status);=0D
-=0D
- DEBUG((DEBUG_INFO, "Restored Size is 0x%x\n", DataSize));=0D
- }=0D
-=0D
- //=0D
- // Mark MemoryConfig to read-only if the Variable Lock protocol exis=
ts=0D
- //=0D
- Status =3D gBS->LocateProtocol(&gEdkiiVariableLockProtocolGuid, NULL=
, (VOID **)&VariableLock);=0D
- if (!EFI_ERROR(Status)) {=0D
- Status =3D VariableLock->RequestToLock(VariableLock, L"MemoryConfi=
g", &gFspNonVolatileStorageHobGuid);=0D
- ASSERT_EFI_ERROR(Status);=0D
+ DEBUG ((DEBUG_INFO, "Saved size of FSP / MRC Training Data: 0x%x\n=
", DataSize));=0D
+ } else {=0D
+ DEBUG ((DEBUG_INFO, "FSP / MRC Training Data is identical to data =
from last boot, no need to save.\n"));=0D
}=0D
-=0D
- FreePool (VariableData);=0D
- } else {=0D
- DEBUG((DEBUG_INFO, "Memory save size is %d\n", DataSize));=0D
}=0D
} else {=0D
DEBUG((DEBUG_ERROR, "Memory S3 Data HOB was not found\n"));=0D
}=0D
=0D
//=0D
- // This driver does not produce any protocol services, so always unload =
it.=0D
+ // This driver cannot be unloaded because DxeRuntimeVariableWriteLib con=
structor will register ExitBootServices callback.=0D
//=0D
- return EFI_REQUEST_UNLOAD_IMAGE;=0D
+ return EFI_SUCCESS;=0D
}=0D
diff --git a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c b/Platfo=
rm/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c
index 96dfd588dc..3f8cf761a7 100644
--- a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c
+++ b/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c
@@ -1,6 +1,6 @@
/** @file=0D
=0D
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -9,13 +9,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DebugLib.h>=0D
#include <Library/PeiServicesLib.h>=0D
#include <Library/MemoryAllocationLib.h>=0D
+#include <Library/LargeVariableReadLib.h>=0D
#include <Ppi/ReadOnlyVariable2.h>=0D
=0D
/**=0D
- Returns the status whether get the variable success. The function retrie=
ves =0D
- variable through the ReadOnlyVariable2 PPI GetVariable(). The =0D
- returned buffer is allocated using AllocatePool(). The caller is respon=
sible=0D
- for freeing this buffer with FreePool().=0D
+ Returns the status whether get the variable success. The function retrie=
ves=0D
+ variable through the ReadOnlyVariable2 PPI GetVariable().=0D
+=0D
+ If the *Size is 0, the returned buffer is allocated using AllocatePool()=
.=0D
+ The buffer is not expected to be freed as PEI does not support a FreePoo=
l().=0D
+=0D
+ If the *Size is non-0, this function just uses caller allocated *Value.=
=0D
=0D
If Name is NULL, then ASSERT().=0D
If Guid is NULL, then ASSERT().=0D
@@ -108,6 +112,71 @@ PeiGetVariable (
return Status;=0D
}=0D
=0D
+/**=0D
+ This function returns a "large variable". A large variable is stored acr=
oss multiple=0D
+ UEFI Variables. This function retrieves the multiple UEFI Variables usin=
g=0D
+ ReadOnlyVariable2 PPI GetVariable().=0D
+ The function uses AllocatePages () to allocate the buffer.=0D
+ The caller is responsible for freeing this buffer with FreePages().=0D
+=0D
+ If Name is NULL, then ASSERT().=0D
+ If Guid is NULL, then ASSERT().=0D
+ If Value is NULL, then ASSERT().=0D
+=0D
+ @param[in] Name The pointer to a Null-terminated Unicode string.=0D
+ @param[in] Guid The pointer to an EFI_GUID structure=0D
+ @param[out] Value The buffer point saved the variable info.=0D
+ @param[out] Size The buffer size of the variable.=0D
+=0D
+ @return EFI_OUT_OF_RESOURCES Allocate buffer failed.=0D
+ @return EFI_SUCCESS Find the specified variable.=0D
+ @return Others Errors Return errors from call to gRT->GetVar=
iable.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+EFIAPI=0D
+PeiGetLargeVariable (=0D
+ IN CHAR16 *Name,=0D
+ IN EFI_GUID *Guid,=0D
+ OUT VOID **Value,=0D
+ OUT UINTN *Size OPTIONAL=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ UINTN VariableSize;=0D
+ VOID *VariableData;=0D
+=0D
+ ASSERT (Name !=3D NULL);=0D
+ ASSERT (Guid !=3D NULL);=0D
+ ASSERT (Value !=3D NULL);=0D
+=0D
+ VariableSize =3D 0;=0D
+ VariableData =3D NULL;=0D
+ Status =3D GetLargeVariable (Name, Guid, &VariableSize, NULL);=0D
+ if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
+ VariableData =3D AllocatePages (EFI_SIZE_TO_PAGES (VariableSize));=0D
+ if (VariableData =3D=3D NULL) {=0D
+ DEBUG ((DEBUG_ERROR, "Error: Cannot create VariableData, out of memo=
ry!\n"));=0D
+ ASSERT (FALSE);=0D
+ return EFI_OUT_OF_RESOURCES;=0D
+ }=0D
+ Status =3D GetLargeVariable (Name, Guid, &VariableSize, VariableData);=
=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "Error: Unable to read UEFI variable Status: %r=
\n", Status));=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ return Status;=0D
+ }=0D
+ if (Value !=3D NULL) {=0D
+ *Value =3D VariableData;=0D
+ }=0D
+ if (Size !=3D NULL) {=0D
+ *Size =3D VariableSize;=0D
+ }=0D
+ return EFI_SUCCESS;=0D
+ }=0D
+ return Status;=0D
+}=0D
+=0D
EFI_PEI_FILE_HANDLE=0D
InternalGetFfsHandleFromAnyFv (=0D
IN CONST EFI_GUID *NameGuid=0D
@@ -139,7 +208,7 @@ InternalGetFfsHandleFromAnyFv (
=0D
/**=0D
Finds the file in any FV and gets file Address and Size=0D
- =0D
+=0D
@param[in] NameGuid File GUID=0D
@param[out] Address Pointer to the File Address=0D
@param[out] Size Pointer to File Size=0D
@@ -162,7 +231,7 @@ PeiGetFfsFromAnyFv (
if (FfsHandle =3D=3D NULL) {=0D
return EFI_NOT_FOUND;=0D
}=0D
- =0D
+=0D
//=0D
// Need get size=0D
//=0D
@@ -185,7 +254,7 @@ PeiGetFfsFromAnyFv (
@param[in] SectionInstance The Instance of Section to be found=0D
@param[out] OutSectionBuffer The section found, including SECTION_HEAD=
ER=0D
@param[out] OutSectionSize The size of section found, including SECT=
ION_HEADER=0D
- =0D
+=0D
@retval EFI_SUCCESS Successfull in reading the section fr=
om FV=0D
**/=0D
EFI_STATUS=0D
@@ -263,7 +332,7 @@ PeiGetSectionFromAnyFv (
EFI_COMMON_SECTION_HEADER *Section;=0D
VOID *FileBuffer;=0D
UINTN FileBufferSize;=0D
- =0D
+=0D
Status =3D PeiGetFfsFromAnyFv (NameGuid, &FileBuffer, &FileBufferSize);=
=0D
if (EFI_ERROR(Status)) {=0D
return Status;=0D
@@ -282,6 +351,6 @@ PeiGetSectionFromAnyFv (
*Size =3D SECTION_SIZE(Section) - sizeof (EFI_COMMON_SECTION_HEADER);=
=0D
*Address =3D (UINT8 *)*Address + sizeof (EFI_COMMON_SECTION_HEADER);=0D
}=0D
- =0D
+=0D
return EFI_SUCCESS;=0D
}=0D
diff --git a/Platform/Intel/MinPlatformPkg/Library/PeiVariableReadLib/PeiVa=
riableReadLib.c b/Platform/Intel/MinPlatformPkg/Library/PeiVariableReadLib/=
PeiVariableReadLib.c
index 5eeee12a3c..b7885dd6c2 100644
--- a/Platform/Intel/MinPlatformPkg/Library/PeiVariableReadLib/PeiVariableR=
eadLib.c
+++ b/Platform/Intel/MinPlatformPkg/Library/PeiVariableReadLib/PeiVariableR=
eadLib.c
@@ -67,7 +67,7 @@ VarLibGetVariable (
&gEfiPeiReadOnlyVariable2PpiGuid,=0D
0,=0D
NULL,=0D
- &VariablePpi=0D
+ (VOID **) &VariablePpi=0D
);=0D
ASSERT_EFI_ERROR (Status);=0D
if (EFI_ERROR (Status)) {=0D
@@ -134,7 +134,7 @@ VarLibGetNextVariableName (
&gEfiPeiReadOnlyVariable2PpiGuid,=0D
0,=0D
NULL,=0D
- &VariablePpi=0D
+ (VOID **) &VariablePpi=0D
);=0D
ASSERT_EFI_ERROR (Status);=0D
if (EFI_ERROR (Status)) {=0D
diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/Save=
MemoryConfig.inf b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfi=
g/SaveMemoryConfig.inf
index 0c8689a6f6..e2dbd2fb49 100644
--- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC=
onfig.inf
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC=
onfig.inf
@@ -1,7 +1,7 @@
### @file=0D
# Component information file for SaveMemoryConfig module=0D
#=0D
-# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -23,11 +23,14 @@
DebugLib=0D
MemoryAllocationLib=0D
BaseMemoryLib=0D
+ LargeVariableReadLib=0D
+ LargeVariableWriteLib=0D
=0D
[Packages]=0D
MdePkg/MdePkg.dec=0D
MdeModulePkg/MdeModulePkg.dec=0D
IntelFsp2Pkg/IntelFsp2Pkg.dec=0D
+ MinPlatformPkg/MinPlatformPkg.dec=0D
=0D
[Sources]=0D
SaveMemoryConfig.c=0D
@@ -35,10 +38,11 @@
[Protocols]=0D
gEfiVariableArchProtocolGuid ## CONSUMES=0D
gEfiVariableWriteArchProtocolGuid ## CONSUMES=0D
- gEdkiiVariableLockProtocolGuid=0D
=0D
[Guids]=0D
gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNonVolatileStorageHob2Guid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## PRODUCES=0D
=0D
[Depex]=0D
gEfiVariableArchProtocolGuid AND=0D
diff --git a/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc b/Pla=
tform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc
index d3c668d441..c12189bd9a 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc
+++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc
@@ -41,6 +41,7 @@
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.in=
f=0D
!endif=0D
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf=0D
+ VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVaria=
bleReadLibNull.inf=0D
=0D
[LibraryClasses.common.PEI_CORE]=0D
TimerLib|PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.inf=0D
diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h b/Platf=
orm/Intel/MinPlatformPkg/Include/Library/PeiLib.h
index d8b1a47c58..eed6502d84 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h
+++ b/Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h
@@ -1,6 +1,6 @@
/** @file=0D
=0D
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -11,11 +11,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <PiPei.h>=0D
=0D
/**=0D
- Returns the status whether get the variable success. The function retrie=
ves =0D
+ Returns the status whether get the variable success. The function retrie=
ves=0D
variable through the ReadOnlyVariable2 PPI GetVariable().=0D
=0D
If the *Size is 0, the returned buffer is allocated using AllocatePool()=
.=0D
- The caller is responsible for freeing this buffer with FreePool().=0D
+ The buffer is not expected to be freed as PEI does not support a FreePoo=
l().=0D
=0D
If the *Size is non-0, this function just uses caller allocated *Value.=
=0D
=0D
@@ -38,9 +38,39 @@ PeiGetVariable (
OUT UINTN *Size=0D
);=0D
=0D
+/**=0D
+ This function returns a "large variable". A large variable is stored acr=
oss multiple=0D
+ UEFI Variables. This function retrieves the multiple UEFI Variables usin=
g=0D
+ ReadOnlyVariable2 PPI GetVariable().=0D
+ The function uses AllocatePages () to allocate the buffer.=0D
+ The caller is responsible for freeing this buffer with FreePages().=0D
+=0D
+ If Name is NULL, then ASSERT().=0D
+ If Guid is NULL, then ASSERT().=0D
+ If Value is NULL, then ASSERT().=0D
+=0D
+ @param[in] Name The pointer to a Null-terminated Unicode string.=0D
+ @param[in] Guid The pointer to an EFI_GUID structure=0D
+ @param[out] Value The buffer point saved the variable info.=0D
+ @param[out] Size The buffer size of the variable.=0D
+=0D
+ @return EFI_OUT_OF_RESOURCES Allocate buffer failed.=0D
+ @return EFI_SUCCESS Find the specified variable.=0D
+ @return Others Errors Return errors from call to gRT->GetVar=
iable.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+EFIAPI=0D
+PeiGetLargeVariable (=0D
+ IN CHAR16 *Name,=0D
+ IN EFI_GUID *Guid,=0D
+ OUT VOID **Value,=0D
+ OUT UINTN *Size OPTIONAL=0D
+ );=0D
+=0D
/**=0D
Finds the file in any FV and gets file Address and Size=0D
- =0D
+=0D
@param[in] NameGuid File GUID=0D
@param[out] Address Pointer to the File Address=0D
@param[out] Size Pointer to File Size=0D
@@ -57,7 +87,7 @@ PeiGetFfsFromAnyFv (
=0D
/**=0D
Finds the section in any FV and gets section Address and Size=0D
- =0D
+=0D
@param[in] NameGuid File GUID=0D
@param[in] SectionType The SectionType of Section to be found=
=0D
@param[in] SectionInstance The Instance of Section to be found=0D
diff --git a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf b/Plat=
form/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf
index 7e740172a0..bd57cf7870 100644
--- a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf
@@ -1,7 +1,7 @@
## @file=0D
# Component information file for Board Init Test Library=0D
#=0D
-# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -20,9 +20,11 @@
PeiServicesLib=0D
MemoryAllocationLib=0D
DebugLib=0D
+ LargeVariableReadLib=0D
=0D
[Packages]=0D
MdePkg/MdePkg.dec=0D
+ MinPlatformPkg/MinPlatformPkg.dec=0D
=0D
[Sources]=0D
PeiLib.c=0D
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec b/Platform/In=
tel/MinPlatformPkg/MinPlatformPkg.dec
index bcb42f0ef9..d6e80a66ce 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
@@ -50,6 +50,7 @@
gBdsEventBeforeConsoleAfterTrustedConsoleGuid =3D {0x51e49ff5, 0x28a9, =
0x4159, { 0xac, 0x8a, 0xb8, 0xc4, 0x88, 0xa7, 0xfd, 0xee}}=0D
gBdsEventBeforeConsoleBeforeEndOfDxeGuid =3D {0xfcf26e41, 0xbda6, =
0x4633, { 0xb5, 0x73, 0xd4, 0xb8, 0x0e, 0x6d, 0xd0, 0x78}}=0D
gBdsEventAfterConsoleReadyBeforeBootOptionGuid =3D {0x8eb3d5dc, 0xf4e7, =
0x4b57, { 0xa9, 0xe7, 0x27, 0x39, 0x10, 0xf2, 0x18, 0x9f}}=0D
+ gFspNvsBufferVariableGuid =3D {0x9c7715cd, 0x8d66, =
0x4d2a, { 0x90, 0x0d, 0x01, 0x45, 0x9a, 0x57, 0x59, 0x6b}}=0D
=0D
[LibraryClasses]=0D
=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH v4 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.

Chiu, Chasel
 

V4:
. Switched to LargeVariableRead(Write)Lib in SaveMemoryConfig driver
. Fixed tailing white space issue in PeiLib.c/.h
. Updated function descriptions for PeiGetVariable() and PeiGetLargeVariable()
. Added VariableReadLib to CorePeiLib.dsc for all platforms
. Fixed white space issue in GalagoPro3/.../PeiFspMiscUpdUpdateLib.c

V3:
Fix another GCC build failure.

V2:
Fix GCC build failures.

V1:
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3678

Implementation should search FSP_NON_VOLATILE_STORAGE_HOB2 firstly
and only search FSP_NON_VOLATILE_STORAGE_HOB when former one is not found.

Also added PeiGetLargeVariable () to support the scenarios where the
variable data size is bigger than a single variable size limit.

Cc: Isaac Oram <isaac.w.oram@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Heng Luo <heng.luo@...>
Cc: Jeremy Soller <jeremy@...>
Cc: Benjamin Doron <benjamin.doron00@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Cc: Deepika Kethi Reddy <deepika.kethi.reddy@...>
Cc: Kathappan Esakkithevar <kathappan.esakkithevar@...>
Cc: Liming Gao <gaoliming@...>
Cc: Eric Dong <eric.dong@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>

Chasel Chiu (9):
MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.
CometlakeOpenBoardPkg: Use same variable name for FspNvsHob.
KabylakeOpenBoardPkg/AspireVn7Dash572G:Use same variable name for
FspNvsHob
KabylakeOpenBoardPkg/GalagoPro3: Use same variable name for FspNvsHob.
KabylakeOpenBoardPkg/KabylakeRvp3: Use same variable name for
FspNvsHob.
TigerlakeOpenBoardPkg: Use same variable name for FspNvsHob.
WhiskeylakeOpenBoardPkg: Use same variable name for FspNvsHob.
WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.
WhitleySiliconPkg: Use same variable name for FspNvsHob.

Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++++-------------------------------------------------
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 24 ++++++++++--------------
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c | 23 +++++++++--------------
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 25 +++++++++++--------------
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 25 ++++++++++---------------
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c | 23 +++++++++--------------
Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------
Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Platform/Intel/MinPlatformPkg/Library/PeiVariableReadLib/PeiVariableReadLib.c | 4 ++--
Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.c | 21 ++++++++++++++++++---
Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++---------------------------------------------------
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++---------------------------------------------------
Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c | 29 +++++++++++++++++++++++------
Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c | 35 +++++++++--------------------------
Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 7 ++++---
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf | 2 +-
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf | 2 +-
Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf | 8 ++++++--
Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc | 1 +
Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h | 40 +++++++++++++++++++++++++++++++++++-----
Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf | 4 +++-
Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec | 1 +
Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf | 1 +
Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 4 ++--
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapInclude.fdf | 18 +++++++++---------
Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.inf | 4 +++-
Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc | 1 +
Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf | 3 ++-
32 files changed, 344 insertions(+), 368 deletions(-)

--
2.28.0.windows.1


Re: [PATCH V2 13/28] UefiCpuPkg: Enable Tdx support in MpInitLib

Gerd Hoffmann
 

On Thu, Oct 14, 2021 at 12:27:13AM +0000, Xu, Min M wrote:
On October 12, 2021 6:32 PM, Gerd Hoffman wrote:
Hi,

+ do {
+ AsmCpuid (0, &LargestEax, &Ebx, &Ecx, &Edx);
Again: this should use PCD.
ConfidentialComputing PCD is set in PlatformPei. So any check of this PCD should be after PlatformPei.
Can we move that to the SEC phase?

MpInitLib will be included in CpuMpPei. So if PCD is checked in MpInitLib, then we must assume CpuMpPei is called after PlatformPei.
In current OVMF, CpuMpPei is called after PlatforPei. But I am not sure if it is always the case. Can we have such assumption?
Based on above consideration, CPUID is used to probe if it is Tdx guest.
Not sure. There are no explicit depex dependencies, so I suspect the
initialization order could change.

take care,
Gerd


Re: [PATCH] OvmfPkg/BhyveBhfPkg: install bhyve's ACPI tables

Peter Grehan
 

I've requested in the past that you do this so I'll request again: please
discuss these changes on the freebsd-virtualization list before sending
patches outside of the project.
I'd suggest to add the list to the bhyve section of Maintainers.txt
then.
Yep, that's fair enough.

later,

Peter.


Re: [PATCH] OvmfPkg/BhyveBhfPkg: install bhyve's ACPI tables

Gerd Hoffmann
 

Hi,

I've requested in the past that you do this so I'll request again: please
discuss these changes on the freebsd-virtualization list before sending
patches outside of the project.
I'd suggest to add the list to the bhyve section of Maintainers.txt
then.

take care,
Gerd


Re: [PATCH] OvmfPkg/BhyveBhfPkg: install bhyve's ACPI tables

Peter Grehan
 

It's much easier to create configuration dependend ACPI tables for > bhyve than for OVMF. For this reason, don't use the statically>
created ACPI tables provided by OVMF. Instead use the dynamically> created ACPI tables of bhyve. If bhyve provides no ACPI tables or> we are unable to detect those, fall back to OVMF tables.
This looks fine though bhyve will need to generate MCFG to get to full parity.

I've requested in the past that you do this so I'll request again: please discuss these changes on the freebsd-virtualization list before sending patches outside of the project.

Acked-by: Peter Grehan <grehan@...>

later,

Peter.


Re: [PATCH V2 0/3] Introduce TdProtocol into EDK2

Min Xu
 

On October 12, 2021 11:27 PM, Sami Mujawar wrote:
Hi Min,

Thank you for this patch.

I think it would greatly help if the EFI_TD_PROTOCOL is changed to something
more architecture neutral. As I understand, this patch series is removing the
dependency on TPM for measurement and is instead providing a lightweight
interface for extending measurements for Confidential Compute Architecture
(CCA) guests.

Considering this, it would be good to generalise EFI_TD_PROTOCOL as a
Confidential Compute Architecture Measurement (CCAM) protocol.
In fact, your v2 series demonstrates this need with the introduction of
MEASURE_BOOT_PROTOCOLS in "[PATCH V2 2/3] SecurityPkg: Support
TdProtocol in DxeTpm2MeasureBootLib
[https://edk2.groups.io/g/devel/message/81651]".

As it stands, I feel most of the code can be reused/common. Some interfaces
may need to use an architecture specific library, and some configuration
options would need to be defined using PCDs.

Kindly let me know your thoughts.
Thanks for your comments. Let me first discuss your feedback with our architecture. We will reply to your proposal a bit later.

Thanks.
Min


Re: [PATCH V2 06/28] MdePkg: Update BaseIoLibIntrinsicSev to support Tdx

Gerd Hoffmann
 

Hi,

Calling CPUID should not be needed, we have a new fancy
ConfidentialComputing PCD for that now.
The gUefiCpuPkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr is defined in UefiCpuPkg. While BaseIoLibIntrinsicSev is in MdePkg.
If the ConfidentialComputing PCD is used, then UefiCpuPkg has to be included in BaseIoLibIntrinsicSev.inf.
I check all the *.inf under MdePkg but no one *.inf include UefiCpuPkg.
I am not sure if UefiCpuPkg can be included in BaseIoLibIntrinsicSev.inf.
Hmm, I guess we should move the pcd then so it cam be used more widely.
Confidential computing has an impact beyond just cpu, it's also memory,
io and more.

Maybe that's something to cleanup for amd (Brijesh?) beforehand, so the
structure is there already and the tdx patches just need to add the "case tdx:"
bits.
Tdx patches can first use above structure. AMD can update it later. Either way is ok.
That'll work too, I don't care much about the ordering.

take care,
Gerd


Re: [PATCH V2 05/28] MdePkg: Add TdxLib to wrap Tdx operations

Gerd Hoffmann
 

Hi,

+UINT8 *mExtendBufferAddress = NULL;
+TDX_EXTEND_BUFFER mExtendBuffer;
+
+/**
+ TD.RTMR.EXTEND requires 64B-aligned guest physical address of
+ 48B-extension data. In runtime we walk thru the Buffer to find
+ out a 64B-aligned start address.
Can't you just use __attribute__((aligned(64))) for that?
In the PoC of TDVF I had thought about it. But at last I gave up such solution. The reasons are:
1) OVMF/TDVF supports both GCC and VS2019 tool chain. __attribute__((aligned(64))) is for GCC. Its counterpart of VS2019 Tool chain is __declspec(align(x)).
2) There is the limitation of /ALIGN:32 in the build scripts which means aligned 64 exceeds the /ALIGN 32, unless /ALIGN is updated to 64.
That's why the current solution is used.
MdePkg/Include/Base.h has a bunch of ALIGN_* macros to do the math for
you, which should simplify this alot. I'd suggest to also drop the
mExtendBufferAddress and the function calculating it. Just use the
macro instead when needed.

take care,
Gerd


Re: [PATCH V2 28/28] OvmfPkg: Add LocalApicTimerDxe

Min Xu
 

On October 12, 2021 9:02 PM, Gerd Hoffmann wrote:
On Tue, Oct 05, 2021 at 11:39:39AM +0800, Min Xu wrote:
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429

TDX guest supports LocalApicTimer. But in current OvmfPkg the
supported timer is 8254TimerDxe. So
gUefiOvmfPkgTokenSpaceGuid.PcdTimerSelector
is introduced to select the running Timer. The Timer driver will check
the TimerSelector in its entry point. The default Timer is 8254.
Hmm.

We already have a local apic timer implementation (XenTimerDxe). Works fine
with kvm, microvm already uses that. See commit 76602f45dcd9
("OvmfPkg/Microvm: use XenTimerDxe (lapic timer)").

So, first I'd suggest to just use that (maybe rename the thing to avoid confusion
as it isn't really Xen specific).
Thanks for reminder. Let me first do some more investigation about the XenTimerDxe. It will be better to use an existing lapic timer than introducing a new one.

Next question is whenever there is a need for a runtime switch. I doubt it is
possible to create a virtual machine without lapic, so switching ovmf from 8254
(aka pit) to lapic unconditionally should work fine.
Quick smoke test (patch below) shows no obvious problems.
Let me do some more investigation.
Thanks.
Min


Re: [PATCH] OvmfPkg/Bhyve: Use QemuFwCfg over BhyveFwCtl

Gerd Hoffmann
 

On Wed, Oct 13, 2021 at 11:26:23AM +0200, Corvin Köhne wrote:
From: Corvin Köhne <CorvinK@...>

QemuFwCfg is more powerful and has more use cases than BhyveFwCtl. Try
to use QemuFwCfg in first place. If that fails, fall back to
BhyveFwCtl.
Does bhyve implement the qemu fwcfg interface?

Acked-by: Gerd Hoffmann <kraxel@...>

take care,
Gerd


Re: [PATCH] OvmfPkg/BhyveBhfPkg: install bhyve's ACPI tables

Gerd Hoffmann
 

Hi,

+#define BHYVE_ACPI_PHYSICAL_ADDRESS ((UINTN)0x000F2400)
+#define BHYVE_BIOS_PHYSICAL_END ((UINTN)0x00100000)
+ //
+ // Detect the RSDP
+ //
+ for (RsdpAddress = BHYVE_ACPI_PHYSICAL_ADDRESS;
+ RsdpAddress < BHYVE_BIOS_PHYSICAL_END;
+ RsdpAddress += 0x10) {
+ Rsdp = NUMERIC_VALUE_AS_POINTER (
+ EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER,
+ RsdpAddress
+ );
+ if (Rsdp->Signature != EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) {
+ continue;
+ }
So bhyve copies the tables to guest memory and ovmf searches for them,
correct?

The commit message should (briefly) describe how the tables are passed
from the host to the guest.

The code looks sane to me, so with a more verbose commit message:
Acked-by: Gerd Hoffmann <kraxel@...>

take care,
Gerd

12721 - 12740 of 94602