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.65; helo=mga03.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 4DC782264A1F7 for ; Wed, 4 Apr 2018 01:13:04 -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 orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2018 01:13:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,405,1517904000"; d="scan'208";a="43881665" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 04 Apr 2018 01:13:04 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 4 Apr 2018 01:13:03 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 4 Apr 2018 01:13:03 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.61]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.241]) with mapi id 14.03.0319.002; Wed, 4 Apr 2018 16:13:01 +0800 From: "Yao, Jiewen" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , Yi Li , "Dong, Eric" , Renhao Liang , "Gao, Liming" , Heyi Guo , "Kinney, Michael D" , "Zeng, Star" Thread-Topic: [edk2] [PATCH V2] MdeModulePkg/Gcd: Filter gCpu->SetMemoryAttributes() calls Thread-Index: AQHTy7nk5n/v1XjSHkqid5+BhIMNpqPwQftw Date: Wed, 4 Apr 2018 08:13:01 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AB339F7@shsmsx102.ccr.corp.intel.com> References: <1522807708-75668-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1522807708-75668-1-git-send-email-star.zeng@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDMyMjc1MWYtZGIxMS00ZjA3LWFkMDYtYWQ1NzAxYzAyNjRiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJpMzlpT290OGpjODJZc0xVeEt3bHF4eDU1MFM4RDNSbVdFXC9VckEyamJTUVlGSDRqTkl3aE45VUxGMGJHSGF2ayJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH V2] MdeModulePkg/Gcd: Filter gCpu->SetMemoryAttributes() calls 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 Apr 2018 08:13:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks. Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of St= ar > Zeng > Sent: Wednesday, April 4, 2018 10:08 AM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Yi Li ; Dong= , Eric > ; Renhao Liang ; Gao, Liming > ; Heyi Guo ; Kinney, Michael D > ; Zeng, Star > Subject: [edk2] [PATCH V2] MdeModulePkg/Gcd: Filter > gCpu->SetMemoryAttributes() calls >=20 > From: "Kinney, Michael D" >=20 > This patch fixes an issue with VlvTbltDevicePkg introduced > by commit 5b91bf82c67b586b9588cbe4bbffa1588f6b5926. >=20 > The history is as below. > To support heap guard feature, > 14dde9e903bb9a719ebb8f3381da72b19509bc36 > added support for SetMemorySpaceAttributes() to handle page attributes, > but after that, a combination of CPU arch attributes and other attributes > was not allowed anymore, for example, UC + RUNTIME. It is a regression. > Then 5b91bf82c67b586b9588cbe4bbffa1588f6b5926 was to fix the regression, > and we thought 0 CPU arch attributes may be used to clear CPU arch > attributes, so 0 CPU arch attributes was allowed to be sent to > gCpu->SetMemoryAttributes(). >=20 > But some implementation of CPU driver may return error for 0 CPU arch > attributes. That fails the case that caller just calls > SetMemorySpaceAttributes() with none CPU arch attributes (for example, > RUNTIME), and the purpose of the case is not to clear CPU arch attributes= . >=20 > This patch filters the call to gCpu->SetMemoryAttributes() > if the requested attributes is 0. It also removes the #define > INVALID_CPU_ARCH_ATTRIBUTES that is no longer used. >=20 > Cc: Heyi Guo > Cc: Yi Li > Cc: Renhao Liang > Cc: Star Zeng > Cc: Eric Dong > Cc: Liming Gao > Cc: Jian J Wang > Cc: Ruiyu Ni > Signed-off-by: Michael D Kinney > Signed-off-by: Star Zeng > Contributed-under: TianoCore Contribution Agreement 1.1 > --- > MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 25 ++++++++++++++++++++++--- > 1 file changed, 22 insertions(+), 3 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > index 907245a3f512..31ddf9c3bb51 100644 > --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > @@ -48,8 +48,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY > KIND, EITHER EXPRESS OR IMPLIED. > #define NONEXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_XP | > EFI_MEMORY_RP | \ > EFI_MEMORY_RO) >=20 > -#define INVALID_CPU_ARCH_ATTRIBUTES 0xffffffff > - > // > // Module Variables > // > @@ -873,7 +871,21 @@ CoreConvertSpace ( > // Call CPU Arch Protocol to attempt to set attributes on the range > // > CpuArchAttributes =3D ConverToCpuArchAttributes (Attributes); > - if (CpuArchAttributes !=3D INVALID_CPU_ARCH_ATTRIBUTES) { > + // > + // CPU arch attributes include page attributes and cache attributes. > + // Only page attributes supports to be cleared, but not cache attrib= utes. > + // Caller is expected to use GetMemorySpaceDescriptor() to get the c= urrent > + // attributes, AND/OR attributes, and then calls > SetMemorySpaceAttributes() > + // to set the new attributes. > + // So 0 CPU arch attributes should not happen as memory should alway= s > have > + // a cache attribute (no matter UC or WB, etc). > + // > + // Here, 0 CPU arch attributes will be filtered to be compatible wit= h the > + // case that caller just calls SetMemorySpaceAttributes() with none = CPU > + // arch attributes (for example, RUNTIME) as the purpose of the case= is not > + // to clear CPU arch attributes. > + // > + if (CpuArchAttributes !=3D 0) { > if (gCpu =3D=3D NULL) { > Status =3D EFI_NOT_AVAILABLE_YET; > } else { > @@ -936,6 +948,13 @@ CoreConvertSpace ( > // Set attributes operation > // > case GCD_SET_ATTRIBUTES_MEMORY_OPERATION: > + if (CpuArchAttributes =3D=3D 0) { > + // > + // Keep original CPU arch attributes when caller just calls > + // SetMemorySpaceAttributes() with none CPU arch attributes (for > example, RUNTIME). > + // > + Attributes |=3D (Entry->Attributes & > (EXCLUSIVE_MEMORY_ATTRIBUTES | NONEXCLUSIVE_MEMORY_ATTRIBUTES)); > + } > Entry->Attributes =3D Attributes; > break; > // > -- > 2.7.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel