From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.2597.1579062667685715231 for ; Tue, 14 Jan 2020 20:31:07 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=Dh5hDyvu; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: michael.a.kubacki@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 20:31:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,321,1574150400"; d="scan'208";a="251624320" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 14 Jan 2020 20:31:07 -0800 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Jan 2020 20:31:06 -0800 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.173) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Jan 2020 20:31:06 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=knbv45wQb0sw2apBgBVNu4dbf0xL//4xqyuAO4y0qjxJQG4m4BwTl0O3Qm9FNHQCntRskhwfk9ng6nCqzlgwbWtpnod79ClhMKoleWr/L+iEvpBu0CH9vr7mpVTd9/t3k7dUTfPRyRAYKzX6MutDtTQdtMvpkrjDEr9mLFr06f4O5xFUhJd5DJcHeRbkqJaCHgaSBrOpi6n/FSm0JzeNXsVhWTmNebX15PAj8mSMkypFZ1/fbf57lg6xJQq7vXo+IW5TZ5ClhVUcDwy2dbPoYFnPz1OmMwDkWs6WyJEvUe2pHDYszT9g9SCla4S3CE7t6349WU+2C9v25iyVJ22crQ== 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=GaakTUas6nb+4ibS6I8rCToHyWg9W/5itrS6FDItHFg=; b=ntvlw3BR7IdnIbiqlgCyxp9zB1nfsVlITMMyG4yAfGCvwEzPdS1zqo6RSmfgEY2iOS7qg7oEblsyWzK2iByjvxGKVJ4WTLCWHGn91aamqRKfVw6mtlfdnUA5ioSoj6V213P8wjRAQFrmlJq2sH7rja56VCYq8DEX9zKnchDkHJIdDgpMvUsNE0HCrw0hf6DPocdVLMeP1RhFF3E5kVev91y06hg0kRAyd8k++imougHoXL00C9MAjkYtMbsrbC59L+qrtvuySHqyOkgjpTRWguJ6/VA8fxtEIVUAwCv/Ps6UBy60gMfCwPjRT8M3QH45zylArE1TXl2aZAQFqTpXNg== 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=GaakTUas6nb+4ibS6I8rCToHyWg9W/5itrS6FDItHFg=; b=Dh5hDyvuisivWuAXZMQACqY1YbMxMrUMlC1sFDFGKRCGGUHlNcp5r0VsSJdJjKly2PoKZJN3KqNfvujWOsyXDi3FR6ybLsFj6TIVy9cA9PWDq+sUoCAA/rYW7c+Aa79EeA9xsi49Q1/JVKWwB4+IsMf5e/yeakgTa2p4ClMYun4= Received: from BY5PR11MB4484.namprd11.prod.outlook.com (52.132.254.155) by BY5PR11MB4404.namprd11.prod.outlook.com (52.132.254.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.9; Wed, 15 Jan 2020 04:31:05 +0000 Received: from BY5PR11MB4484.namprd11.prod.outlook.com ([fe80::b9de:29da:2b58:18b3]) by BY5PR11MB4484.namprd11.prod.outlook.com ([fe80::b9de:29da:2b58:18b3%7]) with mapi id 15.20.2644.015; Wed, 15 Jan 2020 04:31:05 +0000 From: "Kubacki, Michael A" To: "Wang, Jian J" , "devel@edk2.groups.io" 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: AQHVymfr57GN2e33OkSU11c3ihA1NKfptZDwgAFHbaCAAB8PMIAAB/CQ Date: Wed, 15 Jan 2020 04:31:05 +0000 Message-ID: References: <20200113231908.29724-1-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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDU5NjIyMWMtNzIwMy00YmVmLTgwMmYtY2E5YmUwZWE5NmViIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibXVmRFZZTko0WXVhSFdTQ3ZibGVTUkZqKzNub25LNmVtTFFXUTk2b0Z5ZmdKSTNTcWFcL2pXTWVZRWh3U0F2eUgifQ== 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: 0cf48cfe-b3ff-4d4f-8540-08d79973bc25 x-ms-traffictypediagnostic: BY5PR11MB4404: 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:849; x-forefront-prvs: 02830F0362 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(376002)(136003)(39860400002)(366004)(189003)(199004)(64756008)(7696005)(8676002)(5660300002)(71200400001)(478600001)(55016002)(9686003)(66946007)(186003)(76116006)(316002)(110136005)(81166006)(81156014)(966005)(54906003)(4326008)(107886003)(33656002)(52536014)(86362001)(8936002)(6506007)(53546011)(66446008)(66556008)(66476007)(26005)(2906002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY5PR11MB4404;H:BY5PR11MB4484.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MD93iaQnnnN9E/F3Pp/Rws1rz8RfkRLwIsrjcULP2KAfVDxikIi0lK9jFRn2LO+V6/fFbMGdGA1k/CVNDrTTfwRHq2c3iVLd8ZrGqhb9dHXPbpiLRrz9aTkOZMoA5o3Z6hrW0CB9EuvBFX7wXDL8Kl3ESc7nj4Gzh4mj91ou6z2dUfyHBLKs8eOSmICJoXaxLEoP0Jj8Ydfbgg1T3X3Ou+6dV0uMMIyu1/5PP5py1Ni5bnFoS4l2zKRInborUEdFb8JUcHq/2Lssg98VxpkYug9kUBzXjEjc5u5K89QTrRv4V6jOmyN+mtmSlh3WvSawvxHbfTjy/yY1oAGkYfYsA+TXgumY3FnKWofpDNaAl82rIfx/VFtgVXN3Uz/cG9mgPtTPlpNTfCIdwEW6HpmPuQzl8+mEmFyyJBYnKxwmFYw6CyO/EM9104u8tqwHVGEqNRBJyjWAbNdljhSShDc3qxKmZ01grk8WOq9/Dfi+cHk= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 0cf48cfe-b3ff-4d4f-8540-08d79973bc25 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 04:31:05.1020 (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: 1jfoloI0+FTEvKZcoGn08Dyrts8JpjPM5znMi5fHrxfs+S+bDEWqO2+pOHYtMP2kfiEcGv7S/Qo3/I8nIs/12n9dGx+oMS6xvoT1+Hlz69E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4404 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 Since I don't have a strong opinion either, I won't make any changes to V1 = at this time. Thanks, Michael > -----Original Message----- > From: Wang, Jian J > Sent: Tuesday, January 14, 2020 8:09 PM > To: Kubacki, Michael A ; > devel@edk2.groups.io > 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 >=20 > Mike, >=20 > Thanks for explaining. You're right that the error is rare case and it w= on't > cause big problem, and NonVolatileLastVariableOffset will be approaching > the whole FV size after some time. I don't have strong opinion. Both wor= k for > me. >=20 > Regards, > Jian >=20 > > -----Original Message----- > > From: Kubacki, Michael A > > Sent: Wednesday, January 15, 2020 11:53 AM > > To: Wang, Jian J ; devel@edk2.groups.io > > 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 > > > > Hi Jian, > > > > I considered that but these are the reasons I settled on the approach = in > patch V1. > > > > 1. With the variable store filled, the length of > > mVariableModuleGlobal- > > >NonVolatileLastVariableOffset will only marginally be a smaller value > > >than > > mNvVariableCache->Size (since variable writes grow the store for SPI > > mNvVariableCache->flash wear > > leveling). In this case, it will be ~CommonRuntimeVariableSpace which > > is usually a major portion of the variable store size anyway. > > 2. Since mVariableModuleGlobal->NonVolatileLastVariableOffset is a > > global moving value that is more frequently manipulated than the fixed > > variable store size, depending upon it increases the likelihood it > > will be set to an invalid value somewhere else. > > 3. This is a relatively rare case (an error condition) and the memory > > copy is within DRAM for variable stores that are typically ~128KB - ~5= 12KB. > > > > To reduce the copy size, the Offset parameter can be "(UINTN) > > VarErrFlag - > > (UINTN) mNvVariableCache" (just remove the unnecessary addition of > > (UINTN) > > mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase) with > > mVariableModuleGlobal->size > > "sizeof (TempFlag)". How about this in a V2? > > > > Thanks, > > Michael > > > > > -----Original Message----- > > > From: Wang, Jian J > > > Sent: Monday, January 13, 2020 10:43 PM > > > 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 > > > > > > Michael, > > > > > > I'm not sure sync-ing whole variable cache memory is an efficient > operation. > > > What about using > > > mVariableModuleGlobal->NonVolatileLastVariableOffset > > > as Length parameter? > > > > > > Status =3D SynchronizeRuntimeVariableCache ( > > > &mVariableModuleGlobal- > > > > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache, > > > 0, > > > mVariableModuleGlobal->NonVolatileLastVariableOff= set > > > ); > > > > > > 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 > > > > VarErrorFlag RT cache offset calculation > > > > > > > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2457 > > > > > > > > This commit fixes an offset calculation that is used to write the > > > > VarErrorFlag UEFI variable to the UEFI variable runtime cache. > > > > > > > > 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. > > > > > > > > * Observable symptom: An exception in SMM will most likely occur > > > > due to the invalid memory reference when the VarErrorFlag variab= le > > > > is written. The variable is most commonly written when the UEFI > > > > variable store is full. > > > > > > > > * The issue only occurs when the variable runtime cache is enabled > > > > by the following PCD being set to TRUE: > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache > > > > > > > > Fixes: aab3b9b9a1e5e1f3fa966fb1667fc3e6c47e7706 > > > > > > > > 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(-) > > > > > > > > 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 avoid buffer overflow, > > > > integer overflow. It should also check attribute to avoid > > > > authentication > > > bypass. > > > > > > > > -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 > > > > > > > > @@ -335,8 +335,8 @@ RecordVarErrorFlag ( > > > > *VarErrFlag =3D TempFlag; > > > > Status =3D SynchronizeRuntimeVariableCache ( > > > > &mVariableModuleGlobal- > > > > > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache > > > > >, > > > > - (UINTN) VarErrFlag - (UINTN) mNvVariableCache += (UINTN) > > > > mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase, > > > > - sizeof (TempFlag) > > > > + 0, > > > > + mNvVariableCache->Size > > > > ); > > > > ASSERT_EFI_ERROR (Status); > > > > } > > > > -- > > > > 2.16.2.windows.1 > > > > > > > > > > > >=20 > > > > > >=20