From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 60DFE21ECCB0D for ; Wed, 20 Sep 2017 02:27:07 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 20 Sep 2017 02:30:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,420,1500966000"; d="scan'208,223";a="151330537" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 20 Sep 2017 02:30:12 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 20 Sep 2017 02:30:12 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 20 Sep 2017 02:30:11 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.98]) with mapi id 14.03.0319.002; Wed, 20 Sep 2017 17:30:09 +0800 From: "Zeng, Star" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , Laszlo Ersek , "Yao, Jiewen" , "Dong, Eric" , "Zeng, Star" Thread-Topic: [edk2] [PATCH 2/2] MdeModulePkg/Core: Fix out-of-sync issue in GCD Thread-Index: AQHTMQ4FSnTvgp3gnUiWFOeZHnVoPKK9gdsQ Date: Wed, 20 Sep 2017 09:30:08 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B976BAC@shsmsx102.ccr.corp.intel.com> References: <20170919061013.15976-1-jian.j.wang@intel.com> <20170919061013.15976-3-jian.j.wang@intel.com> In-Reply-To: <20170919061013.15976-3-jian.j.wang@intel.com> Accept-Language: zh-CN, 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 09:27:07 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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