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.web10.5068.1571334259681742665 for ; Thu, 17 Oct 2019 10:44:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=qBiYPoAy; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: michael.a.kubacki@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2019 10:44:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,308,1566889200"; d="scan'208";a="221461865" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 17 Oct 2019 10:44:10 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 17 Oct 2019 10:44:10 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 17 Oct 2019 10:44:10 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 17 Oct 2019 10:44:10 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (104.47.38.51) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 17 Oct 2019 10:44:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eKZGMF6YZbsfwwMYCJ17YvWpHssphYI/HJsvjHnqSLDf/ibwazRmV56v4X/Rldso9u9MUkY1aG1180jAjOKljcowvOMT8kDMyvDMCFHR+P864mD/ralKouU1O111ELuJdCW7zpC3knFjNpFVoRPH/31SXDeQx/y3P4yHwekjjFajUIIgk6BtPQ7BEXY2pGzA9CoZy7+ZI+6ewfOB/t2pqJIUrQK/HyMQsGSyuisKs2lDOZjsRsMIiBSO+qn50RqG1Y6oEZaCvVHU3vabI9xtYDlZD29dg3tx5WwyicD0q00wPJUegMAxSc2JDTilOpNhIdo8L9kRFV9A1BYxCb4IPw== 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-SenderADCheck; bh=YQ4oKje18KIBxRu3wVFvxLOPZebSEcsMG/LjZ8gr5Fo=; b=G/0qbtOB6qjIZ3roFP/UJTvKOUlGG4MSGow3KUUPpJ3beHc/YawrXaKwVS4SWMUmR+Bxd1z/P1OwcAfBuPA/t3emNqtX+kFXnj+B8LFQ9L0NCkSyIhdtCJupgSv9uuyLetM3Fb0oN9sIP1fK+3TnAb4iqAj9rYqfN0dJHE+M0VKXIxlWjdYp6MnrsSw5rgdWmcgq9dyOh0tsrMkKSrpMxjQ+i79ooF1r8fO2sMcre849jugegs3C7yG3a5B8/YleWvZI7dhnvre6Mu9/sg0c5PPPbZt4HOt1CWPKoGUOX6ezl/ct8ziYNs0Qld7xJTCRJCVFpxEfNru/GA9lxmVZiw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YQ4oKje18KIBxRu3wVFvxLOPZebSEcsMG/LjZ8gr5Fo=; b=qBiYPoAyFz8nc8EwKARI/BCbuYuPSyItjwNoSmS2bPPGh44ulRWusrkN1nestIPsIUS/lvrqcWeC6XxfLIYiHIKAqeW+niZW69l6vFm8MlwqAXChrspoKHhVJFNRzT7D+iI4XgT6vSvyMErFjxZrQ9XSDw5vBP3qLViKitMZSRE= Received: from DM6PR11MB3834.namprd11.prod.outlook.com (20.179.17.87) by DM6PR11MB4028.namprd11.prod.outlook.com (20.176.125.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Thu, 17 Oct 2019 17:44:06 +0000 Received: from DM6PR11MB3834.namprd11.prod.outlook.com ([fe80::21f7:6d8d:919b:d755]) by DM6PR11MB3834.namprd11.prod.outlook.com ([fe80::21f7:6d8d:919b:d755%6]) with mapi id 15.20.2347.023; Thu, 17 Oct 2019 17:44:06 +0000 From: "Kubacki, Michael A" To: "Wang, Jian J" , "Wu, Hao A" , "devel@edk2.groups.io" CC: "Bi, Dandan" , Ard Biesheuvel , "Dong, Eric" , Laszlo Ersek , "Gao, Liming" , "Kinney, Michael D" , "Ni, Ray" , "Yao, Jiewen" Subject: Re: [PATCH V4 07/10] MdeModulePkg/Variable: Add RT GetVariable() cache support Thread-Topic: [PATCH V4 07/10] MdeModulePkg/Variable: Add RT GetVariable() cache support Thread-Index: AQHVg/dEMkz3g1SQN02GSjHv0+Y2N6de5PQAgAA19/A= Date: Thu, 17 Oct 2019 17:44:06 +0000 Message-ID: References: <20191014233001.33024-1-michael.a.kubacki@intel.com> <20191014233001.33024-8-michael.a.kubacki@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjUzZjkyMmUtYzJkNC00NTUzLThiNjQtMTkyNTkzOWNlYmE4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVG5EZmpuaEw2Z0xxYlwvdTlcL2tMTjdXcVkyaVpmcGpcL2VJMkRYQk8xMyszdEdcL3JqSHhLTWp2RzgrMXZqUUEwNHoifQ== dlp-reaction: no-action dlp-version: 11.2.0.6 authentication-results: spf=none (sender IP is ) smtp.mailfrom=michael.a.kubacki@intel.com; x-originating-ip: [134.134.136.217] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 04d8195b-7b63-4a3a-80ec-08d753299b93 x-ms-traffictypediagnostic: DM6PR11MB4028: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 01930B2BA8 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(376002)(366004)(39860400002)(136003)(396003)(199004)(189003)(51874003)(13464003)(5660300002)(99286004)(8676002)(102836004)(30864003)(81156014)(81166006)(6436002)(229853002)(446003)(6306002)(316002)(8936002)(2906002)(476003)(55016002)(186003)(52536014)(33656002)(11346002)(9686003)(76176011)(7696005)(53546011)(54906003)(110136005)(486006)(26005)(6506007)(66946007)(64756008)(2501003)(66556008)(66476007)(66446008)(76116006)(4326008)(478600001)(25786009)(7736002)(305945005)(66066001)(256004)(6116002)(6246003)(3846002)(14444005)(14454004)(107886003)(71190400001)(71200400001)(86362001)(74316002)(567084001)(559001)(569006);DIR:OUT;SFP:1102;SCL:1;SRVR:DM6PR11MB4028;H:DM6PR11MB3834.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: fudZ3Cia8CHluwWDb9D905MfsnMwvMsHMhuav2dDkQ04JvfTYuSD9GFq5nwAY1Xl7dT8ni3Nxctu7ULSoFDc/8SD9CdaX7uxTJ9voN2F4aohMY3aeaHRJ6EO1wd7T2OAGH+acuzHBn8xOM1FeCf2Ccc1dc9AgXSaZ6IGN8h/TvEcBFSO0oaZuglBkAk0s0LooUOFmM4d6JXZrw/5TIKI3sjf42yqVij2TF30aUa4s/wgBccLMTMn0NthtnueVGEuiJVwHJEFAxBujZldudvXKFb9ZvyJstkimV8cTo3OPy+kubVT4tR4S0osRRMGrzIWZVIhyZfIH1ObX0mRRNwSMjumu47I1NYuZhan1PUa02d/mzvIYLAQBlmj8E4n3IOFIDyBR95+076c0SFiC+Ulzt0yAbYkxtiCQMMpVHavXZ8= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 04d8195b-7b63-4a3a-80ec-08d753299b93 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Oct 2019 17:44:06.3015 (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: 2fMwgf6RatWvmePvcPcGUVCG0jEn0gSQrLwXvFTGfbrs/1KYVDyCZ8vRk7Zl+CzbzrmZEmZOMKkHlFyl+bYLkedFWtNBJrp4KXvy2Y3hx4U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4028 Return-Path: michael.a.kubacki@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Jian, thanks a lot your analysis. The intention was very much to constrain = the flow of information from SMM to the non-SMM environment and not vice versa during runtime cache= operation. I agree that the buffers pointed to in SMM_VARIABLE_COMMUNICATE_RUNTIME_VAR= IABLE_CACHE_CONTEXT should be checked with VariableSmmIsBufferOutsideSmmValid (). I will send a= V5 with this change. Thanks, Michael > -----Original Message----- > From: Wang, Jian J > Sent: Thursday, October 17, 2019 7:23 AM > To: Wu, Hao A ; Kubacki, Michael A > ; devel@edk2.groups.io > Cc: Bi, Dandan ; Ard Biesheuvel > ; Dong, Eric ; Laszlo Ers= ek > ; Gao, Liming ; Kinney, Michael > D ; Ni, Ray ; Yao, Jiewen > > Subject: RE: [PATCH V4 07/10] MdeModulePkg/Variable: Add RT > GetVariable() cache support >=20 > > > > Again, I would like to ask for help from other reviewers to look at thi= s patch > > (patch 7/10) and the next one (patch 8/10) (at least from the security > > perspective). Any help will be appreciated, thanks in advance. > > >=20 > I'm trying to do a simple analysis below from security perspective. Pleas= e > correct me > if anything wrong. >=20 > The patch added 3 new SMI variable Functions > f(a): > SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT > f(b): SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE > f(c): SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO >=20 > f(a) communication buffer is type of > SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT >=20 > which is defined as > typedef struct { > BOOLEAN *ReadLock; > BOOLEAN *PendingUpdate; > BOOLEAN *HobFlushComplete; > VARIABLE_STORE_HEADER *RuntimeHobCache; > VARIABLE_STORE_HEADER *RuntimeNvCache; > VARIABLE_STORE_HEADER *RuntimeVolatileCache; > } > SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT; >=20 > There're 6 fields (all pointers) in the buffer. SMM will handle them in > following ways > - ReadLock and PendingUpdate are used to avoid race condition between > smm and > non-smm code. I don't think there's security breach here. > - RuntimeHobCache, RuntimeNvCache and RuntimeVolatileCache are buffers > passed > to smm code to simply store variable content. Smm code will not read i= ts > content. > I think this won't bring any security risk. >=20 > The SmmVariableHandler() will call VariableSmmIsBufferOutsideSmmValid() > to make sure the communication buffer is outside of smram. But the handle= r > will > not check the above 6 pointers passed through communication buffer to see > if they > are in non-smram scope. This leaves potential security hole to allow smra= m > buffer > to be passed in from non-smm code. >=20 > f(b) doesn't use communication buffer. It's just used to flush variable c= ache. > Then > no security risk here. >=20 > f(c) uses communication buffer with type of >=20 > typedef struct { > UINTN TotalHobStorageSize; > UINTN TotalNvStorageSize; > UINTN TotalVolatileStorageSize; > BOOLEAN AuthenticatedVariableUsage; > } SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO; >=20 > There's no pointer in the buffer and the SMI handler doesn't read its con= tent > but > just store data into it. I think there's no security risk here. >=20 > I also checked data flow newly introduced between smm and non-smm > boundary. > Most of the data flow is just from smm to non-smm. The only exception is > ReadLock > mentioned above. Generally speaking, I don't find security issue in this = patch > series > except to above pointers passed by communication buffer. >=20 > Regards, > Jian >=20 > > -----Original Message----- > > From: Wu, Hao A > > Sent: Wednesday, October 16, 2019 3:57 PM > > To: Kubacki, Michael A ; > devel@edk2.groups.io > > Cc: Bi, Dandan ; Ard Biesheuvel > > ; Dong, Eric ; Laszlo > Ersek > > ; Gao, Liming ; Kinney, > Michael D > > ; Ni, Ray ; Wang, Jian J > > ; Yao, Jiewen > > Subject: RE: [PATCH V4 07/10] MdeModulePkg/Variable: Add RT > GetVariable() > > cache support > > > > Again, I would like to ask for help from other reviewers to look at thi= s patch > > (patch 7/10) and the next one (patch 8/10) (at least from the security > > perspective). Any help will be appreciated, thanks in advance. > > > > > > One comment inherited from the feedback on the V2 series: > > I saw AtRuntime() is still being added in file VariableSmmRuntimeDxe.c, > could > > you help to double confirm? > > > > Another general level comment is that: > > Please help to update the MdeModulePkg.uni file as well for the introdu= ce > of > > the new PCD. > > > > Inline comments below: > > > > > > > -----Original Message----- > > > From: Kubacki, Michael A > > > Sent: Tuesday, October 15, 2019 7:30 AM > > > To: devel@edk2.groups.io > > > Cc: Bi, Dandan; Ard Biesheuvel; Dong, Eric; Laszlo Ersek; Gao, Liming= ; > Kinney, > > > Michael D; Ni, Ray; Wang, Jian J; Wu, Hao A; Yao, Jiewen > > > Subject: [PATCH V4 07/10] MdeModulePkg/Variable: Add RT > GetVariable() > > > cache support > > > > > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2220 > > > > > > This change reduces SMIs for GetVariable () by maintaining a > > > UEFI variable cache in Runtime DXE in addition to the pre- > > > existing cache in SMRAM. When the Runtime Service GetVariable() > > > is invoked, a Runtime DXE cache is used instead of triggering an > > > SMI to VariableSmm. This can improve overall system performance > > > by servicing variable read requests without rendezvousing all > > > cores into SMM. > > > > > > The runtime cache can be disabled with by setting the FeaturePCD > > > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache > > > to FALSE. If the PCD is set to FALSE, the runtime cache will not be > > > used and an SMI will be triggered for Runtime Service > > > GetVariable () and GetNextVariableName () invocations. > > > > > > The following are important points regarding the behavior of the > > > variable drivers when the variable runtime cache is enabled. > > > > > > 1. All of the non-volatile storage contents are loaded into the > > > cache upon driver load. This one time load operation from storage > > > is preferred as opposed to building the cache on demand. An on- > > > demand cache would require a fallback SMI to load data into the > > > cache as variables are requested. > > > > > > 2. SetVariable () requests will continue to always trigger an SMI. > > > This occurs regardless of whether the variable is volatile or > > > non-volatile. > > > > > > 3. Both volatile and non-volatile variables are cached in a runtime > > > buffer. As is the case in the current EDK II variable driver, they > > > continue to be cached in separate buffers. > > > > > > 4. The cache in Runtime DXE and SMM are intended to be exact copies > > > of one another. All SMM variable accesses only return data from th= e > > > SMM cache. The runtime caches are only updated after the variable = I/O > > > operation is successful in SMM. The runtime caches are only update= d > > > from SMM. > > > > > > 5. Synchronization mechanisms are in place to ensure the runtime cach= e > > > content integrity with the SMM cache. These may result in updates = to > > > runtime cache that are the same in content but different in offset= and > > > size from updates to the SMM cache. > > > > > > When using SMM variables with runtime cache enabled, two caches will > now > > > be present. > > > 1. "Runtime Cache" - Maintained in VariableSmmRuntimeDxe. Used to > > > service > > > Runtime Services GetVariable () and GetNextVariableName () callers= . > > > 2. "SMM Cache" - Maintained in VariableSmm to service SMM > GetVariable () > > > and GetNextVariableName () callers. > > > a. This cache is retained so SMM modules do not operate on data > outside > > > SMRAM. > > > > > > Because a race condition can occur if an SMI occurs during the execut= ion > > > of runtime code reading from the runtime cache, a runtime cache read > lock > > > is introduced that explicitly moves pending updates from SMM to the > > > runtime > > > cache if an SMM update occurs while the runtime cache is locked. Note > that > > > it is not expected a Runtime services call will interrupt SMM process= ing > > > since all CPU cores rendezvous in SMM. > > > > > > It is possible to view UEFI variable read and write statistics by set= ting > > > the gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics > > > FeaturePcd > > > to TRUE and using the VariableInfo UEFI application in MdeModulePkg t= o > > > dump > > > variable statistics to the console. By doing so, a user can view the = number > > > of GetVariable () hits from the Runtime DXE variable driver (Runtime > Cache > > > hits) and the SMM variable driver (SMM Cache hits). SMM Cache hits fo= r > > > GetVariable () will occur when SMM modules invoke GetVariable (). > > > > > > Cc: Dandan Bi > > > Cc: Ard Biesheuvel > > > Cc: Eric Dong > > > Cc: Laszlo Ersek > > > Cc: Liming Gao > > > Cc: Michael D Kinney > > > Cc: Ray Ni > > > Cc: Jian J Wang > > > Cc: Hao A Wu > > > Cc: Jiewen Yao > > > Signed-off-by: Michael Kubacki > > > --- > > > MdeModulePkg/MdeModulePkg.dec = | 12 + > > > > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf > > > | 2 + > > > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf > | 2 > > > + > > > > > > > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.i > > > nf | 20 +- > > > > > > > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf > > > | 2 + > > > MdeModulePkg/Include/Guid/SmmVariableCommon.h = | 29 > +- > > > MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h = | 32 > +- > > > > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeCache.h > > > | 51 ++ > > > MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c = | 50 > +- > > > > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeCache.c > > > | 153 ++++++ > > > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c = | > 114 > > > ++++- > > > > > > > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe. > > > c | 512 +++++++++++++++++++- > > > 12 files changed, 938 insertions(+), 41 deletions(-) > > > > > > diff --git a/MdeModulePkg/MdeModulePkg.dec > > > b/MdeModulePkg/MdeModulePkg.dec > > > index 59b8c21713..a00835cb84 100644 > > > --- a/MdeModulePkg/MdeModulePkg.dec > > > +++ b/MdeModulePkg/MdeModulePkg.dec > > > @@ -641,6 +641,18 @@ > > > # @Prompt Enable Device Path From Text support. > > > > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFrom > > > Text|TRUE|BOOLEAN|0x00010038 > > > > > > + ## Indicates if the UEFI variable runtime cache should be enabled. > > > + # This setting only applies if SMM variables are enabled. When > enabled, all > > > variable > > > + # data for Runtime Service GetVariable () and GetNextVariableName > () > > > calls is retrieved > > > + # from a runtime data buffer referred to as the "runtime cache". = An > SMI is > > > not triggered > > > + # at all for these requests. Variables writes still trigger an SM= I. This can > > > greatly > > > + # reduce overall system SMM usage as most boots tend to issue far > more > > > variable reads > > > + # than writes.

> > > + # TRUE - The UEFI variable runtime cache is enabled.
> > > + # FALSE - The UEFI variable runtime cache is disabled.
> > > + # @Prompt Enable the UEFI variable runtime cache. > > > + > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALS > > > E|BOOLEAN|0x00010039 > > > + > > > ## Indicates if the statistics about variable usage will be collec= ted. This > > > information is > > > # stored as a vendor configuration table into the EFI system tabl= e. > > > # Set this PCD to TRUE to use VariableInfo application in > > > MdeModulePkg\Application directory to get > > > diff --git > > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf > > > index 08a5490787..ceea5d1ff9 100644 > > > --- > > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf > > > +++ > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf > > > @@ -40,6 +40,8 @@ > > > VariableNonVolatile.h > > > VariableParsing.c > > > VariableParsing.h > > > + VariableRuntimeCache.c > > > + VariableRuntimeCache.h > > > PrivilegePolymorphic.h > > > Measurement.c > > > TcgMorLockDxe.c > > > diff --git > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf > > > index 6dc2721b81..bc3033588d 100644 > > > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf > > > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf > > > @@ -49,6 +49,8 @@ > > > VariableNonVolatile.h > > > VariableParsing.c > > > VariableParsing.h > > > + VariableRuntimeCache.c > > > + VariableRuntimeCache.h > > > VarCheck.c > > > Variable.h > > > PrivilegePolymorphic.h > > > diff --git > > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > > > e.inf > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > > > e.inf > > > index 14894e6f13..b5a779a233 100644 > > > --- > > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > > > e.inf > > > +++ > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > > > e.inf > > > @@ -13,7 +13,7 @@ > > > # may not be modified without authorization. If platform fails to p= rotect > > > these resources, > > > # the authentication service provided in this driver will be broken= , and > the > > > behavior is undefined. > > > # > > > -# Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.=
> > > +# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.=
> > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > > # > > > ## > > > @@ -39,6 +39,10 @@ > > > VariableSmmRuntimeDxe.c > > > PrivilegePolymorphic.h > > > Measurement.c > > > + VariableParsing.c > > > + VariableParsing.h > > > + VariableRuntimeCache.c > > > + VariableRuntimeCache.h > > > > > > [Packages] > > > MdePkg/MdePkg.dec > > > @@ -65,7 +69,21 @@ > > > gEdkiiVariableLockProtocolGuid ## PRODUCES > > > gEdkiiVarCheckProtocolGuid ## PRODUCES > > > > > > +[FeaturePcd] > > > + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache > > > ## CONSUMES > > > + gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics > ## > > > CONSUMES > > > + > > > [Guids] > > > + ## PRODUCES ## GUID # Signature of Variable store head= er > > > + ## CONSUMES ## GUID # Signature of Variable store head= er > > > + ## SOMETIMES_PRODUCES ## SystemTable > > > + gEfiAuthenticatedVariableGuid > > > + > > > + ## PRODUCES ## GUID # Signature of Variable store head= er > > > + ## CONSUMES ## GUID # Signature of Variable store head= er > > > + ## SOMETIMES_PRODUCES ## SystemTable > > > + gEfiVariableGuid > > > + > > > gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event > > > gEfiEventExitBootServicesGuid ## CONSUMES ## Event > > > ## CONSUMES ## GUID # Locate protocol > > > diff --git > > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.i > > > nf > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm. > > > inf > > > index f8a3742959..6e17f6cdf5 100644 > > > --- > > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.i > > > nf > > > +++ > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm. > > > inf > > > @@ -49,6 +49,8 @@ > > > VariableNonVolatile.h > > > VariableParsing.c > > > VariableParsing.h > > > + VariableRuntimeCache.c > > > + VariableRuntimeCache.h > > > VarCheck.c > > > Variable.h > > > PrivilegePolymorphic.h > > > diff --git a/MdeModulePkg/Include/Guid/SmmVariableCommon.h > > > b/MdeModulePkg/Include/Guid/SmmVariableCommon.h > > > index c527a59891..ceef44dfd2 100644 > > > --- a/MdeModulePkg/Include/Guid/SmmVariableCommon.h > > > +++ b/MdeModulePkg/Include/Guid/SmmVariableCommon.h > > > @@ -1,7 +1,7 @@ > > > /** @file > > > The file defined some common structures used for communicating > > > between SMM variable module and SMM variable wrapper module. > > > > > > -Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved. > > > +Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved. > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > **/ > > > @@ -9,6 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > #ifndef _SMM_VARIABLE_COMMON_H_ > > > #define _SMM_VARIABLE_COMMON_H_ > > > > > > +#include > > > #include > > > > > > #define EFI_SMM_VARIABLE_WRITE_GUID \ > > > @@ -66,6 +67,16 @@ typedef struct { > > > #define > > > SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_GET 10 > > > > > > #define SMM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE 11 > > > +// > > > +// The payload for this function is > > > > SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT > > > +// > > > +#define > > > > SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT > > > 12 > > > + > > > +#define SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE > 13 > > > +// > > > +// The payload for this function is > > > SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO > > > +// > > > +#define SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO > > > 14 > > > > > > /// > > > /// Size of SMM communicate header, without including the payload. > > > @@ -120,4 +131,20 @@ typedef struct { > > > UINTN VariablePayloadSize; > > > } SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE; > > > > > > +typedef struct { > > > + BOOLEAN *ReadLock; > > > + BOOLEAN *PendingUpdate; > > > + BOOLEAN *HobFlushComplete; > > > + VARIABLE_STORE_HEADER *RuntimeHobCache; > > > + VARIABLE_STORE_HEADER *RuntimeNvCache; > > > + VARIABLE_STORE_HEADER *RuntimeVolatileCache; > > > +} > > > > SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT; > > > + > > > +typedef struct { > > > + UINTN TotalHobStorageSize; > > > + UINTN TotalNvStorageSize; > > > + UINTN TotalVolatileStorageSize; > > > + BOOLEAN AuthenticatedVariableUsage; > > > +} SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO; > > > + > > > #endif // _SMM_VARIABLE_COMMON_H_ > > > diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h > > > index fb574b2e32..0b2bb6ae66 100644 > > > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h > > > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h > > > @@ -64,6 +64,21 @@ typedef enum { > > > VariableStoreTypeMax > > > } VARIABLE_STORE_TYPE; > > > > > > +typedef struct { > > > + UINT32 PendingUpdateOffset; > > > + UINT32 PendingUpdateLength; > > > + VARIABLE_STORE_HEADER *Store; > > > +} VARIABLE_RUNTIME_CACHE; > > > + > > > +typedef struct { > > > + BOOLEAN *ReadLock; > > > + BOOLEAN *PendingUpdate; > > > + BOOLEAN *HobFlushComplete; > > > + VARIABLE_RUNTIME_CACHE VariableRuntimeHobCache; > > > + VARIABLE_RUNTIME_CACHE VariableRuntimeNvCache; > > > + VARIABLE_RUNTIME_CACHE VariableRuntimeVolatileCache; > > > +} VARIABLE_RUNTIME_CACHE_CONTEXT; > > > + > > > typedef struct { > > > VARIABLE_HEADER *CurrPtr; > > > // > > > @@ -79,14 +94,15 @@ typedef struct { > > > } VARIABLE_POINTER_TRACK; > > > > > > typedef struct { > > > - EFI_PHYSICAL_ADDRESS HobVariableBase; > > > - EFI_PHYSICAL_ADDRESS VolatileVariableBase; > > > - EFI_PHYSICAL_ADDRESS NonVolatileVariableBase; > > > - EFI_LOCK VariableServicesLock; > > > - UINT32 ReentrantState; > > > - BOOLEAN AuthFormat; > > > - BOOLEAN AuthSupport; > > > - BOOLEAN EmuNvMode; > > > + EFI_PHYSICAL_ADDRESS HobVariableBase; > > > + EFI_PHYSICAL_ADDRESS VolatileVariableBase; > > > + EFI_PHYSICAL_ADDRESS NonVolatileVariableBase; > > > + VARIABLE_RUNTIME_CACHE_CONTEXT > VariableRuntimeCacheContext; > > > + EFI_LOCK VariableServicesLock; > > > + UINT32 ReentrantState; > > > + BOOLEAN AuthFormat; > > > + BOOLEAN AuthSupport; > > > + BOOLEAN EmuNvMode; > > > } VARIABLE_GLOBAL; > > > > > > typedef struct { > > > diff --git > > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeCache.h > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeCache. > > > h > > > new file mode 100644 > > > index 0000000000..f9804a1d69 > > > --- /dev/null > > > +++ > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeCache. > > > h > > > @@ -0,0 +1,51 @@ > > > +/** @file > > > + The common variable volatile store routines shared by the > DXE_RUNTIME > > > variable > > > + module and the DXE_SMM variable module. > > > + > > > +Copyright (c) 2019, Intel Corporation. All rights reserved.
> > > +SPDX-License-Identifier: BSD-2-Clause-Patent > > > + > > > +**/ > > > + > > > +#ifndef _VARIABLE_RUNTIME_CACHE_H_ > > > +#define _VARIABLE_RUNTIME_CACHE_H_ > > > + > > > +#include "Variable.h" > > > + > > > +/** > > > + Copies any pending updates to runtime variable caches. > > > + > > > + @retval EFI_UNSUPPORTED The volatile store to be updated i= s not > > > initialized properly. > > > + @retval EFI_SUCCESS The volatile store was updated > successfully. > > > + > > > +**/ > > > +EFI_STATUS > > > +FlushPendingRuntimeVariableCacheUpdates ( > > > + VOID > > > + ); > > > + > > > +/** > > > + Synchronizes the runtime variable caches with all pending updates > outside > > > runtime. > > > + > > > + Ensures all conditions are met to maintain coherency for runtime c= ache > > > updates. This function will attempt > > > + to write the given update (and any other pending updates) if the > ReadLock > > > is available. Otherwise, the > > > + update is added as a pending update for the given variable store a= nd it > will > > > be flushed to the runtime cache > > > + at the next opportunity the ReadLock is available. > > > + > > > + @param[in] VariableRuntimeCache Variable runtime cache structure > for > > > the runtime cache being synchronized. > > > + @param[in] Offset Offset in bytes to apply the updat= e. > > > + @param[in] Length Length of data in bytes of the upd= ate. > > > + > > > + @retval EFI_SUCCESS The update was added as a pending > update > > > successfully. If the variable runtime > > > + cache ReadLock was available, the = runtime cache was > > > updated successfully. > > > + @retval EFI_UNSUPPORTED The volatile store to be updated i= s not > > > initialized properly. > > > + > > > +**/ > > > +EFI_STATUS > > > +SynchronizeRuntimeVariableCache ( > > > + IN VARIABLE_RUNTIME_CACHE *VariableRuntimeCache, > > > + IN UINTN Offset, > > > + IN UINTN Length > > > + ); > > > + > > > +#endif > > > diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > > > index 0bd2f22e1a..29d6aca993 100644 > > > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > > > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > > > @@ -25,6 +25,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > #include "Variable.h" > > > #include "VariableNonVolatile.h" > > > #include "VariableParsing.h" > > > +#include "VariableRuntimeCache.h" > > > > > > VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal; > > > > > > @@ -332,6 +333,12 @@ RecordVarErrorFlag ( > > > // Update the data in NV cache. > > > // > > > *VarErrFlag =3D TempFlag; > > > + Status =3D SynchronizeRuntimeVariableCache ( > > > + &mVariableModuleGlobal- > > > > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache, > > > + (UINTN) VarErrFlag - (UINTN) mNvVariableCache + (U= INTN) > > > mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase, > > > + sizeof (TempFlag) > > > + ); > > > + ASSERT_EFI_ERROR (Status); > > > } > > > } > > > } > > > @@ -766,12 +773,24 @@ Reclaim ( > > > > > > Done: > > > if (IsVolatile || mVariableModuleGlobal->VariableGlobal.EmuNvMode) > { > > > + Status =3D SynchronizeRuntimeVariableCache ( > > > + &mVariableModuleGlobal- > > > > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCach > > > e, > > > + 0, > > > + VariableStoreHeader->Size > > > + ); > > > + ASSERT_EFI_ERROR (Status); > > > FreePool (ValidBuffer); > > > } else { > > > // > > > // For NV variable reclaim, we use mNvVariableCache as the buffe= r, so > > > copy the data back. > > > // > > > - CopyMem (mNvVariableCache, (UINT8 *)(UINTN)VariableBase, > > > VariableStoreHeader->Size); > > > + CopyMem (mNvVariableCache, (UINT8 *) (UINTN) VariableBase, > > > VariableStoreHeader->Size); > > > + Status =3D SynchronizeRuntimeVariableCache ( > > > + &mVariableModuleGlobal- > > > > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache, > > > + 0, > > > + VariableStoreHeader->Size > > > + ); > > > + ASSERT_EFI_ERROR (Status); > > > } > > > > > > return Status; > > > @@ -1614,6 +1633,7 @@ UpdateVariable ( > > > VARIABLE_POINTER_TRACK *Variable; > > > VARIABLE_POINTER_TRACK NvVariable; > > > VARIABLE_STORE_HEADER *VariableStoreHeader; > > > + VARIABLE_RUNTIME_CACHE *VolatileCacheInstance; > > > UINT8 *BufferForMerge; > > > UINTN MergedBufSize; > > > BOOLEAN DataReady; > > > @@ -2275,6 +2295,23 @@ UpdateVariable ( > > > } > > > > > > Done: > > > + if (!EFI_ERROR (Status)) { > > > + if (Variable->Volatile) { > > > + VolatileCacheInstance =3D &(mVariableModuleGlobal- > > > > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCach > > > e); > > > + } else { > > > + VolatileCacheInstance =3D &(mVariableModuleGlobal- > > > > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache); > > > + } > > > + > > > + if (VolatileCacheInstance->Store !=3D NULL) { > > > + Status =3D SynchronizeRuntimeVariableCache ( > > > + VolatileCacheInstance, > > > + 0, > > > + VolatileCacheInstance->Store->Size > > > + ); > > > + ASSERT_EFI_ERROR (Status); > > > + } > > > + } > > > + > > > return Status; > > > } > > > > > > @@ -3200,6 +3237,14 @@ FlushHobVariableToFlash ( > > > ErrorFlag =3D TRUE; > > > } > > > } > > > + if (mVariableModuleGlobal- > > > > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeHobCache.S > > > tore !=3D NULL) { > > > + Status =3D SynchronizeRuntimeVariableCache ( > > > + &mVariableModuleGlobal- > > > > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeHobCache, > > > + 0, > > > + mVariableModuleGlobal- > > > > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeHobCache.S > > > tore->Size > > > + ); > > > + ASSERT_EFI_ERROR (Status); > > > + } > > > if (ErrorFlag) { > > > // > > > // We still have HOB variable(s) not flushed in flash. > > > @@ -3210,6 +3255,9 @@ FlushHobVariableToFlash ( > > > // All HOB variables have been flushed in flash. > > > // > > > DEBUG ((EFI_D_INFO, "Variable driver: all HOB variables have b= een > > > flushed in flash.\n")); > > > + if (mVariableModuleGlobal- > > > >VariableGlobal.VariableRuntimeCacheContext.HobFlushComplete !=3D > NULL) > > > { > > > + *(mVariableModuleGlobal- > > > >VariableGlobal.VariableRuntimeCacheContext.HobFlushComplete) =3D > TRUE; > > > + } > > > if (!AtRuntime ()) { > > > FreePool ((VOID *) VariableStoreHeader); > > > } > > > diff --git > > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeCache.c > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeCache.c > > > new file mode 100644 > > > index 0000000000..bc93cc07d2 > > > --- /dev/null > > > +++ > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeCache.c > > > @@ -0,0 +1,153 @@ > > > +/** @file > > > + Functions related to managing the UEFI variable runtime cache. Thi= s file > > > should only include functions > > > + used by the SMM UEFI variable driver. > > > + > > > + Caution: This module requires additional review when modified. > > > + This driver will have external input - variable data. They may be = input in > > > SMM mode. > > > + This external input must be validated carefully to avoid security = issue > like > > > + buffer overflow, integer overflow. > > > + > > > +Copyright (c) 2019, Intel Corporation. All rights reserved.
> > > +SPDX-License-Identifier: BSD-2-Clause-Patent > > > + > > > +**/ > > > + > > > +#include "VariableParsing.h" > > > +#include "VariableRuntimeCache.h" > > > + > > > +extern VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal; > > > +extern VARIABLE_STORE_HEADER *mNvVariableCache; > > > + > > > +/** > > > + Copies any pending updates to runtime variable caches. > > > + > > > + @retval EFI_UNSUPPORTED The volatile store to be updated i= s not > > > initialized properly. > > > + @retval EFI_SUCCESS The volatile store was updated > successfully. > > > + > > > +**/ > > > +EFI_STATUS > > > +FlushPendingRuntimeVariableCacheUpdates ( > > > + VOID > > > + ) > > > +{ > > > + VARIABLE_RUNTIME_CACHE_CONTEXT > *VariableRuntimeCacheContext; > > > + > > > + VariableRuntimeCacheContext =3D &mVariableModuleGlobal- > > > >VariableGlobal.VariableRuntimeCacheContext; > > > + > > > + if (VariableRuntimeCacheContext->VariableRuntimeNvCache.Store =3D= =3D > > > NULL || > > > + VariableRuntimeCacheContext- > >VariableRuntimeVolatileCache.Store =3D=3D > > > NULL || > > > + VariableRuntimeCacheContext->PendingUpdate =3D=3D NULL) { > > > + return EFI_UNSUPPORTED; > > > + } > > > + > > > + if (*(VariableRuntimeCacheContext->PendingUpdate)) { > > > + if (VariableRuntimeCacheContext->VariableRuntimeHobCache.Store > !=3D > > > NULL && > > > + mVariableModuleGlobal->VariableGlobal.HobVariableBase > 0) { > > > + CopyMem ( > > > + (VOID *) ( > > > + ((UINT8 *) (UINTN) VariableRuntimeCacheContext- > > > >VariableRuntimeHobCache.Store) + > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeHobCache.PendingUpdateOffset > > > + ), > > > + (VOID *) ( > > > + ((UINT8 *) (UINTN) mVariableModuleGlobal- > > > >VariableGlobal.HobVariableBase) + > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeHobCache.PendingUpdateOffset > > > + ), > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeHobCache.PendingUpdateLength > > > + ); > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeHobCache.PendingUpdateLength =3D 0; > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeHobCache.PendingUpdateOffset =3D 0; > > > + } > > > + > > > + CopyMem ( > > > + (VOID *) ( > > > + ((UINT8 *) (UINTN) VariableRuntimeCacheContext- > > > >VariableRuntimeNvCache.Store) + > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeNvCache.PendingUpdateOffset > > > + ), > > > + (VOID *) ( > > > + ((UINT8 *) (UINTN) mNvVariableCache) + > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeNvCache.PendingUpdateOffset > > > + ), > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeNvCache.PendingUpdateLength > > > + ); > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeNvCache.PendingUpdateLength =3D 0; > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeNvCache.PendingUpdateOffset =3D 0; > > > + > > > + CopyMem ( > > > + (VOID *) ( > > > + ((UINT8 *) (UINTN) VariableRuntimeCacheContext- > > > >VariableRuntimeVolatileCache.Store) + > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeVolatileCache.PendingUpdateOffset > > > + ), > > > + (VOID *) ( > > > + ((UINT8 *) (UINTN) mVariableModuleGlobal- > > > >VariableGlobal.VolatileVariableBase) + > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeVolatileCache.PendingUpdateOffset > > > + ), > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeVolatileCache.PendingUpdateLength > > > + ); > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeVolatileCache.PendingUpdateLength =3D 0; > > > + VariableRuntimeCacheContext- > > > >VariableRuntimeVolatileCache.PendingUpdateOffset =3D 0; > > > + *(VariableRuntimeCacheContext->PendingUpdate) =3D FALSE; > > > + } > > > + > > > + return EFI_SUCCESS; > > > +} > > > + > > > +/** > > > + Synchronizes the runtime variable caches with all pending updates > outside > > > runtime. > > > + > > > + Ensures all conditions are met to maintain coherency for runtime c= ache > > > updates. This function will attempt > > > + to write the given update (and any other pending updates) if the > ReadLock > > > is available. Otherwise, the > > > + update is added as a pending update for the given variable store a= nd it > will > > > be flushed to the runtime cache > > > + at the next opportunity the ReadLock is available. > > > + > > > + @param[in] VariableRuntimeCache Variable runtime cache structure > for > > > the runtime cache being synchronized. > > > + @param[in] Offset Offset in bytes to apply the updat= e. > > > + @param[in] Length Length of data in bytes of the upd= ate. > > > + > > > + @retval EFI_SUCCESS The update was added as a pending > update > > > successfully. If the variable runtime > > > + cache ReadLock was available, the = runtime cache was > > > updated successfully. > > > + @retval EFI_UNSUPPORTED The volatile store to be updated i= s not > > > initialized properly. > > > + > > > +**/ > > > +EFI_STATUS > > > +SynchronizeRuntimeVariableCache ( > > > + IN VARIABLE_RUNTIME_CACHE *VariableRuntimeCache, > > > + IN UINTN Offset, > > > + IN UINTN Length > > > + ) > > > +{ > > > + if (VariableRuntimeCache =3D=3D NULL) { > > > + return EFI_INVALID_PARAMETER; > > > + } else if (VariableRuntimeCache->Store =3D=3D NULL) { > > > + // The runtime cache may not be active or allocated yet. > > > + // In either case, return EFI_SUCCESS instead of > EFI_NOT_AVAILABLE_YET. > > > + return EFI_SUCCESS; > > > + } > > > + > > > + if (mVariableModuleGlobal- > > > >VariableGlobal.VariableRuntimeCacheContext.PendingUpdate =3D=3D NULL > || > > > + mVariableModuleGlobal- > > > >VariableGlobal.VariableRuntimeCacheContext.ReadLock =3D=3D NULL) { > > > + return EFI_UNSUPPORTED; > > > + } > > > + > > > + if (*(mVariableModuleGlobal- > > > >VariableGlobal.VariableRuntimeCacheContext.PendingUpdate) && > > > + VariableRuntimeCache->PendingUpdateLength > 0) { > > > + VariableRuntimeCache->PendingUpdateLength =3D > > > + (UINT32) ( > > > + MAX ( > > > + (UINTN) (VariableRuntimeCache->PendingUpdateOffset + > > > VariableRuntimeCache->PendingUpdateLength), > > > + Offset + Length > > > + ) - MIN ((UINTN) VariableRuntimeCache->PendingUpdateOffset, > Offset) > > > + ); > > > + VariableRuntimeCache->PendingUpdateOffset =3D > > > + (UINT32) MIN ((UINTN) VariableRuntimeCache- > >PendingUpdateOffset, > > > Offset); > > > + } else { > > > + VariableRuntimeCache->PendingUpdateLength =3D (UINT32) Length; > > > + VariableRuntimeCache->PendingUpdateOffset =3D (UINT32) Offset; > > > + } > > > + *(mVariableModuleGlobal- > > > >VariableGlobal.VariableRuntimeCacheContext.PendingUpdate) =3D TRUE; > > > + > > > + if (*(mVariableModuleGlobal- > > > >VariableGlobal.VariableRuntimeCacheContext.ReadLock) =3D=3D FALSE) { > > > + return FlushPendingRuntimeVariableCacheUpdates (); > > > + } > > > + > > > + return EFI_SUCCESS; > > > +} > > > diff --git > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c > > > index 5e24bc4a62..45814b8996 100644 > > > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c > > > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c > > > @@ -31,6 +31,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > #include > > > #include "Variable.h" > > > #include "VariableParsing.h" > > > +#include "VariableRuntimeCache.h" > > > + > > > +extern VARIABLE_STORE_HEADER *mNvVariableCac= he; > > > > > > BOOLEAN mAtRuntime = =3D FALSE; > > > UINT8 *mVariableBuffe= rPayload =3D NULL; > > > @@ -451,25 +454,29 @@ SmmVariableGetStatistics ( > > > EFI_STATUS > > > EFIAPI > > > SmmVariableHandler ( > > > - IN EFI_HANDLE DispatchHandle, > > > - IN CONST VOID *RegisterContext, > > > - IN OUT VOID *CommBuffer, > > > - IN OUT UINTN *CommBufferSize > > > + IN EFI_HANDLE DispatchHa= ndle, > > > + IN CONST VOID *RegisterC= ontext, > > > + IN OUT VOID *CommBuffe= r, > > > + IN OUT UINTN *CommBuffe= rSize > > > ) > > > { > > > - EFI_STATUS Status; > > > - SMM_VARIABLE_COMMUNICATE_HEADER > > > *SmmVariableFunctionHeader; > > > - SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE > > > *SmmVariableHeader; > > > - SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME > > > *GetNextVariableName; > > > - SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO > > > *QueryVariableInfo; > > > - SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE > > > *GetPayloadSize; > > > - VARIABLE_INFO_ENTRY *VariableInfo; > > > - SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE > *VariableToLock; > > > - SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY > > > *CommVariableProperty; > > > - UINTN InfoSize; > > > - UINTN NameBufferSize; > > > - UINTN CommBufferPayload= Size; > > > - UINTN TempCommBufferSiz= e; > > > + EFI_STATUS Status; > > > + SMM_VARIABLE_COMMUNICATE_HEADER > > > *SmmVariableFunctionHeader; > > > + SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE > > > *SmmVariableHeader; > > > + SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME > > > *GetNextVariableName; > > > + SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO > > > *QueryVariableInfo; > > > + SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE > > > *GetPayloadSize; > > > + > > > > SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT > > > *RuntimeVariableCacheContext; > > > + SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO > > > *GetRuntimeCacheInfo; > > > + SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE > > > *VariableToLock; > > > + SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY > > > *CommVariableProperty; > > > + VARIABLE_INFO_ENTRY *VariableI= nfo; > > > + VARIABLE_RUNTIME_CACHE_CONTEXT > > > *VariableCacheContext; > > > + VARIABLE_STORE_HEADER *VariableC= ache; > > > + UINTN InfoSize; > > > + UINTN NameBuffer= Size; > > > + UINTN CommBuffer= PayloadSize; > > > + UINTN TempCommBu= fferSize; > > > > > > // > > > // If input is invalid, stop processing this SMI > > > @@ -789,6 +796,79 @@ SmmVariableHandler ( > > > ); > > > CopyMem (SmmVariableFunctionHeader->Data, > mVariableBufferPayload, > > > CommBufferPayloadSize); > > > break; > > > + case > > > > SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT: > > > + if (CommBufferPayloadSize < sizeof > > > > (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT) > ) > > > { > > > + DEBUG ((DEBUG_ERROR, "InitRuntimeVariableCacheContext: SMM > > > communication buffer size invalid!\n")); > > > + } else if (mEndOfDxe) { > > > + DEBUG ((DEBUG_ERROR, "InitRuntimeVariableCacheContext: > Cannot > > > init context after end of DXE!\n")); > > > + } else { > > > + RuntimeVariableCacheContext =3D > > > > (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT > > > *) SmmVariableFunctionHeader->Data; > > > + VariableCacheContext =3D &mVariableModuleGlobal- > > > >VariableGlobal.VariableRuntimeCacheContext; > > > + > > > + ASSERT (RuntimeVariableCacheContext->RuntimeVolatileCache != =3D > > > NULL); > > > + ASSERT (RuntimeVariableCacheContext->RuntimeNvCache !=3D > NULL); > > > + ASSERT (RuntimeVariableCacheContext->PendingUpdate !=3D NULL= ); > > > + ASSERT (RuntimeVariableCacheContext->ReadLock !=3D NULL); > > > + ASSERT (RuntimeVariableCacheContext->HobFlushComplete !=3D > NULL); > > > + > > > + VariableCacheContext->VariableRuntimeHobCache.Store =3D > > > RuntimeVariableCacheContext->RuntimeHobCache; > > > + VariableCacheContext->VariableRuntimeVolatileCache.Store =3D > > > RuntimeVariableCacheContext->RuntimeVolatileCache; > > > + VariableCacheContext->VariableRuntimeNvCache.Store =3D > > > RuntimeVariableCacheContext->RuntimeNvCache; > > > + VariableCacheContext->PendingUpdate =3D > > > RuntimeVariableCacheContext->PendingUpdate; > > > + VariableCacheContext->ReadLock =3D > > > RuntimeVariableCacheContext->ReadLock; > > > + VariableCacheContext->HobFlushComplete =3D > > > RuntimeVariableCacheContext->HobFlushComplete; > > > + > > > + // Set up the intial pending request since the RT cache need= s to be > in > > > sync with SMM cache > > > + if (mVariableModuleGlobal->VariableGlobal.HobVariableBase = =3D=3D 0) > { > > > + VariableCacheContext- > > > >VariableRuntimeHobCache.PendingUpdateOffset =3D 0; > > > + VariableCacheContext- > > > >VariableRuntimeHobCache.PendingUpdateLength =3D 0; > > > + } else { > > > + VariableCache =3D (VARIABLE_STORE_HEADER *) (UINTN) > > > mVariableModuleGlobal->VariableGlobal.HobVariableBase; > > > + VariableCacheContext- > > > >VariableRuntimeHobCache.PendingUpdateOffset =3D 0; > > > + VariableCacheContext- > > > >VariableRuntimeHobCache.PendingUpdateLength =3D (UINT32) ((UINTN) > > > GetEndPointer (VariableCache) - (UINTN) VariableCache); > > > + CopyGuid (&(VariableCacheContext- > > > >VariableRuntimeHobCache.Store->Signature), &(VariableCache- > > > >Signature)); > > > + } > > > + VariableCache =3D (VARIABLE_STORE_HEADER *) (UINTN) > > > mVariableModuleGlobal->VariableGlobal.VolatileVariableBase; > > > + VariableCacheContext- > > > >VariableRuntimeVolatileCache.PendingUpdateOffset =3D 0; > > > + VariableCacheContext- > > > >VariableRuntimeVolatileCache.PendingUpdateLength =3D (UINT32) > ((UINTN) > > > GetEndPointer (VariableCache) - (UINTN) VariableCache); > > > + CopyGuid (&(VariableCacheContext- > > > >VariableRuntimeVolatileCache.Store->Signature), &(VariableCache- > > > >Signature)); > > > + > > > + VariableCache =3D (VARIABLE_STORE_HEADER *) (UINTN) > > > mNvVariableCache; > > > + VariableCacheContext- > > > >VariableRuntimeNvCache.PendingUpdateOffset =3D 0; > > > + VariableCacheContext- > > > >VariableRuntimeNvCache.PendingUpdateLength =3D (UINT32) ((UINTN) > > > GetEndPointer (VariableCache) - (UINTN) VariableCache); > > > + CopyGuid (&(VariableCacheContext- > >VariableRuntimeNvCache.Store- > > > >Signature), &(VariableCache->Signature)); > > > + > > > + *(VariableCacheContext->PendingUpdate) =3D TRUE; > > > + *(VariableCacheContext->ReadLock) =3D FALSE; > > > + *(VariableCacheContext->HobFlushComplete) =3D FALSE; > > > + } > > > + Status =3D EFI_SUCCESS; > > > + break; > > > + case SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE: > > > + Status =3D FlushPendingRuntimeVariableCacheUpdates (); > > > + break; > > > + case SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO: > > > + if (CommBufferPayloadSize < sizeof > > > (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO)) { > > > + DEBUG ((DEBUG_ERROR, "GetRuntimeCacheInfo: SMM > communication > > > buffer size invalid!\n")); > > > + return EFI_SUCCESS; > > > + } > > > + GetRuntimeCacheInfo =3D > > > (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO *) > > > SmmVariableFunctionHeader->Data; > > > + > > > + if (mVariableModuleGlobal->VariableGlobal.HobVariableBase > 0)= { > > > + VariableCache =3D (VARIABLE_STORE_HEADER *) (UINTN) > > > mVariableModuleGlobal->VariableGlobal.HobVariableBase; > > > + GetRuntimeCacheInfo->TotalHobStorageSize =3D VariableCache- > >Size; > > > + } else { > > > + GetRuntimeCacheInfo->TotalHobStorageSize =3D 0; > > > + } > > > + > > > + VariableCache =3D (VARIABLE_STORE_HEADER *) (UINTN) > > > mVariableModuleGlobal->VariableGlobal.VolatileVariableBase; > > > + GetRuntimeCacheInfo->TotalVolatileStorageSize =3D VariableCach= e- > >Size; > > > + VariableCache =3D (VARIABLE_STORE_HEADER *) (UINTN) > > > mNvVariableCache; > > > + GetRuntimeCacheInfo->TotalNvStorageSize =3D (UINTN) > VariableCache- > > > >Size; > > > + GetRuntimeCacheInfo->AuthenticatedVariableUsage =3D > > > mVariableModuleGlobal->VariableGlobal.AuthFormat; > > > + > > > + Status =3D EFI_SUCCESS; > > > + break; > > > > > > default: > > > Status =3D EFI_UNSUPPORTED; > > > diff --git > > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > > > e.c > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > > > e.c > > > index 0a1888e5ef..e236ddff33 100644 > > > --- > > > > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > > > e.c > > > +++ > > > > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx > > > e.c > > > @@ -13,7 +13,7 @@ > > > > > > InitCommunicateBuffer() is really function to check the variable d= ata > size. > > > > > > -Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. > > > +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved. > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > > > **/ > > > @@ -39,6 +39,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > #include > > > > > > #include "PrivilegePolymorphic.h" > > > +#include "VariableParsing.h" > > > > > > EFI_HANDLE mHandle =3D NULL= ; > > > EFI_SMM_VARIABLE_PROTOCOL *mSmmVariable =3D NULL= ; > > > @@ -46,8 +47,19 @@ EFI_EVENT > mVirtualAddressChangeEvent =3D > > > NULL; > > > EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication > =3D > > > NULL; > > > UINT8 *mVariableBuffer =3D NULL= ; > > > UINT8 *mVariableBufferPhysical =3D NULL= ; > > > +VARIABLE_INFO_ENTRY *mVariableInfo =3D NULL= ; > > > +VARIABLE_STORE_HEADER *mVariableRuntimeHobCacheBuffer > =3D > > > NULL; > > > +VARIABLE_STORE_HEADER *mVariableRuntimeNvCacheBuffer > =3D > > > NULL; > > > +VARIABLE_STORE_HEADER > *mVariableRuntimeVolatileCacheBuffer > > > =3D NULL; > > > UINTN mVariableBufferSize; > > > +UINTN mVariableRuntimeHobCacheBufferSize; > > > +UINTN mVariableRuntimeNvCacheBufferSize; > > > +UINTN mVariableRuntimeVolatileCacheBuffer= Size; > > > UINTN mVariableBufferPayloadSize; > > > +BOOLEAN mVariableRuntimeCachePendingUpdate; > > > +BOOLEAN mVariableRuntimeCacheReadLock; > > > +BOOLEAN mVariableAuthFormat; > > > +BOOLEAN mHobFlushComplete; > > > EFI_LOCK mVariableServicesLock; > > > EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock; > > > EDKII_VAR_CHECK_PROTOCOL mVarCheck; > > > @@ -107,6 +119,72 @@ ReleaseLockOnlyAtBootTime ( > > > } > > > } > > > > > > +/** > > > + Return TRUE if ExitBootServices () has been called. > > > + > > > + @retval TRUE If ExitBootServices () has been called. FALSE if > > > ExitBootServices () has not been called. > > > +**/ > > > +BOOLEAN > > > +AtRuntime ( > > > + VOID > > > + ) > > > +{ > > > + return EfiAtRuntime (); > > > +} > > > + > > > +/** > > > + Initialize the variable cache buffer as an empty variable store. > > > + > > > + @param[out] VariableCacheBuffer A pointer to pointer of a = cache > > > variable store. > > > + @param[in,out] TotalVariableCacheSize On input, the minimum size > > > needed for the UEFI variable store cache > > > + buffer that is allocated. = On output, the actual size > of > > > the buffer allocated. > > > + If TotalVariableCacheSize = is zero, a buffer will not > be > > > allocated and the > > > + function will return with = EFI_SUCCESS. > > > + > > > + @retval EFI_SUCCESS The variable cache was allocated a= nd > initialized > > > successfully. > > > + @retval EFI_INVALID_PARAMETER A given pointer is NULL or an > invalid > > > variable store size was specified. > > > + @retval EFI_OUT_OF_RESOURCES Insufficient resources are availab= le > to > > > allocate the variable store cache buffer. > > > + > > > +**/ > > > +EFI_STATUS > > > +InitVariableCache ( > > > + OUT VARIABLE_STORE_HEADER **VariableCacheBuffer, > > > + IN OUT UINTN *TotalVariableCacheSize > > > + ) > > > +{ > > > + VARIABLE_STORE_HEADER *VariableCacheStorePtr; > > > + > > > + if (TotalVariableCacheSize =3D=3D NULL) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + if (*TotalVariableCacheSize =3D=3D 0) { > > > + return EFI_SUCCESS; > > > + } > > > + if (VariableCacheBuffer =3D=3D NULL || *TotalVariableCacheSize < s= izeof > > > (VARIABLE_STORE_HEADER)) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + *TotalVariableCacheSize =3D ALIGN_VALUE (*TotalVariableCacheSize, > sizeof > > > (UINT32)); > > > + > > > + // > > > + // Allocate NV Storage Cache and initialize it to all 1's (like an= erased FV) > > > + // > > > + *VariableCacheBuffer =3D (VARIABLE_STORE_HEADER *) > > > AllocateRuntimePages ( > > > + EFI_SIZE_TO_PAGES (*TotalVariableCacheSi= ze) > > > + ); > > > + if (*VariableCacheBuffer =3D=3D NULL) { > > > + return EFI_OUT_OF_RESOURCES; > > > + } > > > + VariableCacheStorePtr =3D *VariableCacheBuffer; > > > + SetMem32 ((VOID *) VariableCacheStorePtr, *TotalVariableCacheSize, > > > (UINT32) 0xFFFFFFFF); > > > + > > > + ZeroMem ((VOID *) VariableCacheStorePtr, sizeof > > > (VARIABLE_STORE_HEADER)); > > > + VariableCacheStorePtr->Size =3D (UINT32) *TotalVariableCacheSiz= e; > > > + VariableCacheStorePtr->Format =3D VARIABLE_STORE_FORMATTED; > > > + VariableCacheStorePtr->State =3D VARIABLE_STORE_HEALTHY; > > > + > > > + return EFI_SUCCESS; > > > +} > > > + > > > /** > > > Initialize the communicate buffer using DataSize and Function. > > > > > > @@ -425,7 +503,169 @@ Done: > > > } > > > > > > /** > > > - This code finds variable in storage blocks (Volatile or Non-Volati= le). > > > + Signals SMM to synchronize any pending variable updates with the > > > runtime cache(s). > > > + > > > +**/ > > > +VOID > > > +SyncRuntimeCache ( > > > + VOID > > > + ) > > > +{ > > > + // > > > + // Init the communicate buffer. The buffer data size is: > > > + // SMM_COMMUNICATE_HEADER_SIZE + > > > SMM_VARIABLE_COMMUNICATE_HEADER_SIZE. > > > + // > > > + InitCommunicateBuffer (NULL, 0, > > > SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE); > > > + > > > + // > > > + // Send data to SMM. > > > + // > > > + SendCommunicateBuffer (0); > > > +} > > > + > > > +/** > > > + Check whether a SMI must be triggered to retrieve pending cache > updates. > > > + > > > + If the variable HOB was finished being flushed since the last chec= k for a > > > runtime cache update, this function > > > + will prevent the HOB cache from being used for future runtime cach= e > hits. > > > + > > > +**/ > > > +VOID > > > +CheckForRuntimeCacheSync ( > > > + VOID > > > + ) > > > +{ > > > + if (mVariableRuntimeCachePendingUpdate) { > > > + SyncRuntimeCache (); > > > + } > > > + ASSERT (!mVariableRuntimeCachePendingUpdate); > > > + > > > + // > > > + // The HOB variable data may have finished being flushed in the > runtime > > > cache sync update > > > + // > > > + if (mHobFlushComplete && mVariableRuntimeHobCacheBuffer !=3D > NULL) { > > > + if (!EfiAtRuntime ()) { > > > + FreePool (mVariableRuntimeHobCacheBuffer); > > > + } > > > + mVariableRuntimeHobCacheBuffer =3D NULL; > > > + } > > > +} > > > + > > > +/** > > > + Finds the given variable in a runtime cache variable store. > > > + > > > + Caution: This function may receive untrusted input. > > > + The data size is external input, so this function will validate it= carefully > to > > > avoid buffer overflow. > > > + > > > + @param[in] VariableName Name of Variable to be found. > > > + @param[in] VendorGuid Variable vendor GUID. > > > + @param[out] Attributes Attribute value of the variable= found. > > > + @param[in, out] DataSize Size of Data found. If size is = less than > the > > > + data, this value contains the r= equired size. > > > + @param[out] Data Data pointer. > > > + > > > + @retval EFI_SUCCESS Found the specified variable. > > > + @retval EFI_INVALID_PARAMETER Invalid parameter. > > > + @retval EFI_NOT_FOUND The specified variable could no= t be > found. > > > + > > > +**/ > > > +EFI_STATUS > > > +FindVariableInRuntimeCache ( > > > + IN CHAR16 *VariableName, > > > + IN EFI_GUID *VendorGuid, > > > + OUT UINT32 *Attributes OPTIONAL, > > > + IN OUT UINTN *DataSize, > > > + OUT VOID *Data OPTIONAL > > > + ) > > > +{ > > > + EFI_STATUS Status; > > > + UINTN TempDataSize; > > > + VARIABLE_POINTER_TRACK RtPtrTrack; > > > + VARIABLE_STORE_TYPE StoreType; > > > + VARIABLE_STORE_HEADER > *VariableStoreList[VariableStoreTypeMax]; > > > + > > > + Status =3D EFI_NOT_FOUND; > > > + > > > + if (VariableName =3D=3D NULL || VendorGuid =3D=3D NULL || DataSize= =3D=3D > NULL) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > + // > > > + // The UEFI specification restricts Runtime Services callers from > invoking > > > the same or certain other Runtime Service > > > + // functions prior to completion and return from a previous Runtim= e > > > Service call. These restrictions prevent > > > + // a GetVariable () or GetNextVariable () call from being issued u= ntil a > prior > > > call has returned. The runtime > > > + // cache read lock should always be free when entering this functi= on. > > > + // > > > + ASSERT (!mVariableRuntimeCacheReadLock); > > > + > > > + mVariableRuntimeCacheReadLock =3D TRUE; > > > + CheckForRuntimeCacheSync (); > > > + > > > + if (!mVariableRuntimeCachePendingUpdate) { > > > + // > > > + // 0: Volatile, 1: HOB, 2: Non-Volatile. > > > + // The index and attributes mapping must be kept in this order a= s > > > FindVariable > > > + // makes use of this mapping to implement search algorithm. > > > + // > > > + VariableStoreList[VariableStoreTypeVolatile] =3D > > > mVariableRuntimeVolatileCacheBuffer; > > > + VariableStoreList[VariableStoreTypeHob] =3D > > > mVariableRuntimeHobCacheBuffer; > > > + VariableStoreList[VariableStoreTypeNv] =3D > > > mVariableRuntimeNvCacheBuffer; > > > + > > > + for (StoreType =3D (VARIABLE_STORE_TYPE) 0; StoreType < > > > VariableStoreTypeMax; StoreType++) { > > > + if (VariableStoreList[StoreType] =3D=3D NULL) { > > > + continue; > > > + } > > > + > > > + RtPtrTrack.StartPtr =3D GetStartPointer (VariableStoreList[Sto= reType]); > > > + RtPtrTrack.EndPtr =3D GetEndPointer (VariableStoreList[Sto= reType]); > > > + RtPtrTrack.Volatile =3D (BOOLEAN) (StoreType =3D=3D > > > VariableStoreTypeVolatile); > > > + > > > + Status =3D FindVariableEx (VariableName, VendorGuid, FALSE, > &RtPtrTrack, > > > mVariableAuthFormat); > > > + if (!EFI_ERROR (Status)) { > > > + break; > > > + } > > > + } > > > + > > > + if (!EFI_ERROR (Status)) { > > > + // > > > + // Get data size > > > + // > > > + TempDataSize =3D DataSizeOfVariable (RtPtrTrack.CurrPtr, > > > mVariableAuthFormat); > > > + ASSERT (TempDataSize !=3D 0); > > > + > > > + if (*DataSize >=3D TempDataSize) { > > > + if (Data =3D=3D NULL) { > > > + Status =3D EFI_INVALID_PARAMETER; > > > + goto Done; > > > + } > > > + > > > + CopyMem (Data, GetVariableDataPtr (RtPtrTrack.CurrPtr, > > > mVariableAuthFormat), TempDataSize); > > > + if (Attributes !=3D NULL) { > > > + *Attributes =3D RtPtrTrack.CurrPtr->Attributes; > > > + } > > > + > > > + *DataSize =3D TempDataSize; > > > + > > > + UpdateVariableInfo (VariableName, VendorGuid, > RtPtrTrack.Volatile, > > > TRUE, FALSE, FALSE, TRUE, &mVariableInfo); > > > + > > > + Status =3D EFI_SUCCESS; > > > + goto Done; > > > + } else { > > > + *DataSize =3D TempDataSize; > > > + Status =3D EFI_BUFFER_TOO_SMALL; > > > + goto Done; > > > + } > > > + } > > > + } > > > + > > > +Done: > > > + mVariableRuntimeCacheReadLock =3D FALSE; > > > + > > > + return Status; > > > +} > > > + > > > +/** > > > + Finds the given variable in a variable store in SMM. > > > > > > Caution: This function may receive untrusted input. > > > The data size is external input, so this function will validate it= carefully to > > > avoid buffer overflow. > > > @@ -437,20 +677,18 @@ Done: > > > data, this value contains the r= equired size. > > > @param[out] Data Data pointer. > > > > > > + @retval EFI_SUCCESS Found the specified variable. > > > @retval EFI_INVALID_PARAMETER Invalid parameter. > > > - @retval EFI_SUCCESS Find the specified variable. > > > - @retval EFI_NOT_FOUND Not found. > > > - @retval EFI_BUFFER_TO_SMALL DataSize is too small for the r= esult. > > > + @retval EFI_NOT_FOUND The specified variable could no= t be > found. > > > > > > **/ > > > EFI_STATUS > > > -EFIAPI > > > -RuntimeServiceGetVariable ( > > > +FindVariableInSmm ( > > > IN CHAR16 *VariableName, > > > IN EFI_GUID *VendorGuid, > > > OUT UINT32 *Attributes OPTIONAL, > > > IN OUT UINTN *DataSize, > > > - OUT VOID *Data > > > + OUT VOID *Data OPTIONAL > > > ) > > > { > > > EFI_STATUS Status; > > > @@ -474,8 +712,6 @@ RuntimeServiceGetVariable ( > > > return EFI_INVALID_PARAMETER; > > > } > > > > > > - AcquireLockOnlyAtBootTime(&mVariableServicesLock); > > > - > > > // > > > // Init the communicate buffer. The buffer data size is: > > > // SMM_COMMUNICATE_HEADER_SIZE + > > > SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize. > > > @@ -488,7 +724,7 @@ RuntimeServiceGetVariable ( > > > } > > > PayloadSize =3D OFFSET_OF > > > (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + > > > VariableNameSize + TempDataSize; > > > > > > - Status =3D InitCommunicateBuffer ((VOID **)&SmmVariableHeader, > > > PayloadSize, SMM_VARIABLE_FUNCTION_GET_VARIABLE); > > > + Status =3D InitCommunicateBuffer ((VOID **) &SmmVariableHeader, > > > PayloadSize, SMM_VARIABLE_FUNCTION_GET_VARIABLE); > > > if (EFI_ERROR (Status)) { > > > goto Done; > > > } > > > @@ -534,11 +770,58 @@ RuntimeServiceGetVariable ( > > > } > > > > > > Done: > > > + return Status; > > > +} > > > + > > > +/** > > > + This code finds variable in storage blocks (Volatile or Non-Volati= le). > > > + > > > + Caution: This function may receive untrusted input. > > > + The data size is external input, so this function will validate it= carefully > to > > > avoid buffer overflow. > > > + > > > + @param[in] VariableName Name of Variable to be found. > > > + @param[in] VendorGuid Variable vendor GUID. > > > + @param[out] Attributes Attribute value of the variable= found. > > > + @param[in, out] DataSize Size of Data found. If size is = less than > the > > > + data, this value contains the r= equired size. > > > + @param[out] Data Data pointer. > > > + > > > + @retval EFI_INVALID_PARAMETER Invalid parameter. > > > + @retval EFI_SUCCESS Find the specified variable. > > > + @retval EFI_NOT_FOUND Not found. > > > + @retval EFI_BUFFER_TO_SMALL DataSize is too small for the r= esult. > > > + > > > +**/ > > > +EFI_STATUS > > > +EFIAPI > > > +RuntimeServiceGetVariable ( > > > + IN CHAR16 *VariableName, > > > + IN EFI_GUID *VendorGuid, > > > + OUT UINT32 *Attributes OPTIONAL, > > > + IN OUT UINTN *DataSize, > > > + OUT VOID *Data > > > + ) > > > +{ > > > + EFI_STATUS Status; > > > + > > > + if (VariableName =3D=3D NULL || VendorGuid =3D=3D NULL || DataSize= =3D=3D > NULL) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + if (VariableName[0] =3D=3D 0) { > > > + return EFI_NOT_FOUND; > > > + } > > > + > > > + AcquireLockOnlyAtBootTime (&mVariableServicesLock); > > > + if (FeaturePcdGet (PcdEnableVariableRuntimeCache)) { > > > + Status =3D FindVariableInRuntimeCache (VariableName, VendorGuid, > > > Attributes, DataSize, Data); > > > + } else { > > > + Status =3D FindVariableInSmm (VariableName, VendorGuid, Attribut= es, > > > DataSize, Data); > > > + } > > > ReleaseLockOnlyAtBootTime (&mVariableServicesLock); > > > + > > > return Status; > > > } > > > > > > - > > > /** > > > This code Finds the Next available variable. > > > > > > @@ -870,6 +1153,17 @@ OnReadyToBoot ( > > > // > > > SendCommunicateBuffer (0); > > > > > > + // > > > + // Install the system configuration table for variable info data c= aptured > > > + // > > > + if (FeaturePcdGet (PcdEnableVariableRuntimeCache) && > FeaturePcdGet > > > (PcdVariableCollectStatistics)) { > > > + if (mVariableAuthFormat) { > > > + gBS->InstallConfigurationTable (&gEfiAuthenticatedVariableGuid= , > > > mVariableInfo); > > > + } else { > > > + gBS->InstallConfigurationTable (&gEfiVariableGuid, mVariableIn= fo); > > > + } > > > + } > > > + > > > gBS->CloseEvent (Event); > > > } > > > > > > @@ -893,6 +1187,9 @@ VariableAddressChangeEvent ( > > > { > > > EfiConvertPointer (0x0, (VOID **) &mVariableBuffer); > > > EfiConvertPointer (0x0, (VOID **) &mSmmCommunication); > > > + EfiConvertPointer (0x0, (VOID **) > &mVariableRuntimeHobCacheBuffer); > > > + EfiConvertPointer (0x0, (VOID **) > &mVariableRuntimeNvCacheBuffer); > > > + EfiConvertPointer (0x0, (VOID **) > > > &mVariableRuntimeVolatileCacheBuffer); > > > } > > > > > > /** > > > @@ -969,6 +1266,159 @@ Done: > > > return Status; > > > } > > > > > > +/** > > > + This code gets information needed from SMM for runtime cache > > > initialization. > > > + > > > + @param[out] TotalHobStorageSize Output pointer for the tot= al > HOB > > > storage size in bytes. > > > + @param[out] TotalNvStorageSize Output pointer for the tot= al non- > > > volatile storage size in bytes. > > > + @param[out] TotalVolatileStorageSize Output pointer for the tot= al > > > volatile storage size in bytes. > > > + @param[out] AuthenticatedVariableUsage Output pointer that > indicates if > > > authenticated variables are to be used. > > > + > > > + @retval EFI_SUCCESS Retrieved the size success= fully. > > > + @retval EFI_INVALID_PARAMETER TotalNvStorageSize paramet= er > is > > > NULL. > > > + @retval EFI_OUT_OF_RESOURCES The memory resources > needed > > > for a CommBuffer are not available. > > > + @retval Others Could not retrieve the siz= e successfully. > > > + > > > +**/ > > > +EFI_STATUS > > > +GetRuntimeCacheInfo ( > > > + OUT UINTN *TotalHobStorageSize, > > > + OUT UINTN *TotalNvStorageSize, > > > + OUT UINTN *TotalVolatileStorageSize, > > > + OUT BOOLEAN *AuthenticatedVariableUsage > > > + ) > > > +{ > > > + EFI_STATUS Status; > > > + SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO > > > *SmmGetRuntimeCacheInfo; > > > + EFI_SMM_COMMUNICATE_HEADER > > > *SmmCommunicateHeader; > > > + SMM_VARIABLE_COMMUNICATE_HEADER > > > *SmmVariableFunctionHeader; > > > + UINTN CommSize; > > > + UINT8 *CommBuffer; > > > + > > > + SmmGetRuntimeCacheInfo =3D NULL; > > > + CommBuffer =3D mVariableBuffer; > > > + > > > + if (TotalHobStorageSize =3D=3D NULL || TotalNvStorageSize =3D=3D N= ULL || > > > TotalVolatileStorageSize =3D=3D NULL || AuthenticatedVariableUsage = =3D=3D > NULL) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > + if (CommBuffer =3D=3D NULL) { > > > + return EFI_OUT_OF_RESOURCES; > > > + } > > > + > > > + AcquireLockOnlyAtBootTime (&mVariableServicesLock); > > > + > > > + CommSize =3D SMM_COMMUNICATE_HEADER_SIZE + > > > SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof > > > (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO); > > > + ZeroMem (CommBuffer, CommSize); > > > > > > I would suggest to align with the approach of using the pre-alloacted > > communication buffer like those existing functions: > > > > VariableLockRequestToLock() > > VarCheckVariablePropertySet() > > VarCheckVariablePropertyGet() > > RuntimeServiceGetVariable() > > RuntimeServiceGetNextVariableName() > > RuntimeServiceSetVariable() > > RuntimeServiceQueryVariableInfo() > > OnExitBootServices() > > OnReadyToBoot() > > > > They will: > > 1. Use InitCommunicateBuffer() to get the communication buffer (a data > size > > check will be performed in InitCommunicateBuffer); > > 2. Update the communication buffer content; > > 3. Use SendCommunicateBuffer() to send the data to SMM. > > > > There is a similar case for SendRuntimeVariableCacheContextToSmm() as > well. > > > > Best Regards, > > Hao Wu > > > > > > > + > > > + SmmCommunicateHeader =3D (EFI_SMM_COMMUNICATE_HEADER *) > > > CommBuffer; > > > + CopyGuid (&SmmCommunicateHeader->HeaderGuid, > > > &gEfiSmmVariableProtocolGuid); > > > + SmmCommunicateHeader->MessageLength =3D > > > SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof > > > (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO); > > > + > > > + SmmVariableFunctionHeader =3D > > > (SMM_VARIABLE_COMMUNICATE_HEADER *) > SmmCommunicateHeader- > > > >Data; > > > + SmmVariableFunctionHeader->Function =3D > > > SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO; > > > + SmmGetRuntimeCacheInfo =3D > > > (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO *) > > > SmmVariableFunctionHeader->Data; > > > + > > > + // > > > + // Send data to SMM. > > > + // > > > + Status =3D mSmmCommunication->Communicate > (mSmmCommunication, > > > CommBuffer, &CommSize); > > > + ASSERT_EFI_ERROR (Status); > > > + if (CommSize <=3D SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) { > > > + Status =3D EFI_BAD_BUFFER_SIZE; > > > + goto Done; > > > + } > > > + > > > + Status =3D SmmVariableFunctionHeader->ReturnStatus; > > > + if (EFI_ERROR (Status)) { > > > + goto Done; > > > + } > > > + > > > + // > > > + // Get data from SMM. > > > + // > > > + *TotalHobStorageSize =3D SmmGetRuntimeCacheInfo- > >TotalHobStorageSize; > > > + *TotalNvStorageSize =3D SmmGetRuntimeCacheInfo- > >TotalNvStorageSize; > > > + *TotalVolatileStorageSize =3D SmmGetRuntimeCacheInfo- > > > >TotalVolatileStorageSize; > > > + *AuthenticatedVariableUsage =3D SmmGetRuntimeCacheInfo- > > > >AuthenticatedVariableUsage; > > > + > > > +Done: > > > + ReleaseLockOnlyAtBootTime (&mVariableServicesLock); > > > + return Status; > > > +} > > > + > > > +/** > > > + Sends the runtime variable cache context information to SMM. > > > + > > > + @retval EFI_SUCCESS Retrieved the size successfully. > > > + @retval EFI_INVALID_PARAMETER TotalNvStorageSize parameter is > > > NULL. > > > + @retval EFI_OUT_OF_RESOURCES The memory resources needed > for a > > > CommBuffer are not available. > > > + @retval Others Could not retrieve the size succ= essfully.; > > > + > > > +**/ > > > +EFI_STATUS > > > +SendRuntimeVariableCacheContextToSmm ( > > > + VOID > > > + ) > > > +{ > > > + EFI_STATUS Status; > > > + > > > > SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT > > > *SmmRuntimeVarCacheContext; > > > + EFI_SMM_COMMUNICATE_HEADER > > > *SmmCommunicateHeader; > > > + SMM_VARIABLE_COMMUNICATE_HEADER > > > *SmmVariableFunctionHeader; > > > + UINTN CommSize= ; > > > + UINT8 *CommBuf= fer; > > > + > > > + SmmRuntimeVarCacheContext =3D NULL; > > > + CommBuffer =3D mVariableBuffer; > > > + > > > + if (CommBuffer =3D=3D NULL) { > > > + return EFI_OUT_OF_RESOURCES; > > > + } > > > + > > > + AcquireLockOnlyAtBootTime (&mVariableServicesLock); > > > + > > > + // > > > + // Init the communicate buffer. The buffer data size is: > > > + // SMM_COMMUNICATE_HEADER_SIZE + > > > SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof > > > > (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT) > ; > > > + // > > > + CommSize =3D SMM_COMMUNICATE_HEADER_SIZE + > > > SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof > > > > (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT) > ; > > > + ZeroMem (CommBuffer, CommSize); > > > + > > > + SmmCommunicateHeader =3D (EFI_SMM_COMMUNICATE_HEADER *) > > > CommBuffer; > > > + CopyGuid (&SmmCommunicateHeader->HeaderGuid, > > > &gEfiSmmVariableProtocolGuid); > > > + SmmCommunicateHeader->MessageLength =3D > > > SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof > > > > (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT) > ; > > > + > > > + SmmVariableFunctionHeader =3D > > > (SMM_VARIABLE_COMMUNICATE_HEADER *) > SmmCommunicateHeader- > > > >Data; > > > + SmmVariableFunctionHeader->Function =3D > > > > SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT; > > > + SmmRuntimeVarCacheContext =3D > > > > (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT > > > *) SmmVariableFunctionHeader->Data; > > > + > > > + SmmRuntimeVarCacheContext->RuntimeHobCache =3D > > > mVariableRuntimeHobCacheBuffer; > > > + SmmRuntimeVarCacheContext->RuntimeVolatileCache =3D > > > mVariableRuntimeVolatileCacheBuffer; > > > + SmmRuntimeVarCacheContext->RuntimeNvCache =3D > > > mVariableRuntimeNvCacheBuffer; > > > + SmmRuntimeVarCacheContext->PendingUpdate =3D > > > &mVariableRuntimeCachePendingUpdate; > > > + SmmRuntimeVarCacheContext->ReadLock =3D > > > &mVariableRuntimeCacheReadLock; > > > + SmmRuntimeVarCacheContext->HobFlushComplete =3D > > > &mHobFlushComplete; > > > + > > > + // > > > + // Send data to SMM. > > > + // > > > + Status =3D mSmmCommunication->Communicate > (mSmmCommunication, > > > CommBuffer, &CommSize); > > > + ASSERT_EFI_ERROR (Status); > > > + if (CommSize <=3D SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) { > > > + Status =3D EFI_BAD_BUFFER_SIZE; > > > + goto Done; > > > + } > > > + > > > + Status =3D SmmVariableFunctionHeader->ReturnStatus; > > > + if (EFI_ERROR (Status)) { > > > + goto Done; > > > + } > > > + > > > +Done: > > > + ReleaseLockOnlyAtBootTime (&mVariableServicesLock); > > > + return Status; > > > +} > > > + > > > /** > > > Initialize variable service and install Variable Architectural pro= tocol. > > > > > > @@ -985,7 +1435,7 @@ SmmVariableReady ( > > > { > > > EFI_STATUS Status; > > > > > > - Status =3D gBS->LocateProtocol (&gEfiSmmVariableProtocolGuid, NULL= , > > > (VOID **)&mSmmVariable); > > > + Status =3D gBS->LocateProtocol (&gEfiSmmVariableProtocolGuid, NULL= , > > > (VOID **) &mSmmVariable); > > > if (EFI_ERROR (Status)) { > > > return; > > > } > > > @@ -1007,6 +1457,42 @@ SmmVariableReady ( > > > // > > > mVariableBufferPhysical =3D mVariableBuffer; > > > > > > + if (FeaturePcdGet (PcdEnableVariableRuntimeCache)) { > > > + DEBUG ((DEBUG_INFO, "Variable driver runtime cache is > enabled.\n")); > > > + // > > > + // Allocate runtime variable cache memory buffers. > > > + // > > > + Status =3D GetRuntimeCacheInfo ( > > > + &mVariableRuntimeHobCacheBufferSize, > > > + &mVariableRuntimeNvCacheBufferSize, > > > + &mVariableRuntimeVolatileCacheBufferSize, > > > + &mVariableAuthFormat > > > + ); > > > + if (!EFI_ERROR (Status)) { > > > + Status =3D InitVariableCache (&mVariableRuntimeHobCacheBuffer, > > > &mVariableRuntimeHobCacheBufferSize); > > > + if (!EFI_ERROR (Status)) { > > > + Status =3D InitVariableCache (&mVariableRuntimeNvCacheBuffer= , > > > &mVariableRuntimeNvCacheBufferSize); > > > + if (!EFI_ERROR (Status)) { > > > + Status =3D InitVariableCache > (&mVariableRuntimeVolatileCacheBuffer, > > > &mVariableRuntimeVolatileCacheBufferSize); > > > + if (!EFI_ERROR (Status)) { > > > + Status =3D SendRuntimeVariableCacheContextToSmm (); > > > + if (!EFI_ERROR (Status)) { > > > + SyncRuntimeCache (); > > > + } > > > + } > > > + } > > > + } > > > + if (EFI_ERROR (Status)) { > > > + mVariableRuntimeHobCacheBuffer =3D NULL; > > > + mVariableRuntimeNvCacheBuffer =3D NULL; > > > + mVariableRuntimeVolatileCacheBuffer =3D NULL; > > > + } > > > + } > > > + ASSERT_EFI_ERROR (Status); > > > + } else { > > > + DEBUG ((DEBUG_INFO, "Variable driver runtime cache is > disabled.\n")); > > > + } > > > + > > > gRT->GetVariable =3D RuntimeServiceGetVariable; > > > gRT->GetNextVariableName =3D RuntimeServiceGetNextVariableName; > > > gRT->SetVariable =3D RuntimeServiceSetVariable; > > > -- > > > 2.16.2.windows.1 >=20