From nobody Thu Dec 26 13:34:25 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1505801426868985.1395668652539; Mon, 18 Sep 2017 23:10:26 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A32E921E945F7; Mon, 18 Sep 2017 23:07:21 -0700 (PDT) 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 F094021D046BF for ; Mon, 18 Sep 2017 23:07:20 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Sep 2017 23:10:25 -0700 Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.46]) by orsmga005.jf.intel.com with ESMTP; 18 Sep 2017 23:10:23 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,416,1500966000"; d="scan'208,223";a="150779173" From: Jian J Wang To: edk2-devel@lists.01.org Date: Tue, 19 Sep 2017 14:10:13 +0800 Message-Id: <20170919061013.15976-3-jian.j.wang@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20170919061013.15976-1-jian.j.wang@intel.com> References: <20170919061013.15976-1-jian.j.wang@intel.com> Subject: [edk2] [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: , Cc: Michael Kinney , Laszlo Ersek , Jiewen Yao , Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From GCD perspective, its SetMemorySpaceAttributes() method doesn't accept page related attributes. That means users cannot use it to change page attributes, and have to turn to CPU arch protocol to do it, which is not be allowed 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 Reviewed-by: Star Zeng for this patch. --- 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 & EFI_MEMORY_WC ) =3D=3D EFI_MEMORY_WC) { + CpuArchAttributes |=3D EFI_MEMORY_WC; + } else if ( (Attributes & EFI_MEMORY_WT ) =3D=3D EFI_MEMORY_WT) { + CpuArchAttributes |=3D EFI_MEMORY_WT; + } else if ( (Attributes & EFI_MEMORY_WB) =3D=3D EFI_MEMORY_WB) { + CpuArchAttributes |=3D EFI_MEMORY_WB; + } else if ( (Attributes & EFI_MEMORY_UCE) =3D=3D EFI_MEMORY_UCE) { + CpuArchAttributes |=3D EFI_MEMORY_UCE; + } else if ( (Attributes & EFI_MEMORY_WP) =3D=3D EFI_MEMORY_WP) { + CpuArchAttributes |=3D EFI_MEMORY_WP; + } + + return CpuArchAttributes; } =20 =20 --=20 2.14.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel