From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 72BCF210DF5E0 for ; Mon, 2 Jul 2018 20:21:54 -0700 (PDT) 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; 02 Jul 2018 20:21:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,301,1526367600"; d="scan'208";a="69173571" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga001.fm.intel.com with ESMTP; 02 Jul 2018 20:21:53 -0700 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 2 Jul 2018 20:21:52 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 2 Jul 2018 20:21:52 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.223]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.70]) with mapi id 14.03.0319.002; Tue, 3 Jul 2018 11:21:50 +0800 From: "Zeng, Star" To: Brijesh Singh , "edk2-devel@lists.01.org" CC: Tom Lendacky , "Dong, Eric" , "Justen, Jordan L" , "Laszlo Ersek" , "Zeng, Star" , "Bi, Dandan" Thread-Topic: [PATCH 1/2] MdeModulePkg/Variable: Check EFI_MEMORY_RUNTIME attribute before setting it Thread-Index: AQHUEnuIoVuVH89lR0SrE1bNhJk5eqR81BYA Date: Tue, 3 Jul 2018 03:21:49 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BB60D45@shsmsx102.ccr.corp.intel.com> References: <1530587467-19571-1-git-send-email-brijesh.singh@amd.com> In-Reply-To: <1530587467-19571-1-git-send-email-brijesh.singh@amd.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 1/2] MdeModulePkg/Variable: Check EFI_MEMORY_RUNTIME attribute before setting it X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jul 2018 03:21:54 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please use if ((GcdDescriptor.Attributes & EFI_MEMORY_RUNTIME) =3D=3D 0) { instead of if (!(GcdDescriptor.Attributes & EFI_MEMORY_RUNTIME)) { There is coding style and ECC tool check about it. See https://edk2-docs.gi= tbooks.io/edk-ii-c-coding-standards-specification/content/5_source_files/57= _c_programming.html#table-10-predicate-expression-examples. With the change above, Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: Brijesh Singh [mailto:brijesh.singh@amd.com]=20 Sent: Tuesday, July 3, 2018 11:11 AM To: edk2-devel@lists.01.org Cc: Tom Lendacky ; Brijesh Singh ; Dong, Eric ; Justen, Jordan L ; Zeng, Star ; Laszlo Ersek Subject: [PATCH 1/2] MdeModulePkg/Variable: Check EFI_MEMORY_RUNTIME attrib= ute before setting it Set the EFI_MEMORY_RUNTIME attribute in FtwNotificationEvent() only if the = attribute is not already present. This will ensure that the attributes set = by the platform drivers (e.g Ovmf pflash) is not lost. Cc: Dong Eric Cc: Justen Jordan L Cc: Zeng Star Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c | 16 +++++++++---= ---- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c b/Mde= ModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c index 6b04f4f7b394..f5ab6641ef28 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c @@ -412,13 +412,15 @@ FtwNotificationEvent ( if (EFI_ERROR (Status)) { DEBUG ((DEBUG_WARN, "Variable driver failed to get flash memory attrib= ute.\n")); } else { - Status =3D gDS->SetMemorySpaceAttributes ( - BaseAddress, - Length, - GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIM= E attribute to Flash.\n")); + if (!(GcdDescriptor.Attributes & EFI_MEMORY_RUNTIME)) { + Status =3D gDS->SetMemorySpaceAttributes ( + BaseAddress, + Length, + GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNT= IME attribute to Flash.\n")); + } } } =20 -- 2.7.4