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.web12.2354.1579060375368913343 for ; Tue, 14 Jan 2020 19:52:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=p5aKygtp; 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 fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 19:52:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,321,1574150400"; d="scan'208";a="423407879" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga005.fm.intel.com with ESMTP; 14 Jan 2020 19:52:54 -0800 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Jan 2020 19:52:54 -0800 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 14 Jan 2020 19:52:54 -0800 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 14 Jan 2020 19:52:54 -0800 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (104.47.45.56) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Jan 2020 19:52:53 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ismIM6M03OZGKz1rr1PwJ1M5W6Tt9M/bKUT2vQzjACUH0tHK7xAqTp5mukk3GXOeGLv799/7bv8rIczMjnTx78zO9QaKHDNrqBg3OA9nIl+1XNYWO8EVZ5WGb1NUo6yOaOqFyrj8+4yBt3/bh5sQbXlB/ITEkHvy0cSGVeIXbS+u3x5WIEi6FLj/4U+qbj/Twy6h7qfJ4lnIAkhsL4GKhg+0k/jp0UoUL8L6MKuNQo+wcgd3JLg9Eve0sD6xycxoKpBIirpiLEtz0ig4zwyyQqcq/cYBepZ4J/9ekkkdlD0yNlPjbfOSYdcIImA9N2qOYz8/3ZTiknTp/Ln7q6shzw== 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=pBhVeex7M805iOY55ecvW5UMwyfzV4qIg5LtrLRN/+g=; b=NQVFTQ0JIE4E/F47ShiY7aNk8XPtruSa+cpcagiLAo5Lay7GrmCOA9vJedJQt/iCR/0Lg+yg9jKYhDkz6fPb9WugU61cNz2+uQJu07vtEFC1CUwv8X0g1Dssg1kqxFwuLU/jzKwuJFBjXoyI5aDHcnSv+rH1YfqzrdH1Oe0zElNoz5IIgjAD8tlk0lhKTnSsYeuJzhZ8i8KQIwSuJO7TgTXWhsSaSA3smNLYBoqh/wk6pgI+AQ4Hboz3PxtVoo2fbpzugUjlB/DZ/pdXboAukMEe3e+iWoeDk1mujbUJxWR7zvnjeiTp/Wbm0bFICFhzbxAWbAVMhJb7mzsUYTQbkg== 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=pBhVeex7M805iOY55ecvW5UMwyfzV4qIg5LtrLRN/+g=; b=p5aKygtpwhaD3Pmtw8IAt3Msq7DghrzejOI58kjV9PeS4VmIQQGgm0Us/ose274SqCunhMQ1kQzLvwWboKJzbxYbKFaN385I87AqG4zlMPAXz4rINIPMQc0sgT6N9pCM9blVkkbxItJKjAmhpu6Woyt7AqcrX+VtiFxCbu6IZoc= Received: from BY5PR11MB4484.namprd11.prod.outlook.com (52.132.254.155) by BY5PR11MB4150.namprd11.prod.outlook.com (10.255.163.33) 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 03:52:50 +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 03:52:50 +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: AQHVymfr57GN2e33OkSU11c3ihA1NKfptZDwgAFHbaA= Date: Wed, 15 Jan 2020 03:52:49 +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: e679b23b-e6d7-44f4-ce5e-08d7996e6416 x-ms-traffictypediagnostic: BY5PR11MB4150: 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:1284; x-forefront-prvs: 02830F0362 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(396003)(366004)(346002)(376002)(136003)(189003)(199004)(81166006)(316002)(8676002)(66556008)(64756008)(9686003)(66476007)(66446008)(8936002)(54906003)(2906002)(55016002)(966005)(81156014)(110136005)(86362001)(66946007)(76116006)(7696005)(53546011)(5660300002)(33656002)(107886003)(186003)(71200400001)(6506007)(4326008)(52536014)(478600001)(26005);DIR:OUT;SFP:1102;SCL:1;SRVR:BY5PR11MB4150;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: kwsdcAMyh1Afq0HqmuM6jr+oqb1nwarMxBPrChWXzTUXfFoVUa5G1ZK2Vm1mVvWnm1ED2bk7pKXg+cbvEAF202EQ7zOB+z81RQxdPWWxrObAdBvp0KH2gvlzBdWDIBm7qw/5czRlWktgXj64yVKDSQdZUMmSeYTNjQcfiO5XKAryRfynFPqEjhmXRMkKZJSN4EBFxVHNYt4X6AefOILLON3Qq4J9Kqf8rVs6ulMDZGESjgTE+0f5D9wklWq24UARvOKZoPR2eryuekDCAZDcUxg8yswaK57g1OKnYdMgkwxtU1bgR8nlwQi9bB4lLxrkPtClD4ia3iQbEVjAEct0J/LM/UsD3gdTYGApVUua2btVjDx5iZZcRuJUHuvGvRg1hjgNLavDxEd+SpT7zIGLzP6bdG3z6Bh6XkAy998Y4UkmjFyu3wOIoZpCxuBcrSiWylkzdKhbuqgp6YLz56IejFgIoZC1LGKxzm0rsZPnw+A= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: e679b23b-e6d7-44f4-ce5e-08d7996e6416 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 03:52:49.9373 (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: NOwNlshUN5wpkXELUNcOXXZ/OyNDlHg3vV3c5VOScjc/QTyVmiL7nRDlLS1RxTaexkcCYQ5GMir9gnGwPfvcMdCR/UmyJOKXKj7mkKMKcLI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4150 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 Hi Jian, I considered that but these are the reasons I settled on the approach in p= atch V1. 1. With the variable store filled, the length of mVariableModuleGlobal->No= nVolatileLastVariableOffset will only marginally be a smaller value than mN= vVariableCache->Size (since variable writes grow the store for SPI flash we= ar 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 st= ore size, depending upon it increases the likelihood it will be set to an i= nvalid 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 - ~512KB. 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 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 >=20 > Michael, >=20 > I'm not sure sync-ing whole variable cache memory is an efficient operat= ion. > What about using mVariableModuleGlobal->NonVolatileLastVariableOffset > as Length parameter? >=20 > Status =3D SynchronizeRuntimeVariableCache ( > &mVariableModuleGlobal- > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache, > 0, > mVariableModuleGlobal->NonVolatileLastVariableOffset > ); >=20 > Regards, > Jian >=20 > > -----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 variable > > 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 authentic= ation > 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 + (UI= NTN) > > mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase, > > - sizeof (TempFlag) > > + 0, > > + mNvVariableCache->Size > > ); > > ASSERT_EFI_ERROR (Status); > > } > > -- > > 2.16.2.windows.1 > > > > > >=20 >=20