From nobody Wed May 15 15:10:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+112531+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112531+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1702562009; cv=none; d=zohomail.com; s=zohoarc; b=jBfG0hzsbEpQP8uMVcbL5YAWbYzZzcMRWzc9gISdr8Hir/worwyV1fyMCr939CnmqbZL7VvHJ2YYJWmnNGIpBReTw+iSHuv56cOYETi+/f1MwPcomUALztW8dBPPT8av/TrT8QEUzI6+8YT8r18uMSzmpYsNqzb4KWUK7uPTwbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702562009; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=JOxndya7TnFe9sD/sqy6CS2b/XEog2l1fjGIJMEyM/M=; b=E5a55vVvJq7eqzAYsCHXViD14XamHx4SeTfISY2BroZS0JPxoHfI09F1XwNufedwdXbMBeXxVCssdFZdtwA2fBib/mGUhcK1KlZ/C4OXFABJaUYfZur+HcVtB0+xACTcWEuib+7x+/ssB+6di8q4TRnSR8RLmBwjvJY7gMG3Nnc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112531+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1702562009353852.3860566919493; Thu, 14 Dec 2023 05:53:29 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=+L2zzfWCwUSr+pfGgK0Wq4op1Pm5r0UKPquv1Jpoqhk=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1702562009; v=1; b=IfGcF5OuyQmjNkL9Fwc1+74Zqa/Z9N+O/dcYfLHCC6LiQcRaz4p8vuyxSFPJwGG/lh+nbnkA 0AzsV3xPzQtfjIGsfiMoimcyNiKxGG9eO8/RR0jqqHy+sh0cgFCVgvhcghEqkSI3u0epVoQQ2g8 BufulNhRYUv58oxBfkDYXWMs= X-Received: by 127.0.0.2 with SMTP id tcHUYY1788612xrunXWZa3Ha; Thu, 14 Dec 2023 05:53:29 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mx.groups.io with SMTP id smtpd.web10.22605.1702562004503781636 for ; Thu, 14 Dec 2023 05:53:28 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="1957345" X-IronPort-AV: E=Sophos;i="6.04,275,1695711600"; d="scan'208";a="1957345" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 05:53:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="947581769" X-IronPort-AV: E=Sophos;i="6.04,275,1695711600"; d="scan'208";a="947581769" X-Received: from sh1gapp1015.ccr.corp.intel.com ([10.239.189.85]) by orsmga005.jf.intel.com with ESMTP; 14 Dec 2023 05:53:26 -0800 From: "Wang Fan" To: devel@edk2.groups.io Cc: Fan Wang , Michael D Kinney , Liming Gao , Ray Ni , Guomin Jiang Subject: [edk2-devel] [PATCH v5 1/2] MdeModulePkg: Support customized FV Migration Information Date: Thu, 14 Dec 2023 21:53:18 +0800 Message-Id: <20231214135319.3986-2-fan.wang@intel.com> In-Reply-To: <20231214135319.3986-1-fan.wang@intel.com> References: <20231214135319.3986-1-fan.wang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,fan.wang@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: kFIYjZr775fep3efleJ0Smatx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1702562010382100001 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4533 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 Cc: Liming Gao Cc: Ray Ni Cc: Guomin Jiang Signed-off-by: Fan Wang --- MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 84 ++++++++++++++----- MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 40 --------- MdeModulePkg/Core/Pei/PeiMain.h | 11 --- MdeModulePkg/Core/Pei/PeiMain.inf | 1 + MdeModulePkg/Include/Guid/MigratedFvInfo.h | 42 +++++++++- MdeModulePkg/MdeModulePkg.dec | 3 +- 6 files changed, 106 insertions(+), 75 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/C= ore/Pei/Dispatcher/Dispatcher.c index 5f32ebb560ae..4cd8c843cd92 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -1184,7 +1184,12 @@ EvacuateTempRam ( =20 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; =20 ASSERT (Private->PeiMemoryInstalled); =20 @@ -1211,6 +1216,13 @@ EvacuateTempRam ( =20 ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle); =20 + Hob.Raw =3D GetFirstGuidHob (&gEdkiiMigrationInfoGuid); + if (Hob.Raw !=3D NULL) { + MigrationInfo =3D GET_GUID_HOB_DATA (Hob); + } else { + MigrationInfo =3D NULL; + } + for (FvIndex =3D 0; FvIndex < Private->FvCount; FvIndex++) { FvHeader =3D Private->Fv[FvIndex].FvHeader; ASSERT (FvHeader !=3D NULL); @@ -1224,8 +1236,33 @@ EvacuateTempRam ( ) ) { + if ((MigrationInfo =3D=3D NULL) || (MigrationInfo->MigrateAll =3D=3D= TRUE)) { + // + // Migrate all FVs and copy raw data + // + FvMigrationFlags =3D FLAGS_FV_RAW_DATA_COPY; + } else { + for (Index =3D 0; Index < MigrationInfo->ToMigrateFvCount; Index++= ) { + ToMigrateFvInfo =3D ((TO_MIGRATE_FV_INFO *)(MigrationInfo + 1)) = + Index; + if (ToMigrateFvInfo->FvOrgBaseOnTempRam =3D=3D (UINT32)(UINTN)Fv= Header) { + // + // This FV is to migrate + // + FvMigrationFlags =3D ToMigrateFvInfo->FvMigrationFlags; + break; + } + } + + if (Index =3D=3D MigrationInfo->ToMigrateFvCount) { + // + // This FV is not expected to migrate + // + continue; + } + } + // - // Allocate page to save the rebased PEIMs, the PEIMs will get dispa= tched later. + // Allocate pages to save the rebased PEIMs, the PEIMs will get disp= atched later. // Status =3D PeiServicesAllocatePages ( EfiBootServicesCode, @@ -1234,18 +1271,7 @@ EvacuateTempRam ( ); ASSERT_EFI_ERROR (Status); MigratedFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHeaderAd= dress; - - // - // Allocate pool to save the raw PEIMs, which is used to keep consis= tent context across - // multiple boot and PCR0 will keep the same no matter if the addres= s of allocated page is changed. - // - Status =3D PeiServicesAllocatePages ( - EfiBootServicesCode, - EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength), - &FvHeaderAddress - ); - ASSERT_EFI_ERROR (Status); - RawDataFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHeaderAdd= ress; + CopyMem (MigratedFvHeader, FvHeader, (UINTN)FvHeader->FvLength); =20 DEBUG (( DEBUG_VERBOSE, @@ -1256,17 +1282,33 @@ EvacuateTempRam ( )); =20 // - // Copy the context to the rebased pages and raw pages, and create h= ob to save the - // information. The MigratedFvInfo HOB will never be produced when - // PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the PCD c= ontrol the - // feature. + // Create hob to save MigratedFvInfo, this hob will only be produced= when + // Migration feature PCD PcdMigrateTemporaryRamFirmwareVolumes is se= t to TRUE. // - CopyMem (MigratedFvHeader, FvHeader, (UINTN)FvHeader->FvLength); - CopyMem (RawDataFvHeader, MigratedFvHeader, (UINTN)FvHeader->FvLengt= h); MigratedFvInfo.FvOrgBase =3D (UINT32)(UINTN)FvHeader; MigratedFvInfo.FvNewBase =3D (UINT32)(UINTN)MigratedFvHeader; - MigratedFvInfo.FvDataBase =3D (UINT32)(UINTN)RawDataFvHeader; + MigratedFvInfo.FvDataBase =3D 0; MigratedFvInfo.FvLength =3D (UINT32)(UINTN)FvHeader->FvLength; + + // + // When FLAGS_FV_RAW_DATA_COPY bit is set, copy the context to the r= aw pages and + // reset raw data base address in MigratedFvInfo hob. + // + if ((FvMigrationFlags & FLAGS_FV_RAW_DATA_COPY) =3D=3D FLAGS_FV_RAW_= DATA_COPY) { + // + // Allocate pages to save the raw PEIMs + // + Status =3D PeiServicesAllocatePages ( + EfiBootServicesCode, + EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength), + &FvHeaderAddress + ); + ASSERT_EFI_ERROR (Status); + RawDataFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHeaderA= ddress; + CopyMem (RawDataFvHeader, MigratedFvHeader, (UINTN)FvHeader->FvLen= gth); + MigratedFvInfo.FvDataBase =3D (UINT32)(UINTN)RawDataFvHeader; + } + BuildGuidDataHob (&gEdkiiMigratedFvInfoGuid, &MigratedFvInfo, sizeof= (MigratedFvInfo)); =20 // @@ -1330,8 +1372,6 @@ EvacuateTempRam ( } } =20 - RemoveFvHobsInTemporaryMemory (Private); - return Status; } =20 diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/C= ore/Pei/Memory/MemoryServices.c index 3b2e15699fc3..a30925da39ee 100644 --- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c +++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c @@ -166,46 +166,6 @@ MigrateMemoryPages ( Private->FreePhysicalMemoryTop =3D NewMemPagesBase; } =20 -/** - Removes any FV HOBs whose base address is not in PEI installed memory. - - @param[in] Private Pointer to PeiCore's private data structure. - -**/ -VOID -RemoveFvHobsInTemporaryMemory ( - IN PEI_CORE_INSTANCE *Private - ) -{ - EFI_PEI_HOB_POINTERS Hob; - EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob; - - DEBUG ((DEBUG_INFO, "Removing FVs in FV HOB not already migrated to perm= anent memory.\n")); - - for (Hob.Raw =3D GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw =3D GET_= NEXT_HOB (Hob)) { - if ((GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_FV) || (GET_HOB_TYPE (Hob)= =3D=3D EFI_HOB_TYPE_FV2) || (GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_FV3)) { - FirmwareVolumeHob =3D Hob.FirmwareVolume; - DEBUG ((DEBUG_INFO, " Found FV HOB.\n")); - DEBUG (( - DEBUG_INFO, - " BA=3D%016lx L=3D%016lx\n", - FirmwareVolumeHob->BaseAddress, - FirmwareVolumeHob->Length - )); - if ( - !( - ((EFI_PHYSICAL_ADDRESS)(UINTN)FirmwareVolumeHob->BaseAddress >= =3D Private->PhysicalMemoryBegin) && - (((EFI_PHYSICAL_ADDRESS)(UINTN)FirmwareVolumeHob->BaseAddress = + (FirmwareVolumeHob->Length - 1)) < Private->FreePhysicalMemoryTop) - ) - ) - { - DEBUG ((DEBUG_INFO, " Removing FV HOB to an FV in T-RAM (was = not migrated).\n")); - Hob.Header->HobType =3D EFI_HOB_TYPE_UNUSED; - } - } - } -} - /** Migrate the base address in firmware volume allocation HOBs from temporary memory to PEI installed memory. diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMai= n.h index 556beddad533..46b6c23014a3 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.h +++ b/MdeModulePkg/Core/Pei/PeiMain.h @@ -1046,17 +1046,6 @@ MigrateMemoryPages ( IN BOOLEAN TemporaryRamMigrated ); =20 -/** - Removes any FV HOBs whose base address is not in PEI installed memory. - - @param[in] Private Pointer to PeiCore's private data structure. - -**/ -VOID -RemoveFvHobsInTemporaryMemory ( - IN PEI_CORE_INSTANCE *Private - ); - /** Migrate the base address in firmware volume allocation HOBs from temporary memory to PEI installed memory. diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiM= ain.inf index 0cf357371a16..893bdc052798 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 =20 [Ppis] gEfiPeiStatusCodePpiGuid ## SOMETIMES_CONSUMES # Pe= iReportStatusService is not ready if this PPI doesn't exist diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h b/MdeModulePkg/Incl= ude/Guid/MigratedFvInfo.h index aca2332a0ec6..1c8b0dfefc49 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__ =20 +// +// FLAGS_FV_RAW_DATA_COPY indicates FV raw data will be copied to permanen= t 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 sk= ipped 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 indi= cate which +/// FVs need migration to optimize boot performance. If this hob is not de= tected 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 co= py 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 no= t copied UINT32 FvLength; // Fv Length } EDKII_MIGRATED_FV_INFO; =20 +extern EFI_GUID gEdkiiMigrationInfoGuid; extern EFI_GUID gEdkiiMigratedFvInfoGuid; =20 #endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__ diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 1a162e97e6fb..a2cd83345f5b 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -421,7 +421,8 @@ gEdkiiCapsuleOnDiskNameGuid =3D { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93, 0x= 9a, 0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } } =20 ## Include/Guid/MigratedFvInfo.h - gEdkiiMigratedFvInfoGuid =3D { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4,= 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } } + gEdkiiMigrationInfoGuid =3D { 0xb4b140a5, 0x72f6, 0x4c21, { 0x93, 0xe4= , 0xac, 0xc4, 0xec, 0xcb, 0x23, 0x23 } } + gEdkiiMigratedFvInfoGuid =3D { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4= , 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } } =20 ## Include/Guid/RngAlgorithm.h gEdkiiRngAlgorithmUnSafe =3D { 0x869f728c, 0x409d, 0x4ab4, {0xac, 0x03, = 0x71, 0xd3, 0x09, 0xc1, 0xb3, 0xf4 }} --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112531): https://edk2.groups.io/g/devel/message/112531 Mute This Topic: https://groups.io/mt/103169823/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Wed May 15 15:10:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+112532+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112532+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1702562013; cv=none; d=zohomail.com; s=zohoarc; b=Cl9fgd4IdrgJlYUPm7XeuQdsQ5hPwbevNMIy2gKlrc6iVQDMHZeO88PtPakg1rtksERmYbfDOLGn+bwCnHk++rVrws78ndAPPyBW0z0liydeKfKgdfenUzomnELmz2vk0Ae5EJ/8DAHR+oMdYrHB7rg6b6hoahtVJZzwo5kKAr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702562013; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=SSar0EHY9jqVyKSjLx0pU73KGJ2MpIKuK2JDvL51mOc=; b=CtgMne2rc6G//BNN0c15Nk2HF0KyjiCkNiEN7TFjaAYu5vHRNCu4oh4uiRbEZmQGov2kCYLCk1buBOKrRgU6VT+T4YALo0p4zwMfoJG7RYpUna5KsQeZzIf5NqnJLnwsBdJBLufN943Knwuqyf9xoqi9ESutpVIEjW/pyesyX1Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112532+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1702562013430725.2025759954125; Thu, 14 Dec 2023 05:53:33 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=ZaWYNl4ETdfQWWUbXZ9ZGn28MqUC88avaBjW1wBaAy4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1702562013; v=1; b=KvB8nh658aqApgNDA6tae6fDhoX5baLtwymfupa6K7E1F0pTIJtjy28Ggd6JhUWCv3ZZIK7h 7Xv7HaRoWWtKaWWQdlXjQLhNDj0MXR7QBuWlLqwugz8cLK2zrdQxKvg/VB3/pZJ+/ziZAaEvuwc jMpPKJ4jDqJHPFT/+l3LlF3E= X-Received: by 127.0.0.2 with SMTP id hDdxYY1788612x4EwFV62jdG; Thu, 14 Dec 2023 05:53:33 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mx.groups.io with SMTP id smtpd.web10.22605.1702562004503781636 for ; Thu, 14 Dec 2023 05:53:32 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="1957352" X-IronPort-AV: E=Sophos;i="6.04,275,1695711600"; d="scan'208";a="1957352" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 05:53:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="947581780" X-IronPort-AV: E=Sophos;i="6.04,275,1695711600"; d="scan'208";a="947581780" X-Received: from sh1gapp1015.ccr.corp.intel.com ([10.239.189.85]) by orsmga005.jf.intel.com with ESMTP; 14 Dec 2023 05:53:30 -0800 From: "Wang Fan" To: devel@edk2.groups.io Cc: Fan Wang , Liming Gao , Rahul Kumar , Jian J Wang Subject: [edk2-devel] [PATCH v5 2/2] SecurityPkg: Support customized FV Migration Information Date: Thu, 14 Dec 2023 21:53:19 +0800 Message-Id: <20231214135319.3986-3-fan.wang@intel.com> In-Reply-To: <20231214135319.3986-1-fan.wang@intel.com> References: <20231214135319.3986-1-fan.wang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,fan.wang@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 4TRP1L0B2bOGJEi3kAgmEQZux1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1702562014368100001 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4533 In Tcg driver, when MigratedFvInfo hob is detected, existing code logic is assuming FV raw data is already copied, and raw data base address is also recorded. Due to the new PeiCore change, the platform can publish hob to indicate raw data need be copied or not along with FV migration. Two cases need be considered to skip copy for boot performance: The first case is FV is not expected to be measured in post-mem phase, we should use MeasurementExcludedPpiGuid to skip measurement. The second case is FV raw data has no need to do rebase operation after migration, then measurement should calculate hash directly from FV base address. Cc: Liming Gao Cc: Rahul Kumar Cc: Jian J Wang Signed-off-by: Fan Wang --- SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 7 +++++-- SecurityPkg/Tcg/TcgPei/TcgPei.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c b/SecurityPkg/Tcg/Tcg2Pei/Tc= g2Pei.c index 1caaa4e319bc..daaf49e644b2 100644 --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c @@ -726,8 +726,11 @@ MeasureFvImage ( // // Found the migrated FV info // - FvOrgBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBas= e; - FvDataBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBa= se; + FvOrgBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase; + if (MigratedFvInfo->FvDataBase !=3D 0) { + FvDataBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvData= Base; + } + break; } =20 diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPe= i.c index 5aa80511aa81..d35c2ad0bc55 100644 --- a/SecurityPkg/Tcg/TcgPei/TcgPei.c +++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c @@ -463,8 +463,11 @@ MeasureFvImage ( // // Found the migrated FV info // - FvOrgBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBas= e; - FvDataBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBa= se; + FvOrgBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase; + if (MigratedFvInfo->FvDataBase !=3D 0) { + FvDataBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvData= Base; + } + break; } =20 --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112532): https://edk2.groups.io/g/devel/message/112532 Mute This Topic: https://groups.io/mt/103169824/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-