From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 3EA7B21ECCB1D for ; Wed, 20 Sep 2017 16:59:06 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2017 17:02:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,422,1500966000"; d="scan'208,223";a="314441519" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga004.fm.intel.com with ESMTP; 20 Sep 2017 17:02:12 -0700 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 20 Sep 2017 17:02:12 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 20 Sep 2017 17:02:12 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.98]) with mapi id 14.03.0319.002; Thu, 21 Sep 2017 08:02:09 +0800 From: "Wang, Jian J" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , Laszlo Ersek , "Yao, Jiewen" , "Dong, Eric" Thread-Topic: [edk2] [PATCH 2/2] MdeModulePkg/Core: Fix out-of-sync issue in GCD Thread-Index: AQHTMQ4FSnTvgp3gnUiWFOeZHnVoPKK9gdsQgAD1OUA= Date: Thu, 21 Sep 2017 00:02:09 +0000 Message-ID: References: <20170919061013.15976-1-jian.j.wang@intel.com> <20170919061013.15976-3-jian.j.wang@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B976BAC@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B976BAC@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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 2/2] MdeModulePkg/Core: Fix out-of-sync issue in GCD X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Sep 2017 23:59:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Sure. I'll submit a new patch after enough validation. Thanks for the revie= w. -----Original Message----- From: Zeng, Star=20 Sent: Wednesday, September 20, 2017 5:30 PM To: Wang, Jian J ; edk2-devel@lists.01.org Cc: Kinney, Michael D ; Laszlo Ersek ; Yao, Jiewen ; Dong, Eric ; Zeng, Star Subject: RE: [edk2] [PATCH 2/2] MdeModulePkg/Core: Fix out-of-sync issue in= GCD Reviewed-by: Star Zeng for this patch. Please notice that the MemoryProtection.c is using gCpu->SetMemoryAttribute= s but not GCD SetMemorySpaceAttributes. You should need update it to use GCD SetMemorySpaceAttributes, you can have= separated patch to cover it. Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jian= J Wang Sent: Tuesday, September 19, 2017 2:10 PM To: edk2-devel@lists.01.org Cc: Kinney, Michael D ; Laszlo Ersek ; Yao, Jiewen ; Dong, Eric ; Zeng, Star Subject: [edk2] [PATCH 2/2] MdeModulePkg/Core: Fix out-of-sync issue in GCD >>From GCD perspective, its SetMemorySpaceAttributes() method doesn't accept = page related attributes. That means users cannot use it to change page attr= ibutes, and have to turn to CPU arch protocol to do it, which is not be all= owed by PI spec. Cc: Jiewen Yao Cc: Eric Dong Cc: Star Zeng Cc: Laszlo Ersek Cc: Michael Kinney Suggested-by: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 45 ++++++++++++++++++++++++-------------= ---- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gc= d.c index a06f8bb77c..e9d1d5b612 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -40,6 +40,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHE= R EXPRESS OR IMPLIED. =20 #define PRESENT_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT) =20 +#define EXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_UC | EFI_MEMORY_WC | \ + EFI_MEMORY_WT | EFI_MEMORY_WB | \ + EFI_MEMORY_WP | EFI_MEMORY_UCE) + +#define NONEXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_XP | EFI_MEMORY_RP | \ + EFI_MEMORY_RO) + #define INVALID_CPU_ARCH_ATTRIBUTES 0xffffffff =20 // @@ -654,28 +661,30 @@ ConverToCpuArchAttributes ( UINT64 Attributes ) { - if ( (Attributes & EFI_MEMORY_UC) =3D=3D EFI_MEMORY_UC) { - return EFI_MEMORY_UC; - } + UINT64 CpuArchAttributes; =20 - if ( (Attributes & EFI_MEMORY_WC ) =3D=3D EFI_MEMORY_WC) { - return EFI_MEMORY_WC; + if ((Attributes & ~(EXCLUSIVE_MEMORY_ATTRIBUTES | + NONEXCLUSIVE_MEMORY_ATTRIBUTES)) !=3D 0) { + return INVALID_CPU_ARCH_ATTRIBUTES; } =20 - if ( (Attributes & EFI_MEMORY_WT ) =3D=3D EFI_MEMORY_WT) { - return EFI_MEMORY_WT; - } - - if ( (Attributes & EFI_MEMORY_WB) =3D=3D EFI_MEMORY_WB) { - return EFI_MEMORY_WB; - } - - if ( (Attributes & EFI_MEMORY_WP) =3D=3D EFI_MEMORY_WP) { - return EFI_MEMORY_WP; - } - - return INVALID_CPU_ARCH_ATTRIBUTES; + CpuArchAttributes =3D Attributes & NONEXCLUSIVE_MEMORY_ATTRIBUTES; =20 + if ( (Attributes & EFI_MEMORY_UC) =3D=3D EFI_MEMORY_UC) { + CpuArchAttributes |=3D EFI_MEMORY_UC; } else if ( (Attributes &=20 + EFI_MEMORY_WC ) =3D=3D EFI_MEMORY_WC) { + CpuArchAttributes |=3D EFI_MEMORY_WC; } else if ( (Attributes &=20 + EFI_MEMORY_WT ) =3D=3D EFI_MEMORY_WT) { + CpuArchAttributes |=3D EFI_MEMORY_WT; } else if ( (Attributes &=20 + EFI_MEMORY_WB) =3D=3D EFI_MEMORY_WB) { + CpuArchAttributes |=3D EFI_MEMORY_WB; } else if ( (Attributes &=20 + EFI_MEMORY_UCE) =3D=3D EFI_MEMORY_UCE) { + CpuArchAttributes |=3D EFI_MEMORY_UCE; } else if ( (Attributes &=20 + EFI_MEMORY_WP) =3D=3D EFI_MEMORY_WP) { + CpuArchAttributes |=3D EFI_MEMORY_WP; } + + return CpuArchAttributes; } =20 =20 -- 2.14.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel