From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 751292096FAD4 for ; Wed, 4 Jul 2018 07:23:35 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 07:23:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,306,1526367600"; d="scan'208";a="242624451" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga005.fm.intel.com with ESMTP; 04 Jul 2018 07:23:34 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 4 Jul 2018 07:23:34 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 4 Jul 2018 07:23:33 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.81]) with mapi id 14.03.0319.002; Wed, 4 Jul 2018 22:23:32 +0800 From: "Zeng, Star" To: Brijesh Singh , "edk2-devel@lists.01.org" CC: Tom Lendacky , "Dong, Eric" , "Justen, Jordan L" , "Laszlo Ersek" , "Zeng, Star" Thread-Topic: [PATCH v2 1/1] MdeModulePkg/Variable: Check EFI_MEMORY_RUNTIME attribute before setting it Thread-Index: AQHUEzsVMk+TL1ar2kGD6t+emkHi1qR/FuMAgAAHtUA= Date: Wed, 4 Jul 2018 14:23:31 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BB70302@shsmsx102.ccr.corp.intel.com> References: <1530669736-6941-1-git-send-email-brijesh.singh@amd.com> <0C09AFA07DD0434D9E2A0C6AEB0483103BB6E213@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103BB6E213@shsmsx102.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNmU0MDU3NzQtNmM3Yy00MWY4LTg1NTQtM2MxNmUxMzgxMzA0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQjY2YkJRSVIrTmpaOTdwQTVNdlJ3UWxSa1wvdnpjZjl3cnAyc3J2R1pPeUNBdVZuakF5VXlqUE1HYWJHUkdNV1QifQ== dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 1/1] 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: Wed, 04 Jul 2018 14:23:35 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Pushed at f88290964fe528ffeb67ff108e8174fc2ce52741. Thanks, Star -----Original Message----- From: Zeng, Star=20 Sent: Wednesday, July 4, 2018 10:00 PM To: Brijesh Singh ; edk2-devel@lists.01.org Cc: Tom Lendacky ; Dong, Eric ; Justen, Jordan L ; Laszlo Ersek ; Zeng, Star Subject: RE: [PATCH v2 1/1] MdeModulePkg/Variable: Check EFI_MEMORY_RUNTIME= attribute before setting it Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: Brijesh Singh [mailto:brijesh.singh@amd.com]=20 Sent: Wednesday, July 4, 2018 10:02 AM To: edk2-devel@lists.01.org Cc: Tom Lendacky ; Brijesh Singh ; Dong, Eric ; Justen, Jordan L ; Zeng, Star ; Laszlo Ersek Subject: [PATCH v2 1/1] MdeModulePkg/Variable: Check EFI_MEMORY_RUNTIME att= ribute 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 Reviewed-by: Star Zeng Signed-off-by: Brijesh Singh --- Change since v1: - fix coding style 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..23186176be75 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) =3D=3D 0) { + 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