From nobody Sat Apr 27 10:09:20 2024 Delivered-To: importer@patchew.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 1509670655635754.8870302974871; Thu, 2 Nov 2017 17:57:35 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 73AD921F7F5D3; Thu, 2 Nov 2017 17:53:39 -0700 (PDT) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 012802034A896 for ; Thu, 2 Nov 2017 17:53:38 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2017 17:57:32 -0700 Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.100]) by fmsmga002.fm.intel.com with ESMTP; 02 Nov 2017 17:57:31 -0700 X-Original-To: edk2-devel@lists.01.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; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,336,1505804400"; d="scan'208";a="1239046027" From: Jian J Wang To: edk2-devel@lists.01.org Date: Fri, 3 Nov 2017 08:57:29 +0800 Message-Id: <20171103005729.7856-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 Subject: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of RT_CODE in memory map 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: Laszlo Ersek , Jiewen Yao , Eric Dong 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" > v2 > a. Fix an issue which will cause setting capability failure if size is sm= aller > than a page. More than one entry of RT_CODE memory might cause boot problem for some old OSs. This patch will fix this issue to keep OS compatibility as much as possible. More detailed information, please refer to https://bugzilla.tianocore.org/show_bug.cgi?id=3D753 Cc: Eric Dong Cc: Jiewen Yao Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang Acked-by: Laszlo Ersek --- UefiCpuPkg/CpuDxe/CpuPageTable.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTa= ble.c index d312eb66f8..4a7827ebc9 100644 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c @@ -809,7 +809,9 @@ RefreshGcdMemoryAttributesFromPaging ( PageLength =3D 0; =20 for (Index =3D 0; Index < NumberOfDescriptors; Index++) { - if (MemorySpaceMap[Index].GcdMemoryType =3D=3D EfiGcdMemoryTypeNonExis= tent) { + if (MemorySpaceMap[Index].GcdMemoryType =3D=3D EfiGcdMemoryTypeNonExis= tent + || (MemorySpaceMap[Index].BaseAddress & EFI_PAGE_MASK) !=3D 0 + || (MemorySpaceMap[Index].Length & EFI_PAGE_MASK) !=3D 0) { continue; } =20 @@ -829,6 +831,15 @@ RefreshGcdMemoryAttributesFromPaging ( // Sync real page attributes to GCD BaseAddress =3D MemorySpaceMap[Index].BaseAddress; MemorySpaceLength =3D MemorySpaceMap[Index].Length; + Capabilities =3D MemorySpaceMap[Index].Capabilities | + EFI_MEMORY_PAGETYPE_MASK; + Status =3D gDS->SetMemorySpaceCapabilities ( + BaseAddress, + MemorySpaceLength, + Capabilities + ); + ASSERT_EFI_ERROR (Status); + while (MemorySpaceLength > 0) { if (PageLength =3D=3D 0) { PageEntry =3D GetPageTableEntry (&PagingContext, BaseAddress, &Pag= eAttribute); @@ -846,7 +857,6 @@ RefreshGcdMemoryAttributesFromPaging ( if (Attributes !=3D (MemorySpaceMap[Index].Attributes & EFI_MEMORY= _PAGETYPE_MASK)) { DoUpdate =3D TRUE; Attributes |=3D (MemorySpaceMap[Index].Attributes & ~EFI_MEMORY_= PAGETYPE_MASK); - Capabilities =3D Attributes | MemorySpaceMap[Index].Capabilities; } else { DoUpdate =3D FALSE; } @@ -854,8 +864,8 @@ RefreshGcdMemoryAttributesFromPaging ( =20 Length =3D MIN (PageLength, MemorySpaceLength); if (DoUpdate) { - gDS->SetMemorySpaceCapabilities (BaseAddress, Length, Capabilities= ); - gDS->SetMemorySpaceAttributes (BaseAddress, Length, Attributes); + Status =3D gDS->SetMemorySpaceAttributes (BaseAddress, Length, Att= ributes); + ASSERT_EFI_ERROR (Status); DEBUG ((DEBUG_INFO, "Update memory space attribute: [%02d] %016lx = - %016lx (%08lx -> %08lx)\r\n", Index, BaseAddress, BaseAddress + Length - 1, MemorySpaceMap[Index].Attributes, Attributes)= ); --=20 2.14.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel