* [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information
@ 2023-12-11 9:06 Wang Fan
2023-12-12 0:46 ` 回复: " gaoliming via groups.io
2023-12-13 3:23 ` Ni, Ray
0 siblings, 2 replies; 4+ messages in thread
From: Wang Fan @ 2023-12-11 9:06 UTC (permalink / raw)
To: devel
Cc: Fan Wang, Michael D Kinney, Liming Gao, Ray Ni, Guomin Jiang,
Jian J Wang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4533
There are use cases which not all FVs need be migrated from TempRam to
permanent memory before TempRam tears down. This new guid is introduced
to avoid unnecessary FV migration to improve boot performance. Platform
can publish MigrationInfo hob with this guid to customize FV migration
info, and PeiCore will only migrate FVs indicated by this Hob info.
This is a backwards compatible change, PeiCore will check MigrationInfo
hob before migration. If MigrationInfo hobs exists, only migrate FVs
recorded by hobs. If MigrationInfo hobs not exists, migrate all FVs to
permanent memory.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Fan Wang <fan.wang@intel.com>
---
MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 79 +++++++++++++------
MdeModulePkg/Core/Pei/PeiMain.inf | 1 +
MdeModulePkg/Include/Guid/MigratedFvInfo.h | 42 +++++++++-
MdeModulePkg/MdeModulePkg.dec | 3 +-
SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 7 +-
SecurityPkg/Tcg/TcgPei/TcgPei.c | 7 +-
6 files changed, 111 insertions(+), 28 deletions(-)
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 5f32ebb560..0086087e82 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -1184,7 +1184,12 @@ EvacuateTempRam (
PEI_CORE_FV_HANDLE PeiCoreFvHandle;
EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;
+ EFI_PEI_HOB_POINTERS Hob;
+ EDKII_MIGRATION_INFO *MigrationInfo;
+ TO_MIGRATE_FV_INFO *ToMigrateFvInfo;
+ UINT32 FvMigrationFlags;
EDKII_MIGRATED_FV_INFO MigratedFvInfo;
+ UINTN Index;
ASSERT (Private->PeiMemoryInstalled);
@@ -1211,6 +1216,13 @@ EvacuateTempRam (
ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle);
+ Hob.Raw = GetFirstGuidHob (&gEdkiiMigrationInfoGuid);
+ if (Hob.Raw != NULL) {
+ MigrationInfo = GET_GUID_HOB_DATA (Hob);
+ } else {
+ MigrationInfo = NULL;
+ }
+
for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
FvHeader = Private->Fv[FvIndex].FvHeader;
ASSERT (FvHeader != NULL);
@@ -1224,20 +1236,27 @@ EvacuateTempRam (
)
)
{
- //
- // Allocate page to save the rebased PEIMs, the PEIMs will get dispatched later.
- //
- Status = PeiServicesAllocatePages (
- EfiBootServicesCode,
- EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength),
- &FvHeaderAddress
- );
- ASSERT_EFI_ERROR (Status);
- MigratedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHeaderAddress;
+ if ((MigrationInfo == NULL) || (MigrationInfo->MigrateAll == TRUE)) {
+ // Migrate all FVs and copy raw data
+ FvMigrationFlags = FLAGS_FV_RAW_DATA_COPY;
+ } else {
+ for (Index = 0; Index < MigrationInfo->ToMigrateFvCount; Index++) {
+ ToMigrateFvInfo = ((TO_MIGRATE_FV_INFO *)(MigrationInfo + 1)) + Index;
+ if (ToMigrateFvInfo->FvOrgBaseOnTempRam == (UINT32)(UINTN)FvHeader) {
+ // This FV is to migrate
+ FvMigrationFlags = ToMigrateFvInfo->FvMigrationFlags;
+ break;
+ }
+ }
+
+ if (Index == MigrationInfo->ToMigrateFvCount) {
+ // This FV is not expected to migrate
+ continue;
+ }
+ }
//
- // Allocate pool to save the raw PEIMs, which is used to keep consistent context across
- // multiple boot and PCR0 will keep the same no matter if the address of allocated page is changed.
+ // Allocate pages to save the rebased PEIMs, the PEIMs will get dispatched later.
//
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
@@ -1245,7 +1264,8 @@ EvacuateTempRam (
&FvHeaderAddress
);
ASSERT_EFI_ERROR (Status);
- RawDataFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHeaderAddress;
+ MigratedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHeaderAddress;
+ CopyMem (MigratedFvHeader, FvHeader, (UINTN)FvHeader->FvLength);
DEBUG ((
DEBUG_VERBOSE,
@@ -1256,17 +1276,34 @@ EvacuateTempRam (
));
//
- // Copy the context to the rebased pages and raw pages, and create hob to save the
- // information. The MigratedFvInfo HOB will never be produced when
- // PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the PCD control the
- // feature.
+ // Create hob to save MigratedFvInfo, this hob will only be produced when
+ // Migration feature PCD PcdMigrateTemporaryRamFirmwareVolumes is set to TRUE.
//
- CopyMem (MigratedFvHeader, FvHeader, (UINTN)FvHeader->FvLength);
- CopyMem (RawDataFvHeader, MigratedFvHeader, (UINTN)FvHeader->FvLength);
MigratedFvInfo.FvOrgBase = (UINT32)(UINTN)FvHeader;
MigratedFvInfo.FvNewBase = (UINT32)(UINTN)MigratedFvHeader;
- MigratedFvInfo.FvDataBase = (UINT32)(UINTN)RawDataFvHeader;
+ MigratedFvInfo.FvDataBase = 0;
MigratedFvInfo.FvLength = (UINT32)(UINTN)FvHeader->FvLength;
+
+ //
+ // When FLAGS_FV_RAW_DATA_COPY bit is set, copy the context to the raw pages and
+ // reset raw data base address in MigratedFvInfo hob.
+ //
+ if ((FvMigrationFlags & FLAGS_FV_RAW_DATA_COPY) == FLAGS_FV_RAW_DATA_COPY) {
+ DEBUG ((DEBUG_INFO, " Copying Raw Data ...\n"));
+ //
+ // Allocate pages to save the raw PEIMs
+ //
+ Status = PeiServicesAllocatePages (
+ EfiBootServicesCode,
+ EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength),
+ &FvHeaderAddress
+ );
+ ASSERT_EFI_ERROR (Status);
+ RawDataFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHeaderAddress;
+ CopyMem (RawDataFvHeader, MigratedFvHeader, (UINTN)FvHeader->FvLength);
+ MigratedFvInfo.FvDataBase = (UINT32)(UINTN)RawDataFvHeader;
+ }
+
BuildGuidDataHob (&gEdkiiMigratedFvInfoGuid, &MigratedFvInfo, sizeof (MigratedFvInfo));
//
@@ -1330,8 +1367,6 @@ EvacuateTempRam (
}
}
- RemoveFvHobsInTemporaryMemory (Private);
-
return Status;
}
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf
index 0cf357371a..893bdc0527 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -78,6 +78,7 @@
gEfiFirmwareFileSystem3Guid
gStatusCodeCallbackGuid
gEdkiiMigratedFvInfoGuid ## SOMETIMES_PRODUCES ## HOB
+ gEdkiiMigrationInfoGuid ## SOMETIMES_CONSUMES ## HOB
[Ppis]
gEfiPeiStatusCodePpiGuid ## SOMETIMES_CONSUMES # PeiReportStatusService is not ready if this PPI doesn't exist
diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
index aca2332a0e..1c8b0dfefc 100644
--- a/MdeModulePkg/Include/Guid/MigratedFvInfo.h
+++ b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
@@ -9,13 +9,53 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
#define __EDKII_MIGRATED_FV_INFO_GUID_H__
+//
+// FLAGS_FV_RAW_DATA_COPY indicates FV raw data will be copied to permanent memory
+// or not. When FV is migrated to permanent memory, it will be rebased and raw
+// data will be lost. This bit can be configured as below values:
+// 0: FV raw data will not be used in later phase, and the copy will be skipped to
+// optimize boot performance.
+// 1: FV raw data will be copied to permanent memory for later phase use (such as
+// FV measurement).
+//
+#define FLAGS_FV_RAW_DATA_COPY BIT0
+
+///
+/// In real use cases, not all FVs need migrate to permanent memory before TempRam tears
+/// down. EDKII_MIGRATION_INFO hob should be published by platform to indicate which
+/// FVs need migration to optimize boot performance. If this hob is not detected by Pei
+/// Core, all FVs on TempRam will be migrated and FV raw data will also be copied.
+/// Only one EDKII_MIGRATION_INFO hob should be published by platform, and this hob will
+/// take effect only when migration feature is enabled by PCD.
+///
+typedef struct {
+ UINT32 FvOrgBaseOnTempRam; // Original FV address on Temporary Ram
+ //
+ // FV Migration Flags:
+ // Bit0: Indicate to copy FV raw data or not
+ // Others: Reserved bits
+ //
+ UINT32 FvMigrationFlags;
+} TO_MIGRATE_FV_INFO;
+
+typedef struct {
+ BOOLEAN MigrateAll; // Migrate all FVs and also copy FV raw data
+ //
+ // ToMigrateFvCount and ToMigrateFvInfo array indicate which FVs need be migrated, and
+ // these info should be ignored when MigrateAll field is set to TRUE.
+ //
+ UINT32 ToMigrateFvCount;
+ // TO_MIGRATE_FV_INFO ToMigrateFvInfo[];
+} EDKII_MIGRATION_INFO;
+
typedef struct {
UINT32 FvOrgBase; // original FV address
UINT32 FvNewBase; // new FV address
- UINT32 FvDataBase; // original FV data
+ UINT32 FvDataBase; // original FV data, 0 means raw data is not copied
UINT32 FvLength; // Fv Length
} EDKII_MIGRATED_FV_INFO;
+extern EFI_GUID gEdkiiMigrationInfoGuid;
extern EFI_GUID gEdkiiMigratedFvInfoGuid;
#endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 1a162e97e6..a2cd83345f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -421,7 +421,8 @@
gEdkiiCapsuleOnDiskNameGuid = { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93, 0x9a, 0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } }
## Include/Guid/MigratedFvInfo.h
- gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }
+ gEdkiiMigrationInfoGuid = { 0xb4b140a5, 0x72f6, 0x4c21, { 0x93, 0xe4, 0xac, 0xc4, 0xec, 0xcb, 0x23, 0x23 } }
+ gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }
## Include/Guid/RngAlgorithm.h
gEdkiiRngAlgorithmUnSafe = { 0x869f728c, 0x409d, 0x4ab4, {0xac, 0x03, 0x71, 0xd3, 0x09, 0xc1, 0xb3, 0xf4 }}
diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 1caaa4e319..daaf49e644 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -726,8 +726,11 @@ MeasureFvImage (
//
// Found the migrated FV info
//
- FvOrgBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
- FvDataBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
+ FvOrgBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
+ if (MigratedFvInfo->FvDataBase != 0) {
+ FvDataBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
+ }
+
break;
}
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index 5aa80511aa..d35c2ad0bc 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -463,8 +463,11 @@ MeasureFvImage (
//
// Found the migrated FV info
//
- FvOrgBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
- FvDataBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
+ FvOrgBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
+ if (MigratedFvInfo->FvDataBase != 0) {
+ FvDataBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
+ }
+
break;
}
--
2.26.2.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112276): https://edk2.groups.io/g/devel/message/112276
Mute This Topic: https://groups.io/mt/103105558/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 4+ messages in thread
* 回复: [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information
2023-12-11 9:06 [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information Wang Fan
@ 2023-12-12 0:46 ` gaoliming via groups.io
2023-12-13 3:23 ` Ni, Ray
1 sibling, 0 replies; 4+ messages in thread
From: gaoliming via groups.io @ 2023-12-12 0:46 UTC (permalink / raw)
To: devel, fan.wang
Cc: 'Michael D Kinney', 'Ray Ni',
'Guomin Jiang', 'Jian J Wang'
Fan:
Please separate the patch for the different packages.
Thanks
Liming
> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Wang Fan
> 发送时间: 2023年12月11日 17:06
> 收件人: devel@edk2.groups.io
> 抄送: Fan Wang <fan.wang@intel.com>; Michael D Kinney
> <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
> Ray Ni <ray.ni@intel.com>; Guomin Jiang <guomin.jiang@intel.com>; Jian J
> Wang <jian.j.wang@intel.com>
> 主题: [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV
> Migration Information
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4533
>
> There are use cases which not all FVs need be migrated from TempRam to
> permanent memory before TempRam tears down. This new guid is introduced
> to avoid unnecessary FV migration to improve boot performance. Platform
> can publish MigrationInfo hob with this guid to customize FV migration
> info, and PeiCore will only migrate FVs indicated by this Hob info.
>
> This is a backwards compatible change, PeiCore will check MigrationInfo
> hob before migration. If MigrationInfo hobs exists, only migrate FVs
> recorded by hobs. If MigrationInfo hobs not exists, migrate all FVs to
> permanent memory.
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Guomin Jiang <guomin.jiang@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Signed-off-by: Fan Wang <fan.wang@intel.com>
> ---
> MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 79
> +++++++++++++------
> MdeModulePkg/Core/Pei/PeiMain.inf | 1 +
> MdeModulePkg/Include/Guid/MigratedFvInfo.h | 42 +++++++++-
> MdeModulePkg/MdeModulePkg.dec | 3 +-
> SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 7 +-
> SecurityPkg/Tcg/TcgPei/TcgPei.c | 7 +-
> 6 files changed, 111 insertions(+), 28 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index 5f32ebb560..0086087e82 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -1184,7 +1184,12 @@ EvacuateTempRam (
>
>
> PEI_CORE_FV_HANDLE PeiCoreFvHandle;
>
> EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;
>
> + EFI_PEI_HOB_POINTERS Hob;
>
> + EDKII_MIGRATION_INFO *MigrationInfo;
>
> + TO_MIGRATE_FV_INFO *ToMigrateFvInfo;
>
> + UINT32 FvMigrationFlags;
>
> EDKII_MIGRATED_FV_INFO MigratedFvInfo;
>
> + UINTN Index;
>
>
>
> ASSERT (Private->PeiMemoryInstalled);
>
>
>
> @@ -1211,6 +1216,13 @@ EvacuateTempRam (
>
>
> ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle);
>
>
>
> + Hob.Raw = GetFirstGuidHob (&gEdkiiMigrationInfoGuid);
>
> + if (Hob.Raw != NULL) {
>
> + MigrationInfo = GET_GUID_HOB_DATA (Hob);
>
> + } else {
>
> + MigrationInfo = NULL;
>
> + }
>
> +
>
> for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
>
> FvHeader = Private->Fv[FvIndex].FvHeader;
>
> ASSERT (FvHeader != NULL);
>
> @@ -1224,20 +1236,27 @@ EvacuateTempRam (
> )
>
> )
>
> {
>
> - //
>
> - // Allocate page to save the rebased PEIMs, the PEIMs will get
> dispatched later.
>
> - //
>
> - Status = PeiServicesAllocatePages (
>
> - EfiBootServicesCode,
>
> - EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength),
>
> - &FvHeaderAddress
>
> - );
>
> - ASSERT_EFI_ERROR (Status);
>
> - MigratedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + if ((MigrationInfo == NULL) || (MigrationInfo->MigrateAll == TRUE))
{
>
> + // Migrate all FVs and copy raw data
>
> + FvMigrationFlags = FLAGS_FV_RAW_DATA_COPY;
>
> + } else {
>
> + for (Index = 0; Index < MigrationInfo->ToMigrateFvCount; Index++)
> {
>
> + ToMigrateFvInfo = ((TO_MIGRATE_FV_INFO *)(MigrationInfo +
> 1)) + Index;
>
> + if (ToMigrateFvInfo->FvOrgBaseOnTempRam ==
> (UINT32)(UINTN)FvHeader) {
>
> + // This FV is to migrate
>
> + FvMigrationFlags = ToMigrateFvInfo->FvMigrationFlags;
>
> + break;
>
> + }
>
> + }
>
> +
>
> + if (Index == MigrationInfo->ToMigrateFvCount) {
>
> + // This FV is not expected to migrate
>
> + continue;
>
> + }
>
> + }
>
>
>
> //
>
> - // Allocate pool to save the raw PEIMs, which is used to keep
> consistent context across
>
> - // multiple boot and PCR0 will keep the same no matter if the
> address of allocated page is changed.
>
> + // Allocate pages to save the rebased PEIMs, the PEIMs will get
> dispatched later.
>
> //
>
> Status = PeiServicesAllocatePages (
>
> EfiBootServicesCode,
>
> @@ -1245,7 +1264,8 @@ EvacuateTempRam (
> &FvHeaderAddress
>
> );
>
> ASSERT_EFI_ERROR (Status);
>
> - RawDataFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + MigratedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + CopyMem (MigratedFvHeader, FvHeader,
> (UINTN)FvHeader->FvLength);
>
>
>
> DEBUG ((
>
> DEBUG_VERBOSE,
>
> @@ -1256,17 +1276,34 @@ EvacuateTempRam (
> ));
>
>
>
> //
>
> - // Copy the context to the rebased pages and raw pages, and create
> hob to save the
>
> - // information. The MigratedFvInfo HOB will never be produced when
>
> - // PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the
> PCD control the
>
> - // feature.
>
> + // Create hob to save MigratedFvInfo, this hob will only be
produced
> when
>
> + // Migration feature PCD
> PcdMigrateTemporaryRamFirmwareVolumes is set to TRUE.
>
> //
>
> - CopyMem (MigratedFvHeader, FvHeader,
> (UINTN)FvHeader->FvLength);
>
> - CopyMem (RawDataFvHeader, MigratedFvHeader,
> (UINTN)FvHeader->FvLength);
>
> MigratedFvInfo.FvOrgBase = (UINT32)(UINTN)FvHeader;
>
> MigratedFvInfo.FvNewBase = (UINT32)(UINTN)MigratedFvHeader;
>
> - MigratedFvInfo.FvDataBase = (UINT32)(UINTN)RawDataFvHeader;
>
> + MigratedFvInfo.FvDataBase = 0;
>
> MigratedFvInfo.FvLength =
> (UINT32)(UINTN)FvHeader->FvLength;
>
> +
>
> + //
>
> + // When FLAGS_FV_RAW_DATA_COPY bit is set, copy the context to
> the raw pages and
>
> + // reset raw data base address in MigratedFvInfo hob.
>
> + //
>
> + if ((FvMigrationFlags & FLAGS_FV_RAW_DATA_COPY) ==
> FLAGS_FV_RAW_DATA_COPY) {
>
> + DEBUG ((DEBUG_INFO, " Copying Raw Data ...\n"));
>
> + //
>
> + // Allocate pages to save the raw PEIMs
>
> + //
>
> + Status = PeiServicesAllocatePages (
>
> + EfiBootServicesCode,
>
> + EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength),
>
> + &FvHeaderAddress
>
> + );
>
> + ASSERT_EFI_ERROR (Status);
>
> + RawDataFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + CopyMem (RawDataFvHeader, MigratedFvHeader,
> (UINTN)FvHeader->FvLength);
>
> + MigratedFvInfo.FvDataBase =
> (UINT32)(UINTN)RawDataFvHeader;
>
> + }
>
> +
>
> BuildGuidDataHob (&gEdkiiMigratedFvInfoGuid, &MigratedFvInfo,
> sizeof (MigratedFvInfo));
>
>
>
> //
>
> @@ -1330,8 +1367,6 @@ EvacuateTempRam (
> }
>
> }
>
>
>
> - RemoveFvHobsInTemporaryMemory (Private);
>
> -
>
> return Status;
>
> }
>
>
>
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf
> b/MdeModulePkg/Core/Pei/PeiMain.inf
> index 0cf357371a..893bdc0527 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.inf
> +++ b/MdeModulePkg/Core/Pei/PeiMain.inf
> @@ -78,6 +78,7 @@
> gEfiFirmwareFileSystem3Guid
>
> gStatusCodeCallbackGuid
>
> gEdkiiMigratedFvInfoGuid ##
> SOMETIMES_PRODUCES ## HOB
>
> + gEdkiiMigrationInfoGuid ##
> SOMETIMES_CONSUMES ## HOB
>
>
>
> [Ppis]
>
> gEfiPeiStatusCodePpiGuid ##
> SOMETIMES_CONSUMES # PeiReportStatusService is not ready if this PPI
> doesn't exist
>
> diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> index aca2332a0e..1c8b0dfefc 100644
> --- a/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> +++ b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> @@ -9,13 +9,53 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
>
> #define __EDKII_MIGRATED_FV_INFO_GUID_H__
>
>
>
> +//
>
> +// FLAGS_FV_RAW_DATA_COPY indicates FV raw data will be copied to
> permanent memory
>
> +// or not. When FV is migrated to permanent memory, it will be rebased
and
> raw
>
> +// data will be lost. This bit can be configured as below values:
>
> +// 0: FV raw data will not be used in later phase, and the copy will be
skipped
> to
>
> +// optimize boot performance.
>
> +// 1: FV raw data will be copied to permanent memory for later phase use
> (such as
>
> +// FV measurement).
>
> +//
>
> +#define FLAGS_FV_RAW_DATA_COPY BIT0
>
> +
>
> +///
>
> +/// In real use cases, not all FVs need migrate to permanent memory
before
> TempRam tears
>
> +/// down. EDKII_MIGRATION_INFO hob should be published by platform to
> indicate which
>
> +/// FVs need migration to optimize boot performance. If this hob is not
> detected by Pei
>
> +/// Core, all FVs on TempRam will be migrated and FV raw data will also
be
> copied.
>
> +/// Only one EDKII_MIGRATION_INFO hob should be published by platform,
> and this hob will
>
> +/// take effect only when migration feature is enabled by PCD.
>
> +///
>
> +typedef struct {
>
> + UINT32 FvOrgBaseOnTempRam; // Original FV address on
> Temporary Ram
>
> + //
>
> + // FV Migration Flags:
>
> + // Bit0: Indicate to copy FV raw data or not
>
> + // Others: Reserved bits
>
> + //
>
> + UINT32 FvMigrationFlags;
>
> +} TO_MIGRATE_FV_INFO;
>
> +
>
> +typedef struct {
>
> + BOOLEAN MigrateAll; // Migrate all FVs and
> also copy FV raw data
>
> + //
>
> + // ToMigrateFvCount and ToMigrateFvInfo array indicate which FVs need
> be migrated, and
>
> + // these info should be ignored when MigrateAll field is set to TRUE.
>
> + //
>
> + UINT32 ToMigrateFvCount;
>
> + // TO_MIGRATE_FV_INFO ToMigrateFvInfo[];
>
> +} EDKII_MIGRATION_INFO;
>
> +
>
> typedef struct {
>
> UINT32 FvOrgBase; // original FV address
>
> UINT32 FvNewBase; // new FV address
>
> - UINT32 FvDataBase; // original FV data
>
> + UINT32 FvDataBase; // original FV data, 0 means raw data is
> not copied
>
> UINT32 FvLength; // Fv Length
>
> } EDKII_MIGRATED_FV_INFO;
>
>
>
> +extern EFI_GUID gEdkiiMigrationInfoGuid;
>
> extern EFI_GUID gEdkiiMigratedFvInfoGuid;
>
>
>
> #endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 1a162e97e6..a2cd83345f 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -421,7 +421,8 @@
> gEdkiiCapsuleOnDiskNameGuid = { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93,
> 0x9a, 0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } }
>
>
>
> ## Include/Guid/MigratedFvInfo.h
>
> - gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4,
> 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }
>
> + gEdkiiMigrationInfoGuid = { 0xb4b140a5, 0x72f6, 0x4c21, { 0x93, 0xe4,
> 0xac, 0xc4, 0xec, 0xcb, 0x23, 0x23 } }
>
> + gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4,
> 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }
>
>
>
> ## Include/Guid/RngAlgorithm.h
>
> gEdkiiRngAlgorithmUnSafe = { 0x869f728c, 0x409d, 0x4ab4, {0xac, 0x03,
> 0x71, 0xd3, 0x09, 0xc1, 0xb3, 0xf4 }}
>
> diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> index 1caaa4e319..daaf49e644 100644
> --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> @@ -726,8 +726,11 @@ MeasureFvImage (
> //
>
> // Found the migrated FV info
>
> //
>
> - FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> - FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> + if (MigratedFvInfo->FvDataBase != 0) {
>
> + FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + }
>
> +
>
> break;
>
> }
>
>
>
> diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c
b/SecurityPkg/Tcg/TcgPei/TcgPei.c
> index 5aa80511aa..d35c2ad0bc 100644
> --- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
> +++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
> @@ -463,8 +463,11 @@ MeasureFvImage (
> //
>
> // Found the migrated FV info
>
> //
>
> - FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> - FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> + if (MigratedFvInfo->FvDataBase != 0) {
>
> + FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + }
>
> +
>
> break;
>
> }
>
>
>
> --
> 2.26.2.windows.1
>
>
>
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#112276):
> https://edk2.groups.io/g/devel/message/112276
> Mute This Topic: https://groups.io/mt/103105558/4905953
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub
> [gaoliming@byosoft.com.cn]
> -=-=-=-=-=-=
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112350): https://edk2.groups.io/g/devel/message/112350
Mute This Topic: https://groups.io/mt/103121557/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information
2023-12-11 9:06 [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information Wang Fan
2023-12-12 0:46 ` 回复: " gaoliming via groups.io
@ 2023-12-13 3:23 ` Ni, Ray
2023-12-13 8:53 ` Wang Fan
1 sibling, 1 reply; 4+ messages in thread
From: Ni, Ray @ 2023-12-13 3:23 UTC (permalink / raw)
To: Wang, Fan, devel@edk2.groups.io
Cc: Kinney, Michael D, Gao, Liming, Jiang, Guomin, Wang, Jian J
Fan,
1. MigrateAll can potentially replace the needs of the existing PCD. So, do you think it's better to locate the HOB always, instead of only when the PCD is TRUE?
2. Is the change in TcgPei necessary?
Thanks,
Ray
> -----Original Message-----
> From: Wang, Fan <fan.wang@intel.com>
> Sent: Monday, December 11, 2023 5:06 PM
> To: devel@edk2.groups.io
> Cc: Wang, Fan <fan.wang@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Ni,
> Ray <ray.ni@intel.com>; Jiang, Guomin <guomin.jiang@intel.com>; Wang,
> Jian J <jian.j.wang@intel.com>
> Subject: [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration
> Information
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4533
>
> There are use cases which not all FVs need be migrated from TempRam to
> permanent memory before TempRam tears down. This new guid is introduced
> to avoid unnecessary FV migration to improve boot performance. Platform
> can publish MigrationInfo hob with this guid to customize FV migration
> info, and PeiCore will only migrate FVs indicated by this Hob info.
>
> This is a backwards compatible change, PeiCore will check MigrationInfo
> hob before migration. If MigrationInfo hobs exists, only migrate FVs
> recorded by hobs. If MigrationInfo hobs not exists, migrate all FVs to
> permanent memory.
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Guomin Jiang <guomin.jiang@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Signed-off-by: Fan Wang <fan.wang@intel.com>
> ---
> MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 79
> +++++++++++++------
> MdeModulePkg/Core/Pei/PeiMain.inf | 1 +
> MdeModulePkg/Include/Guid/MigratedFvInfo.h | 42 +++++++++-
> MdeModulePkg/MdeModulePkg.dec | 3 +-
> SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 7 +-
> SecurityPkg/Tcg/TcgPei/TcgPei.c | 7 +-
> 6 files changed, 111 insertions(+), 28 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index 5f32ebb560..0086087e82 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -1184,7 +1184,12 @@ EvacuateTempRam (
>
>
> PEI_CORE_FV_HANDLE PeiCoreFvHandle;
>
> EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;
>
> + EFI_PEI_HOB_POINTERS Hob;
>
> + EDKII_MIGRATION_INFO *MigrationInfo;
>
> + TO_MIGRATE_FV_INFO *ToMigrateFvInfo;
>
> + UINT32 FvMigrationFlags;
>
> EDKII_MIGRATED_FV_INFO MigratedFvInfo;
>
> + UINTN Index;
>
>
>
> ASSERT (Private->PeiMemoryInstalled);
>
>
>
> @@ -1211,6 +1216,13 @@ EvacuateTempRam (
>
>
> ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle);
>
>
>
> + Hob.Raw = GetFirstGuidHob (&gEdkiiMigrationInfoGuid);
>
> + if (Hob.Raw != NULL) {
>
> + MigrationInfo = GET_GUID_HOB_DATA (Hob);
>
> + } else {
>
> + MigrationInfo = NULL;
>
> + }
>
> +
>
> for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
>
> FvHeader = Private->Fv[FvIndex].FvHeader;
>
> ASSERT (FvHeader != NULL);
>
> @@ -1224,20 +1236,27 @@ EvacuateTempRam (
> )
>
> )
>
> {
>
> - //
>
> - // Allocate page to save the rebased PEIMs, the PEIMs will get
> dispatched later.
>
> - //
>
> - Status = PeiServicesAllocatePages (
>
> - EfiBootServicesCode,
>
> - EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength),
>
> - &FvHeaderAddress
>
> - );
>
> - ASSERT_EFI_ERROR (Status);
>
> - MigratedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + if ((MigrationInfo == NULL) || (MigrationInfo->MigrateAll == TRUE)) {
>
> + // Migrate all FVs and copy raw data
>
> + FvMigrationFlags = FLAGS_FV_RAW_DATA_COPY;
>
> + } else {
>
> + for (Index = 0; Index < MigrationInfo->ToMigrateFvCount; Index++)
> {
>
> + ToMigrateFvInfo = ((TO_MIGRATE_FV_INFO *)(MigrationInfo +
> 1)) + Index;
>
> + if (ToMigrateFvInfo->FvOrgBaseOnTempRam ==
> (UINT32)(UINTN)FvHeader) {
>
> + // This FV is to migrate
>
> + FvMigrationFlags = ToMigrateFvInfo->FvMigrationFlags;
>
> + break;
>
> + }
>
> + }
>
> +
>
> + if (Index == MigrationInfo->ToMigrateFvCount) {
>
> + // This FV is not expected to migrate
>
> + continue;
>
> + }
>
> + }
>
>
>
> //
>
> - // Allocate pool to save the raw PEIMs, which is used to keep
> consistent context across
>
> - // multiple boot and PCR0 will keep the same no matter if the address
> of allocated page is changed.
>
> + // Allocate pages to save the rebased PEIMs, the PEIMs will get
> dispatched later.
>
> //
>
> Status = PeiServicesAllocatePages (
>
> EfiBootServicesCode,
>
> @@ -1245,7 +1264,8 @@ EvacuateTempRam (
> &FvHeaderAddress
>
> );
>
> ASSERT_EFI_ERROR (Status);
>
> - RawDataFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + MigratedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + CopyMem (MigratedFvHeader, FvHeader,
> (UINTN)FvHeader->FvLength);
>
>
>
> DEBUG ((
>
> DEBUG_VERBOSE,
>
> @@ -1256,17 +1276,34 @@ EvacuateTempRam (
> ));
>
>
>
> //
>
> - // Copy the context to the rebased pages and raw pages, and create
> hob to save the
>
> - // information. The MigratedFvInfo HOB will never be produced when
>
> - // PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the
> PCD control the
>
> - // feature.
>
> + // Create hob to save MigratedFvInfo, this hob will only be produced
> when
>
> + // Migration feature PCD
> PcdMigrateTemporaryRamFirmwareVolumes is set to TRUE.
>
> //
>
> - CopyMem (MigratedFvHeader, FvHeader,
> (UINTN)FvHeader->FvLength);
>
> - CopyMem (RawDataFvHeader, MigratedFvHeader,
> (UINTN)FvHeader->FvLength);
>
> MigratedFvInfo.FvOrgBase = (UINT32)(UINTN)FvHeader;
>
> MigratedFvInfo.FvNewBase = (UINT32)(UINTN)MigratedFvHeader;
>
> - MigratedFvInfo.FvDataBase = (UINT32)(UINTN)RawDataFvHeader;
>
> + MigratedFvInfo.FvDataBase = 0;
>
> MigratedFvInfo.FvLength =
> (UINT32)(UINTN)FvHeader->FvLength;
>
> +
>
> + //
>
> + // When FLAGS_FV_RAW_DATA_COPY bit is set, copy the context to
> the raw pages and
>
> + // reset raw data base address in MigratedFvInfo hob.
>
> + //
>
> + if ((FvMigrationFlags & FLAGS_FV_RAW_DATA_COPY) ==
> FLAGS_FV_RAW_DATA_COPY) {
>
> + DEBUG ((DEBUG_INFO, " Copying Raw Data ...\n"));
>
> + //
>
> + // Allocate pages to save the raw PEIMs
>
> + //
>
> + Status = PeiServicesAllocatePages (
>
> + EfiBootServicesCode,
>
> + EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength),
>
> + &FvHeaderAddress
>
> + );
>
> + ASSERT_EFI_ERROR (Status);
>
> + RawDataFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + CopyMem (RawDataFvHeader, MigratedFvHeader,
> (UINTN)FvHeader->FvLength);
>
> + MigratedFvInfo.FvDataBase =
> (UINT32)(UINTN)RawDataFvHeader;
>
> + }
>
> +
>
> BuildGuidDataHob (&gEdkiiMigratedFvInfoGuid, &MigratedFvInfo,
> sizeof (MigratedFvInfo));
>
>
>
> //
>
> @@ -1330,8 +1367,6 @@ EvacuateTempRam (
> }
>
> }
>
>
>
> - RemoveFvHobsInTemporaryMemory (Private);
>
> -
>
> return Status;
>
> }
>
>
>
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf
> b/MdeModulePkg/Core/Pei/PeiMain.inf
> index 0cf357371a..893bdc0527 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.inf
> +++ b/MdeModulePkg/Core/Pei/PeiMain.inf
> @@ -78,6 +78,7 @@
> gEfiFirmwareFileSystem3Guid
>
> gStatusCodeCallbackGuid
>
> gEdkiiMigratedFvInfoGuid ##
> SOMETIMES_PRODUCES ## HOB
>
> + gEdkiiMigrationInfoGuid ##
> SOMETIMES_CONSUMES ## HOB
>
>
>
> [Ppis]
>
> gEfiPeiStatusCodePpiGuid ##
> SOMETIMES_CONSUMES # PeiReportStatusService is not ready if this PPI
> doesn't exist
>
> diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> index aca2332a0e..1c8b0dfefc 100644
> --- a/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> +++ b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> @@ -9,13 +9,53 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
>
> #define __EDKII_MIGRATED_FV_INFO_GUID_H__
>
>
>
> +//
>
> +// FLAGS_FV_RAW_DATA_COPY indicates FV raw data will be copied to
> permanent memory
>
> +// or not. When FV is migrated to permanent memory, it will be rebased and
> raw
>
> +// data will be lost. This bit can be configured as below values:
>
> +// 0: FV raw data will not be used in later phase, and the copy will be skipped
> to
>
> +// optimize boot performance.
>
> +// 1: FV raw data will be copied to permanent memory for later phase use
> (such as
>
> +// FV measurement).
>
> +//
>
> +#define FLAGS_FV_RAW_DATA_COPY BIT0
>
> +
>
> +///
>
> +/// In real use cases, not all FVs need migrate to permanent memory before
> TempRam tears
>
> +/// down. EDKII_MIGRATION_INFO hob should be published by platform to
> indicate which
>
> +/// FVs need migration to optimize boot performance. If this hob is not
> detected by Pei
>
> +/// Core, all FVs on TempRam will be migrated and FV raw data will also be
> copied.
>
> +/// Only one EDKII_MIGRATION_INFO hob should be published by platform,
> and this hob will
>
> +/// take effect only when migration feature is enabled by PCD.
>
> +///
>
> +typedef struct {
>
> + UINT32 FvOrgBaseOnTempRam; // Original FV address on
> Temporary Ram
>
> + //
>
> + // FV Migration Flags:
>
> + // Bit0: Indicate to copy FV raw data or not
>
> + // Others: Reserved bits
>
> + //
>
> + UINT32 FvMigrationFlags;
>
> +} TO_MIGRATE_FV_INFO;
>
> +
>
> +typedef struct {
>
> + BOOLEAN MigrateAll; // Migrate all FVs and
> also copy FV raw data
>
> + //
>
> + // ToMigrateFvCount and ToMigrateFvInfo array indicate which FVs need
> be migrated, and
>
> + // these info should be ignored when MigrateAll field is set to TRUE.
>
> + //
>
> + UINT32 ToMigrateFvCount;
>
> + // TO_MIGRATE_FV_INFO ToMigrateFvInfo[];
>
> +} EDKII_MIGRATION_INFO;
>
> +
>
> typedef struct {
>
> UINT32 FvOrgBase; // original FV address
>
> UINT32 FvNewBase; // new FV address
>
> - UINT32 FvDataBase; // original FV data
>
> + UINT32 FvDataBase; // original FV data, 0 means raw data is
> not copied
>
> UINT32 FvLength; // Fv Length
>
> } EDKII_MIGRATED_FV_INFO;
>
>
>
> +extern EFI_GUID gEdkiiMigrationInfoGuid;
>
> extern EFI_GUID gEdkiiMigratedFvInfoGuid;
>
>
>
> #endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 1a162e97e6..a2cd83345f 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -421,7 +421,8 @@
> gEdkiiCapsuleOnDiskNameGuid = { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93,
> 0x9a, 0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } }
>
>
>
> ## Include/Guid/MigratedFvInfo.h
>
> - gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4,
> 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }
>
> + gEdkiiMigrationInfoGuid = { 0xb4b140a5, 0x72f6, 0x4c21, { 0x93, 0xe4,
> 0xac, 0xc4, 0xec, 0xcb, 0x23, 0x23 } }
>
> + gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4,
> 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }
>
>
>
> ## Include/Guid/RngAlgorithm.h
>
> gEdkiiRngAlgorithmUnSafe = { 0x869f728c, 0x409d, 0x4ab4, {0xac, 0x03,
> 0x71, 0xd3, 0x09, 0xc1, 0xb3, 0xf4 }}
>
> diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> index 1caaa4e319..daaf49e644 100644
> --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> @@ -726,8 +726,11 @@ MeasureFvImage (
> //
>
> // Found the migrated FV info
>
> //
>
> - FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> - FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> + if (MigratedFvInfo->FvDataBase != 0) {
>
> + FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + }
>
> +
>
> break;
>
> }
>
>
>
> diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c
> b/SecurityPkg/Tcg/TcgPei/TcgPei.c
> index 5aa80511aa..d35c2ad0bc 100644
> --- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
> +++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
> @@ -463,8 +463,11 @@ MeasureFvImage (
> //
>
> // Found the migrated FV info
>
> //
>
> - FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> - FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> + if (MigratedFvInfo->FvDataBase != 0) {
>
> + FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + }
>
> +
>
> break;
>
> }
>
>
>
> --
> 2.26.2.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112464): https://edk2.groups.io/g/devel/message/112464
Mute This Topic: https://groups.io/mt/103105558/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information
2023-12-13 3:23 ` Ni, Ray
@ 2023-12-13 8:53 ` Wang Fan
0 siblings, 0 replies; 4+ messages in thread
From: Wang Fan @ 2023-12-13 8:53 UTC (permalink / raw)
To: Ni, Ray, devel@edk2.groups.io
Cc: Kinney, Michael D, Gao, Liming, Jiang, Guomin, Wang, Jian J
Thank you Ray.
For your question 1, my thought is to keep only one way to turn on/off this feature. So I'm preferring two-steps work:
Step #1. Introduce this HOB, let PCD control this feature turn on/off and HOB to publish extra information, which is a compatible change.
Step #2. Retire this PCD, and let the HOB control this feature turn on/off, which will be an incompatible change. "MigrateAll" field can help this transfer more smooth (platforms can publish this HOB easily with this field and not impact by this EDK2 change).
For your question 2, I think it's necessary.
Previous logic in TcgPei driver is: When MigratedFvInfo HOB is detected, raw data is already copied and always measure this FV from raw data base.
But now we are breaking this assumption, so I updated this logic to: When MigratedFvInfo HOB is detected, measure FV from raw data base if raw data is copied, otherwise measure FV from the base Input parameter indicated.
Best Regards
Fan
-----Original Message-----
From: Ni, Ray <ray.ni@intel.com>
Sent: Wednesday, December 13, 2023 11:24 AM
To: Wang, Fan <fan.wang@intel.com>; devel@edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Jiang, Guomin <guomin.jiang@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
Subject: RE: [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information
Fan,
1. MigrateAll can potentially replace the needs of the existing PCD. So, do you think it's better to locate the HOB always, instead of only when the PCD is TRUE?
2. Is the change in TcgPei necessary?
Thanks,
Ray
> -----Original Message-----
> From: Wang, Fan <fan.wang@intel.com>
> Sent: Monday, December 11, 2023 5:06 PM
> To: devel@edk2.groups.io
> Cc: Wang, Fan <fan.wang@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> Ni, Ray <ray.ni@intel.com>; Jiang, Guomin <guomin.jiang@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>
> Subject: [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration
> Information
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4533
>
> There are use cases which not all FVs need be migrated from TempRam to
> permanent memory before TempRam tears down. This new guid is
> introduced to avoid unnecessary FV migration to improve boot
> performance. Platform can publish MigrationInfo hob with this guid to
> customize FV migration info, and PeiCore will only migrate FVs indicated by this Hob info.
>
> This is a backwards compatible change, PeiCore will check
> MigrationInfo hob before migration. If MigrationInfo hobs exists, only
> migrate FVs recorded by hobs. If MigrationInfo hobs not exists,
> migrate all FVs to permanent memory.
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Guomin Jiang <guomin.jiang@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Signed-off-by: Fan Wang <fan.wang@intel.com>
> ---
> MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 79
> +++++++++++++------
> MdeModulePkg/Core/Pei/PeiMain.inf | 1 +
> MdeModulePkg/Include/Guid/MigratedFvInfo.h | 42 +++++++++-
> MdeModulePkg/MdeModulePkg.dec | 3 +-
> SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 7 +-
> SecurityPkg/Tcg/TcgPei/TcgPei.c | 7 +-
> 6 files changed, 111 insertions(+), 28 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index 5f32ebb560..0086087e82 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -1184,7 +1184,12 @@ EvacuateTempRam (
>
>
> PEI_CORE_FV_HANDLE PeiCoreFvHandle;
>
> EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;
>
> + EFI_PEI_HOB_POINTERS Hob;
>
> + EDKII_MIGRATION_INFO *MigrationInfo;
>
> + TO_MIGRATE_FV_INFO *ToMigrateFvInfo;
>
> + UINT32 FvMigrationFlags;
>
> EDKII_MIGRATED_FV_INFO MigratedFvInfo;
>
> + UINTN Index;
>
>
>
> ASSERT (Private->PeiMemoryInstalled);
>
>
>
> @@ -1211,6 +1216,13 @@ EvacuateTempRam (
>
>
> ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle);
>
>
>
> + Hob.Raw = GetFirstGuidHob (&gEdkiiMigrationInfoGuid);
>
> + if (Hob.Raw != NULL) {
>
> + MigrationInfo = GET_GUID_HOB_DATA (Hob);
>
> + } else {
>
> + MigrationInfo = NULL;
>
> + }
>
> +
>
> for (FvIndex = 0; FvIndex < Private->FvCount; FvIndex++) {
>
> FvHeader = Private->Fv[FvIndex].FvHeader;
>
> ASSERT (FvHeader != NULL);
>
> @@ -1224,20 +1236,27 @@ EvacuateTempRam (
> )
>
> )
>
> {
>
> - //
>
> - // Allocate page to save the rebased PEIMs, the PEIMs will get
> dispatched later.
>
> - //
>
> - Status = PeiServicesAllocatePages (
>
> - EfiBootServicesCode,
>
> - EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength),
>
> - &FvHeaderAddress
>
> - );
>
> - ASSERT_EFI_ERROR (Status);
>
> - MigratedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + if ((MigrationInfo == NULL) || (MigrationInfo->MigrateAll ==
> + TRUE)) {
>
> + // Migrate all FVs and copy raw data
>
> + FvMigrationFlags = FLAGS_FV_RAW_DATA_COPY;
>
> + } else {
>
> + for (Index = 0; Index < MigrationInfo->ToMigrateFvCount;
> + Index++)
> {
>
> + ToMigrateFvInfo = ((TO_MIGRATE_FV_INFO *)(MigrationInfo +
> 1)) + Index;
>
> + if (ToMigrateFvInfo->FvOrgBaseOnTempRam ==
> (UINT32)(UINTN)FvHeader) {
>
> + // This FV is to migrate
>
> + FvMigrationFlags = ToMigrateFvInfo->FvMigrationFlags;
>
> + break;
>
> + }
>
> + }
>
> +
>
> + if (Index == MigrationInfo->ToMigrateFvCount) {
>
> + // This FV is not expected to migrate
>
> + continue;
>
> + }
>
> + }
>
>
>
> //
>
> - // Allocate pool to save the raw PEIMs, which is used to keep
> consistent context across
>
> - // multiple boot and PCR0 will keep the same no matter if the address
> of allocated page is changed.
>
> + // Allocate pages to save the rebased PEIMs, the PEIMs will get
> dispatched later.
>
> //
>
> Status = PeiServicesAllocatePages (
>
> EfiBootServicesCode,
>
> @@ -1245,7 +1264,8 @@ EvacuateTempRam (
> &FvHeaderAddress
>
> );
>
> ASSERT_EFI_ERROR (Status);
>
> - RawDataFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + MigratedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + CopyMem (MigratedFvHeader, FvHeader,
> (UINTN)FvHeader->FvLength);
>
>
>
> DEBUG ((
>
> DEBUG_VERBOSE,
>
> @@ -1256,17 +1276,34 @@ EvacuateTempRam (
> ));
>
>
>
> //
>
> - // Copy the context to the rebased pages and raw pages, and create
> hob to save the
>
> - // information. The MigratedFvInfo HOB will never be produced when
>
> - // PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the
> PCD control the
>
> - // feature.
>
> + // Create hob to save MigratedFvInfo, this hob will only be
> + produced
> when
>
> + // Migration feature PCD
> PcdMigrateTemporaryRamFirmwareVolumes is set to TRUE.
>
> //
>
> - CopyMem (MigratedFvHeader, FvHeader,
> (UINTN)FvHeader->FvLength);
>
> - CopyMem (RawDataFvHeader, MigratedFvHeader,
> (UINTN)FvHeader->FvLength);
>
> MigratedFvInfo.FvOrgBase = (UINT32)(UINTN)FvHeader;
>
> MigratedFvInfo.FvNewBase = (UINT32)(UINTN)MigratedFvHeader;
>
> - MigratedFvInfo.FvDataBase = (UINT32)(UINTN)RawDataFvHeader;
>
> + MigratedFvInfo.FvDataBase = 0;
>
> MigratedFvInfo.FvLength =
> (UINT32)(UINTN)FvHeader->FvLength;
>
> +
>
> + //
>
> + // When FLAGS_FV_RAW_DATA_COPY bit is set, copy the context to
> the raw pages and
>
> + // reset raw data base address in MigratedFvInfo hob.
>
> + //
>
> + if ((FvMigrationFlags & FLAGS_FV_RAW_DATA_COPY) ==
> FLAGS_FV_RAW_DATA_COPY) {
>
> + DEBUG ((DEBUG_INFO, " Copying Raw Data ...\n"));
>
> + //
>
> + // Allocate pages to save the raw PEIMs
>
> + //
>
> + Status = PeiServicesAllocatePages (
>
> + EfiBootServicesCode,
>
> + EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength),
>
> + &FvHeaderAddress
>
> + );
>
> + ASSERT_EFI_ERROR (Status);
>
> + RawDataFvHeader = (EFI_FIRMWARE_VOLUME_HEADER
> *)(UINTN)FvHeaderAddress;
>
> + CopyMem (RawDataFvHeader, MigratedFvHeader,
> (UINTN)FvHeader->FvLength);
>
> + MigratedFvInfo.FvDataBase =
> (UINT32)(UINTN)RawDataFvHeader;
>
> + }
>
> +
>
> BuildGuidDataHob (&gEdkiiMigratedFvInfoGuid, &MigratedFvInfo,
> sizeof (MigratedFvInfo));
>
>
>
> //
>
> @@ -1330,8 +1367,6 @@ EvacuateTempRam (
> }
>
> }
>
>
>
> - RemoveFvHobsInTemporaryMemory (Private);
>
> -
>
> return Status;
>
> }
>
>
>
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf
> b/MdeModulePkg/Core/Pei/PeiMain.inf
> index 0cf357371a..893bdc0527 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.inf
> +++ b/MdeModulePkg/Core/Pei/PeiMain.inf
> @@ -78,6 +78,7 @@
> gEfiFirmwareFileSystem3Guid
>
> gStatusCodeCallbackGuid
>
> gEdkiiMigratedFvInfoGuid ##
> SOMETIMES_PRODUCES ## HOB
>
> + gEdkiiMigrationInfoGuid ##
> SOMETIMES_CONSUMES ## HOB
>
>
>
> [Ppis]
>
> gEfiPeiStatusCodePpiGuid ##
> SOMETIMES_CONSUMES # PeiReportStatusService is not ready if this PPI
> doesn't exist
>
> diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> index aca2332a0e..1c8b0dfefc 100644
> --- a/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> +++ b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
> @@ -9,13 +9,53 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
>
> #define __EDKII_MIGRATED_FV_INFO_GUID_H__
>
>
>
> +//
>
> +// FLAGS_FV_RAW_DATA_COPY indicates FV raw data will be copied to
> permanent memory
>
> +// or not. When FV is migrated to permanent memory, it will be
> +rebased and
> raw
>
> +// data will be lost. This bit can be configured as below values:
>
> +// 0: FV raw data will not be used in later phase, and the copy will
> +be skipped
> to
>
> +// optimize boot performance.
>
> +// 1: FV raw data will be copied to permanent memory for later phase
> +use
> (such as
>
> +// FV measurement).
>
> +//
>
> +#define FLAGS_FV_RAW_DATA_COPY BIT0
>
> +
>
> +///
>
> +/// In real use cases, not all FVs need migrate to permanent memory
> +before
> TempRam tears
>
> +/// down. EDKII_MIGRATION_INFO hob should be published by platform to
> indicate which
>
> +/// FVs need migration to optimize boot performance. If this hob is
> +not
> detected by Pei
>
> +/// Core, all FVs on TempRam will be migrated and FV raw data will
> +also be
> copied.
>
> +/// Only one EDKII_MIGRATION_INFO hob should be published by
> +platform,
> and this hob will
>
> +/// take effect only when migration feature is enabled by PCD.
>
> +///
>
> +typedef struct {
>
> + UINT32 FvOrgBaseOnTempRam; // Original FV address on
> Temporary Ram
>
> + //
>
> + // FV Migration Flags:
>
> + // Bit0: Indicate to copy FV raw data or not
>
> + // Others: Reserved bits
>
> + //
>
> + UINT32 FvMigrationFlags;
>
> +} TO_MIGRATE_FV_INFO;
>
> +
>
> +typedef struct {
>
> + BOOLEAN MigrateAll; // Migrate all FVs and
> also copy FV raw data
>
> + //
>
> + // ToMigrateFvCount and ToMigrateFvInfo array indicate which FVs
> + need
> be migrated, and
>
> + // these info should be ignored when MigrateAll field is set to TRUE.
>
> + //
>
> + UINT32 ToMigrateFvCount;
>
> + // TO_MIGRATE_FV_INFO ToMigrateFvInfo[];
>
> +} EDKII_MIGRATION_INFO;
>
> +
>
> typedef struct {
>
> UINT32 FvOrgBase; // original FV address
>
> UINT32 FvNewBase; // new FV address
>
> - UINT32 FvDataBase; // original FV data
>
> + UINT32 FvDataBase; // original FV data, 0 means raw data is
> not copied
>
> UINT32 FvLength; // Fv Length
>
> } EDKII_MIGRATED_FV_INFO;
>
>
>
> +extern EFI_GUID gEdkiiMigrationInfoGuid;
>
> extern EFI_GUID gEdkiiMigratedFvInfoGuid;
>
>
>
> #endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec index 1a162e97e6..a2cd83345f 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -421,7 +421,8 @@
> gEdkiiCapsuleOnDiskNameGuid = { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93,
> 0x9a, 0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } }
>
>
>
> ## Include/Guid/MigratedFvInfo.h
>
> - gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2,
> 0xf4, 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }
>
> + gEdkiiMigrationInfoGuid = { 0xb4b140a5, 0x72f6, 0x4c21, { 0x93, 0xe4,
> 0xac, 0xc4, 0xec, 0xcb, 0x23, 0x23 } }
>
> + gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2,
> + 0xf4,
> 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }
>
>
>
> ## Include/Guid/RngAlgorithm.h
>
> gEdkiiRngAlgorithmUnSafe = { 0x869f728c, 0x409d, 0x4ab4, {0xac,
> 0x03, 0x71, 0xd3, 0x09, 0xc1, 0xb3, 0xf4 }}
>
> diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> index 1caaa4e319..daaf49e644 100644
> --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> @@ -726,8 +726,11 @@ MeasureFvImage (
> //
>
> // Found the migrated FV info
>
> //
>
> - FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> - FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> + if (MigratedFvInfo->FvDataBase != 0) {
>
> + FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + }
>
> +
>
> break;
>
> }
>
>
>
> diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c
> b/SecurityPkg/Tcg/TcgPei/TcgPei.c index 5aa80511aa..d35c2ad0bc 100644
> --- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
> +++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
> @@ -463,8 +463,11 @@ MeasureFvImage (
> //
>
> // Found the migrated FV info
>
> //
>
> - FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> - FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + FvOrgBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;
>
> + if (MigratedFvInfo->FvDataBase != 0) {
>
> + FvDataBase =
> (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;
>
> + }
>
> +
>
> break;
>
> }
>
>
>
> --
> 2.26.2.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112467): https://edk2.groups.io/g/devel/message/112467
Mute This Topic: https://groups.io/mt/103105558/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-12-13 8:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-11 9:06 [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information Wang Fan
2023-12-12 0:46 ` 回复: " gaoliming via groups.io
2023-12-13 3:23 ` Ni, Ray
2023-12-13 8:53 ` Wang Fan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox