public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Park, Aiden" <aiden.park@intel.com>
To: guo.dong@intel.com, maurice.ma@intel.com, devel@edk2.groups.io
Cc: aiden.park@intel.com
Subject: [PATCH] UefiPayloadPkg: Update EFI Memory Service conditions
Date: Thu, 28 Jan 2021 17:59:37 -0800	[thread overview]
Message-ID: <20210129015937.1983-1-aiden.park@intel.com> (raw)

From: Aiden Park <aiden.park@intel.com>

The CoreInitializeMemoryServices() looks for a suitable memory region
for EFI Memory Service from the ResourceDescriptor Hob.
This patch does not allow legacy memory region for the Memory Service
and provides default memory type information to calculate minimal
required memory size properly for the Memory Service.

Signed-off-by: Aiden Park <aiden.park@intel.com>
---
 .../UefiPayloadEntry/UefiPayloadEntry.c       | 20 +++++++++++++++++++
 .../UefiPayloadEntry/UefiPayloadEntry.inf     |  5 +++++
 2 files changed, 25 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 805f5448d9..d2e6f962cd 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -6,6 +6,16 @@
 **/
 
 #include "UefiPayloadEntry.h"
+#include <Guid/MemoryTypeInformation.h>
+
+EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
+  { EfiACPIReclaimMemory,   FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory) },
+  { EfiACPIMemoryNVS,       FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS) },
+  { EfiReservedMemoryType,  FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryType) },
+  { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesData) },
+  { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode) },
+  { EfiMaxMemoryType,       0     }
+};
 
 /**
    Callback function to build resource descriptor HOB
@@ -44,6 +54,9 @@ MemInfoCallback (
     // Remove tested attribute to avoid DXE core to dispatch driver to memory above 4GB
     Attribue &= ~EFI_RESOURCE_ATTRIBUTE_TESTED;
   }
+  if (Base == 0x00) {
+    Attribue &= ~EFI_RESOURCE_ATTRIBUTE_TESTED;
+  }
 
   BuildResourceDescriptorHob (Type, Attribue, (EFI_PHYSICAL_ADDRESS)Base, Size);
   DEBUG ((DEBUG_INFO , "buildhob: base = 0x%lx, size = 0x%lx, type = 0x%x\n", Base, Size, Type));
@@ -315,6 +328,13 @@ BuildGenericHob (
   UINT8                            PhysicalAddressBits;
   EFI_RESOURCE_ATTRIBUTE_TYPE      ResourceAttribute;
 
+  //
+  // Create Memory Type Information HOB
+  //
+  BuildGuidDataHob (&gEfiMemoryTypeInformationGuid,
+                    mDefaultMemoryTypeInformation,
+                    sizeof (mDefaultMemoryTypeInformation));
+
   // The UEFI payload FV
   BuildMemoryAllocationHob (PcdGet32 (PcdPayloadFdMemBase), PcdGet32 (PcdPayloadFdMemSize), EfiBootServicesData);
 
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
index cc59f1903b..5cb084ca51 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
@@ -86,6 +86,11 @@
   gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize
   gUefiPayloadPkgTokenSpaceGuid.PcdPayloadStackTop
   gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize
+  gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
+  gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS
+  gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType
+  gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData
+  gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack               ## SOMETIMES_CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
-- 
2.20.1


             reply	other threads:[~2021-01-29  1:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-29  1:59 Park, Aiden [this message]
2021-01-29  3:45 ` [edk2-devel] [PATCH] UefiPayloadPkg: Update EFI Memory Service conditions Ni, Ray
2021-01-29 21:08   ` Park, Aiden
2021-01-31  4:19     ` Benjamin You

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=20210129015937.1983-1-aiden.park@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