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.43; helo=mga05.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 D778B21FB7D2B for ; Mon, 2 Apr 2018 18:24:03 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Apr 2018 18:24:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,398,1517904000"; d="scan'208";a="42894105" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 02 Apr 2018 18:24:03 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 2 Apr 2018 18:24:02 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.235]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.226]) with mapi id 14.03.0319.002; Tue, 3 Apr 2018 09:24:00 +0800 From: "Wang, Jian J" To: "Zeng, Star" , "Kinney, Michael D" , Heyi Guo , "edk2-devel@lists.01.org" CC: Yi Li , Renhao Liang , "Dong, Eric" , "Gao, Liming" , "Ni, Ruiyu" Thread-Topic: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute conversion Thread-Index: AQHTxzbJJRpzAG/vcUKy7/oyPRPnIaPsergAgAEH9wCAADa0gIAABKOAgACGo7A= Date: Tue, 3 Apr 2018 01:24:00 +0000 Message-ID: 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> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103BA7549E@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzY0ZWVhODYtYjc3NC00YjhlLWJhODUtNzc4OTdjOTNjZmQ5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJyWUs4WnNleGFUWmdrSmY5Z2lXTFZTemdQV0RaZ1MrZ3A4azBkMUFkRXdncUp2eU5pdnF6SW02VlZXbzU3T21oIn0= 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 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 01:24:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable The NX Memory Protection and Heap Guard features need to clear paging attri= butes. Allowing 0 attribute is the current only choice without changing arch proto= col. 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 > ; edk2-devel@lists.01.org > Cc: Yi Li ; Renhao Liang > ; Dong, Eric ; Gao, Liming > ; Wang, Jian J ; Ni, Ruiyu > ; Zeng, Star > Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute conversio= n >=20 > Current gCpu->SetMemoryAttributes does not support getting memory > attributes, and has no clear description about clearing memory attributes= . >=20 > I noticed we introduced > SmmMemoryAttribute(MdeModulePkg\Include\Protocol\SmmMemoryAttribute. > h) protocol for heap guard feature in SMM environment. > Seemingly, we also need introduce MemoryAttribute protocol for DXE? >=20 >=20 > Thanks, > Star > -----Original Message----- > From: Zeng, Star > Sent: Tuesday, April 3, 2018 8:59 AM > To: Kinney, Michael D ; Heyi Guo > ; edk2-devel@lists.01.org > Cc: Yi Li ; Renhao Liang > ; Dong, Eric ; Gao, Liming > ; Wang, Jian J ; Ni, Ruiyu > ; Zeng, Star > Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute conversio= n >=20 > Mike, >=20 > 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 > https://lists.01.org/pipermail/edk2-devel/2018-March/023315.html. > It came to the question that should the 0 Attributes case be handled by > SetMemoryAttributes() to clear the page attributes? >=20 >=20 > Thanks, > Star > -----Original Message----- > From: Kinney, Michael D > Sent: Tuesday, April 3, 2018 5:43 AM > To: Zeng, Star ; Heyi Guo ; edk= 2- > devel@lists.01.org; Kinney, Michael D > Cc: Yi Li ; Renhao Liang > ; Dong, Eric ; Gao, Liming > ; Wang, Jian J ; Ni, Ruiyu > > Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute conversio= n >=20 > Star, >=20 > This commit breaks Vlv2TbltDevicePkg. >=20 > On this platform, there are 2 calls to > gDS->SetMemorySpaceAttributes() for an MMIO > range to set only the EFI_MEMORY_RUNTIME bit. >=20 > With this commit, ConverToCpuArchAttributes()returns 0, and 0 is passed t= o > gCpu->SetMemoryAttributes()that returns EFI_INVALID_PARAMETER on > Vlv2TbltDevicePkg. >=20 > Before this commit, ConverToCpuArchAttributes() returns > INVALID_CPU_ARCH_ATTRIBUTES which causes the call to gCpu- > >SetMemoryAttributes()to be skipped so no error is generated. >=20 > 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 supported alon= g with > call the set both the RUNTIME bit and other cache related bits. >=20 > I will send a patch soon with the proposed fix. >=20 > Mike >=20 > > -----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 > > ; Dong, Eric ; Kinney, > > Michael D ; Gao, Liming > > ; Wang, Jian J ; Ni, > > Ruiyu ; Zeng, Star > > Subject: RE: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute > > 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 ; > > Renhao Liang ; Zeng, Star > > ; Dong, Eric ; Kinney, > > Michael D ; Gao, Liming > > ; Wang, Jian J ; Ni, > > Ruiyu > > Subject: [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute conversion > > > > For gDS->SetMemorySpaceAttributes(), when user passes a combined > > memory attribute including CPU arch attribute and other attributes, > > like EFI_MEMORY_RUNTIME, > > ConverToCpuArchAttributes() will return INVALID_CPU_ARCH_ATTRIBUTES > > and skip setting page/cache attribute for the specified memory space. > > > > We don't see any reason to forbid combining CPU arch attributes and > > non-CPU-arch attributes when calling gDS- > > >SetMemorySpaceAttributes(), so we remove the check code > > in ConverToCpuArchAttributes(); the remaining code is enough to 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 > > 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 & > > NONEXCLUSIVE_MEMORY_ATTRIBUTES; > > > > if ( (Attributes & EFI_MEMORY_UC) =3D=3D EFI_MEMORY_UC) { > > -- > > 2.7.4