From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D2FC4AC0EB4 for ; Mon, 11 Dec 2023 09:37:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=QzWEqVT4Z0rcLqBVIkSiFy+gzQWbjGQEjrky2Zbc/uE=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1702287434; v=1; b=r1WAwa1hL4zRqJkdbgITK9Le8GLm5eR5+3unAMnivGiCGQL53sgCf9WTBmP++AWIY9Y4M5VY YxheMAD3++zows+skW1QGU70bXYCTNf1ueYiSgOQLU5oI6TbwtmQhPfH1edrVjtSPcuR2OrzMmW A8Ahxh828eAFcE68YTy9xaoQ= X-Received: by 127.0.0.2 with SMTP id 4XWCYY7687511xliOX22UBg0; Mon, 11 Dec 2023 01:37:14 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by mx.groups.io with SMTP id smtpd.web10.4736.1702287434055724707 for ; Mon, 11 Dec 2023 01:37:14 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10920"; a="1431716" X-IronPort-AV: E=Sophos;i="6.04,267,1695711600"; d="scan'208";a="1431716" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 01:37:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10920"; a="749217784" X-IronPort-AV: E=Sophos;i="6.04,267,1695711600"; d="scan'208";a="749217784" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga006.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 11 Dec 2023 01:37:12 -0800 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 11 Dec 2023 01:37:11 -0800 X-Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 11 Dec 2023 01:37:11 -0800 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.100) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 11 Dec 2023 01:37:10 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j4Ned2G2MXCC0FBdnoYOvsgRgkYrBerb9PY8diRAovjgllRtMQ/esvJqJxElAWsFh5lQL/6vm9fNoh/a91TzLDXIkgD5rEt3UsaEC+XRV2WyVWoRNgTVW6zbHQhCCHyMez/1LU1CTVmCAqxkO7LtJZYCs2/nhw1x2TY0IY6p//50W5tIWmNT5EijFG4WwhUUbd9Wuu/FHwDeZ7CXcC3rIlHUZq67Ki4Ncg8xW6vdu53Wnj2BvPyo5zPkjVxyhGeaQGH1VQKjCQVmB2AgNcZc4uzErSHmEEX/f/O+W1wVHk53Q2Ok/+0fohEJACquqBP3cpXFJYWnCvtpDj+ik6XOoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eucF/+BUvoNLHvt0a4Q3LMmpTy7mmMaZe6+LSU2uAcs=; b=gPbB14Z7wgUOlDrrftDCVd1qFfySpnYgVeCJiRsd34SmVqKdZ6n5NI9NW0N/qcUfsmRZs2ChA+/O8FlZfKGix5s1Y2T6www4Tlu6smJHdCf93M9BSQWbBb3OaDpvuHBdVlAd+ZRr0cEHFBSm3mnnyrexqtEaPXCX/JEmLkIY+wCnCKs4MbxclMldyTaC6B/GKP0mP2brRiDLHxV+46Fh+huDvHrydtlabMgVnOcj8Crwa3Km0W45EzU/bNNFL0wciXunxJm4KAeJ9bG2EuKgjK7HEQfSBPvHaGgClhiDC4pHliAA00iKF+YrC9q1DkuFsALGJMGBlhEamPQNcAajZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from DM8PR11MB5752.namprd11.prod.outlook.com (2603:10b6:8:13::15) by MW3PR11MB4570.namprd11.prod.outlook.com (2603:10b6:303:5f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 09:37:06 +0000 X-Received: from DM8PR11MB5752.namprd11.prod.outlook.com ([fe80::1f3:4ad1:ee6c:ef22]) by DM8PR11MB5752.namprd11.prod.outlook.com ([fe80::1f3:4ad1:ee6c:ef22%5]) with mapi id 15.20.7068.031; Mon, 11 Dec 2023 09:37:05 +0000 From: "Wang Fan" To: "devel@edk2.groups.io" , "Kinney, Michael D" , "Gao, Liming" , "Ni, Ray" , "Wang, Jian J" CC: "Jiang, Guomin" , "Wang, Fan" Subject: Re: [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information Thread-Topic: [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information Thread-Index: AQHaLBFniVdoKzJA/kmHWL2+cAfMp7Cj0mhA Date: Mon, 11 Dec 2023 09:37:05 +0000 Message-ID: References: <179FBBB695BFE040.24323@groups.io> In-Reply-To: <179FBBB695BFE040.24323@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM8PR11MB5752:EE_|MW3PR11MB4570:EE_ x-ms-office365-filtering-correlation-id: bfb7048d-9ebc-4c41-48d0-08dbfa2cbce7 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 66aklyZ+MKU8aN9yH6eGzJWyRmsy9s0etFT7JIIU/Xbjzg30cnm2a7b/uDKRHRJqOeoEbJy3gwMYJc0afdVPqdtD4KGcfCsCpVVmPgQRnYTGTvtj+EH5Mll69Jb8BIM+WRiCl4R8PqeMbeJQzu9Je3tjCcaJwngayrwEsiXCErXU7vcX9rzWAjd+G3q1sc34O4hJcamMbsbKuw2XgXjXj7bnLslCjYn9F50uvb1SkD86SXd7oc0OxfXEy97Eoco7NMnHouKHdzggjDFSKZ5qqhWWkm0+ta7c27kKzEbja/nS/UkJseWmIDsOTHBZHUMRUQ9NM2lMMvk/AagGi+ym3UetDwDRMgTLclOljRdv1Jz5+i6RTM+eHsaI0iRpiwPzWKCM/ekatsf4ZmUnBqhqMKjI/vCnwFz1czLU38mcrShN1aKlQBO0Q92N7xrzdB82D3thTb7za70DxiDY36RgmbW4DPEXMOpvA4CfcVuC/nJVFA7JKGq9BCSK9GLlQVr3aEQIcz5U0ZpLat9ZWjyIwVVI3fSUHXNH1F74nC/hOX9VSMUrSQCh77j2FQU0cQRDMR9FwNEJmRk3ZrlVwIJFPdB4kzkU/pfI/SYc4zj8RK87wJ9gyUz96p7tUt4QxRxWVtNhCJpZFO2RYZ+NUGIsHg== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?KyVOMHamIHzB+K7JHdKl7PgcUtni5bU5AAsPFsLvgesX7+anLRzCmHIYnn8s?= =?us-ascii?Q?OL4pacgzWaq/bREhkmIkU0GXxJBSvBjOsHiqYwytXo/COeRPV3ip8szbrPTb?= =?us-ascii?Q?HyjdvU9fWykLGt7jqkNlqkqQsT8v/WkKipVqfpzOXSqGvnk1kudhgTUStCax?= =?us-ascii?Q?J8+zHGdbc9zj8fSijZd51vyeT3ZPIYpmY5Vn/NRL5IR23NxY9a4wH5Cqypt1?= =?us-ascii?Q?pRzMzW6ON1J+W9Nd5qlJVmcwG6u5aygGes/uPj8koCKm46ZTPVTl6wyJDesv?= =?us-ascii?Q?j1vbl4Q/5VMFdVhdYsakUSCSSWuoFdXHAkq0m+bVl5SS7q+U9Wz5kUnztQGa?= =?us-ascii?Q?Tn6H4b1FYwZGoy9Mkdbbx01o1VZPsoL+jMpTLgbbksZCZbnFXGw2hNtVO2QS?= =?us-ascii?Q?tkJ6qaIALhYckG8bDkvWQY5Ajr/fpBrUg0B4ZQaazqicFsOc9yr912e1pkLN?= =?us-ascii?Q?0v7lpRdzXqtCJqxzjQevkGqSUZTPNLoZAKdi8KF4gsIaVKHPNfJ8iH+EVBfJ?= =?us-ascii?Q?Tx2n6OFxAKUdj0blHeYB6blBoF97P6tF1ISMe1afqGYB+XFkOxlhEHCR4wZp?= =?us-ascii?Q?BAS0/5dg/oxah6Ej7i3029bdMkvvS7hokB5adsA1StywiKgXWpBXdaVw2YRc?= =?us-ascii?Q?BA3pMkGXvV28+clHXfssV2ale6l6pLMQVwNJmt1yl8d2HZWHytoUrWjWeTfo?= =?us-ascii?Q?onHB/8o6IZftNdjPhU17tb+cGlLqV9udIekQaR+hMlg/Su5k4RaQzMMZJCub?= =?us-ascii?Q?QzjU+E6pqDSWVgkGH+60vUgPESo6MewbEYW5NCUFRvw975IzA6/yPqzx38yQ?= =?us-ascii?Q?C4VEdPmv+TuQrgxSgR7+jzyKUzVZeOoPc5WqtrJ4135PcfQhdBvxVQdvBoj3?= =?us-ascii?Q?r/gPwYjblN33mzaXURqq09R4H3raYXOBTpPF+ldCis/ac3enLFeWVEUtfOu3?= =?us-ascii?Q?EuRRvynoMs8S2dEYjUtQuJyMjZwiQanCAp/A5zOfnI3Hc87GjEYJ6SIxmnse?= =?us-ascii?Q?BEuJcWIUQZeli9EqbFBgs38YEUFLO4/9kCqN9sEzgUxT6vZW0ObOSrJlt1B7?= =?us-ascii?Q?7rsuu32qDTMfHm/AjdubnbBzebMKLf3m6G4/Z0ozzPbYH+AZf2Fqsm/8VgM4?= =?us-ascii?Q?mqYgVIBFWskNXHiQSF1GofUhr+FnLwCkqCFvhAfUtbiNBlk5oV5wggR3y+5D?= =?us-ascii?Q?p1Qo7eUiiMfeO+grOlZLDwdPOJPCp/OY9+ZGeORTRalRelzNhnVURQ0eycMU?= =?us-ascii?Q?eyC0zO9wt8/AuZ0hDACpEOX7tFwCx13EwJadnpsAyeUpJgq2fbkPAtpohj4V?= =?us-ascii?Q?mhSlda33dgZ6ZvlEkTsTcwho+T7PUJHp2UF2dAsN3Sg8Z6COFPB7mehNEphT?= =?us-ascii?Q?QMhIfxLFacT5qG1v0aI+FfB7qBZnmYQDFRqfTiupaEBZZ7gC87PmzLsk54VX?= =?us-ascii?Q?9R7p2HBTgpTpG4W3tzskOeKUWvoyjRV2MD4YmVo8Q8y82qOsUgH7RguhcYBB?= =?us-ascii?Q?kJTh5xrL6JiL7rXJYQ33rrNGNJbVb7fuk1tnEUWa4XGexroMJ8AaJMibckyx?= =?us-ascii?Q?W+Dby+w8Ny1fj32rcvo=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8PR11MB5752.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfb7048d-9ebc-4c41-48d0-08dbfa2cbce7 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Dec 2023 09:37:05.7311 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: G2kDK8Kw+myqSyd8aiKWgKpahaC1D+tF3xX/3+dxQEdBN35vTtHsaR2nPaLb5Ww2LHoSpiwFdxq1lAOeO1jdjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4570 X-OriginatorOrg: intel.com 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: DEEbJXOVsAWMPCyTCH16tnUJx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=r1WAwa1h; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Hi Ray, Liming, Mike and Jian I have updated the patch v4: https://edk2.groups.io/g/devel/message/112276 Pull Request: https://github.com/tianocore/edk2/pull/5124 v2: - Update commit message for better describe this feature v3: - Add more descriptions for "gEdkiiToMigrateFvInfoGuid" PPI usages and back= ground, but still keep the name. - Update "FvOrgBase" to "FvTemporaryRamBase" in EDKII_TO_MIGRATE_FV_INFO. - Remove flag "FLAGS_SKIP_FV_MIGRATION", since it's not needed. - Add more descriptions to flag "FLAGS_SKIP_FV_RAW_DATA_COPY". - Remove the variable MigrateAllFvs to simplify logic. - Correct "allocate pool" to "allocate pages" to align with descriptions. v4: - Re-design EDKII_MIGRATION_INFO to include all FV migration info in one Ho= b - Update "FvTemporaryRamBase" to "FvOrgBaseOnTempRam" to avoid misunderstan= ding - Update flag name "FLAGS_SKIP_FV_RAW_DATA_COPY" to "FLAGS_FV_RAW_DATA_COPY= " - Refine the logic to NOT impact building MigratedFvInfo hob with raw data = copy flag Best Regards Fan -----Original Message----- From: devel@edk2.groups.io On Behalf Of Wang Fan Sent: Monday, December 11, 2023 5:06 PM To: devel@edk2.groups.io Cc: Wang, Fan ; Kinney, Michael D ; Gao, Liming ; Ni, Ray = ; Jiang, Guomin ; Wang, Jian J Subject: [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Mi= gration Information REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4533 There are use cases which not all FVs need be migrated from TempRam to perm= anent memory before TempRam tears down. This new guid is introduced to avoi= d unnecessary FV migration to improve boot performance. Platform can publis= h MigrationInfo hob with this guid to customize FV migration info, and PeiC= ore 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 mem= ory. Cc: Michael D Kinney Cc: Liming Gao Cc: Ray Ni Cc: Guomin Jiang Cc: Jian J Wang Signed-off-by: Fan Wang --- 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/C= ore/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_LOCATI= ON_PPI *PeiCoreFvLocationPpi;+ EFI_PEI_HOB_POINTERS Hob;+ EDKII= _MIGRATION_INFO *MigrationInfo;+ TO_MIGRATE_FV_INFO *T= oMigrateFvInfo;+ UINT32 FvMigrationFlags; EDKII_M= IGRATED_FV_INFO MigratedFvInfo;+ UINTN Inde= x; ASSERT (Private->PeiMemoryInstalled); @@ -1211,6 +1216,13 @@ Evacuate= TempRam ( ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle); + Hob.Raw =3D G= etFirstGuidHob (&gEdkiiMigrationInfoGuid);+ if (Hob.Raw !=3D NULL) {+ M= igrationInfo =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 NU= LL);@@ -1224,20 +1236,27 @@ EvacuateTempRam ( ) ) {- //- // Allocate page to save the re= based PEIMs, the PEIMs will get dispatched later.- //- Status =3D= PeiServicesAllocatePages (- EfiBootServicesCode,- = EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength),- = &FvHeaderAddress- );- ASSERT_EFI_ERROR (Status);- = MigratedFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvHeaderAddres= s;+ if ((MigrationInfo =3D=3D NULL) || (MigrationInfo->MigrateAll =3D= =3D TRUE)) {+ // Migrate all FVs and copy raw data+ FvMigrati= onFlags =3D FLAGS_FV_RAW_DATA_COPY;+ } else {+ for (Index =3D 0= ; Index < MigrationInfo->ToMigrateFvCount; Index++) {+ ToMigrateFv= Info =3D ((TO_MIGRATE_FV_INFO *)(MigrationInfo + 1)) + Index;+ if = (ToMigrateFvInfo->FvOrgBaseOnTempRam =3D=3D (UINT32)(UINTN)FvHeader) {+ = // This FV is to migrate+ FvMigrationFlags =3D ToMigrate= FvInfo->FvMigrationFlags;+ break;+ }+ }++ = if (Index =3D=3D MigrationInfo->ToMigrateFvCount) {+ // This FV i= s not expected to migrate+ continue;+ }+ } //- = // Allocate pool to save the raw PEIMs, which is used to keep consiste= nt context across- // multiple boot and PCR0 will keep the same no mat= ter if the address of allocated page is changed.+ // Allocate pages to= save the rebased PEIMs, the PEIMs will get dispatched later. // = Status =3D PeiServicesAllocatePages ( EfiBootServicesC= ode,@@ -1245,7 +1264,8 @@ EvacuateTempRam ( &FvHeaderAddress ); ASSERT_EFI_E= RROR (Status);- RawDataFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *)(UIN= TN)FvHeaderAddress;+ MigratedFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER = *)(UINTN)FvHeaderAddress;+ CopyMem (MigratedFvHeader, FvHeader, (UINTN= )FvHeader->FvLength); DEBUG (( DEBUG_VERBOSE,@@ -1256,17 +12= 76,34 @@ EvacuateTempRam ( )); //- // Copy the context to the rebased pages and r= aw pages, and create hob to save the- // information. The MigratedFvIn= fo HOB will never be produced when- // PcdMigrateTemporaryRamFirmwareV= olumes is FALSE, because the PCD control the- // feature.+ // Cre= ate hob to save MigratedFvInfo, this hob will only be produced when+ /= / Migration feature PCD PcdMigrateTemporaryRamFirmwareVolumes is set to TRU= E. //- CopyMem (MigratedFvHeader, FvHeader, (UINTN)FvHeader->FvL= ength);- CopyMem (RawDataFvHeader, MigratedFvHeader, (UINTN)FvHeader->= FvLength); MigratedFvInfo.FvOrgBase =3D (UINT32)(UINTN)FvHeader; = MigratedFvInfo.FvNewBase =3D (UINT32)(UINTN)MigratedFvHeader;- Mig= ratedFvInfo.FvDataBase =3D (UINT32)(UINTN)RawDataFvHeader;+ MigratedFv= Info.FvDataBase =3D 0; MigratedFvInfo.FvLength =3D (UINT32)(UINTN)F= vHeader->FvLength;++ //+ // When FLAGS_FV_RAW_DATA_COPY bit is se= t, copy the context to the raw pages and+ // reset raw data base addre= ss in MigratedFvInfo hob.+ //+ if ((FvMigrationFlags & FLAGS_FV_R= AW_DATA_COPY) =3D=3D FLAGS_FV_RAW_DATA_COPY) {+ DEBUG ((DEBUG_INFO, = " Copying Raw Data ...\n"));+ //+ // 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)FvHeaderAddress;+ CopyMem (= RawDataFvHeader, MigratedFvHeader, (UINTN)FvHeader->FvLength);+ Migr= atedFvInfo.FvDataBase =3D (UINT32)(UINTN)RawDataFvHeader;+ }+ Bu= ildGuidDataHob (&gEdkiiMigratedFvInfoGuid, &MigratedFvInfo, sizeof (Migrate= dFvInfo)); //@@ -1330,8 +1367,6 @@ EvacuateTempRam ( } } - RemoveFvHobsInTemporaryMemory (Private);- return Status; } = diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiM= ain.inf index 0cf357371a..893bdc0527 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.inf +++ b/MdeModulePkg/Core/Pei/PeiMain.inf @@ -78,6 +78,7 @@ gEfiFirmwareFileSystem3Guid gStatusCodeCallbackGuid gEdkiiMigratedFv= InfoGuid ## SOMETIMES_PRODUCES ## HOB+ gEdkiiMigr= ationInfoGuid ## SOMETIMES_CONSUMES ## HOB [Ppis= ] gEfiPeiStatusCodePpiGuid ## SOMETIMES_CONSUMES # P= eiReportStatusService is not ready if this PPI doesn't existdiff --git a/Md= eModulePkg/Include/Guid/MigratedFvInfo.h b/MdeModulePkg/Include/Guid/Migrat= edFvInfo.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 copie= d to permanent memory+// or not. When FV is migrated to permanent memory, i= t 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 m= easurement).+//+#define FLAGS_FV_RAW_DATA_COPY BIT0++///+/// In real use c= ases, 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 ra= w data will also be copied.+/// Only one EDKII_MIGRATION_INFO hob should be= published by platform, and this hob will+/// take effect only when migrati= on feature is enabled by PCD.+///+typedef struct {+ UINT32 FvOrgBaseOnT= empRam; // Original FV address on Temporary Ram+ //+ // FV Migrati= on Flags:+ // Bit0: Indicate to copy FV raw data or not+ // Others: Reser= ved 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;+ type= def struct { UINT32 FvOrgBase; // original FV address UINT32= FvNewBase; // new FV address- UINT32 FvDataBase; // = original FV data+ UINT32 FvDataBase; // original FV data, 0 mean= s raw data is not copied UINT32 FvLength; // Fv Length } EDKI= I_MIGRATED_FV_INFO; +extern EFI_GUID gEdkiiMigrationInfoGuid; extern EFI_G= UID gEdkiiMigratedFvInfoGuid; #endif // #ifndef __EDKII_MIGRATED_FV_INFO_= GUID_H__diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModule= Pkg.dec index 1a162e97e6..a2cd83345f 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 } } ## Include/Guid/MigratedFvInfo= .h- gEdkiiMigratedFvInfoGuid =3D { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf= 4, 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } }+ gEdkiiMigrationInfoGuid =3D {= 0xb4b140a5, 0x72f6, 0x4c21, { 0x93, 0xe4, 0xac, 0xc4, 0xec, 0xcb, 0x23, 0x= 23 } }+ gEdkiiMigratedFvInfoGuid =3D { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2= , 0xf4, 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } } ## Include/Guid/RngAlgori= thm.h gEdkiiRngAlgorithmUnSafe =3D { 0x869f728c, 0x409d, 0x4ab4, {0xac, 0= x03, 0x71, 0xd3, 0x09, 0xc1, 0xb3, 0xf4 }}diff --git a/SecurityPkg/Tcg/Tcg2= Pei/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 =3D= (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;- FvDataBase = =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;+ FvOrgBas= e =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;+ if (Mig= ratedFvInfo->FvDataBase !=3D 0) {+ FvDataBase =3D (EFI_PHYSICAL_ADDR= ESS)(UINTN)MigratedFvInfo->FvDataBase;+ }+ break; } diff --g= it 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 =3D= (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;- FvDataBase = =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase;+ FvOrgBas= e =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase;+ if (Mig= ratedFvInfo->FvDataBase !=3D 0) {+ FvDataBase =3D (EFI_PHYSICAL_ADDR= ESS)(UINTN)MigratedFvInfo->FvDataBase;+ }+ break; } --=20 2.26.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D 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/1782799 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [fan.wang@intel.com] -=3D= -=3D-=3D-=3D-=3D-=3D -=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 (#112280): https://edk2.groups.io/g/devel/message/112280 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-