From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::22e; helo=mail-pl0-x22e.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x22e.google.com (mail-pl0-x22e.google.com [IPv6:2607:f8b0:400e:c01::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B82D72256863F for ; Tue, 3 Apr 2018 18:12:48 -0700 (PDT) Received: by mail-pl0-x22e.google.com with SMTP id b6-v6so9660126pla.11 for ; Tue, 03 Apr 2018 18:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=N0CnWWGwkg0WzUat2z6oRvssoN7GhZy+eTLHyc/RHuc=; b=KAXpHpfXi1TdiPch2FtECvAB0ZL0V85RfKVLvbDza25rqLrl8m+iVDvlGN2kyfPor/ ynCaRT/sjtfpOJnK17exO19+JXSjqC7v4apNZffzT5eBTZexu3Kw8iXcRa4CFJe8lrZf SkU+woDDUb0UJ0DSReCTYHzKqIrkaUIFDaWLw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=N0CnWWGwkg0WzUat2z6oRvssoN7GhZy+eTLHyc/RHuc=; b=I6Vf8xWskxyyoGjl5xU+vSt4EJ3EY6f2zDaebHpyTwggZirfUsTJrpl5tqKzMLaGGY 7PHh8dKLWKQqP5atD3E3ucX+JKSKDXbeiICvNesCn+u6QHTkLh+FdZtiaihce1R5JyWd obaAeMSyMNmjl6nzjmlISqYp/Kr7fmxg600NXsbGq+qBkgwMBN5TRg/Dj7MlBy+NySO5 1BUeKD85ryXtkX9/g2uwuNIQ+HuQqCv2pUnM13qyK87X9wud5gc/ts5mpe6oEGlGNf2X dxo6MV4ehdZdezFD4IPyJjWz4qlrWGqvTLAlJuTIQ4ikPWh0ajM3v8ocuiZiGitxdalE Qbug== X-Gm-Message-State: AElRT7HCAfq+dRQyGe5x9+Jy55VC7/dD6uUZcsddu4QzLOZNGLJhBo0I A6VFUrmLtXzS9Wo2qKSWGkfvhg== X-Google-Smtp-Source: AIpwx48dUzVfsiWsLCMa1VfilUDst2TLxY2qliF0XA5Z7YdrF9t+aHGTjDXszJB4vEZWVMFiJRTTdQ== X-Received: by 10.99.53.6 with SMTP id c6mr10698384pga.413.1522804368040; Tue, 03 Apr 2018 18:12:48 -0700 (PDT) Received: from SZX1000114654 ([45.56.152.115]) by smtp.gmail.com with ESMTPSA id v62sm6996588pfv.141.2018.04.03.18.12.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Apr 2018 18:12:47 -0700 (PDT) From: Guo Heyi X-Google-Original-From: Guo Heyi Date: Wed, 4 Apr 2018 09:12:43 +0800 To: "Yao, Jiewen" Cc: "Wang, Jian J" , "Zeng, Star" , "Kinney, Michael D" , Heyi Guo , "edk2-devel@lists.01.org" , "Ni, Ruiyu" , Yi Li , "Gao, Liming" , "Dong, Eric" , Renhao Liang Message-ID: <20180404011243.GB111107@SZX1000114654> 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> MIME-Version: 1.0 In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503AB1F68A@shsmsx102.ccr.corp.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) 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: Wed, 04 Apr 2018 01:12:48 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Apr 03, 2018 at 02:25:30AM +0000, Yao, Jiewen wrote: > I have a discussion with Star/Jian. > > The expectation for the CPU driver is to handle PageAttribute. > The expectation for the platform driver is to use GetAttribute(), AND/OR attribute, then call SetAttribute(). Agree, "Get and then Set" seems to be the clearest definition for gDS->SetMemoryAttributes(). Thanks, Heyi > Because the DRAM always has a cache attribute (no matter UC or WB), 0 should not happen. (0 might happen for a GCD reserved memory, but there is no need to set page attribute) > > If all drivers use above way, there won't be any issue. There is no need to introduce a new protocol so far. > > We did encounter some error, because the platform/silicon/CPU code is not updated yet. (For example, the MinnowMax which is using binary) > The fix to filter 0 seems a workable way to resolve the compatibility issue. > > Later, I suggest we update MinnowMax binary - Add paging handling for CPU driver, and use GetAttribute()/SetAttribute() for platform/silicon code. > > > Thank you > Yao Jiewen > > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Wang, > > Jian J > > Sent: Tuesday, April 3, 2018 9:24 AM > > To: Zeng, Star ; Kinney, Michael D > > ; Heyi Guo ; > > edk2-devel@lists.01.org > > Cc: Ni, Ruiyu ; Yi Li ; Gao, > > Liming ; Dong, Eric ; Renhao > > Liang > > Subject: Re: [edk2] [PATCH 1/1] MdeModulePkg/Gcd: Fix bug of attribute > > conversion > > > > The NX Memory Protection and Heap Guard features need to clear paging > > attributes. > > Allowing 0 attribute is the current only choice without changing arch protocol. > > 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 conversion > > > > > > Current gCpu->SetMemoryAttributes does not support getting memory > > > attributes, and has no clear description about clearing memory attributes. > > > > > > 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 > > > ; 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 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 > > > 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? > > > > > > > > > Thanks, > > > Star > > > -----Original Message----- > > > From: Kinney, Michael D > > > Sent: Tuesday, April 3, 2018 5:43 AM > > > To: Zeng, Star ; Heyi Guo ; edk2- > > > 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 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 passed to > > > gCpu->SetMemoryAttributes()that returns EFI_INVALID_PARAMETER on > > > Vlv2TbltDevicePkg. > > > > > > Before this commit, ConverToCpuArchAttributes() returns > > > 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 supported along with > > > call the set both the RUNTIME bit and other cache 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 > > > > ; 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)) > > > > != 0) { > > > > - return INVALID_CPU_ARCH_ATTRIBUTES; > > > > - } > > > > - > > > > CpuArchAttributes = Attributes & > > > > NONEXCLUSIVE_MEMORY_ATTRIBUTES; > > > > > > > > if ( (Attributes & EFI_MEMORY_UC) == EFI_MEMORY_UC) { > > > > -- > > > > 2.7.4 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel