From nobody Wed May 1 22:44:24 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 1508741434040429.0845995057149; Sun, 22 Oct 2017 23:50:34 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 34A0A202E5CC4; Sun, 22 Oct 2017 23:46:47 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 B4AF02034CF63 for ; Sun, 22 Oct 2017 23:46:46 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2017 23:50:28 -0700 Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.55]) by fmsmga004.fm.intel.com with ESMTP; 22 Oct 2017 23:50:28 -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=192.55.52.93; helo=mga11.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.43,421,1503385200"; d="scan'208";a="326433006" From: Jian J Wang To: edk2-devel@lists.01.org Date: Mon, 23 Oct 2017 14:50:22 +0800 Message-Id: <20171023065022.1272-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 Subject: [edk2] [PATCH] 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: 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" 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. Cc: Eric Dong Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- UefiCpuPkg/CpuDxe/CpuPageTable.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTa= ble.c index d312eb66f8..0802464b9d 100644 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c @@ -829,6 +829,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 +855,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 +862,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