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.31; helo=mga06.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 52D8E21FB7D3F for ; Mon, 2 Apr 2018 19:41:14 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Apr 2018 19:41:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,398,1517904000"; d="scan'208";a="38904192" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by FMSMGA003.fm.intel.com with ESMTP; 02 Apr 2018 19:41:14 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 2 Apr 2018 19:41:14 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 2 Apr 2018 19:41:13 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.80]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.129]) with mapi id 14.03.0319.002; Tue, 3 Apr 2018 10:41:11 +0800 From: "Zeng, Star" To: "Yao, Jiewen" , "Wang, Jian J" , "Kinney, Michael D" , Heyi Guo , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , Yi Li , "Gao, Liming" , "Dong, Eric" , "Renhao Liang" , "Zeng, Star" Thread-Topic: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute conversion Thread-Index: AQHTxzbVMQvHVBZY20yNQkEJtf3o/KPtAMYQgACB6QCAALrAQIAABRcA//990wCAABEuAIAAh06Q//97K4CAAIcF8A== Date: Tue, 3 Apr 2018 02:41:11 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BA7654C@shsmsx102.ccr.corp.intel.com> References: <1522311590-104218-1-git-send-email-heyi.guo@linaro.org> <0C09AFA07DD0434D9E2A0C6AEB0483103BA75236@shsmsx102.ccr.corp.intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103BA7547F@shsmsx102.ccr.corp.intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103BA7549E@shsmsx102.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AB1F68A@shsmsx102.ccr.corp.intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103BA7652B@shsmsx102.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AB1F71F@shsmsx102.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503AB1F71F@shsmsx102.ccr.corp.intel.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/1] MdeModulePkg/Gcd: Fix bug of attribute conversion 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 Apr 2018 02:41:15 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Just thought more about the case. If a memory range has WB attribute, and code is to set RUNTIME attribute, t= hen the WB attribute will be clear in GCD database, it seems wrong. :( For this case, need have OR operation ( | RUNTIME) to original attribute in= GCD database? Thanks, Star -----Original Message----- From: Yao, Jiewen=20 Sent: Tuesday, April 3, 2018 10:34 AM To: Zeng, Star ; Wang, Jian J ;= Kinney, Michael D ; Heyi Guo ; edk2-devel@lists.01.org Cc: Ni, Ruiyu ; Yi Li ; Gao, L= iming ; Dong, Eric ; Renhao Lian= g Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute conversion That is good idea. Just add more description as the code comment, please. It is easy for code review later. Thank you Yao Jiewen > -----Original Message----- > From: Zeng, Star > Sent: Tuesday, April 3, 2018 10:33 AM > To: Yao, Jiewen ; Wang, Jian J=20 > ; Kinney, Michael D=20 > ; Heyi Guo ;=20 > edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Yi Li ;=20 > Gao, Liming ; Dong, Eric ;=20 > Renhao Liang ; Zeng, Star=20 > > Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute=20 > conversion >=20 > Agree. >=20 > And I agree we need the fix at > https://lists.01.org/pipermail/edk2-devel/2018-April/023364.html from=20 > Mike for compatibility. > And I think more precious and precise information need to be added=20 > into the commit log or code comments since we have been crazy about=20 > handling attributes in the GCD service. :) >=20 >=20 > Thanks, > Star > -----Original Message----- > From: Yao, Jiewen > Sent: Tuesday, April 3, 2018 10:26 AM > To: Wang, Jian J ; Zeng, Star=20 > ; Kinney, Michael D ;=20 > Heyi Guo ; edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Yi Li ;=20 > Gao, Liming ; Dong, Eric ;=20 > Renhao Liang > Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute=20 > conversion >=20 > I have a discussion with Star/Jian. >=20 > The expectation for the CPU driver is to handle PageAttribute. > The expectation for the platform driver is to use GetAttribute(),=20 > AND/OR attribute, then call SetAttribute(). > Because the DRAM always has a cache attribute (no matter UC or WB), 0=20 > should not happen. (0 might happen for a GCD reserved memory, but=20 > there is no need to set page attribute) >=20 > If all drivers use above way, there won't be any issue. There is no=20 > need to introduce a new protocol so far. >=20 > We did encounter some error, because the platform/silicon/CPU code is=20 > not updated yet. (For example, the MinnowMax which is using binary)=20 > The fix to filter 0 seems a workable way to resolve the compatibility iss= ue. >=20 > Later, I suggest we update MinnowMax binary - Add paging handling for=20 > CPU driver, and use GetAttribute()/SetAttribute() for platform/silicon co= de. >=20 >=20 > Thank you > Yao Jiewen >=20 > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf=20 > > Of Wang, Jian J > > Sent: Tuesday, April 3, 2018 9:24 AM > > To: Zeng, Star ; Kinney, Michael D=20 > > ; Heyi Guo ;=20 > > edk2-devel@lists.01.org > > Cc: Ni, Ruiyu ; Yi Li ;=20 > > Gao, Liming ; Dong, Eric=20 > > ; Renhao Liang > > Subject: Re: [edk2] [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of=20 > > attribute conversion > > > > The NX Memory Protection and Heap Guard features need to clear=20 > > paging attributes. > > Allowing 0 attribute is the current only choice without changing arch p= rotocol. > > Maybe > > It's time to introduce a new protocol. > > > > Regards, > > Jian > > > > > > > -----Original Message----- > > > From: Zeng, Star > > > Sent: Tuesday, April 03, 2018 9:16 AM > > > To: Kinney, Michael D ; Heyi Guo=20 > > > ; edk2-devel@lists.01.org > > > Cc: Yi Li ; Renhao Liang=20 > > > ; Dong, Eric ; Gao,=20 > > > Liming ; Wang, Jian J=20 > > > ; Ni, Ruiyu ; Zeng,=20 > > > Star > > > Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute=20 > > > conversion > > > > > > Current gCpu->SetMemoryAttributes does not support getting memory=20 > > > attributes, and has no clear description about clearing memory attrib= utes. > > > > > > I noticed we introduced > > > > > > SmmMemoryAttribute(MdeModulePkg\Include\Protocol\SmmMemoryAttribut > > e. > > > h) protocol for heap guard feature in SMM environment. > > > Seemingly, we also need introduce MemoryAttribute protocol for DXE? > > > > > > > > > Thanks, > > > Star > > > -----Original Message----- > > > From: Zeng, Star > > > Sent: Tuesday, April 3, 2018 8:59 AM > > > To: Kinney, Michael D ; Heyi Guo=20 > > > ; edk2-devel@lists.01.org > > > Cc: Yi Li ; Renhao Liang=20 > > > ; Dong, Eric ; Gao,=20 > > > Liming ; Wang, Jian J=20 > > > ; Ni, Ruiyu ; Zeng,=20 > > > Star > > > Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute=20 > > > conversion > > > > > > Mike, > > > > > > Agree the problem. > > > We need support only RUNTIME attribute. > > > We need support only cache attributes. > > > We need support only page attributes. > > > We need support RUNTIME + cache + page attributes. > > > Do we need support the 0 Attributes case to clear page attributes? > > > There was discussion about the 0 Attributes case at=20 > > > https://lists.01.org/pipermail/edk2-devel/2018-March/023315.html. > > > It came to the question that should the 0 Attributes case be=20 > > > handled by > > > SetMemoryAttributes() to clear the page attributes? > > > > > > > > > Thanks, > > > Star > > > -----Original Message----- > > > From: Kinney, Michael D > > > Sent: Tuesday, April 3, 2018 5:43 AM > > > To: Zeng, Star ; Heyi Guo=20 > > > ; edk2- devel@lists.01.org; Kinney, Michael D=20 > > > > > > Cc: Yi Li ; Renhao Liang=20 > > > ; Dong, Eric ; Gao,=20 > > > Liming ; Wang, Jian J=20 > > > ; Ni, Ruiyu > > > Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute=20 > > > conversion > > > > > > Star, > > > > > > This commit breaks Vlv2TbltDevicePkg. > > > > > > On this platform, there are 2 calls to > > > gDS->SetMemorySpaceAttributes() for an MMIO > > > range to set only the EFI_MEMORY_RUNTIME bit. > > > > > > With this commit, ConverToCpuArchAttributes()returns 0, and 0 is=20 > > > passed to > > > gCpu->SetMemoryAttributes()that returns EFI_INVALID_PARAMETER on > > > Vlv2TbltDevicePkg. > > > > > > Before this commit, ConverToCpuArchAttributes() returns=20 > > > INVALID_CPU_ARCH_ATTRIBUTES which causes the call to gCpu- > > > >SetMemoryAttributes()to be skipped so no error is generated. > > > > > > I think the right fix is to skip the call to > > > gCpu->SetMemoryAttributes() if CpuArchAttributes > > > is 0 so a call that only sets the RUNTIME attribute can be=20 > > > supported along with call the set both the RUNTIME bit and other cach= e related bits. > > > > > > I will send a patch soon with the proposed fix. > > > > > > Mike > > > > > > > -----Original Message----- > > > > From: Zeng, Star > > > > Sent: Sunday, April 1, 2018 10:59 PM > > > > To: Heyi Guo ; edk2- devel@lists.01.org > > > > Cc: Yi Li ; Renhao Liang=20 > > > > ; Dong, Eric ;=20 > > > > Kinney, Michael D ; Gao, Liming=20 > > > > ; Wang, Jian J ;=20 > > > > Ni, Ruiyu ; Zeng, Star > > > > Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute=20 > > > > conversion > > > > > > > > Pushed at 5b91bf82c67b586b9588cbe4bbffa1588f6b5926. > > > > > > > > Thanks, > > > > Star > > > > -----Original Message----- > > > > From: Heyi Guo [mailto:heyi.guo@linaro.org] > > > > Sent: Thursday, March 29, 2018 4:20 PM > > > > To: edk2-devel@lists.01.org > > > > Cc: Heyi Guo ; Yi Li=20 > > > > ; Renhao Liang=20 > > > > ; Zeng, Star ;=20 > > > > Dong, Eric ; Kinney, Michael D=20 > > > > ; Gao, Liming=20 > > > > ; Wang, Jian J ;=20 > > > > Ni, Ruiyu > > > > Subject: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute=20 > > > > conversion > > > > > > > > For gDS->SetMemorySpaceAttributes(), when user passes a combined=20 > > > > memory attribute including CPU arch attribute and other=20 > > > > attributes, like EFI_MEMORY_RUNTIME, > > > > ConverToCpuArchAttributes() will return=20 > > > > INVALID_CPU_ARCH_ATTRIBUTES and skip setting page/cache=20 > > > > attribute for > the specified memory space. > > > > > > > > We don't see any reason to forbid combining CPU arch attributes=20 > > > > and non-CPU-arch attributes when calling gDS- > > > > >SetMemorySpaceAttributes(), so we remove the check code > > > > in ConverToCpuArchAttributes(); the remaining code is enough to=20 > > > > grab the interested bits for > > > > Cpu->SetMemoryAttributes(). > > > > > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > > > Signed-off-by: Heyi Guo > > > > Signed-off-by: Yi Li > > > > Signed-off-by: Renhao Liang > > > > Cc: Star Zeng > > > > Cc: Eric Dong > > > > Cc: Michael D Kinney > > > > Cc: Liming Gao > > > > Cc: Jian J Wang > > > > Cc: Ruiyu Ni > > > > --- > > > > MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 5 ----- > > > > 1 file changed, 5 deletions(-) > > > > > > > > diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c=20 > > > > b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c index > > > > 77f4adb4bc01..907245a3f512 100644 > > > > --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > > > > +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > > > > @@ -673,11 +673,6 @@ ConverToCpuArchAttributes ( { > > > > UINT64 CpuArchAttributes; > > > > > > > > - if ((Attributes & ~(EXCLUSIVE_MEMORY_ATTRIBUTES | > > > > - NONEXCLUSIVE_MEMORY_ATTRIBUTES)) > > > > !=3D 0) { > > > > - return INVALID_CPU_ARCH_ATTRIBUTES; > > > > - } > > > > - > > > > CpuArchAttributes =3D Attributes &=20 > > > > NONEXCLUSIVE_MEMORY_ATTRIBUTES; > > > > > > > > if ( (Attributes & EFI_MEMORY_UC) =3D=3D EFI_MEMORY_UC) { > > > > -- > > > > 2.7.4 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel