From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web09.7377.1578984178043363918 for ; Mon, 13 Jan 2020 22:42:58 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: jian.j.wang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jan 2020 22:42:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,431,1571727600"; d="scan'208";a="305063127" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga001.jf.intel.com with ESMTP; 13 Jan 2020 22:42:56 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 13 Jan 2020 22:42:56 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 13 Jan 2020 22:42:56 -0800 Received: from shsmsx107.ccr.corp.intel.com ([169.254.9.210]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.203]) with mapi id 14.03.0439.000; Tue, 14 Jan 2020 14:42:54 +0800 From: "Wang, Jian J" To: "devel@edk2.groups.io" , "Kubacki, Michael A" CC: "Gao, Liming" , "Kinney, Michael D" , Michael Turner , "Wu, Hao A" Subject: Re: [edk2-devel] [PATCH V1 1/1] MdeModulePkg/Variable: Fix VarErrorFlag RT cache offset calculation Thread-Topic: [edk2-devel] [PATCH V1 1/1] MdeModulePkg/Variable: Fix VarErrorFlag RT cache offset calculation Thread-Index: AQHVymfr57GN2e33OkSU11c3ihA1NKfptZDw Date: Tue, 14 Jan 2020 06:42:53 +0000 Message-ID: References: <20200113231908.29724-1-michael.a.kubacki@intel.com> In-Reply-To: <20200113231908.29724-1-michael.a.kubacki@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDU5NjIyMWMtNzIwMy00YmVmLTgwMmYtY2E5YmUwZWE5NmViIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibXVmRFZZTko0WXVhSFdTQ3ZibGVTUkZqKzNub25LNmVtTFFXUTk2b0Z5ZmdKSTNTcWFcL2pXTWVZRWh3U0F2eUgifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: jian.j.wang@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Michael, I'm not sure sync-ing whole variable cache memory is an efficient operatio= n. What about using mVariableModuleGlobal->NonVolatileLastVariableOffset as Length parameter? Status =3D SynchronizeRuntimeVariableCache ( &mVariableModuleGlobal->VariableGlobal.VariableRuntimeC= acheContext.VariableRuntimeNvCache, 0, mVariableModuleGlobal->NonVolatileLastVariableOffset ); Regards, Jian > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Kubacki, > Michael A > Sent: Tuesday, January 14, 2020 7:19 AM > To: devel@edk2.groups.io > Cc: Gao, Liming ; Kinney, Michael D > ; Michael Turner > ; Wang, Jian J ; Wu= , > Hao A > Subject: [edk2-devel] [PATCH V1 1/1] MdeModulePkg/Variable: Fix VarError= Flag > RT cache offset calculation >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2457 >=20 > This commit fixes an offset calculation that is used to write the > VarErrorFlag UEFI variable to the UEFI variable runtime cache. >=20 > Currently a physical address is used instead of an offset. This > commit changes the offset to zero with a length of the entire > non-volatile variable store so the entire non-volatile variable > store buffer in SMRAM (with the variable update modification) is > copied to the runtime variable cache. This follows the same pattern > used in other SynchronizeRuntimeVariableCache () calls for > consistency. >=20 > * Observable symptom: An exception in SMM will most likely occur > due to the invalid memory reference when the VarErrorFlag variable > is written. The variable is most commonly written when the UEFI > variable store is full. >=20 > * The issue only occurs when the variable runtime cache is enabled > by the following PCD being set to TRUE: > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache >=20 > Fixes: aab3b9b9a1e5e1f3fa966fb1667fc3e6c47e7706 >=20 > Cc: Liming Gao > Cc: Michael D Kinney > Cc: Michael Turner > Cc: Jian J Wang > Cc: Hao A Wu > Signed-off-by: Michael Kubacki > --- > MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > index b0ee5e50d0..d23aea4bc7 100644 > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > @@ -16,7 +16,7 @@ > VariableServiceSetVariable() should also check authenticate data to a= void > buffer overflow, > integer overflow. It should also check attribute to avoid authenticat= ion bypass. >=20 > -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
> (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -335,8 +335,8 @@ RecordVarErrorFlag ( > *VarErrFlag =3D TempFlag; > Status =3D SynchronizeRuntimeVariableCache ( > &mVariableModuleGlobal- > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache, > - (UINTN) VarErrFlag - (UINTN) mNvVariableCache + (UINT= N) > mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase, > - sizeof (TempFlag) > + 0, > + mNvVariableCache->Size > ); > ASSERT_EFI_ERROR (Status); > } > -- > 2.16.2.windows.1 >=20 >=20 >=20