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.151; helo=mga17.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 220722063D750 for ; Wed, 4 Jul 2018 07:00:49 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 07:00:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,306,1526367600"; d="scan'208";a="51988027" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga007.fm.intel.com with ESMTP; 04 Jul 2018 06:59:45 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 4 Jul 2018 06:59:45 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 4 Jul 2018 06:59:45 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.173]) with mapi id 14.03.0319.002; Wed, 4 Jul 2018 21:59:43 +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/FuMA Date: Wed, 4 Jul 2018 13:59:42 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BB6E213@shsmsx102.ccr.corp.intel.com> References: <1530669736-6941-1-git-send-email-brijesh.singh@amd.com> In-Reply-To: <1530669736-6941-1-git-send-email-brijesh.singh@amd.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:00:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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