From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.5778.1661302525797287122 for ; Tue, 23 Aug 2022 17:55:26 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=MYm8jFCN; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: isaac.w.oram@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661302526; x=1692838526; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=vh5jNYD6MTTmdESDRhymdjtHqgXPOVfehjdQB4l3JLI=; b=MYm8jFCN5EV0vcs7cTqwZxw0ox0mvZkOmrj5befTvgP+qBFNkpLlEbYi 4A8ekQJoFBAnj2H2cHJ6zerIO1Vp+2rPLM8Aq9lj8uvdgCEXQhdB/pSrp eIw85qit3QEGLYI4c27k+KzeEtfLSvZmFEZUekYSEj8/bJxPcAMAmDqGM JIlOGyn1/nH7pn87SYM/LgLB9ANC/f1hU19qaYEozFS9YBTbwdl/31xHe h7Edx0aXbn1RoyxWLlA2oWL3TQ7YMAdiw1Nsygu5PNr+eCixlVGzkbeOK EZ1am0tkU2rH7l77dluoYcvtCCbLRaIeKoKYx+li740l/TWe3q8qMIopy A==; X-IronPort-AV: E=McAfee;i="6500,9779,10448"; a="292577204" X-IronPort-AV: E=Sophos;i="5.93,259,1654585200"; d="scan'208";a="292577204" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2022 17:55:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,259,1654585200"; d="scan'208";a="638889646" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2022 17:55:24 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 23 Aug 2022 17:55:24 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 23 Aug 2022 17:55:24 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 23 Aug 2022 17:55:24 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.108) 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.2375.31; Tue, 23 Aug 2022 17:55:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NmSa7OckKnMc64MwBZwes+67UW+Mg+9v3nLt9PWMYcgBrKSic9l3S+OWaMaWTKDD+Jfu0jRV2mnNWMLno6FyQaL6HGyxlB7z2OwWqntmzww/lwByelPr0czCLW7RWhN1yHltM53RVX/HHZad3CuOdrqeWEPkNKrEM1Y6BiqKRvFa1OCqJVN7UqoDtkUqdKoNnFm1ktrm0vVmfFkUjMwA2/KxskLcn1TjUEsLc1K1jGGOS469MoFjZbOCJgOKoRM38Cqtpp3wiCFacKvlHJYtQGZj0GEcDPojsXxFtkJrEV5BqC6a4UuM6DwDSNpHV+ATSUyEdPhRH8Qn95fgUBqjkg== 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=owr8fnhPiXsHxysUDSwctZOAXAU2D0yDQ+uXbUeGX7I=; b=KdOD7ANf+xgLQQvJOywk9Lzc19X0fwK5wVzd5YotA/DmTKaunM/Nxc+0ul9MKgppTrgROgJxFnqI/AQgqnKQoWravKGaSIHKy+1sLuSPGtMTglRy9siJLTSTO9tcKXKZiGq23kKMKdClDK+DGQ5RJ7CdkuxUNDOLz8QkM0TDPioTlzhNBdOw6adbfes6tGh4LLjZBcT0CXAorFTSvMmm2Eqi2xTI6NLB5JOAr0sOPismXA9ji/R099FkjCb2NakLSO9BZOXwKoJ61BabmuhmOiyAcgzfCBghMDb2Puun9u6TufapaJ6TcbDITpjblhKoT7bAH9heVKrws4MAQcEbog== 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 Received: from SA1PR11MB5801.namprd11.prod.outlook.com (2603:10b6:806:23d::13) by BN6PR11MB2002.namprd11.prod.outlook.com (2603:10b6:404:4a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.22; Wed, 24 Aug 2022 00:55:16 +0000 Received: from SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::d1ab:10f2:3d04:2b09]) by SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::d1ab:10f2:3d04:2b09%4]) with mapi id 15.20.5566.014; Wed, 24 Aug 2022 00:55:16 +0000 From: "Oram, Isaac W" To: "Desimone, Nathaniel L" , "devel@edk2.groups.io" , "mikuback@linux.microsoft.com" CC: "Chiu, Chasel" , "Gao, Liming" , "Dong, Eric" Subject: Re: [edk2-devel] [edk2-platforms][PATCH v2 1/1] MinPlatformPkg: Add FspNvsBuffer compression option Thread-Topic: [edk2-devel] [edk2-platforms][PATCH v2 1/1] MinPlatformPkg: Add FspNvsBuffer compression option Thread-Index: AQHYtp/DaUsNYq0gf0qb8c1nG96ZMa28yJAQgAAdkACAAEwNsA== Date: Wed, 24 Aug 2022 00:55:16 +0000 Message-ID: References: <20220823032253.1686-1-mikuback@linux.microsoft.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.500.17 dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 047cefc6-febd-4ba4-521f-08da856b4f34 x-ms-traffictypediagnostic: BN6PR11MB2002:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: IwT5T9btwqGrxRmGsJsARmntjQrafzkN/4WtuopNgP1jQrwFssKVIqvCK4cPmm2tT33k7NnBAdhSV9lOtgRYr82QlTsgNevDSHu5nVYbsn0SvLyi18Vt2zwJrEvLXWM1v0HHcDdh4WNTHif80isqEQ6R/kBRkAohVoFB9Z3OkFRC6+9tX8E5gHehMvYtJkkd81C44kmO3IBVEvs8cunmVQhsoT7iVXLpPHcgB5rE8nX+17LzYm3WD2exd+i8bQOPLHvlrR4qpr6d+JonggR844olTTRq/FoqNyr0dKH/V6oxn5H21gtzS4LNkFYJzWMZJBuK86/nBFRXJy/tEEAfsjk8cw3navaVwPDSiStzBNiXpM4n9H5txQfA7fdEFTq3WsBoA/52VXJ40xyVPYxPiHqehmlCykChlr1RaKzzdpK/TVpt9Xj6jRtim65LBd/iGRQZRD8TyUdUbEJ0Mx8MfcFkwc8JC46pW3eAOWyWAyxv2DjJ3oJlOaJq38CUPAXfbeTeQ/3Fw/+mbdpiN8uPI6dkRFau2YYDHR1IIWA5QnexdvOQMlzzxZRWbo5hX0+OXoGb/CMLAhtrsCutZTU8Fh24I+4WteoDC0R8AqmCJjJAwVekDbCutKECEOt9Ho+auTqxWPA/MPdUfTrXmWMhcPaThEzEq3zbpE51YTMqJFMWVpu3awr5oQcUG4EkYRVZwSCVT/zO2fceUY/xq6FmeYTT+hEIT5FqNPmXEbGs4KxVcdNZkV74RK5xSP2A1G4aaXhFW7lMoNUeBYUkhW9ez+a4B7DBL1oo1/0PvtFSSb4Cl/NRPhG+FO5kfIpBAN4b4f3NAQmzWOJbL2T3amkwcA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR11MB5801.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39860400002)(396003)(366004)(136003)(346002)(376002)(54906003)(110136005)(122000001)(19627235002)(83380400001)(86362001)(186003)(38100700002)(478600001)(966005)(316002)(33656002)(66476007)(71200400001)(8676002)(4326008)(66446008)(41300700001)(38070700005)(66556008)(45080400002)(82960400001)(66946007)(64756008)(76116006)(2906002)(8936002)(9686003)(53546011)(6506007)(7696005)(52536014)(55016003)(30864003)(26005)(5660300002)(107886003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?G2xZaxGLI0O++3E+YdX1+rMwXw85+KEiNIeDxZkEMkK+0KZeYWHo1eO+euyR?= =?us-ascii?Q?GswlyThjhjAwP9v9fetah7eZ+CYicZfbVbKwOa8AMa5tNa1O0M48pfQJMBWs?= =?us-ascii?Q?nusrT0p0lGS9qkmikRqgCXvp80XgZ4lVELRL0PYwUJVO2eskvi1bKqDyKcaT?= =?us-ascii?Q?FSCatWny1+RGhXe86prnDa/tn5mwVp9/NRAN/Nz3MwbQhCAkCXiSROF93FKg?= =?us-ascii?Q?y7gH+ZnzU4xhUFtBucL9/CMVrt1trBidNfv5dVBz3f9WLd+OWUOXBZCaORNx?= =?us-ascii?Q?GDCTPWtKnT5tzVkplFEgM1VJywEcGtNIyPMR2UzMkFpQBpxY7CpbzZyqPFbt?= =?us-ascii?Q?6eHA1fuiGkHHDF6XuT+hs+1UGNoVeju5jEUQ5IXiVNLmjt7m1C+HhJOm/uXo?= =?us-ascii?Q?IZeIzYwIdSLjCueeuYzPxfMicK/9fPfQGL4cgq/mWXq9y+aAQXxPK1DFHBnl?= =?us-ascii?Q?dApqYDAiVuhlqEmB4LhA1Pxg0823jIIQa+NtLOQeXvOODvacU+7hjG8L9bzw?= =?us-ascii?Q?D08xMkxzJPY3R/V781tS2J5NmiOpv2C8qzSNOzlMWOnx5ucEUKqC6CdjNGln?= =?us-ascii?Q?5Vl0xdeESF4tT8hXmF9hG7vE3WzFGHFFLoZmaR0tR7JCB2k00DFC2htNYRY+?= =?us-ascii?Q?fMtVmmPPVf5QxHFCHqzNjDpwt9cbo+B0l+V/vS/dIRiUTO/4EIRzAnCsX++K?= =?us-ascii?Q?z0gd0nk6kEmMETIaYisyS1c/1QMp2Dco4PNJPKUWkJA8zzVwbBrWQuhKw86X?= =?us-ascii?Q?rAiug3kkMcYu3yREeuV2U3Jepqw6ZAv3WQOL/lQ0Rq9g12N/Kq5SVsMA9KeC?= =?us-ascii?Q?6h3c4xK3ZTkd/JfBBlLNWqek01fx+61Um886nfna8yYWrqN2dewKp+k+geXA?= =?us-ascii?Q?TYeGIWoj1/JAINdPtquo0H2GJ7tztoWtnMkoPjObI3u+AVyMB+rM6dNowTaH?= =?us-ascii?Q?7x9Drxfw0gz0z/mub4lYoBanIAPw8V8GNBjMrIBSuOJYjBzlKpfcgVaXK+1q?= =?us-ascii?Q?RYonR/ZbcrgNfWT8szpN7lpgjixkrJ1bfFJyj733ec9f27D9otcsj1EAvoGv?= =?us-ascii?Q?78n5UzYsgM6QH7AmgI9LvgPcdr+10YSmr4jEy2fvVkwR9TMS6BV/T4KKLs4W?= =?us-ascii?Q?nbiY+UcGecqrGYR0rlZNwO4ua7AWhrpanTJiAykYOeQZGwdf/n/UgqeDzBj2?= =?us-ascii?Q?keJMRJHaWhXMvqbhrleIsZwBCZQ0xIjjmRawZUAbehCv5w7Ajko6k/QBXMqQ?= =?us-ascii?Q?ekqslZh3rbf+8m0/WSojHDbGogQKNZnJuGt+RKOhTImP/IuhyTJ3x9MmcXYw?= =?us-ascii?Q?dkRtmd6b9vOf2+B2dSrmTMxQ97QnyKKb9vis0YlG+3Ndsh6HuSgp2KNpb6bS?= =?us-ascii?Q?defznKqnWPBbbptupLTbGMBFCmVJFfwhQPz1Ujfmn1vBrKbiqxtpUsfEvDdJ?= =?us-ascii?Q?iz0Tp9b0M5Xjnr25r/yJdOgdZDQ2cxwaDw5CXTIycZ1OZcQV71YjWYlZVVxa?= =?us-ascii?Q?nRKKpLjO6juMpXie8YL3UFgg5Ht/aW2dnGA8cYW9g+iUeWxOkL+vQDZfaxM5?= =?us-ascii?Q?ke084zKUIhzU//H6dB8EzupYLjaMj2aqBPitdOZ5?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR11MB5801.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 047cefc6-febd-4ba4-521f-08da856b4f34 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Aug 2022 00:55:16.2701 (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: LtCoamKnsJUkgxh9Z0wpm59nMXTcE82KArjVNaSXAzj0nM848Pzix2KhtGSDZ5fdot8WHJMOuCvzZ/Axp32sCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB2002 Return-Path: isaac.w.oram@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable A PCD to control library class instance seems redundant. The build already= has capabilities to control library class instance per driver, per driver = type, per architecture, etc. Let me know if there is some benefit to overr= iding PCD in board DSC vs overriding library class in board DSC that I am m= issing. We want to simplify what developers need to see and deal with. Minimize th= e number of basic decisions needed to get a functional port. I would prefe= r a single instance of LargeVariable*Lib. As a board port developer, if yo= ur silicon FSP supports compressing the data and your board port doesn't wa= nt the redundancy, that is a stage 7 optimization to write your own instanc= e of the library class or your own version of SaveMemoryConfigDxe. No need= to burden the rest of the boards with needing to know about and configure = this to optimize a corner case. I also think decompression and compression decisions should reside at the b= oot loader level not internal to FSP. First to minimize FSP content, secon= d because bootloaders already typically decide and implement decompression = that matches their build specific compression. I will grant that it is pro= bably mostly the same common algorithm implementation. Ultimately though, those are mostly philosophical objections. If you reall= y want two instances of the library, I can live with it. I will be able to= have reasonable default behavior that is pretty simple for most. The more concrete objection is the asymmetric design, where common code imp= lements compression and per platform code implements decompression. That s= eems distasteful. I can live with this too because it is kind of already t= his way, but more consistent combined with more encapsulated seems better t= han expanding the asymmetric design. Regards, Isaac -----Original Message----- From: Desimone, Nathaniel L =20 Sent: Tuesday, August 23, 2022 12:51 PM To: Oram, Isaac W ; devel@edk2.groups.io; mikuback@= linux.microsoft.com Cc: Chiu, Chasel ; Gao, Liming ; Dong, Eric Subject: RE: [edk2-devel] [edk2-platforms][PATCH v2 1/1] MinPlatformPkg: Ad= d FspNvsBuffer compression option Agreed with Isaac that having the compression capability be more general us= e would be nice. However, I think it would better match the EDK II design s= tyle if we had a second implementation of LargeVariable*Lib that added the = compression capability on top of the original LargeVariable*Lib. I also think having a PCD to explicitly control whether to apply compressio= n to the FSP NVS buffer is important. Because there are some FSP implementa= tions like ICX and SPR that already include the CompressLib inside the FSP = binary itself. On those FSP implementations, the data in the FSP_NON_VOLATI= LE_STORAGE_HOB is already compressed. Said PCD would simply control which i= nstance of the LibraryClass gets linked with SaveMemoryConfigDxe. Also agreed with Isaac to please be careful to make sure that any new Libra= ryClasses are in the Include/*.dsc files somewhere so existing boards don't= need modifications to their BoardPkg.dsc file. Thanks, Nate -----Original Message----- From: Oram, Isaac W Sent: Tuesday, August 23, 2022 11:34 AM To: devel@edk2.groups.io; mikuback@linux.microsoft.com Cc: Chiu, Chasel ; Desimone, Nathaniel L ; Gao, Liming ; Dong, Eric <= eric.dong@intel.com> Subject: RE: [edk2-devel] [edk2-platforms][PATCH v2 1/1] MinPlatformPkg: Ad= d FspNvsBuffer compression option Implementing this way will break the build for most of the open MinPlatform= ports. At minimum, please add the CompressLib to CoreCommonLib.dsc next t= o the UefiDecompressLib instantiation so that it is included automatically = for most boards. Regarding the design, I agree this is a good capability. And it makes sens= e to me to be board controlled rather than FSP controlled. I wonder if it might be better to modify the LargeVariableRead/Write such t= hat it compresses/decompresses large variables automatically. Could be con= trolled via library class instance or maybe via PatchablePerModule PCD. Bo= ards would still have a lot of control if they wanted. Regards, Isaac -----Original Message----- From: devel@edk2.groups.io On Behalf Of Michael Kuba= cki Sent: Monday, August 22, 2022 8:23 PM To: devel@edk2.groups.io Cc: Chiu, Chasel ; Desimone, Nathaniel L ; Oram, Isaac W ; Gao, Liming = ; Dong, Eric Subject: [edk2-devel] [edk2-platforms][PATCH v2 1/1] MinPlatformPkg: Add Fs= pNvsBuffer compression option From: Michael Kubacki Adds a PCD called "PcdEnableCompressedFspNvsBuffer" that allows the "FspNvs= Buffer" UEFI variable data to be saved as compressed data. Especially due to the nature of the data saved in this variable, it compres= ses well. For example, it has been found to reduce ~63KB of data to ~13KB. = Boot time impact has been found to be negligible. The default value is FALSE to keep default behavior consistent. Decompression can be performed on the variable data using the standard Uefi= DecompressLib. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Isaac Oram Cc: Liming Gao Cc: Eric Dong Signed-off-by: Michael Kubacki --- Notes: v2: Rebase onto 9769bf28d1fc Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig= .c | 62 ++++++++++++++++---- Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig= .inf | 4 ++ Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec = | 6 ++ Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc = | 1 + 4 files changed, 60 insertions(+), 13 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/Save= MemoryConfig.c b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/= SaveMemoryConfig.c index 0215e8eeddfb..95b8cef8b32b 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC= onfig.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemo +++ ryConfig.c @@ -3,6 +3,7 @@ exists, and saves the data to nvRAM. =20 Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -10,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include @@ -19,6 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #includ= e +#include #include #include =20 @@ -38,20 +41,26 @@ SaveMemoryConfigEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - EFI_HOB_GUID_TYPE *GuidHob; - VOID *HobData; - VOID *VariableData; - UINTN DataSize; - UINTN BufferSize; - BOOLEAN DataIsIdentical; + EFI_STATUS Status; + EFI_HOB_GUID_TYPE *GuidHob; + VOID *HobData; + VOID *VariableData; + UINTN DataSize; + UINTN BufferSize; + BOOLEAN DataIsIdentical; + VOID *CompressedData; + UINT64 CompressedSize; + UINTN CompressedAllocationPages; =20 - DataSize =3D 0; - BufferSize =3D 0; - VariableData =3D NULL; - GuidHob =3D NULL; - HobData =3D NULL; - DataIsIdentical =3D FALSE; + DataSize =3D 0; + BufferSize =3D 0; + VariableData =3D NULL; + GuidHob =3D NULL; + HobData =3D NULL; + DataIsIdentical =3D FALSE; + CompressedData =3D NULL; + CompressedSize =3D 0; + CompressedAllocationPages =3D 0; =20 // // Search for the Memory Configuration GUID HOB. If it is not present, = then @@ -73,6 +82,29 @@ SaveMemoryConfigEntryPoint ( } } =20 + if (PcdGetBool (PcdEnableCompressedFspNvsBuffer)) { + if (DataSize > 0) { + CompressedAllocationPages =3D EFI_SIZE_TO_PAGES (DataSize); + CompressedData =3D AllocatePages (CompressedAllocationPag= es); + if (CompressedData =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "[%a] - Failed to allocate compressed data bu= ffer.\n", __FUNCTION__)); + ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES); + return EFI_OUT_OF_RESOURCES; + } + + CompressedSize =3D EFI_PAGES_TO_SIZE (CompressedAllocationPages); + Status =3D Compress (HobData, DataSize, CompressedData, &Com= pressedSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "[%a] - failed to compress data. Status =3D %= r\n", __FUNCTION__, Status)); + ASSERT_EFI_ERROR (Status); + return Status; + } + } + + HobData =3D CompressedData; + DataSize =3D (UINTN)CompressedSize; + } + if (HobData !=3D NULL) { DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataLength:%d\n", DataSize)); DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataPtr : 0x%x\n", HobData)); @@ -136,6 +168,10 @@ SaveMemoryConfigEntryPoint ( DEBUG((DEBUG_ERROR, "Memory S3 Data HOB was not found\n")); } =20 + if (CompressedData !=3D NULL) { + FreePages (CompressedData, CompressedAllocationPages); } + // // This driver does not produce any protocol services, so always unload = it. // diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/Save= MemoryConfig.inf b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfi= g/SaveMemoryConfig.inf index 61e85a658693..0f12deb131ca 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC= onfig.inf +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemo +++ ryConfig.inf @@ -26,6 +26,7 @@ [LibraryClasses] LargeVariableReadLib LargeVariableWriteLib BaseLib + CompressLib =20 [Packages] MdePkg/MdePkg.dec @@ -45,6 +46,9 @@ [Guids] gFspNonVolatileStorageHob2Guid ## CONSUMES gFspNvsBufferVariableGuid ## PRODUCES =20 +[Pcd] + gMinPlatformPkgTokenSpaceGuid.PcdEnableCompressedFspNvsBuffer + [Depex] gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid \ No newline at end of file diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec b/Platform/In= tel/MinPlatformPkg/MinPlatformPkg.dec index 8e603b7bf94b..94353cb76824 100644 --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec @@ -306,6 +306,12 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic,= PcdsDynamicEx] =20 gMinPlatformPkgTokenSpaceGuid.PcdPlatformMemoryCheckLevel|0|UINT32|0x300= 00009 =20 + ## Controls whether the FSP NVS buffer is saved as compressed data. + # Data compression can significantly reduce variable storage usage for F= SP NVS buffer data. + # Platforms that choose to compress the data will need to decompress=20 + the variable data upon # extraction. + =20 + gMinPlatformPkgTokenSpaceGuid.PcdEnableCompressedFspNvsBuffer|FALSE|BO + OLEAN|0x30000010 + ## This PCD is to control which device is the potential trusted console = input device.

# For example:
# USB Short Form: UsbHID(0xFFFF,0xFFFF,0x1,0x1)
diff --git a/Platfor= m/Intel/MinPlatformPkg/MinPlatformPkg.dsc b/Platform/Intel/MinPlatformPkg/M= inPlatformPkg.dsc index 09aa6fe4d51c..ae170f87d548 100644 --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc @@ -106,6 +106,7 @@ [LibraryClasses.common.DXE_DRIVER] FspWrapperPlatformLib|MinPlatformPkg/FspWrapper/Library/DxeFspWrapperPla= tformLib/DxeFspWrapperPlatformLib.inf TestPointCheckLib|MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestP= ointCheckLib.inf TestPointLib|MinPlatformPkg/Test/Library/TestPointLib/DxeTestPointLib.in= f + CompressLib|MinPlatformPkg/Library/CompressLib/CompressLib.inf =20 [LibraryClasses.common.DXE_SMM_DRIVER] TestPointCheckLib|MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestP= ointCheckLib.inf -- 2.28.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92644): https://edk2.groups.io/g/devel/message/92644 Mute This Topic: https://groups.io/mt/93197638/1492418 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [isaac.w.oram@intel.com] = -=3D-=3D-=3D-=3D-=3D-=3D