From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id A7D5A7803CE for ; Mon, 20 May 2024 07:07:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=QpkmvxNGwkAhgGZhVnOar2ge/Kfsgc4nH8NrS8AfyLU=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type; s=20240206; t=1716188848; v=1; b=KXEcoG279QZJNof3iVZNWyZeYwEU/wV20tExl+S9jj942QQNcKr45N3K3pDxK2isZ0oOMux6 vpxGSq67e99HqI2aNfkBTAMTFIF+L/qnWIlMk/cQ42Pg8pqNCscSlQC0FhpIVdgLpYWHPJIpnim /wUGEg8QbmmFTu+PjwzRgsO9EdmwexWlFetcrJASt1HnkNEg6r5XpRVEn9/x37tEGMkmm1I5mko umOirLMrGC8Nf2mXm2kFoY6nMlvShLUdiArlFFBPkBcwKS6g+IkPvdOnEQUee+3/W87f+Ol0rx8 sAEFBMudvye2sJrm7ch0e9zZhhEreP1bVTPZQFXVH+J1A== X-Received: by 127.0.0.2 with SMTP id x2eRYY7687511xeuQKw5I32x; Mon, 20 May 2024 00:07:28 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by mx.groups.io with SMTP id smtpd.web11.55368.1716188846810420134 for ; Mon, 20 May 2024 00:07:26 -0700 X-CSE-ConnectionGUID: lU+ed0LFTk+A0jLHpXL5ug== X-CSE-MsgGUID: dcgwhR1DSEeFIBeLH0joSg== X-IronPort-AV: E=McAfee;i="6600,9927,11077"; a="12171235" X-IronPort-AV: E=Sophos;i="6.08,174,1712646000"; d="scan'208,217";a="12171235" X-Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 00:07:27 -0700 X-CSE-ConnectionGUID: lywYC5cuQfyRV40w0L5LEg== X-CSE-MsgGUID: 7pU8xj2uRlmc1cy+SCE+jg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,174,1712646000"; d="scan'208,217";a="63665218" X-Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmviesa001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 May 2024 00:07:25 -0700 X-Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 20 May 2024 00:07:25 -0700 X-Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Mon, 20 May 2024 00:07:25 -0700 X-Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.41) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 20 May 2024 00:07:24 -0700 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by PH7PR11MB8033.namprd11.prod.outlook.com (2603:10b6:510:246::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Mon, 20 May 2024 07:07:22 +0000 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::41a4:c775:32e6:76a8]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::41a4:c775:32e6:76a8%4]) with mapi id 15.20.7587.028; Mon, 20 May 2024 07:07:22 +0000 From: "Ni, Ray" To: Kun Qin , "Tan, Dun" , "devel@edk2.groups.io" CC: Liming Gao , Sean Brogan Subject: Re: [edk2-devel] [PATCH 7/9] MdeModulePkg:Consume gEdkiiVariableRuntimeCacheInfoHobGuid Thread-Topic: [PATCH 7/9] MdeModulePkg:Consume gEdkiiVariableRuntimeCacheInfoHobGuid Thread-Index: AQHaqD+4wfakm1/BA0W6naTE392Kl7GbVWhMgABO8vCABBNFmQ== Date: Mon, 20 May 2024 07:07:22 +0000 Message-ID: References: <20240517094917.513-1-dun.tan@intel.com> <20240517094917.513-8-dun.tan@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=4639c382-fc80-450c-89c8-c107026a4b98;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2024-05-17T16:51:13Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|PH7PR11MB8033:EE_ x-ms-office365-filtering-correlation-id: 7a37c7f8-9194-45b3-67b0-08dc789b7eee x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?Windows-1252?Q?M7bj6rN0uymk/mqkw+1wjG/30yz/peM6dK7WSotDgLUxhyQbYouWHYJ6?= =?Windows-1252?Q?WVHcZF0PmHmSgoUr9fMWLRBP08PwP9VkTLFT7IK4NN0wKYGhwXxGJrSV?= =?Windows-1252?Q?MjV95kMtePKeARC8d1nXTiPBQtK2fr1p+ymTt1NrJwgFEL7Vi2+a8MSE?= =?Windows-1252?Q?pGvfhEoIv6L/q2VYhP/PK97eVRQ49Cj4r2N+piBEJEeeWf1YEBya9rUs?= =?Windows-1252?Q?ffIQfxjMidmhDuzGRG28HTULk+D36AoDaltMifwFJH1ElM0AViar2Ep4?= =?Windows-1252?Q?zmPBpv7lFvABTMVKECJDxrcWg/Du7XzFJu+ZIIpZeR8q6E1eDhMSMBoz?= =?Windows-1252?Q?bBGIzypEzE3fwg/nILI8/37k7mnnbzynstkpg6wCqLk4QwaU/3FANFo8?= =?Windows-1252?Q?p1L/mBdN50pb915ljNVhKO/s7ZkrT+Pz51pa119VIIHdYL3nmCRXpY5K?= =?Windows-1252?Q?3wefTz//VDWKxCpyqnnu/2ny/UMNmkGxMcx26aWS8zjkFrbCzH1VrUzt?= =?Windows-1252?Q?m/FXsBR88PBp+OFOl+M/Wr5pzs6CQJfizvIhXU4SQ91azDFPoxybCcsw?= =?Windows-1252?Q?6i0caCtDXj4N8mVgDnNekZAcjMOGexDSINfQsnrh4wZpCah16Cx815ki?= =?Windows-1252?Q?wil4TpryzPIjSxrZzMBlInivfN//bB5/1PVtXloo8/Ss/5VNPOtljJBB?= =?Windows-1252?Q?xGbR3rM0fX1Uev+5oqbwRpsyB14Hzpph6Cz80XBVhhUvxAbZZnADkufF?= =?Windows-1252?Q?mREvhJyGFxKzXYUD3FxAWSdUzbroaBzVP8YbrIJMxsHE4Wtl9jbPF4z5?= =?Windows-1252?Q?5PYVTDrJQE6AD2K6ioH6yQ6oZgFq7gxtyX6UN1DUSgINpfz6ekw4H5Zm?= =?Windows-1252?Q?EyGSHxwZeWLYbqJv8OFTP3DT5fzARjy3obG8qgp0oEpCYzZQdLoolMEZ?= =?Windows-1252?Q?IpEbbvmJ6ZvheYD714OAHo+FKU4aJ6L8aHn1o25F7YJQwPxaJq16PlXM?= =?Windows-1252?Q?ITfscmhgSbNAqJ70aiwY2KWNyc2EZ3WminMIKFe4GTghQ7stPcgvGVwr?= =?Windows-1252?Q?yRRbGB79WEc+py7SLRCSmgXCNbwFa7QwLQtce93HyLcJpTcf93Yrah2i?= =?Windows-1252?Q?MEUUevm6VlVxQSr/7LEdWb6BpmTJxVE+xiqfisd8JiqhS7qrfysVoIGH?= =?Windows-1252?Q?drbWIjQ6ULMVifTzAk/RrpJ3gPyKnrWnlY11DEpxjl+LL+pRb/y+IdSO?= =?Windows-1252?Q?8S03LXMwzOz2EO3sMTDXtWRfDl0P/3MO9wel4lkOFSF1Ecu4DAj8EpVW?= =?Windows-1252?Q?chN92UITUJFoRF9e36FsfiHNfbgnZzpJyEesvAc913zQvIEYw4kgIm2X?= =?Windows-1252?Q?HvY4gUae78nVyw=3D=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?a0wI32kWxvPx39efoT599QUqx+IKZdVKH0ARgGAbamfQuPtGUVwAphwS?= =?Windows-1252?Q?nSh/yjNMRR6rWTT7u9kkAlljulI6ok3BC8kg2HPF7rHeE215DdyE5Ibf?= =?Windows-1252?Q?hwLzIYTRxNL/LypMIHgD0u4f4be2g2YA75wKmhPpa2gKKnpnWt0Da6I4?= =?Windows-1252?Q?2ZoZmqaH0Pm+GAAZk9u3plBWX5J/O1Px+ufp5QizDGmmlo+RbuekDMnY?= =?Windows-1252?Q?ZMtcSQHM7slK0+bMPSVstOXLIU4Jv9mw4gbQi1uA+tocHRIa2wFWoyM9?= =?Windows-1252?Q?kNP0jMlWNmcGczh/ZaOsUQJCRyz0p/TNEjxgqLMMgQBULWnGoI65JFBq?= =?Windows-1252?Q?t5Ui5MyHD/XgT4yx7qrSqJvoSmpa74cxp0z50OdnGyd8NsgXDAA0dTrn?= =?Windows-1252?Q?DrmfCbCB0fS8T2jNrVvDyJ0mc2iMPGXr8tm6amARLvxJidIGsz3jY0+d?= =?Windows-1252?Q?A6qayixPhC/39I6vr6upgMLbgQZNaqvXkokaN63e6edEB24nI0koQGUq?= =?Windows-1252?Q?o2TgW7mBsiBkHV5QYDci/vlNcl7utlOwLiKCVyJfr1t3wpVwNYuM7JqS?= =?Windows-1252?Q?0IPUX8Al7wCns1OJKVszsSkhPF3Aq7IHMnbTiLLwq6bAwdPO66krBakg?= =?Windows-1252?Q?gWO85ozn6tebrm0fN07WMfnQDi+9pery5BGv5dobPqQqkQCf+bYS0+07?= =?Windows-1252?Q?W1Ku2LdL2yMofk7UF5JjveSQLFXZ0kl+eE/I7MldVToXDCjpg2qeoTEU?= =?Windows-1252?Q?g8Z9nElu8b5RaNCjy/n6X+cvDtiHbGzegJHQzSaY1QkpMooa6/MWnqH8?= =?Windows-1252?Q?7Mr6coJpIrqphmME2+06R33xTqF7X4qT+u7YNcJJilRKuzqWSkBjpegJ?= =?Windows-1252?Q?ASraI4XOrqbILisWH6sBk8elEOrYwcvcVuBgGOzueAMjB5cOW7imr3t2?= =?Windows-1252?Q?Spa13mSFoR609d9ZX7aSYo0b4Trdp/9qkUS4Gj42HZhp9pfcbrom1v7L?= =?Windows-1252?Q?fKZOrGtPuKEjRELGRA59mDUg3Vx7diaNKy+w/K0bPCOaKgsCcGKfVFg0?= =?Windows-1252?Q?VbVve4qxxum7uaOv4dKNhT76YHpFvNzddSL3W4Ywr3St+aRO1mMaGIaG?= =?Windows-1252?Q?GSOjlu8gmcqDdmQCsI+CdVE76mTZEK0c7+NalbpOt75wz/ncF2YgyuZ8?= =?Windows-1252?Q?mqYrcq5tn4kxhY2RZNyg8HMaVPo1sAArY8Jk9WczaKpx0zbevwQs5PDG?= =?Windows-1252?Q?hEhjcyNRAeRbC8syPqFfz+driwJ8ls7QYgJqkHKUVvzaYoLhuCfpSvuR?= =?Windows-1252?Q?JBP32xcH8SiQ7euD6mxbVOLiJLSwEH0oGWn9k2vJzGsiYWv43TPcA9DO?= =?Windows-1252?Q?NJwpPQxIWDe8L1wktM1wZqxTaFvpHzTOF2dCX1f8k6NOl7e6oS2Ou8gY?= =?Windows-1252?Q?U/rvk3dz62rlDWv/DU0Ni8RRAgNkw/i3PcN5kbCjr4MWs3KfZKozZB1p?= =?Windows-1252?Q?+WFH7I8/jBz3Y5qTGB2NINtpbagfQhCatF+4yGnjGrrl/KpU7YGt+hzM?= =?Windows-1252?Q?2r7c/Zwjt9duJ20EPJ4Q9w5q7mVQqx5OKKc432O5MV2+NmAME37Pvtvw?= =?Windows-1252?Q?fRLrNh8ue/3Xl3zVt5Sl7tdvJqfHICXVQbrgwOSf/tSUDITGd4E+vjYc?= =?Windows-1252?Q?rwdEES3CyQc=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a37c7f8-9194-45b3-67b0-08dc789b7eee X-MS-Exchange-CrossTenant-originalarrivaltime: 20 May 2024 07:07:22.3981 (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: VTCFRpOVCIxxTMijsJnMLldwWfOmWlXNwwmPtnh6htx+NxW+FbvEx/tVyy/pNNSJy2d++rvx8e/OO0v7IZu58Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB8033 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 Resent-Date: Mon, 20 May 2024 00:07:26 -0700 Resent-From: ray.ni@intel.com Reply-To: devel@edk2.groups.io,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: P0asd1Un2d2JtrClXBstrVoix7686176AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MN6PR11MB82445BB018660BE58E0D21D98CE92MN6PR11MB8244namp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=KXEcoG27; 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 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io --_000_MN6PR11MB82445BB018660BE58E0D21D98CE92MN6PR11MB8244namp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Kun, Good to know that you have no concerns on the patch. The patch set aims to = finalize the unblock memory regions before standalone MM env is launched. The PeiNotifyPpi() can still notify the PPI callback when the PPI has been = installed already. Thanks, Ray ________________________________ From: Kun Qin Sent: Saturday, May 18, 2024 1:09 To: Ni, Ray ; Tan, Dun ; devel@edk2.gr= oups.io Cc: Liming Gao ; Sean Brogan Subject: RE: [PATCH 7/9] MdeModulePkg:Consume gEdkiiVariableRuntimeCacheInf= oHobGuid Hi Ray & Dun, Thanks for adding me to the patch. I think the proposed solution should wor= k. One question, which is actually on the hob creator patch (https://edk2.g= roups.io/g/devel/message/119022), is that I understand the hob creation dep= ends on =93gEfiPeiMemoryDiscoveredPpiGuid=94, but does this routine still r= un properly if variable PEIM is loaded much later than memory discovered? Regards, Kun From: Ni, Ray Sent: Friday, May 17, 2024 5:10 AM To: Tan, Dun ; devel@edk2.groups.io Cc: Liming Gao ; Kun Qin ;= Sean Brogan Subject: [EXTERNAL] Re: [PATCH 7/9] MdeModulePkg:Consume gEdkiiVariableRunt= imeCacheInfoHobGuid Reviewed-by: Ray Ni > Thanks, Ray ________________________________ From: Tan, Dun > Sent: Friday, May 17, 2024 17:49 To: devel@edk2.groups.io > Cc: Ni, Ray >; Liming Gao > Subject: [PATCH 7/9] MdeModulePkg:Consume gEdkiiVariableRuntimeCacheInfoHob= Guid Consume gEdkiiVariableRuntimeCacheInfoHobGuid in VariableSmmRuntimeDxe driver to initialize the following variable cache related buffer: *mVariableRuntimeHobCacheBuffer *mVariableRuntimeNvCacheBuffer *mVariableRuntimeVolatileCacheBuffer *mVariableRuntimeCachePendingUpdate *mVariableRuntimeCacheReadLock *mHobFlushComplete The code to to allocate and unblock the buffer for different type cache in VariableSmmRuntimeDxe is also removed in this commit. Signed-off-by: Dun Tan > Cc: Ray Ni > Cc: Liming Gao > Cc: Jiaxin Wu > --- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c | 120= +++++++++++++++++++++++++++++++++++++++++++++++++-------------------------= ---------------------------------------------- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf | 5= +++-- 2 files changed, 52 insertions(+), 73 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeD= xe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c index 8b42ae7d72..68a249c5ac 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c @@ -35,10 +35,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include +#include #include #include +#include #include "PrivilegePolymorphic.h" #include "VariableParsing.h" @@ -56,10 +57,10 @@ VARIABLE_STORE_HEADER *mVariableRuntimeVolati= leCacheBuffer =3D NULL; UINTN mVariableBufferSize; UINTN mVariableRuntimeHobCacheBufferSize; UINTN mVariableBufferPayloadSize; -BOOLEAN mVariableRuntimeCachePendingUpdate; -BOOLEAN mVariableRuntimeCacheReadLock; +BOOLEAN *mVariableRuntimeCachePendingUpdate; +BOOLEAN *mVariableRuntimeCacheReadLock; BOOLEAN mVariableAuthFormat; -BOOLEAN mHobFlushComplete; +BOOLEAN *mHobFlushComplete; EFI_LOCK mVariableServicesLock; EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock; EDKII_VAR_CHECK_PROTOCOL mVarCheck; @@ -180,27 +181,6 @@ InitVariableCache ( *TotalVariableCacheSize =3D ALIGN_VALUE (*TotalVariableCacheSize, sizeof= (UINT32)); - // - // Allocate NV Storage Cache and initialize it to all 1's (like an erase= d FV) - // - *VariableCacheBuffer =3D (VARIABLE_STORE_HEADER *)AllocateRuntimePages = ( - EFI_SIZE_TO_PAGES (*T= otalVariableCacheSize) - ); - if (*VariableCacheBuffer =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Request to unblock the newly allocated cache region to be accessible = from inside MM - // - Status =3D MmUnblockMemoryRequest ( - (EFI_PHYSICAL_ADDRESS)(UINTN)*VariableCacheBuffer, - EFI_SIZE_TO_PAGES (*TotalVariableCacheSize) - ); - if ((Status !=3D EFI_UNSUPPORTED) && EFI_ERROR (Status)) { - return Status; - } - VariableCacheStorePtr =3D *VariableCacheBuffer; SetMem32 ((VOID *)VariableCacheStorePtr, *TotalVariableCacheSize, (UINT3= 2)0xFFFFFFFF); @@ -568,16 +548,16 @@ CheckForRuntimeCacheSync ( VOID ) { - if (mVariableRuntimeCachePendingUpdate) { + if (*mVariableRuntimeCachePendingUpdate) { SyncRuntimeCache (); } - ASSERT (!mVariableRuntimeCachePendingUpdate); + ASSERT (!(*mVariableRuntimeCachePendingUpdate)); // // The HOB variable data may have finished being flushed in the runtime = cache sync update // - if (mHobFlushComplete && (mVariableRuntimeHobCacheBuffer !=3D NULL)) { + if ((*mHobFlushComplete) && (mVariableRuntimeHobCacheBuffer !=3D NULL)) = { if (!EfiAtRuntime ()) { FreePages (mVariableRuntimeHobCacheBuffer, EFI_SIZE_TO_PAGES (mVaria= bleRuntimeHobCacheBufferSize)); } @@ -633,12 +613,12 @@ FindVariableInRuntimeCache ( // a GetVariable () or GetNextVariable () call from being issued until a= prior call has returned. The runtime // cache read lock should always be free when entering this function. // - ASSERT (!mVariableRuntimeCacheReadLock); + ASSERT (!(*mVariableRuntimeCacheReadLock)); - mVariableRuntimeCacheReadLock =3D TRUE; + *mVariableRuntimeCacheReadLock =3D TRUE; CheckForRuntimeCacheSync (); - if (!mVariableRuntimeCachePendingUpdate) { + if (!(*mVariableRuntimeCachePendingUpdate)) { // // 0: Volatile, 1: HOB, 2: Non-Volatile. // The index and attributes mapping must be kept in this order as Find= Variable @@ -698,7 +678,7 @@ Done: } } - mVariableRuntimeCacheReadLock =3D FALSE; + *mVariableRuntimeCacheReadLock =3D FALSE; return Status; } @@ -921,12 +901,12 @@ GetNextVariableNameInRuntimeCache ( // a GetVariable () or GetNextVariable () call from being issued until a= prior call has returned. The runtime // cache read lock should always be free when entering this function. // - ASSERT (!mVariableRuntimeCacheReadLock); + ASSERT (!(*mVariableRuntimeCacheReadLock)); CheckForRuntimeCacheSync (); - mVariableRuntimeCacheReadLock =3D TRUE; - if (!mVariableRuntimeCachePendingUpdate) { + *mVariableRuntimeCacheReadLock =3D TRUE; + if (!(*mVariableRuntimeCachePendingUpdate)) { // // 0: Volatile, 1: HOB, 2: Non-Volatile. // The index and attributes mapping must be kept in this order as Find= Variable @@ -958,7 +938,7 @@ GetNextVariableNameInRuntimeCache ( } } - mVariableRuntimeCacheReadLock =3D FALSE; + *mVariableRuntimeCacheReadLock =3D FALSE; return Status; } @@ -1622,37 +1602,9 @@ SendRuntimeVariableCacheContextToSmm ( SmmRuntimeVarCacheContext->RuntimeHobCache =3D mVariableRuntimeHobC= acheBuffer; SmmRuntimeVarCacheContext->RuntimeVolatileCache =3D mVariableRuntimeVola= tileCacheBuffer; SmmRuntimeVarCacheContext->RuntimeNvCache =3D mVariableRuntimeNvCa= cheBuffer; - SmmRuntimeVarCacheContext->PendingUpdate =3D &mVariableRuntimeCac= hePendingUpdate; - SmmRuntimeVarCacheContext->ReadLock =3D &mVariableRuntimeCac= heReadLock; - SmmRuntimeVarCacheContext->HobFlushComplete =3D &mHobFlushComplete; - - // - // Request to unblock this region to be accessible from inside MM enviro= nment - // These fields "should" be all on the same page, but just to be on the = safe side... - // - Status =3D MmUnblockMemoryRequest ( - (EFI_PHYSICAL_ADDRESS)ALIGN_VALUE ((UINTN)SmmRuntimeVarCacheC= ontext->PendingUpdate - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE), - EFI_SIZE_TO_PAGES (sizeof (mVariableRuntimeCachePendingUpdate= )) - ); - if ((Status !=3D EFI_UNSUPPORTED) && EFI_ERROR (Status)) { - goto Done; - } - - Status =3D MmUnblockMemoryRequest ( - (EFI_PHYSICAL_ADDRESS)ALIGN_VALUE ((UINTN)SmmRuntimeVarCacheC= ontext->ReadLock - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE), - EFI_SIZE_TO_PAGES (sizeof (mVariableRuntimeCacheReadLock)) - ); - if ((Status !=3D EFI_UNSUPPORTED) && EFI_ERROR (Status)) { - goto Done; - } - - Status =3D MmUnblockMemoryRequest ( - (EFI_PHYSICAL_ADDRESS)ALIGN_VALUE ((UINTN)SmmRuntimeVarCacheC= ontext->HobFlushComplete - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE), - EFI_SIZE_TO_PAGES (sizeof (mHobFlushComplete)) - ); - if ((Status !=3D EFI_UNSUPPORTED) && EFI_ERROR (Status)) { - goto Done; - } + SmmRuntimeVarCacheContext->PendingUpdate =3D mVariableRuntimeCach= ePendingUpdate; + SmmRuntimeVarCacheContext->ReadLock =3D mVariableRuntimeCach= eReadLock; + SmmRuntimeVarCacheContext->HobFlushComplete =3D mHobFlushComplete; // // Send data to SMM. @@ -1688,9 +1640,14 @@ SmmVariableReady ( IN VOID *Context ) { - EFI_STATUS Status; - UINTN RuntimeNvCacheSize; - UINTN RuntimeVolatileCacheSize; + EFI_STATUS Status; + UINTN RuntimeNvCacheSize; + UINTN RuntimeVolatileCacheSize; + UINTN AllocatedHobCacheSize; + UINTN AllocatedNvCacheSize; + UINTN AllocatedVolatileCacheSize; + EFI_HOB_GUID_TYPE *GuidHob; + VARIABLE_RUNTIME_CACHE_INFO *VariableRuntimeCacheHob; Status =3D gBS->LocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOI= D **)&mSmmVariable); if (EFI_ERROR (Status)) { @@ -1717,7 +1674,7 @@ SmmVariableReady ( if (FeaturePcdGet (PcdEnableVariableRuntimeCache)) { DEBUG ((DEBUG_INFO, "Variable driver runtime cache is enabled.\n")); // - // Allocate runtime variable cache memory buffers. + // Get needed runtime cache buffer size and check if auth variables ar= e to be used from SMM // Status =3D GetRuntimeCacheInfo ( &mVariableRuntimeHobCacheBufferSize, @@ -1726,6 +1683,27 @@ SmmVariableReady ( &mVariableAuthFormat ); if (!EFI_ERROR (Status)) { + GuidHob =3D GetFirstGuidHob (&gEdkiiVariableRuntimeCacheInfoHobGuid)= ; + ASSERT (GuidHob !=3D NULL); + VariableRuntimeCacheHob =3D GET_GUID_HOB_DATA (GuidHob); + AllocatedHobCacheSize =3D EFI_PAGES_TO_SIZE (VariableRuntimeCac= heHob->RuntimeHobCachePages); + AllocatedNvCacheSize =3D EFI_PAGES_TO_SIZE (VariableRuntimeCac= heHob->RuntimeNvCachePages); + AllocatedVolatileCacheSize =3D EFI_PAGES_TO_SIZE (VariableRuntimeCac= heHob->RuntimeVolatileCachePages); + + ASSERT ( + (AllocatedHobCacheSize >=3D mVariableRuntimeHobCacheBufferSize) && + (AllocatedNvCacheSize >=3D RuntimeNvCacheSize) && + (AllocatedVolatileCacheSize >=3D RuntimeVolatileCacheSize) + ); + + mVariableRuntimeHobCacheBuffer =3D (VARIABLE_STORE_HEADER *)(UI= NTN)VariableRuntimeCacheHob->RuntimeHobCacheBuffer; + mVariableRuntimeNvCacheBuffer =3D (VARIABLE_STORE_HEADER *)(UI= NTN)VariableRuntimeCacheHob->RuntimeNvCacheBuffer; + mVariableRuntimeVolatileCacheBuffer =3D (VARIABLE_STORE_HEADER *)(UI= NTN)VariableRuntimeCacheHob->RuntimeVolatileCacheBuffer; + mVariableRuntimeCachePendingUpdate =3D &VariableRuntimeCacheHob->Ca= cheInfoFlag->PendingUpdate; + mVariableRuntimeCacheReadLock =3D &VariableRuntimeCacheHob->Ca= cheInfoFlag->ReadLock; + mHobFlushComplete =3D &VariableRuntimeCacheHob->Ca= cheInfoFlag->HobFlushComplete; + mVariableRuntimeHobCacheBufferSize =3D AllocatedHobCacheSize; + Status =3D InitVariableCache (&mVariableRuntimeHobCacheBuffer, &mVar= iableRuntimeHobCacheBufferSize); if (!EFI_ERROR (Status)) { Status =3D InitVariableCache (&mVariableRuntimeNvCacheBuffer, &Run= timeNvCacheSize); diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeD= xe.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.i= nf index e1085653fe..2d16f28674 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf @@ -13,7 +13,7 @@ # may not be modified without authorization. If platform fails to protect= these resources, # the authentication service provided in this driver will be broken, and = the behavior is undefined. # -# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2024, Intel Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -60,7 +60,7 @@ TpmMeasurementLib SafeIntLib PcdLib - MmUnblockMemoryLib + HobLib [Protocols] gEfiVariableWriteArchProtocolGuid ## PRODUCES @@ -113,6 +113,7 @@ gVarCheckPolicyLibMmiHandlerGuid gEfiEndOfDxeEventGroupGuid gEfiDeviceSignatureDatabaseGuid + gEdkiiVariableRuntimeCacheInfoHobGuid [Depex] gEfiMmCommunication2ProtocolGuid -- 2.31.1.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 (#119074): https://edk2.groups.io/g/devel/message/119074 Mute This Topic: https://groups.io/mt/106150805/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- --_000_MN6PR11MB82445BB018660BE58E0D21D98CE92MN6PR11MB8244namp_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
Kun,
Good to know that you have no concerns on the patch. The patch set aims to = finalize the unblock memory regions before standalone MM env is launched.
The PeiNotifyPpi() can still notify the PPI callback when the PPI has been = installed already.

Thanks,
Ray

From: Kun Qin <Kun.Qin@m= icrosoft.com>
Sent: Saturday, May 18, 2024 1:09
To: Ni, Ray <ray.ni@intel.com>; Tan, Dun <dun.tan@intel.com= >; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Liming Gao <gaoliming@byosoft.com.cn>; Sean Brogan <sea= n.brogan@microsoft.com>
Subject: RE: [PATCH 7/9] MdeModulePkg:Consume gEdkiiVariableRuntimeC= acheInfoHobGuid
 

Hi Ray & Dun,

 

Thanks for adding me to the patch. I think the p= roposed solution should work. One question, which is actually on the hob cr= eator patch (https://edk2.groups.io/g/devel/message/119022), is that I understand the hob creation depends on =93gEfiPeiMemoryDiscovere= dPpiGuid=94, but does this routine still run properly if variable PEIM is l= oaded much later than memory discovered?

 

Regards,

Kun

 

From: Ni, Ray <ray.ni@intel.c= om>
Sent: Friday, May 17, 2024 5:10 AM
To: Tan, Dun <dun.tan@intel.com>; devel@edk2.groups.io
Cc: Liming Gao <gaoliming@byosoft.com.cn>; Kun Qin <Kun.Qin= @microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
Subject: [EXTERNAL] Re: [PATCH 7/9] MdeModulePkg:Consume gEdkiiVaria= bleRuntimeCacheInfoHobGuid

 

Revi= ewed-by: Ray Ni <ray.ni@intel.com>

&nbs= p;

Than= ks,

Ray<= /span>


From: = Tan, Dun <dun.tan@intel.co= m>
Sent: Friday, May 17, 2024 17:49
To:
devel@edk2.grou= ps.io <devel@edk2.groups.io>
Cc: Ni, Ray <
ray.ni@= intel.com>; Liming Gao <gaoliming@byosoft.com.cn>
Subject: [PATCH 7/9] MdeModulePkg:Consume gEdkiiVariableRuntimeCache= InfoHobGuid

 

Consume gEdkiiVariableRuntimeCacheInfoHobGuid in

VariableSmmRuntimeDxe driver to initialize the following

variable cache related buffer:
  *mVariableRuntimeHobCacheBuffer
  *mVariableRuntimeNvCacheBuffer
  *mVariableRuntimeVolatileCacheBuffer
  *mVariableRuntimeCachePendingUpdate
  *mVariableRuntimeCacheReadLock
  *mHobFlushComplete

The code to to allocate
and unblock the buffer for
different type cache in VariableSmmRuntimeDxe is also
removed in this commit.

Signed-off-by: Dun Tan <
dun.tan@intel.com>
Cc: Ray Ni <
ray.ni@intel.com>
Cc: Liming Gao <
gaoliming@byosoft.com.cn>

Cc: Jiaxin Wu <
jiaxin.wu@intel.com>
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c&nb= sp;  | 120 +++++++++++++++++++++++++++++++++++++++++++++++++----------= -------------------------------------------------------------
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf = |   5 +++--
 2 files changed, 52 insertions(+), 73 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeD= xe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c index 8b42ae7d72..68a249c5ac 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c @@ -35,10 +35,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/DebugLib.h>
 #include <Library/UefiLib.h>
 #include <Library/BaseLib.h>
-#include <Library/MmUnblockMemoryLib.h>
+#include <Library/HobLib.h>
 
 #include <Guid/EventGroup.h>
 #include <Guid/SmmVariableCommon.h>
+#include <Guid/VariableRuntimeCacheInfo.h>
 
 #include "PrivilegePolymorphic.h"
 #include "VariableParsing.h"
@@ -56,10 +57,10 @@ VARIABLE_STORE_HEADER     &nbs= p;     *mVariableRuntimeVolatileCacheBuffer =3D NULL;  UINTN          &nbs= p;            &= nbsp;   mVariableBufferSize;
 UINTN          &nbs= p;            &= nbsp;   mVariableRuntimeHobCacheBufferSize;
 UINTN          &nbs= p;            &= nbsp;   mVariableBufferPayloadSize;
-BOOLEAN           &= nbsp;           &nbs= p; mVariableRuntimeCachePendingUpdate;
-BOOLEAN           &= nbsp;           &nbs= p; mVariableRuntimeCacheReadLock;
+BOOLEAN           &= nbsp;           &nbs= p; *mVariableRuntimeCachePendingUpdate;
+BOOLEAN           &= nbsp;           &nbs= p; *mVariableRuntimeCacheReadLock;
 BOOLEAN          &n= bsp;            = ;  mVariableAuthFormat;
-BOOLEAN           &= nbsp;           &nbs= p; mHobFlushComplete;
+BOOLEAN           &= nbsp;           &nbs= p; *mHobFlushComplete;
 EFI_LOCK          &= nbsp;           &nbs= p; mVariableServicesLock;
 EDKII_VARIABLE_LOCK_PROTOCOL    mVariableLock;
 EDKII_VAR_CHECK_PROTOCOL        mV= arCheck;
@@ -180,27 +181,6 @@ InitVariableCache (
 
   *TotalVariableCacheSize =3D ALIGN_VALUE (*TotalVariableCacheSi= ze, sizeof (UINT32));
 
-  //
-  // Allocate NV Storage Cache and initialize it to all 1's (like an = erased FV)
-  //
-  *VariableCacheBuffer =3D  (VARIABLE_STORE_HEADER *)AllocateRun= timePages (
-            &n= bsp;            = ;            &n= bsp;            = ;   EFI_SIZE_TO_PAGES (*TotalVariableCacheSize)
-            &n= bsp;            = ;            &n= bsp;            = ;   );
-  if (*VariableCacheBuffer =3D=3D NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  //
-  // Request to unblock the newly allocated cache region to be access= ible from inside MM
-  //
-  Status =3D MmUnblockMemoryRequest (
-             (= EFI_PHYSICAL_ADDRESS)(UINTN)*VariableCacheBuffer,
-             E= FI_SIZE_TO_PAGES (*TotalVariableCacheSize)
-             )= ;
-  if ((Status !=3D EFI_UNSUPPORTED) && EFI_ERROR (Status)) {<= br> -    return Status;
-  }
-
   VariableCacheStorePtr =3D *VariableCacheBuffer;
   SetMem32 ((VOID *)VariableCacheStorePtr, *TotalVariableCacheSi= ze, (UINT32)0xFFFFFFFF);
 
@@ -568,16 +548,16 @@ CheckForRuntimeCacheSync (
   VOID
   )
 {
-  if (mVariableRuntimeCachePendingUpdate) {
+  if (*mVariableRuntimeCachePendingUpdate) {
     SyncRuntimeCache ();
   }
 
-  ASSERT (!mVariableRuntimeCachePendingUpdate);
+  ASSERT (!(*mVariableRuntimeCachePendingUpdate));
 
   //
   // The HOB variable data may have finished being flushed in th= e runtime cache sync update
   //
-  if (mHobFlushComplete && (mVariableRuntimeHobCacheBuffer != =3D NULL)) {
+  if ((*mHobFlushComplete) && (mVariableRuntimeHobCacheBuffer= !=3D NULL)) {
     if (!EfiAtRuntime ()) {
       FreePages (mVariableRuntimeHobCacheBuf= fer, EFI_SIZE_TO_PAGES (mVariableRuntimeHobCacheBufferSize));
     }
@@ -633,12 +613,12 @@ FindVariableInRuntimeCache (
   // a GetVariable () or GetNextVariable () call from being issu= ed until a prior call has returned. The runtime
   // cache read lock should always be free when entering this fu= nction.
   //
-  ASSERT (!mVariableRuntimeCacheReadLock);
+  ASSERT (!(*mVariableRuntimeCacheReadLock));
 
-  mVariableRuntimeCacheReadLock =3D TRUE;
+  *mVariableRuntimeCacheReadLock =3D TRUE;
   CheckForRuntimeCacheSync ();
 
-  if (!mVariableRuntimeCachePendingUpdate) {
+  if (!(*mVariableRuntimeCachePendingUpdate)) {
     //
     // 0: Volatile, 1: HOB, 2: Non-Volatile.
     // The index and attributes mapping must be kept i= n this order as FindVariable
@@ -698,7 +678,7 @@ Done:
     }
   }
 
-  mVariableRuntimeCacheReadLock =3D FALSE;
+  *mVariableRuntimeCacheReadLock =3D FALSE;
 
   return Status;
 }
@@ -921,12 +901,12 @@ GetNextVariableNameInRuntimeCache (
   // a GetVariable () or GetNextVariable () call from being issu= ed until a prior call has returned. The runtime
   // cache read lock should always be free when entering this fu= nction.
   //
-  ASSERT (!mVariableRuntimeCacheReadLock);
+  ASSERT (!(*mVariableRuntimeCacheReadLock));
 
   CheckForRuntimeCacheSync ();
 
-  mVariableRuntimeCacheReadLock =3D TRUE;
-  if (!mVariableRuntimeCachePendingUpdate) {
+  *mVariableRuntimeCacheReadLock =3D TRUE;
+  if (!(*mVariableRuntimeCachePendingUpdate)) {
     //
     // 0: Volatile, 1: HOB, 2: Non-Volatile.
     // The index and attributes mapping must be kept i= n this order as FindVariable
@@ -958,7 +938,7 @@ GetNextVariableNameInRuntimeCache (
     }
   }
 
-  mVariableRuntimeCacheReadLock =3D FALSE;
+  *mVariableRuntimeCacheReadLock =3D FALSE;
 
   return Status;
 }
@@ -1622,37 +1602,9 @@ SendRuntimeVariableCacheContextToSmm (
   SmmRuntimeVarCacheContext->RuntimeHobCache   = ;   =3D mVariableRuntimeHobCacheBuffer;
   SmmRuntimeVarCacheContext->RuntimeVolatileCache =3D mVariab= leRuntimeVolatileCacheBuffer;
   SmmRuntimeVarCacheContext->RuntimeNvCache   =     =3D mVariableRuntimeNvCacheBuffer;
-  SmmRuntimeVarCacheContext->PendingUpdate    =     =3D &mVariableRuntimeCachePendingUpdate;
-  SmmRuntimeVarCacheContext->ReadLock     = ;        =3D &mVariableRuntimeCacheR= eadLock;
-  SmmRuntimeVarCacheContext->HobFlushComplete   &nb= sp; =3D &mHobFlushComplete;
-
-  //
-  // Request to unblock this region to be accessible from inside MM e= nvironment
-  // These fields "should" be all on the same page, but jus= t to be on the safe side...
-  //
-  Status =3D MmUnblockMemoryRequest (
-             (= EFI_PHYSICAL_ADDRESS)ALIGN_VALUE ((UINTN)SmmRuntimeVarCacheContext->Pend= ingUpdate - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE),
-             E= FI_SIZE_TO_PAGES (sizeof (mVariableRuntimeCachePendingUpdate))
-             )= ;
-  if ((Status !=3D EFI_UNSUPPORTED) && EFI_ERROR (Status)) {<= br> -    goto Done;
-  }
-
-  Status =3D MmUnblockMemoryRequest (
-             (= EFI_PHYSICAL_ADDRESS)ALIGN_VALUE ((UINTN)SmmRuntimeVarCacheContext->Read= Lock - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE),
-             E= FI_SIZE_TO_PAGES (sizeof (mVariableRuntimeCacheReadLock))
-             )= ;
-  if ((Status !=3D EFI_UNSUPPORTED) && EFI_ERROR (Status)) {<= br> -    goto Done;
-  }
-
-  Status =3D MmUnblockMemoryRequest (
-             (= EFI_PHYSICAL_ADDRESS)ALIGN_VALUE ((UINTN)SmmRuntimeVarCacheContext->HobF= lushComplete - EFI_PAGE_SIZE + 1, EFI_PAGE_SIZE),
-             E= FI_SIZE_TO_PAGES (sizeof (mHobFlushComplete))
-             )= ;
-  if ((Status !=3D EFI_UNSUPPORTED) && EFI_ERROR (Status)) {<= br> -    goto Done;
-  }
+  SmmRuntimeVarCacheContext->PendingUpdate    =     =3D mVariableRuntimeCachePendingUpdate;
+  SmmRuntimeVarCacheContext->ReadLock     = ;        =3D mVariableRuntimeCacheReadLo= ck;
+  SmmRuntimeVarCacheContext->HobFlushComplete   &nb= sp; =3D mHobFlushComplete;
 
   //
   // Send data to SMM.
@@ -1688,9 +1640,14 @@ SmmVariableReady (
   IN  VOID       *Context
   )
 {
-  EFI_STATUS  Status;
-  UINTN       RuntimeNvCacheSize;
-  UINTN       RuntimeVolatileCacheSize;=
+  EFI_STATUS         &nb= sp;         Status;
+  UINTN          &n= bsp;            = ; RuntimeNvCacheSize;
+  UINTN          &n= bsp;            = ; RuntimeVolatileCacheSize;
+  UINTN          &n= bsp;            = ; AllocatedHobCacheSize;
+  UINTN          &n= bsp;            = ; AllocatedNvCacheSize;
+  UINTN          &n= bsp;            = ; AllocatedVolatileCacheSize;
+  EFI_HOB_GUID_TYPE        &n= bsp;   *GuidHob;
+  VARIABLE_RUNTIME_CACHE_INFO  *VariableRuntimeCacheHob;
 
   Status =3D gBS->LocateProtocol (&gEfiSmmVariableProtoco= lGuid, NULL, (VOID **)&mSmmVariable);
   if (EFI_ERROR (Status)) {
@@ -1717,7 +1674,7 @@ SmmVariableReady (
   if (FeaturePcdGet (PcdEnableVariableRuntimeCache)) {
     DEBUG ((DEBUG_INFO, "Variable driver runtime = cache is enabled.\n"));
     //
-    // Allocate runtime variable cache memory buffers.
+    // Get needed runtime cache buffer size and check if au= th variables are to be used from SMM
     //
     Status =3D  GetRuntimeCacheInfo (
            &nb= sp;    &mVariableRuntimeHobCacheBufferSize,
@@ -1726,6 +1683,27 @@ SmmVariableReady (
            &nb= sp;    &mVariableAuthFormat
            &nb= sp;    );
     if (!EFI_ERROR (Status)) {
+      GuidHob =3D GetFirstGuidHob (&gEdkiiVar= iableRuntimeCacheInfoHobGuid);
+      ASSERT (GuidHob !=3D NULL);
+      VariableRuntimeCacheHob    = =3D GET_GUID_HOB_DATA (GuidHob);
+      AllocatedHobCacheSize   &nbs= p;  =3D EFI_PAGES_TO_SIZE (VariableRuntimeCacheHob->RuntimeHobCache= Pages);
+      AllocatedNvCacheSize    = ;   =3D EFI_PAGES_TO_SIZE (VariableRuntimeCacheHob->RuntimeNvC= achePages);
+      AllocatedVolatileCacheSize =3D EFI_PAGES_TO= _SIZE (VariableRuntimeCacheHob->RuntimeVolatileCachePages);
+
+      ASSERT (
+        (AllocatedHobCacheSize >=3D = mVariableRuntimeHobCacheBufferSize) &&
+        (AllocatedNvCacheSize >=3D R= untimeNvCacheSize) &&
+        (AllocatedVolatileCacheSize >= ;=3D RuntimeVolatileCacheSize)
+        );
+
+      mVariableRuntimeHobCacheBuffer  &= nbsp;   =3D (VARIABLE_STORE_HEADER *)(UINTN)VariableRuntimeCacheH= ob->RuntimeHobCacheBuffer;
+      mVariableRuntimeNvCacheBuffer  &n= bsp;    =3D (VARIABLE_STORE_HEADER *)(UINTN)VariableRuntimeC= acheHob->RuntimeNvCacheBuffer;
+      mVariableRuntimeVolatileCacheBuffer =3D (VA= RIABLE_STORE_HEADER *)(UINTN)VariableRuntimeCacheHob->RuntimeVolatileCac= heBuffer;
+      mVariableRuntimeCachePendingUpdate  = =3D &VariableRuntimeCacheHob->CacheInfoFlag->PendingUpdate;
+      mVariableRuntimeCacheReadLock  &n= bsp;    =3D &VariableRuntimeCacheHob->CacheInfoFlag-&= gt;ReadLock;
+      mHobFlushComplete    &n= bsp;            = ;  =3D &VariableRuntimeCacheHob->CacheInfoFlag->HobFlushComp= lete;
+      mVariableRuntimeHobCacheBufferSize  = =3D AllocatedHobCacheSize;
+
       Status =3D InitVariableCache (&mVa= riableRuntimeHobCacheBuffer, &mVariableRuntimeHobCacheBufferSize);
       if (!EFI_ERROR (Status)) {
         Status =3D InitVariableCac= he (&mVariableRuntimeNvCacheBuffer, &RuntimeNvCacheSize);
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeD= xe.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.i= nf
index e1085653fe..2d16f28674 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf<= br> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf<= br> @@ -13,7 +13,7 @@
 #  may not be modified without authorization. If platform fails = to protect these resources,
 #  the authentication service provided in this driver will be br= oken, and the behavior is undefined.
 #
-# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR= >
+# Copyright (c) 2010 - 2024, Intel Corporation. All rights reserved.<BR= >
 # Copyright (c) Microsoft Corporation.<BR>
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -60,7 +60,7 @@
   TpmMeasurementLib
   SafeIntLib
   PcdLib
-  MmUnblockMemoryLib
+  HobLib
 
 [Protocols]
   gEfiVariableWriteArchProtocolGuid     = ;        ## PRODUCES
@@ -113,6 +113,7 @@
   gVarCheckPolicyLibMmiHandlerGuid
   gEfiEndOfDxeEventGroupGuid
   gEfiDeviceSignatureDatabaseGuid
+  gEdkiiVariableRuntimeCacheInfoHobGuid
 
 [Depex]
   gEfiMmCommunication2ProtocolGuid
--
2.31.1.windows.1

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#119074) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_MN6PR11MB82445BB018660BE58E0D21D98CE92MN6PR11MB8244namp_--