From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,421,1503385200"; d="scan'208";a="326433006" 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 From: Jian J Wang To: edk2-devel@lists.01.org Cc: Eric Dong , Jiewen Yao 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: [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: , X-List-Received-Date: Mon, 23 Oct 2017 06:46:46 -0000 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/CpuPageTable.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 = MemorySpaceMap[Index].BaseAddress; MemorySpaceLength = MemorySpaceMap[Index].Length; + Capabilities = MemorySpaceMap[Index].Capabilities | + EFI_MEMORY_PAGETYPE_MASK; + Status = gDS->SetMemorySpaceCapabilities ( + BaseAddress, + MemorySpaceLength, + Capabilities + ); + ASSERT_EFI_ERROR (Status); + while (MemorySpaceLength > 0) { if (PageLength == 0) { PageEntry = GetPageTableEntry (&PagingContext, BaseAddress, &PageAttribute); @@ -846,7 +855,6 @@ RefreshGcdMemoryAttributesFromPaging ( if (Attributes != (MemorySpaceMap[Index].Attributes & EFI_MEMORY_PAGETYPE_MASK)) { DoUpdate = TRUE; Attributes |= (MemorySpaceMap[Index].Attributes & ~EFI_MEMORY_PAGETYPE_MASK); - Capabilities = Attributes | MemorySpaceMap[Index].Capabilities; } else { DoUpdate = FALSE; } @@ -854,8 +862,8 @@ RefreshGcdMemoryAttributesFromPaging ( Length = MIN (PageLength, MemorySpaceLength); if (DoUpdate) { - gDS->SetMemorySpaceCapabilities (BaseAddress, Length, Capabilities); - gDS->SetMemorySpaceAttributes (BaseAddress, Length, Attributes); + Status = gDS->SetMemorySpaceAttributes (BaseAddress, Length, Attributes); + 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)); -- 2.14.1.windows.1