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 D078FAC0D90 for ; Wed, 13 Dec 2023 08:53:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=qDRbno0+oJJAUecbhhDtga5LkyJjmgmCh5jt1RgC6hc=; 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=1702457627; v=1; b=nQsT6UqSoHmvhZtX/x7dLQ3Lh4iV7xcO3/8Y14XQyRAuNob9Lg8zw61C7r+yKjYGRRs01PQU EU3k2tFhTN1/wUKsv7l849MggqQwBz7LyEcbVhJctmmpBn42QppeUDUPeLDTa4ggROcl9/qvZv9 Smm2AYZanfxREc1V0nU5vpK4= X-Received: by 127.0.0.2 with SMTP id DCgAYY7687511xxCiDwLRnXR; Wed, 13 Dec 2023 00:53:47 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.31752.1702457626522145122 for ; Wed, 13 Dec 2023 00:53:46 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="374439285" X-IronPort-AV: E=Sophos;i="6.04,272,1695711600"; d="scan'208";a="374439285" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2023 00:53:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="777416602" X-IronPort-AV: E=Sophos;i="6.04,272,1695711600"; d="scan'208";a="777416602" X-Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga007.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 13 Dec 2023 00:53:45 -0800 X-Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 13 Dec 2023 00:53:45 -0800 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 13 Dec 2023 00:53:45 -0800 X-Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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; Wed, 13 Dec 2023 00:53:45 -0800 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 13 Dec 2023 00:53:45 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iq+JF0svp2WkNxITnij+EeVYjHGLU8kNc88RVu2fFiTLxDGV9x05aPe4oFlmXctQ57BB78NdozyUVCd11hE7fx8KQII+ZYL50CX/yN0OWxHnRk68g+cASIf3Ht2kDXU55vBz7VtK6yi/XR+hmvx2rYbWdMLKb10VOrIZ37lykrL1UNHd6JjZE387saj8lhik0cu7DwJaRvakZ3YvBRlQHLiva4EzrN7mg6sYES+eprKUF3oSFXLiBkngBB/9Rvop7I4pl3L2QwaUiVqPYdLmKs7XwuuXGU5m6UR9HGkKPF420UHhEydZg+S4rvZdxbgY/69rRiHUa/3CUdh4ER3/nw== 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=ICdbwYyTIaCgz/QzhioYbanw4GMHAGlMPdcnjgHKUEo=; b=AOE80uL/EyvSOiLw02Qtu0scRBV2Sg4u3g1uuB1mJjsO80jn6r4tZig+AVvyxCUrCBB7+nYJCADYhAD2bR7uILJ4NYwK2cbSYJbLNzEB0yqVNyzoux+/jmki/vqnfMG3pLygC4c1KX8KsFecq/QTsQXTojxoUqituGhVDEgabnCq2huk545zrAIfbZG4v2U5F4gLX3Hc+LyUuZNyKXA5LUDViMqjBHDlhpMeASvL5vnOgQA4toHG6tfQH7oZUFXHpZeKOJX4NahGQo1uBlJe9vXLS1SiOQup4zltlP0gDVs0ovzCCVfYPxpoq3ZUMRtn3Jnt6I3gUoNrjpk3JoAbsQ== 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 SN7PR11MB7043.namprd11.prod.outlook.com (2603:10b6:806:29a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26; Wed, 13 Dec 2023 08:53:42 +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.7091.022; Wed, 13 Dec 2023 08:53:42 +0000 From: "Wang Fan" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Kinney, Michael D" , "Gao, Liming" , "Jiang, Guomin" , "Wang, Jian J" Subject: Re: [edk2-devel] [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information Thread-Topic: [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration Information Thread-Index: AQHaLBFUH0X4gibwLEiZTkV2RXvHcbCmj28AgABVhrA= Date: Wed, 13 Dec 2023 08:53:42 +0000 Message-ID: References: <20231211090611.3780-1-fan.wang@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM8PR11MB5752:EE_|SN7PR11MB7043:EE_ x-ms-office365-filtering-correlation-id: 6546151f-f1b5-40e3-8e5d-08dbfbb901d0 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: EDz68gLfk80qnFjTX4CVHFi88T+SGzCp55m521bRq90MBsNOnqX5mWeNymA++BTMWF9rAeyCqqoJbK+T0CrEQhUwpbcryq2VPsvKdOKFbzEnHDutEOXhO+ITFlwnMnjI2iTJsawm4FhMYshlS6zFW3wZ3MLi6N4j59jP/X8DIUNiZGDKmhFbjn9GTAyCrwZUURZ7Da4X1NoQaGHiqmIUnt5h2RzhOUi7J81NKx6NBYsieXC3MMIXoRTXAoYnW16gE47ILp9YHI5zJiPM3WbGbq8CowxMJI0UbSO6b8ffcvukikb1VfPZTXuv8Qsr/AXC0/eOx71wvkOFq1wPer+ixbJFuf4OUR4WhaYMWQbFoMUChambC0ODxJn9VirPr4ghb4ss/X1acdexkFYM4RmmFIGIq+0x9o5Ly76MNhm4N7jX937Rn2eye6Bl8geOgo/gxD2IOl3V3nKR3h0zn4x1iJcYDLVURr3vn5ak9vAOKicg45HiDmH+DY/hiYU44gVmsBiDkzRrZaNkX6CCs/AHbKQcS5OH2W1PWZQRCmH9kSI1k0jGUJRKSV5aWh2xelWu6xFexiJ4JoUkuv3noH9xmvR8Uc1f57IFbGmxBDVM7eM= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?UGj0xod8nULdS6ItpZ2pZrcvAf3KImcDNLcXDH9EjCqdyAuTi2i7x783WmvK?= =?us-ascii?Q?fGGqHvc23avRw1rUYSn2GBfML6ZT3L1k+MT6CnlOwb10ham6/52e4SeMkT+5?= =?us-ascii?Q?/aiJll4gkqO4cajTayCqzzcKkNjs448VP+fo7IHUnNv8n4Qiv7ldBZp7pG6l?= =?us-ascii?Q?gqYAcYvmZFP+jiQG/R2qH/sI/GCZRPsUuTWzn73cF55nmatGNkCBR9aPMWym?= =?us-ascii?Q?PPonE23bsRcZvNUQgba+7SSl8GK/S8FISu2bUmYgcEaai0CPeplHA2OeV+Sx?= =?us-ascii?Q?I00LqyxVdRvP23wwZMFo2ddNX3QOb+d54mcEg/LaXss8vmHg+lFdgFM7oql+?= =?us-ascii?Q?x6mxY9Zv1xXPCsl7AcjC/x0T1Yi+do3kPOYiJuxIVUrBhCxFomjnzmcqOFG1?= =?us-ascii?Q?Cd8HttQAhTbh/pCJ4V5unwtRdeqCEonW+g5ihS/BPtR+c8gyrqEBLKjxn8Uk?= =?us-ascii?Q?mrBTsphTuSHHblTLv4allx1MyqezelBegTmi4FnkmPX4IIwnHn7QuYIsExz0?= =?us-ascii?Q?0u6ApN32jLxop2xr1VpEDJOh3Gwz9rR097ST8s24/PB0oMNrvb4oA8hcGeKo?= =?us-ascii?Q?Mc3rQpECYxbvEqFmGyL4DQRU8N0bponXYCFyFqi6WUgEhc1rxjN6vAJzz5rt?= =?us-ascii?Q?N/ZyIh2kh5MVYpghv38Mpm1rINjfO6uJKU9Gw/QOxARsYTDL+ALH/71gxyXd?= =?us-ascii?Q?CoENyceVkxP1FiELRK8Ulb1/6oskHjCwtIqWbMVHMvYdmjpp3uUCyoKxjPEM?= =?us-ascii?Q?Yxy6MtAE8RCIf05tLkkcUs6THLu5sldiLFa0Z3bbuttdMsqY5XcowKJA3aVg?= =?us-ascii?Q?Cu6lgxQW5MSXhnsid9k9wlO50o2towmcLGfA3bvGxzzV0gkaBjbvfJYd9Ix2?= =?us-ascii?Q?SDJZ1YHSQ+DRWc165VmWOgwdhdKr+i92E/XDEPTtioEIHfaJCQsu/E17WbDv?= =?us-ascii?Q?P/kpfOTwvFrcUtEqW+S3eHeTTjkDpe6d3Yk655WH6ZyfZmodNGALGAdMKgBi?= =?us-ascii?Q?IKXIypV2OnVJFQLzvL5gv1/tCceEOsDYGLy34SxjikByfyb22U6QsBG9FCrT?= =?us-ascii?Q?KV0cq8t5NhiCU/D02C7xFqF+eLm7HZllu2Jcc0NPHs+1tbzpQABlxyhEpEk/?= =?us-ascii?Q?yGYIs9x/hLb/02e0xIPiwogPLphOb/zI+NLHGPb2FXLhlFbvD71OUIs4TgYR?= =?us-ascii?Q?PzgBzUrxmQJ8Ell8Cem/Oy223o8apWTj98mF8VrbOpfGmEV0+XtPRL8/qXTc?= =?us-ascii?Q?KGFv8JUaI6RIYz4I6qQZE2sjEwL6BdUJcmkkr/k7hFce5M4ITSu3p+PaJ8+w?= =?us-ascii?Q?LRnrHn7wzginA9WEILarO7AjH3Oof4QZ9rKjf6bkVxKhwiDeuB3FwGLhJQC/?= =?us-ascii?Q?EuRJxwuenQg32QHm6uuFrY8vp7DQpmNvGieOqBqBoQLyG8SHgC/yU91qDKJ+?= =?us-ascii?Q?fNol7KcL46QJdZy2O/4J2W+9tJGpmWgFLWS676OPlavJuRE2K1kvgnKhyGuT?= =?us-ascii?Q?He8WwTjXqaTOCD5yQbAa3ucCWgc9Mqf9YP5Mk6T+cVplnET30igi2JnrSmuq?= =?us-ascii?Q?S1NIdp10cXuSAdimcM6v0qkPYoHy43LR3z6aUgHs?= 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: 6546151f-f1b5-40e3-8e5d-08dbfbb901d0 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Dec 2023 08:53:42.0918 (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: YeRfGrtHPaUpTmYrdllNEGHOVL71q9wj+OLovP73PS75rSGxm7X8tDcrz1MdBBDgNluWvBA4rggR7g4g0tCrvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR11MB7043 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: wh36RHuFWE3A94T7eltv8Hldx7686176AA= 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=nQsT6UqS; 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 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:=20 Step #1. Introduce this HOB, let PCD control this feature turn on/off and H= OB 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 tra= nsfer more smooth (platforms can publish this HOB easily with this field an= d not impact by this EDK2 change). For your question 2, I think it's necessary.=20 Previous logic in TcgPei driver is: When MigratedFvInfo HOB is detected, ra= w 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 M= igratedFvInfo 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 =20 Sent: Wednesday, December 13, 2023 11:24 AM To: Wang, Fan ; devel@edk2.groups.io Cc: Kinney, Michael D ; Gao, Liming ; Jiang, Guomin ; Wang, Jian J Subject: RE: [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration I= nformation 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 P= CD is TRUE? 2. Is the change in TcgPei necessary? Thanks, Ray > -----Original Message----- > From: Wang, Fan > Sent: Monday, December 11, 2023 5:06 PM > To: devel@edk2.groups.io > Cc: Wang, Fan ; Kinney, Michael D=20 > ; Gao, Liming ;=20 > Ni, Ray ; Jiang, Guomin ;=20 > Wang, Jian J > Subject: [PATCH v4 1/1] MdeModulePkg: Support customized FV Migration=20 > Information >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4533 >=20 > There are use cases which not all FVs need be migrated from TempRam to=20 > permanent memory before TempRam tears down. This new guid is=20 > introduced to avoid unnecessary FV migration to improve boot=20 > performance. Platform can publish MigrationInfo hob with this guid to=20 > customize FV migration info, and PeiCore will only migrate FVs indicated = by this Hob info. >=20 > This is a backwards compatible change, PeiCore will check=20 > MigrationInfo hob before migration. If MigrationInfo hobs exists, only=20 > migrate FVs recorded by hobs. If MigrationInfo hobs not exists,=20 > migrate all FVs to permanent memory. >=20 > 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(-) >=20 > 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 ( >=20 >=20 > PEI_CORE_FV_HANDLE PeiCoreFvHandle; >=20 > EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi; >=20 > + EFI_PEI_HOB_POINTERS Hob; >=20 > + EDKII_MIGRATION_INFO *MigrationInfo; >=20 > + TO_MIGRATE_FV_INFO *ToMigrateFvInfo; >=20 > + UINT32 FvMigrationFlags; >=20 > EDKII_MIGRATED_FV_INFO MigratedFvInfo; >=20 > + UINTN Index; >=20 >=20 >=20 > ASSERT (Private->PeiMemoryInstalled); >=20 >=20 >=20 > @@ -1211,6 +1216,13 @@ EvacuateTempRam ( >=20 >=20 > ConvertPeiCorePpiPointers (Private, &PeiCoreFvHandle); >=20 >=20 >=20 > + Hob.Raw =3D GetFirstGuidHob (&gEdkiiMigrationInfoGuid); >=20 > + if (Hob.Raw !=3D NULL) { >=20 > + MigrationInfo =3D GET_GUID_HOB_DATA (Hob); >=20 > + } else { >=20 > + MigrationInfo =3D NULL; >=20 > + } >=20 > + >=20 > for (FvIndex =3D 0; FvIndex < Private->FvCount; FvIndex++) { >=20 > FvHeader =3D Private->Fv[FvIndex].FvHeader; >=20 > ASSERT (FvHeader !=3D NULL); >=20 > @@ -1224,20 +1236,27 @@ EvacuateTempRam ( > ) >=20 > ) >=20 > { >=20 > - // >=20 > - // Allocate page to save the rebased PEIMs, the PEIMs will get > dispatched later. >=20 > - // >=20 > - Status =3D PeiServicesAllocatePages ( >=20 > - EfiBootServicesCode, >=20 > - EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength), >=20 > - &FvHeaderAddress >=20 > - ); >=20 > - ASSERT_EFI_ERROR (Status); >=20 > - MigratedFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER > *)(UINTN)FvHeaderAddress; >=20 > + if ((MigrationInfo =3D=3D NULL) || (MigrationInfo->MigrateAll =3D= =3D=20 > + TRUE)) { >=20 > + // Migrate all FVs and copy raw data >=20 > + FvMigrationFlags =3D FLAGS_FV_RAW_DATA_COPY; >=20 > + } else { >=20 > + for (Index =3D 0; Index < MigrationInfo->ToMigrateFvCount;=20 > + Index++) > { >=20 > + ToMigrateFvInfo =3D ((TO_MIGRATE_FV_INFO *)(MigrationInfo + > 1)) + Index; >=20 > + if (ToMigrateFvInfo->FvOrgBaseOnTempRam =3D=3D > (UINT32)(UINTN)FvHeader) { >=20 > + // This FV is to migrate >=20 > + FvMigrationFlags =3D ToMigrateFvInfo->FvMigrationFlags; >=20 > + break; >=20 > + } >=20 > + } >=20 > + >=20 > + if (Index =3D=3D MigrationInfo->ToMigrateFvCount) { >=20 > + // This FV is not expected to migrate >=20 > + continue; >=20 > + } >=20 > + } >=20 >=20 >=20 > // >=20 > - // Allocate pool to save the raw PEIMs, which is used to keep > consistent context across >=20 > - // multiple boot and PCR0 will keep the same no matter if the addr= ess > of allocated page is changed. >=20 > + // Allocate pages to save the rebased PEIMs, the PEIMs will get > dispatched later. >=20 > // >=20 > Status =3D PeiServicesAllocatePages ( >=20 > EfiBootServicesCode, >=20 > @@ -1245,7 +1264,8 @@ EvacuateTempRam ( > &FvHeaderAddress >=20 > ); >=20 > ASSERT_EFI_ERROR (Status); >=20 > - RawDataFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER > *)(UINTN)FvHeaderAddress; >=20 > + MigratedFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER > *)(UINTN)FvHeaderAddress; >=20 > + CopyMem (MigratedFvHeader, FvHeader, > (UINTN)FvHeader->FvLength); >=20 >=20 >=20 > DEBUG (( >=20 > DEBUG_VERBOSE, >=20 > @@ -1256,17 +1276,34 @@ EvacuateTempRam ( > )); >=20 >=20 >=20 > // >=20 > - // Copy the context to the rebased pages and raw pages, and create > hob to save the >=20 > - // information. The MigratedFvInfo HOB will never be produced when >=20 > - // PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the > PCD control the >=20 > - // feature. >=20 > + // Create hob to save MigratedFvInfo, this hob will only be=20 > + produced > when >=20 > + // Migration feature PCD > PcdMigrateTemporaryRamFirmwareVolumes is set to TRUE. >=20 > // >=20 > - CopyMem (MigratedFvHeader, FvHeader, > (UINTN)FvHeader->FvLength); >=20 > - CopyMem (RawDataFvHeader, MigratedFvHeader, > (UINTN)FvHeader->FvLength); >=20 > MigratedFvInfo.FvOrgBase =3D (UINT32)(UINTN)FvHeader; >=20 > MigratedFvInfo.FvNewBase =3D (UINT32)(UINTN)MigratedFvHeader; >=20 > - MigratedFvInfo.FvDataBase =3D (UINT32)(UINTN)RawDataFvHeader; >=20 > + MigratedFvInfo.FvDataBase =3D 0; >=20 > MigratedFvInfo.FvLength =3D > (UINT32)(UINTN)FvHeader->FvLength; >=20 > + >=20 > + // >=20 > + // When FLAGS_FV_RAW_DATA_COPY bit is set, copy the context to > the raw pages and >=20 > + // reset raw data base address in MigratedFvInfo hob. >=20 > + // >=20 > + if ((FvMigrationFlags & FLAGS_FV_RAW_DATA_COPY) =3D=3D > FLAGS_FV_RAW_DATA_COPY) { >=20 > + DEBUG ((DEBUG_INFO, " Copying Raw Data ...\n")); >=20 > + // >=20 > + // Allocate pages to save the raw PEIMs >=20 > + // >=20 > + Status =3D PeiServicesAllocatePages ( >=20 > + EfiBootServicesCode, >=20 > + EFI_SIZE_TO_PAGES ((UINTN)FvHeader->FvLength), >=20 > + &FvHeaderAddress >=20 > + ); >=20 > + ASSERT_EFI_ERROR (Status); >=20 > + RawDataFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER > *)(UINTN)FvHeaderAddress; >=20 > + CopyMem (RawDataFvHeader, MigratedFvHeader, > (UINTN)FvHeader->FvLength); >=20 > + MigratedFvInfo.FvDataBase =3D > (UINT32)(UINTN)RawDataFvHeader; >=20 > + } >=20 > + >=20 > BuildGuidDataHob (&gEdkiiMigratedFvInfoGuid, &MigratedFvInfo,=20 > sizeof (MigratedFvInfo)); >=20 >=20 >=20 > // >=20 > @@ -1330,8 +1367,6 @@ EvacuateTempRam ( > } >=20 > } >=20 >=20 >=20 > - RemoveFvHobsInTemporaryMemory (Private); >=20 > - >=20 > return Status; >=20 > } >=20 >=20 >=20 > 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 >=20 > gStatusCodeCallbackGuid >=20 > gEdkiiMigratedFvInfoGuid ## > SOMETIMES_PRODUCES ## HOB >=20 > + gEdkiiMigrationInfoGuid ## > SOMETIMES_CONSUMES ## HOB >=20 >=20 >=20 > [Ppis] >=20 > gEfiPeiStatusCodePpiGuid ## > SOMETIMES_CONSUMES # PeiReportStatusService is not ready if this PPI=20 > doesn't exist >=20 > 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 =20 > #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__ >=20 > #define __EDKII_MIGRATED_FV_INFO_GUID_H__ >=20 >=20 >=20 > +// >=20 > +// FLAGS_FV_RAW_DATA_COPY indicates FV raw data will be copied to > permanent memory >=20 > +// or not. When FV is migrated to permanent memory, it will be=20 > +rebased and > raw >=20 > +// data will be lost. This bit can be configured as below values: >=20 > +// 0: FV raw data will not be used in later phase, and the copy will=20 > +be skipped > to >=20 > +// optimize boot performance. >=20 > +// 1: FV raw data will be copied to permanent memory for later phase=20 > +use > (such as >=20 > +// FV measurement). >=20 > +// >=20 > +#define FLAGS_FV_RAW_DATA_COPY BIT0 >=20 > + >=20 > +/// >=20 > +/// In real use cases, not all FVs need migrate to permanent memory=20 > +before > TempRam tears >=20 > +/// down. EDKII_MIGRATION_INFO hob should be published by platform to > indicate which >=20 > +/// FVs need migration to optimize boot performance. If this hob is=20 > +not > detected by Pei >=20 > +/// Core, all FVs on TempRam will be migrated and FV raw data will=20 > +also be > copied. >=20 > +/// Only one EDKII_MIGRATION_INFO hob should be published by=20 > +platform, > and this hob will >=20 > +/// take effect only when migration feature is enabled by PCD. >=20 > +/// >=20 > +typedef struct { >=20 > + UINT32 FvOrgBaseOnTempRam; // Original FV address on > Temporary Ram >=20 > + // >=20 > + // FV Migration Flags: >=20 > + // Bit0: Indicate to copy FV raw data or not >=20 > + // Others: Reserved bits >=20 > + // >=20 > + UINT32 FvMigrationFlags; >=20 > +} TO_MIGRATE_FV_INFO; >=20 > + >=20 > +typedef struct { >=20 > + BOOLEAN MigrateAll; // Migrate all FVs and > also copy FV raw data >=20 > + // >=20 > + // ToMigrateFvCount and ToMigrateFvInfo array indicate which FVs=20 > + need > be migrated, and >=20 > + // these info should be ignored when MigrateAll field is set to TRUE. >=20 > + // >=20 > + UINT32 ToMigrateFvCount; >=20 > + // TO_MIGRATE_FV_INFO ToMigrateFvInfo[]; >=20 > +} EDKII_MIGRATION_INFO; >=20 > + >=20 > typedef struct { >=20 > UINT32 FvOrgBase; // original FV address >=20 > UINT32 FvNewBase; // new FV address >=20 > - UINT32 FvDataBase; // original FV data >=20 > + UINT32 FvDataBase; // original FV data, 0 means raw data is > not copied >=20 > UINT32 FvLength; // Fv Length >=20 > } EDKII_MIGRATED_FV_INFO; >=20 >=20 >=20 > +extern EFI_GUID gEdkiiMigrationInfoGuid; >=20 > extern EFI_GUID gEdkiiMigratedFvInfoGuid; >=20 >=20 >=20 > #endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__ >=20 > diff --git a/MdeModulePkg/MdeModulePkg.dec=20 > b/MdeModulePkg/MdeModulePkg.dec index 1a162e97e6..a2cd83345f 100644 > --- a/MdeModulePkg/MdeModulePkg.dec > +++ b/MdeModulePkg/MdeModulePkg.dec > @@ -421,7 +421,8 @@ > gEdkiiCapsuleOnDiskNameGuid =3D { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93,= =20 > 0x9a, 0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } } >=20 >=20 >=20 > ## Include/Guid/MigratedFvInfo.h >=20 > - gEdkiiMigratedFvInfoGuid =3D { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2,=20 > 0xf4, 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } } >=20 > + gEdkiiMigrationInfoGuid =3D { 0xb4b140a5, 0x72f6, 0x4c21, { 0x93, 0x= e4, > 0xac, 0xc4, 0xec, 0xcb, 0x23, 0x23 } } >=20 > + gEdkiiMigratedFvInfoGuid =3D { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2,=20 > + 0xf4, > 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } } >=20 >=20 >=20 > ## Include/Guid/RngAlgorithm.h >=20 > gEdkiiRngAlgorithmUnSafe =3D { 0x869f728c, 0x409d, 0x4ab4, {0xac,=20 > 0x03, 0x71, 0xd3, 0x09, 0xc1, 0xb3, 0xf4 }} >=20 > 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 ( > // >=20 > // Found the migrated FV info >=20 > // >=20 > - FvOrgBase =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase; >=20 > - FvDataBase =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase; >=20 > + FvOrgBase =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase; >=20 > + if (MigratedFvInfo->FvDataBase !=3D 0) { >=20 > + FvDataBase =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase; >=20 > + } >=20 > + >=20 > break; >=20 > } >=20 >=20 >=20 > diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c=20 > 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 ( > // >=20 > // Found the migrated FV info >=20 > // >=20 > - FvOrgBase =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase; >=20 > - FvDataBase =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase; >=20 > + FvOrgBase =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvOrgBase; >=20 > + if (MigratedFvInfo->FvDataBase !=3D 0) { >=20 > + FvDataBase =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)MigratedFvInfo->FvDataBase; >=20 > + } >=20 > + >=20 > break; >=20 > } >=20 >=20 >=20 > -- > 2.26.2.windows.1 -=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 (#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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-