From: "Min Xu" <min.m.xu@intel.com>
To: devel@edk2.groups.io
Cc: Min M Xu <min.m.xu@intel.com>,
Jian J Wang <jian.j.wang@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>, Ray Ni <ray.ni@intel.com>,
Erdem Aktas <erdemaktas@google.com>,
Gerd Hoffmann <kraxel@redhat.com>,
James Bottomley <jejb@linux.ibm.com>,
Jiewen Yao <jiewen.yao@intel.com>,
Tom Lendacky <thomas.lendacky@amd.com>
Subject: [PATCH 05/14] MdeModulePkg: Update Dxe to handle unaccepted memory type
Date: Mon, 6 Jun 2022 10:59:53 +0800 [thread overview]
Message-ID: <48f0b328f456550ac532462b7034da53cfe99886.1654420875.git.min.m.xu@intel.com> (raw)
In-Reply-To: <cover.1654420875.git.min.m.xu@intel.com>
From: Min M Xu <min.m.xu@intel.com>
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3937
Unaccepted memory is a kind of new memory type,
CoreInitializeGcdServices() and CoreGetMemoryMap() are updated to handle
the unaccepted memory type.
Ref: microsoft/mu_basecore@97e9c31
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
---
MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 5 +++++
MdeModulePkg/Core/Dxe/Mem/Page.c | 28 ++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index 3763467bdbc0..b82fe11cb0f3 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -8,6 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Pi/PrePiHob.h>
#include "DxeMain.h"
#include "Gcd.h"
#include "Mem/HeapGuard.h"
@@ -103,6 +104,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdMemoryTypeNames[] = {
"MMIO ", // EfiGcdMemoryTypeMemoryMappedIo
"PersisMem", // EfiGcdMemoryTypePersistent
"MoreRelia", // EfiGcdMemoryTypeMoreReliable
+ "Unaccepte", // EfiGcdMemoryTypeUnaccepted
"Unknown " // EfiGcdMemoryTypeMaximum
};
@@ -2600,6 +2602,9 @@ CoreInitializeGcdServices (
case EFI_RESOURCE_MEMORY_RESERVED:
GcdMemoryType = EfiGcdMemoryTypeReserved;
break;
+ case EFI_RESOURCE_MEMORY_UNACCEPTED:
+ GcdMemoryType = EfiGcdMemoryTypeUnaccepted;
+ break;
case EFI_RESOURCE_IO:
GcdIoType = EfiGcdIoTypeIo;
break;
diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c
index 47d4c5d92e15..008efdf397e0 100644
--- a/MdeModulePkg/Core/Dxe/Mem/Page.c
+++ b/MdeModulePkg/Core/Dxe/Mem/Page.c
@@ -61,6 +61,7 @@ EFI_MEMORY_TYPE_STATISTICS mMemoryTypeStatistics[EfiMaxMemoryType + 1] = {
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiMemoryMappedIOPortSpace
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiPalCode
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiPersistentMemory
+ { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiUnacceptedMemory
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // EfiMaxMemoryType
};
@@ -83,6 +84,7 @@ EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1] = {
{ EfiMemoryMappedIOPortSpace, 0 },
{ EfiPalCode, 0 },
{ EfiPersistentMemory, 0 },
+ { EfiGcdMemoryTypeUnaccepted, 0 },
{ EfiMaxMemoryType, 0 }
};
//
@@ -1947,6 +1949,32 @@ CoreGetMemoryMap (
MemoryMap = MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, Size);
}
+ if (MergeGcdMapEntry.GcdMemoryType == EfiGcdMemoryTypeUnaccepted) {
+ //
+ // Page Align GCD range is required. When it is converted to EFI_MEMORY_DESCRIPTOR,
+ // it will be recorded as page PhysicalStart and NumberOfPages.
+ //
+ ASSERT ((MergeGcdMapEntry.BaseAddress & EFI_PAGE_MASK) == 0);
+ ASSERT (((MergeGcdMapEntry.EndAddress - MergeGcdMapEntry.BaseAddress + 1) & EFI_PAGE_MASK) == 0);
+
+ //
+ // Create EFI_MEMORY_DESCRIPTOR for every Unaccepted GCD entries
+ //
+ MemoryMap->PhysicalStart = MergeGcdMapEntry.BaseAddress;
+ MemoryMap->VirtualStart = 0;
+ MemoryMap->NumberOfPages = RShiftU64 ((MergeGcdMapEntry.EndAddress - MergeGcdMapEntry.BaseAddress + 1), EFI_PAGE_SHIFT);
+ MemoryMap->Attribute = MergeGcdMapEntry.Attributes |
+ (MergeGcdMapEntry.Capabilities & (EFI_MEMORY_RP | EFI_MEMORY_WP | EFI_MEMORY_XP | EFI_MEMORY_RO |
+ EFI_MEMORY_UC | EFI_MEMORY_UCE | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB));
+ MemoryMap->Type = EfiUnacceptedMemory;
+
+ //
+ // Check to see if the new Memory Map Descriptor can be merged with an
+ // existing descriptor if they are adjacent and have the same attributes
+ //
+ MemoryMap = MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, Size);
+ }
+
if (Link == &mGcdMemorySpaceMap) {
//
// break loop when arrive at head.
--
2.29.2.windows.2
next prev parent reply other threads:[~2022-06-06 3:00 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-06 2:59 [PATCH 00/14] Introduce Lazy-accept for Tdx guest Min Xu
2022-06-06 2:59 ` [PATCH 01/14] MdeModulePkg: Add PrePiHob.h Min Xu
2022-06-06 2:59 ` [PATCH 02/14] MdePkg: Increase EFI_RESOURCE_MAX_MEMORY_TYPE Min Xu
2022-06-06 3:23 ` Yao, Jiewen
2022-06-07 10:39 ` Gerd Hoffmann
2022-06-08 0:02 ` [edk2-devel] " Min Xu
2022-06-06 2:59 ` [PATCH 03/14] OvmfPkg: Use EFI_RESOURCE_MEMORY_UNACCEPTED which defined in MdeModulePkg Min Xu
2022-06-06 2:59 ` [PATCH 04/14] MdePkg: Add UEFI Unaccepted memory definition Min Xu
2022-06-06 3:23 ` Yao, Jiewen
[not found] ` <004301d87ec6$72e53d00$58afb700$@byosoft.com.cn>
2022-06-15 5:39 ` Min Xu
2022-06-06 2:59 ` Min Xu [this message]
[not found] ` <005601d87ec8$7f6f7700$7e4e6500$@byosoft.com.cn>
2022-06-15 6:18 ` [edk2-devel] [PATCH 05/14] MdeModulePkg: Update Dxe to handle unaccepted memory type Min Xu
2022-06-06 2:59 ` [PATCH 06/14] ShellPkg: Update shell command memmap to show unaccepted memory Min Xu
2022-06-06 3:01 ` Ni, Ray
2022-06-06 3:19 ` Min Xu
2022-06-06 2:59 ` [PATCH 07/14] OvmfPkg: Add PCD and DEFINEs for Lazy Accept page Min Xu
2022-06-07 10:45 ` Gerd Hoffmann
2022-06-08 0:06 ` Min Xu
2022-06-08 6:18 ` Gerd Hoffmann
2022-06-15 3:07 ` Min Xu
2022-06-15 8:05 ` Gerd Hoffmann
2022-06-15 20:51 ` Dionna Glaze
2022-06-16 0:05 ` [edk2-devel] " Min Xu
2022-06-16 5:51 ` Gerd Hoffmann
2022-06-16 7:33 ` Min Xu
2022-06-16 13:09 ` Lendacky, Thomas
2022-06-16 16:44 ` Dionna Glaze
2022-06-16 18:33 ` Lendacky, Thomas
2022-06-16 23:47 ` Dionna Glaze
2022-06-14 16:10 ` Dionna Glaze
2022-06-15 3:08 ` Min Xu
2022-06-06 2:59 ` [PATCH 08/14] OvmfPkg: Use PcdOvmfWorkAreaBase instead of PcdSevEsWorkAreaBase Min Xu
2022-06-07 10:48 ` Gerd Hoffmann
2022-06-08 0:08 ` Min Xu
2022-06-06 2:59 ` [PATCH 09/14] OvmfPkg: Add MaxAcceptedMemoryAddress in TDX work area Min Xu
2022-06-06 2:59 ` [PATCH 10/14] OvmfPkg: Introduce lazy accept in PlatformInitLib and PlatformPei Min Xu
2022-06-06 2:59 ` [PATCH 11/14] OvmfPkg: Update ConstructFwHobList for lazy accept Min Xu
2022-06-06 3:00 ` [PATCH 12/14] MdePkg: The prototype definition of EfiMemoryAcceptProtocol Min Xu
2022-06-06 3:22 ` Yao, Jiewen
2022-06-08 0:49 ` Min Xu
2022-06-06 3:00 ` [PATCH 13/14] OvmfPkg: Realize EfiMemoryAcceptProtocol in TdxDxe Min Xu
2022-06-06 3:00 ` [PATCH 14/14] MdeModulePkg: Pool and page functions accept memory when OOM occurs Min Xu
2022-08-11 3:17 ` [PATCH 00/14] Introduce Lazy-accept for Tdx guest Min Xu
2022-08-16 6:47 ` Gerd Hoffmann
2022-09-22 20:29 ` Dionna Glaze
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48f0b328f456550ac532462b7034da53cfe99886.1654420875.git.min.m.xu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox