From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 E2B7021A1099A for ; Sun, 26 Nov 2017 21:30:40 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2017 21:35:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,463,1505804400"; d="scan'208";a="7418455" Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.52]) by fmsmga001.fm.intel.com with ESMTP; 26 Nov 2017 21:35:00 -0800 From: Jian J Wang To: edk2-devel@lists.01.org Cc: Jiewen Yao , Star Zeng , Laszlo Ersek Date: Mon, 27 Nov 2017 13:34:56 +0800 Message-Id: <20171127053456.14312-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 Subject: [PATCH] MdeModulePkg/Core: Merge memory map after filtering paging capability 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, 27 Nov 2017 05:30:41 -0000 Once the paging capabilities were filtered out, there might be some adjacent entries sharing the same capabilities. It's recommended to merge those entries for the OS compatibility purpose. This patch makes use of existing method MergeMemoryMap() to do it. This is done by simply turning this method from static to extern, and call it after filter code. This patch is related to an issue described at https://bugzilla.tianocore.org/show_bug.cgi?id=753 This patch is also passed test of booting follow OSs: Windows 10 Windows Server 2016 Fedora 26 Fedora 25 Cc: Jiewen Yao Cc: Star Zeng Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- MdeModulePkg/Core/Dxe/DxeMain.h | 18 ++++++++++++++++++ MdeModulePkg/Core/Dxe/Mem/Page.c | 1 + MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 1 - 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 1a0babba71..07b86ba696 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -2948,4 +2948,22 @@ ApplyMemoryProtectionPolicy ( IN UINT64 Length ); +/** + Merge continous memory map entries whose have same attributes. + + @param MemoryMap A pointer to the buffer in which firmware places + the current memory map. + @param MemoryMapSize A pointer to the size, in bytes, of the + MemoryMap buffer. On input, this is the size of + the current memory map. On output, + it is the size of new memory map after merge. + @param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR. +**/ +VOID +MergeMemoryMap ( + IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, + IN OUT UINTN *MemoryMapSize, + IN UINTN DescriptorSize + ); + #endif diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index 962ae90d3d..ca4ce69a3f 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -1915,6 +1915,7 @@ CoreGetMemoryMap ( EFI_MEMORY_XP); MemoryMap = NEXT_MEMORY_DESCRIPTOR (MemoryMap, Size); } + MergeMemoryMap (MemoryMapStart, &BufferSize, Size); Status = EFI_SUCCESS; diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c index 6cf5edcbe5..75d9b14c1f 100644 --- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c @@ -182,7 +182,6 @@ SortMemoryMap ( it is the size of new memory map after merge. @param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR. **/ -STATIC VOID MergeMemoryMap ( IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, -- 2.14.1.windows.1