public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/4] remove generation of EFI properties table
@ 2020-03-26 10:24 Ard Biesheuvel
  2020-03-26 10:24 ` [PATCH 1/4] OvmfPkg: remove handling of " Ard Biesheuvel
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2020-03-26 10:24 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Ray Ni, Jiewen Yao, Bret Barkelew

The EFI properties table is broken by design, deprecated, and seems to be
causing confusion as it is unclear to some how it differs from the memory
attributes table (which supersedes it). So let's get rid of the code that
generates it entirely, along with the GUID definitions, PCDs etc.

Due to how the two implementations are intertwined, patch #2 makes the
minimal changes required to stop producing the table (and to allow patch
#3 to remove the associated definitions from MdePkg). Patch #4 is optional
and merges the code together.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>

Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633

Ard Biesheuvel (4):
  OvmfPkg: remove handling of properties table
  MdeModulePkg: disable properties table generation but retain the code
  MdePkg: remove PropertiesTable GUID
  MdeModulePkg/DxeCore: merge properties table routines into MAT
    handling

 MdeModulePkg/Core/Dxe/DxeMain.h               |    9 -
 MdeModulePkg/Core/Dxe/DxeMain.inf             |    3 -
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c       |    1 -
 .../Core/Dxe/Misc/MemoryAttributesTable.c     | 1226 ++++++++++++++-
 MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c |    1 -
 MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c  | 1373 -----------------
 MdeModulePkg/MdeModulePkg.dec                 |   24 -
 MdeModulePkg/MdeModulePkg.uni                 |   21 -
 MdePkg/Include/Guid/PropertiesTable.h         |   31 -
 MdePkg/MdePkg.dec                             |    3 -
 OvmfPkg/OvmfPkgIa32.dsc                       |    1 -
 OvmfPkg/OvmfPkgIa32X64.dsc                    |    1 -
 OvmfPkg/OvmfPkgX64.dsc                        |    1 -
 OvmfPkg/OvmfXen.dsc                           |    1 -
 OvmfPkg/PlatformPei/Platform.c                |    1 -
 OvmfPkg/PlatformPei/PlatformPei.inf           |    1 -
 16 files changed, 1222 insertions(+), 1476 deletions(-)
 delete mode 100644 MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
 delete mode 100644 MdePkg/Include/Guid/PropertiesTable.h

-- 
2.17.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/4] OvmfPkg: remove handling of properties table
  2020-03-26 10:24 [PATCH 0/4] remove generation of EFI properties table Ard Biesheuvel
@ 2020-03-26 10:24 ` Ard Biesheuvel
  2020-03-27 14:01   ` [edk2-devel] " Laszlo Ersek
  2020-03-26 10:24 ` [PATCH 2/4] MdeModulePkg: disable properties table generation but retain the code Ard Biesheuvel
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Ard Biesheuvel @ 2020-03-26 10:24 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Ray Ni, Jiewen Yao, Bret Barkelew

The UEFI properties table and the associated memory protection feature was
severely broken from the start, and has been deprecated for a while. Let's
drop all references to it from OVMF so we can safely remove it from the
DXE core as well.

Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 OvmfPkg/OvmfPkgIa32.dsc             | 1 -
 OvmfPkg/OvmfPkgIa32X64.dsc          | 1 -
 OvmfPkg/OvmfPkgX64.dsc              | 1 -
 OvmfPkg/OvmfXen.dsc                 | 1 -
 OvmfPkg/PlatformPei/Platform.c      | 1 -
 OvmfPkg/PlatformPei/PlatformPei.inf | 1 -
 6 files changed, 6 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 02ca17db8b2a..47926ac9e235 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -570,7 +570,6 @@ [PcdsDynamicDefault]
 
   # Noexec settings for DXE.
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
 
   # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index d08cf558c6aa..37943624dc72 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -581,7 +581,6 @@ [PcdsDynamicDefault]
 
   # Noexec settings for DXE.
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
 
   # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index b2dccc40a865..f41ebb95d717 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -580,7 +580,6 @@ [PcdsDynamicDefault]
 
   # Noexec settings for DXE.
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
 
   # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index 85fe39f7896c..67b95d7b788c 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -483,7 +483,6 @@ [PcdsDynamicDefault]
 
   # Noexec settings for DXE.
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
 
   # Set memory encryption mask
   gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 587ca68fc210..088e616a980c 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -315,7 +315,6 @@ NoexecDxeInitialization (
   VOID
   )
 {
-  UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdPropertiesTableEnable);
   UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdSetNxForStack);
 }
 
diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
index 8531c63995c1..19f2424981bc 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -94,7 +94,6 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
   gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
   gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/4] MdeModulePkg: disable properties table generation but retain the code
  2020-03-26 10:24 [PATCH 0/4] remove generation of EFI properties table Ard Biesheuvel
  2020-03-26 10:24 ` [PATCH 1/4] OvmfPkg: remove handling of " Ard Biesheuvel
@ 2020-03-26 10:24 ` Ard Biesheuvel
  2020-03-26 10:24 ` [PATCH 3/4] MdePkg: remove PropertiesTable GUID Ard Biesheuvel
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2020-03-26 10:24 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Ray Ni, Jiewen Yao, Bret Barkelew

This is the minimal change required to stop exposing the EFI properties
table, which is deprecated. Given how the implementation is entangled
with the code that exposes the related memory attributes table, most of
the code is retained, and further cleanups are relegated to subsequent
patches.

Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/Core/Dxe/DxeMain.inf                  |   2 -
 MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c |   7 +-
 MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c      |   1 -
 MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c       | 107 ++------------------
 MdeModulePkg/MdeModulePkg.dec                      |  24 -----
 MdeModulePkg/MdeModulePkg.uni                      |  21 ----
 6 files changed, 14 insertions(+), 148 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf
index 61161bee28e1..75e0a968f0cf 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -120,7 +120,6 @@ [Guids]
   gEventExitBootServicesFailedGuid              ## SOMETIMES_PRODUCES   ## Event
   gEfiVectorHandoffTableGuid                    ## SOMETIMES_PRODUCES   ## SystemTable
   gEdkiiMemoryProfileGuid                       ## SOMETIMES_PRODUCES   ## GUID # Install protocol
-  gEfiPropertiesTableGuid                       ## SOMETIMES_PRODUCES   ## SystemTable
   gEfiMemoryAttributesTableGuid                 ## SOMETIMES_PRODUCES   ## SystemTable
   gEfiEndOfDxeEventGroupGuid                    ## SOMETIMES_CONSUMES   ## Event
   gEfiHobMemoryAllocStackGuid                   ## SOMETIMES_CONSUMES   ## SystemTable
@@ -180,7 +179,6 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType                 ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask               ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath                 ## CONSUMES
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable                   ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy                   ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy             ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask        ## CONSUMES
diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
index ebdeb35079a2..0b0ed4413c28 100644
--- a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
@@ -18,7 +18,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Guid/EventGroup.h>
 
 #include <Guid/MemoryAttributesTable.h>
-#include <Guid/PropertiesTable.h>
 
 #include "DxeMain.h"
 
@@ -64,7 +63,7 @@ CoreGetMemoryMapWithSeparatedImageSection (
   OUT UINT32                    *DescriptorVersion
   );
 
-extern EFI_PROPERTIES_TABLE  mPropertiesTable;
+BOOLEAN                      mMemoryAttributesTableEnable = TRUE;
 EFI_MEMORY_ATTRIBUTES_TABLE  *mMemoryAttributesTable = NULL;
 BOOLEAN                      mMemoryAttributesTableReadyToBoot = FALSE;
 
@@ -96,8 +95,8 @@ InstallMemoryAttributesTable (
     return;
   }
 
-  if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {
-    DEBUG ((EFI_D_VERBOSE, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DATA is not set, "));
+  if (!mMemoryAttributesTableEnable) {
+    DEBUG ((EFI_D_VERBOSE, "Cannot install Memory Attributes Table "));
     DEBUG ((EFI_D_VERBOSE, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));
     return ;
   }
diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
index 47edf86dfbf3..92a442f517b2 100644
--- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
+++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
@@ -35,7 +35,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include <Guid/EventGroup.h>
 #include <Guid/MemoryAttributesTable.h>
-#include <Guid/PropertiesTable.h>
 
 #include <Protocol/FirmwareVolume2.h>
 #include <Protocol/SimpleFileSystem.h>
diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
index 53bb6b7c912c..6ee8a8af9098 100644
--- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
@@ -23,8 +23,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/PeCoffGetEntryPointLib.h>
 #include <Protocol/Runtime.h>
 
-#include <Guid/PropertiesTable.h>
-
 #include "DxeMain.h"
 #include "HeapGuard.h"
 
@@ -47,18 +45,12 @@ IMAGE_PROPERTIES_PRIVATE_DATA  mImagePropertiesPrivateData = {
   INITIALIZE_LIST_HEAD_VARIABLE (mImagePropertiesPrivateData.ImageRecordList)
 };
 
-EFI_PROPERTIES_TABLE  mPropertiesTable = {
-  EFI_PROPERTIES_TABLE_VERSION,
-  sizeof(EFI_PROPERTIES_TABLE),
-  EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA
-};
-
 EFI_LOCK           mPropertiesTableLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
 
-BOOLEAN            mPropertiesTableEnable;
-
 BOOLEAN            mPropertiesTableEndOfDxe = FALSE;
 
+extern BOOLEAN     mMemoryAttributesTableEnable;
+
 //
 // Below functions are for MemoryMap
 //
@@ -359,11 +351,7 @@ SetNewRecord (
       //
       // DATA
       //
-      if (!mPropertiesTableEnable) {
-        NewRecord->Type = TempRecord.Type;
-      } else {
-        NewRecord->Type = EfiRuntimeServicesData;
-      }
+      NewRecord->Type          = TempRecord.Type;
       NewRecord->PhysicalStart = TempRecord.PhysicalStart;
       NewRecord->VirtualStart  = 0;
       NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentBase - NewRecord->PhysicalStart);
@@ -376,11 +364,7 @@ SetNewRecord (
       //
       // CODE
       //
-      if (!mPropertiesTableEnable) {
-        NewRecord->Type = TempRecord.Type;
-      } else {
-        NewRecord->Type = EfiRuntimeServicesCode;
-      }
+      NewRecord->Type          = TempRecord.Type;
       NewRecord->PhysicalStart = ImageRecordCodeSection->CodeSegmentBase;
       NewRecord->VirtualStart  = 0;
       NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentSize);
@@ -404,11 +388,7 @@ SetNewRecord (
   // Final DATA
   //
   if (TempRecord.PhysicalStart < ImageEnd) {
-    if (!mPropertiesTableEnable) {
-      NewRecord->Type = TempRecord.Type;
-    } else {
-      NewRecord->Type = EfiRuntimeServicesData;
-    }
+    NewRecord->Type          = TempRecord.Type;
     NewRecord->PhysicalStart = TempRecord.PhysicalStart;
     NewRecord->VirtualStart  = 0;
     NewRecord->NumberOfPages = EfiSizeToPages (ImageEnd - TempRecord.PhysicalStart);
@@ -519,14 +499,8 @@ SplitRecord (
         //
         NewRecord = PREVIOUS_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
         IsLastRecordData = FALSE;
-        if (!mPropertiesTableEnable) {
-          if ((NewRecord->Attribute & EFI_MEMORY_XP) != 0) {
-            IsLastRecordData = TRUE;
-          }
-        } else {
-          if (NewRecord->Type == EfiRuntimeServicesData) {
-            IsLastRecordData = TRUE;
-          }
+        if ((NewRecord->Attribute & EFI_MEMORY_XP) != 0) {
+          IsLastRecordData = TRUE;
         }
         if (IsLastRecordData) {
           //
@@ -538,11 +512,7 @@ SplitRecord (
           // Last record is CODE, create a new DATA entry.
           //
           NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
-          if (!mPropertiesTableEnable) {
-            NewRecord->Type = TempRecord.Type;
-          } else {
-            NewRecord->Type = EfiRuntimeServicesData;
-          }
+          NewRecord->Type          = TempRecord.Type;
           NewRecord->PhysicalStart = TempRecord.PhysicalStart;
           NewRecord->VirtualStart  = 0;
           NewRecord->NumberOfPages = TempRecord.NumberOfPages;
@@ -751,7 +721,7 @@ CoreGetMemoryMapWithSeparatedImageSection (
   //
   // If PE code/data is not aligned, just return.
   //
-  if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {
+  if (!mMemoryAttributesTableEnable) {
     return CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey, DescriptorSize, DescriptorVersion);
   }
 
@@ -803,12 +773,9 @@ SetPropertiesTableSectionAlignment (
   )
 {
   if (((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) &&
-      ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) != 0)) {
+      mMemoryAttributesTableEnable) {
     DEBUG ((EFI_D_VERBOSE, "SetPropertiesTableSectionAlignment - Clear\n"));
-    mPropertiesTable.MemoryProtectionAttribute &= ~((UINT64)EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA);
-    gBS->GetMemoryMap = CoreGetMemoryMap;
-    gBS->Hdr.CRC32 = 0;
-    gBS->CalculateCrc32 ((UINT8 *)gBS, gBS->Hdr.HeaderSize, &gBS->Hdr.CRC32);
+    mMemoryAttributesTableEnable = FALSE;
   }
 }
 
@@ -1018,35 +985,6 @@ SortImageRecord (
   }
 }
 
-/**
-  Dump image record.
-**/
-STATIC
-VOID
-DumpImageRecord (
-  VOID
-  )
-{
-  IMAGE_PROPERTIES_RECORD      *ImageRecord;
-  LIST_ENTRY                   *ImageRecordLink;
-  LIST_ENTRY                   *ImageRecordList;
-  UINTN                        Index;
-
-  ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;
-
-  for (ImageRecordLink = ImageRecordList->ForwardLink, Index= 0;
-       ImageRecordLink != ImageRecordList;
-       ImageRecordLink = ImageRecordLink->ForwardLink, Index++) {
-    ImageRecord = CR (
-                    ImageRecordLink,
-                    IMAGE_PROPERTIES_RECORD,
-                    Link,
-                    IMAGE_PROPERTIES_RECORD_SIGNATURE
-                    );
-    DEBUG ((EFI_D_VERBOSE, "  Image[%d]: 0x%016lx - 0x%016lx\n", Index, ImageRecord->ImageBase, ImageRecord->ImageSize));
-  }
-}
-
 /**
   Insert image record.
 
@@ -1323,29 +1261,6 @@ InstallPropertiesTable (
   )
 {
   mPropertiesTableEndOfDxe = TRUE;
-  if (PcdGetBool (PcdPropertiesTableEnable)) {
-    EFI_STATUS  Status;
-
-    Status = gBS->InstallConfigurationTable (&gEfiPropertiesTableGuid, &mPropertiesTable);
-    ASSERT_EFI_ERROR (Status);
-
-    DEBUG ((EFI_D_INFO, "MemoryProtectionAttribute - 0x%016lx\n", mPropertiesTable.MemoryProtectionAttribute));
-    if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {
-      DEBUG ((EFI_D_ERROR, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DATA is not set, "));
-      DEBUG ((EFI_D_ERROR, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));
-      return ;
-    }
-
-    gBS->GetMemoryMap = CoreGetMemoryMapWithSeparatedImageSection;
-    gBS->Hdr.CRC32 = 0;
-    gBS->CalculateCrc32 ((UINT8 *)gBS, gBS->Hdr.HeaderSize, &gBS->Hdr.CRC32);
-
-    DEBUG ((EFI_D_VERBOSE, "Total Image Count - 0x%x\n", mImagePropertiesPrivateData.ImageRecordCount));
-    DEBUG ((EFI_D_VERBOSE, "Dump ImageRecord:\n"));
-    DumpImageRecord ();
-
-    mPropertiesTableEnable = TRUE;
-  }
 }
 
 /**
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 91a3c608231c..aeb8b820db1b 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1866,30 +1866,6 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
   # @Prompt Flag to request system reboot after processing capsule.
   gEfiMdeModulePkgTokenSpaceGuid.PcdSystemRebootAfterCapsuleProcessFlag|0x0001|UINT16|0x0000006d
 
-  ## Publish PropertiesTable or not.
-  #
-  # If this PCD is TRUE, DxeCore publishs PropertiesTable.
-  # DxeCore evaluates if all runtime drivers has 4K aligned PE sections. If all
-  # PE sections in runtime drivers are 4K aligned, DxeCore sets BIT0 in
-  # PropertiesTable. Or DxeCore clears BIT0 in PropertiesTable.
-  # If this PCD is FALSE, DxeCore does not publish PropertiesTable.
-  #
-  # If PropertiesTable has BIT0 set, DxeCore uses below policy in UEFI memory map:
-  #   1) Use EfiRuntimeServicesCode for runtime driver PE image code section and
-  #      use EfiRuntimeServicesData for runtime driver PE image header and other section.
-  #   2) Set EfiRuntimeServicesCode to be EFI_MEMORY_RO.
-  #   3) Set EfiRuntimeServicesData to be EFI_MEMORY_XP.
-  #   4) Set EfiMemoryMappedIO and EfiMemoryMappedIOPortSpace to be EFI_MEMORY_XP.
-  #
-  # NOTE: Platform need gurantee this PCD is set correctly. Platform should set
-  # this PCD to be TURE if and only if all runtime driver has seperated Code/Data
-  # section. If PE code/data sections are merged, the result is unpredictable.
-  #
-  # UEFI 2.6 specification does not recommend to use this BIT0 attribute.
-  #
-  # @Prompt Publish UEFI PropertiesTable.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE|BOOLEAN|0x0000006e
-
   ## Default OEM ID for ACPI table creation, its length must be 0x6 bytes to follow ACPI specification.
   # @Prompt Default OEM ID for ACPI table creation.
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId|"INTEL "|VOID*|0x30001034
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni
index 2c856ed07333..2007e0596c4f 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -891,27 +891,6 @@
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFrontPageFormSetGuid_HELP  #language en-US "This PCD points to the front page formset GUID\n"
                                                                                          "Compare the FormsetGuid or ClassGuid with this PCD value can detect whether in front page"
 
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPropertiesTableEnable_PROMPT  #language en-US "Publish UEFI PropertiesTable."
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPropertiesTableEnable_HELP  #language en-US "Publish PropertiesTable or not.\n"
-                                                                                          "\n"
-                                                                                          "If this PCD is TRUE, DxeCore publishs PropertiesTable.\n"
-                                                                                          "DxeCore evaluates if all runtime drivers has 4K aligned PE sections. If all\n"
-                                                                                          "PE sections in runtime drivers are 4K aligned, DxeCore sets BIT0 in\n"
-                                                                                          "PropertiesTable. Or DxeCore clears BIT0 in PropertiesTable.\n"
-                                                                                          "If this PCD is FALSE, DxeCore does not publish PropertiesTable.\n"
-                                                                                          "\n"
-                                                                                          "If PropertiesTable has BIT0 set, DxeCore uses below policy in UEFI memory map:\n"
-                                                                                          "1) Use EfiRuntimeServicesCode for runtime driver PE image code section and\n"
-                                                                                          "use EfiRuntimeServicesData for runtime driver PE image header and other section.\n"
-                                                                                          "2) Set EfiRuntimeServicesCode to be EFI_MEMORY_RO.\n"
-                                                                                          "3) Set EfiRuntimeServicesData to be EFI_MEMORY_XP.\n"
-                                                                                          "4) Set EfiMemoryMappedIO and EfiMemoryMappedIOPortSpace to be EFI_MEMORY_XP.\n"
-                                                                                          "\n"
-                                                                                          "NOTE: Platform need gurantee this PCD is set correctly. Platform should set\n"
-                                                                                          "this PCD to be TURE if and only if all runtime driver has seperated Code/Data\n"
-                                                                                          "section. If PE code/data sections are merged, the result is unpredictable.\n"
-
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdShadowPeimOnBoot_HELP  #language en-US "Indicates if to shadow PEIM and PeiCore after memory is ready.<BR><BR>\n"
                                                                                      "This PCD is used on other boot path except for S3 boot.\n"
                                                                                      "TRUE  - Shadow PEIM and PeiCore after memory is ready.<BR>\n"
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/4] MdePkg: remove PropertiesTable GUID
  2020-03-26 10:24 [PATCH 0/4] remove generation of EFI properties table Ard Biesheuvel
  2020-03-26 10:24 ` [PATCH 1/4] OvmfPkg: remove handling of " Ard Biesheuvel
  2020-03-26 10:24 ` [PATCH 2/4] MdeModulePkg: disable properties table generation but retain the code Ard Biesheuvel
@ 2020-03-26 10:24 ` Ard Biesheuvel
  2020-03-27  1:02   ` [EXTERNAL] " Bret Barkelew
  2020-03-26 10:24 ` [PATCH 4/4] MdeModulePkg/DxeCore: merge properties table routines into MAT handling Ard Biesheuvel
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Ard Biesheuvel @ 2020-03-26 10:24 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Ray Ni, Jiewen Yao, Bret Barkelew

Remove the GUID definition that describes the deprecated properties table,
which is no longer generated by the DXE core.

Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdePkg/Include/Guid/PropertiesTable.h | 31 --------------------
 MdePkg/MdePkg.dec                     |  3 --
 2 files changed, 34 deletions(-)

diff --git a/MdePkg/Include/Guid/PropertiesTable.h b/MdePkg/Include/Guid/PropertiesTable.h
deleted file mode 100644
index 56dbc7f96138..000000000000
--- a/MdePkg/Include/Guid/PropertiesTable.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/** @file
-  GUIDs used for UEFI Properties Table in the UEFI 2.5 specification.
-
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __EFI_PROPERTIES_TABLE_H__
-#define __EFI_PROPERTIES_TABLE_H__
-
-#define EFI_PROPERTIES_TABLE_GUID {\
-  0x880aaca3, 0x4adc, 0x4a04, {0x90, 0x79, 0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5} \
-}
-
-typedef struct {
-  UINT32    Version;
-  UINT32    Length;
-  UINT64    MemoryProtectionAttribute;
-} EFI_PROPERTIES_TABLE;
-
-#define EFI_PROPERTIES_TABLE_VERSION  0x00010000
-
-//
-// Memory attribute (Not defined bit is reserved)
-//
-#define EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA        0x1
-
-extern EFI_GUID gEfiPropertiesTableGuid;
-
-#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index ac1f5339af06..6c37c2181c62 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -578,9 +578,6 @@ [Guids]
   # GUIDs defined in UEFI2.5
   #
 
-  ## Include/Guid/PropertiesTable.h
-  gEfiPropertiesTableGuid        = { 0x880aaca3, 0x4adc, 0x4a04, {0x90, 0x79, 0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5 }}
-
   ## Include/Guid/SystemResourceTable.h
   gEfiSystemResourceTableGuid    = { 0xb122a263, 0x3661, 0x4f68, {0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 }}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/4] MdeModulePkg/DxeCore: merge properties table routines into MAT handling
  2020-03-26 10:24 [PATCH 0/4] remove generation of EFI properties table Ard Biesheuvel
                   ` (2 preceding siblings ...)
  2020-03-26 10:24 ` [PATCH 3/4] MdePkg: remove PropertiesTable GUID Ard Biesheuvel
@ 2020-03-26 10:24 ` Ard Biesheuvel
  2020-03-27  5:00 ` [PATCH 0/4] remove generation of EFI properties table Yao, Jiewen
  2020-04-03  2:22 ` Dandan Bi
  5 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2020-03-26 10:24 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Ray Ni, Jiewen Yao, Bret Barkelew

The memory attributes table handling code shared some parts of the
properties table handling code when it was introduced. The latter has
been dropped, and so we can merge the remaining pieces into the former.

Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/Core/Dxe/DxeMain.h                    |    9 -
 MdeModulePkg/Core/Dxe/DxeMain.inf                  |    1 -
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c            |    1 -
 MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c | 1219 ++++++++++++++++++
 MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c       | 1288 --------------------
 5 files changed, 1219 insertions(+), 1299 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index 6a64852730fb..9bd3c0d08411 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -2815,15 +2815,6 @@ CoreUpdateMemoryAttributes (
   IN UINT64                NewAttributes
   );
 
-/**
-  Initialize PropertiesTable support.
-**/
-VOID
-EFIAPI
-CoreInitializePropertiesTable (
-  VOID
-  );
-
 /**
   Initialize MemoryAttrubutesTable support.
 **/
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf
index 75e0a968f0cf..1d4b11dc7318 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -34,7 +34,6 @@ [Sources]
   Misc/Stall.c
   Misc/SetWatchdogTimer.c
   Misc/InstallConfigurationTable.c
-  Misc/PropertiesTable.c
   Misc/MemoryAttributesTable.c
   Misc/MemoryProtection.c
   Library/Library.c
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
index 514d1aa75ada..5ee4cd10b436 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -423,7 +423,6 @@ DxeMain (
 
   MemoryProfileInstallProtocol ();
 
-  CoreInitializePropertiesTable ();
   CoreInitializeMemoryAttributesTable ();
   CoreInitializeMemoryProtection ();
 
diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
index 0b0ed4413c28..bb1c48ab6c4e 100644
--- a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
@@ -20,6 +20,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Guid/MemoryAttributesTable.h>
 
 #include "DxeMain.h"
+#include "HeapGuard.h"
 
 /**
   This function for GetMemoryMap() with properties table capability.
@@ -63,7 +64,29 @@ CoreGetMemoryMapWithSeparatedImageSection (
   OUT UINT32                    *DescriptorVersion
   );
 
+#define PREVIOUS_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
+  ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size)))
+
+#define IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('I','P','P','D')
+
+typedef struct {
+  UINT32                 Signature;
+  UINTN                  ImageRecordCount;
+  UINTN                  CodeSegmentCountMax;
+  LIST_ENTRY             ImageRecordList;
+} IMAGE_PROPERTIES_PRIVATE_DATA;
+
+STATIC IMAGE_PROPERTIES_PRIVATE_DATA  mImagePropertiesPrivateData = {
+  IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE,
+  0,
+  0,
+  INITIALIZE_LIST_HEAD_VARIABLE (mImagePropertiesPrivateData.ImageRecordList)
+};
+
+STATIC EFI_LOCK              mMemoryAttributesTableLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
+
 BOOLEAN                      mMemoryAttributesTableEnable = TRUE;
+BOOLEAN                      mMemoryAttributesTableEndOfDxe = FALSE;
 EFI_MEMORY_ATTRIBUTES_TABLE  *mMemoryAttributesTable = NULL;
 BOOLEAN                      mMemoryAttributesTableReadyToBoot = FALSE;
 
@@ -247,6 +270,7 @@ InstallMemoryAttributesTableOnEndOfDxe (
   IN VOID               *Context
   )
 {
+  mMemoryAttributesTableEndOfDxe = TRUE;
   InstallMemoryAttributesTable ();
 }
 
@@ -293,3 +317,1198 @@ CoreInitializeMemoryAttributesTable (
   ASSERT_EFI_ERROR (Status);
   return ;
 }
+
+//
+// Below functions are for MemoryMap
+//
+
+/**
+  Converts a number of EFI_PAGEs to a size in bytes.
+
+  NOTE: Do not use EFI_PAGES_TO_SIZE because it handles UINTN only.
+
+  @param  Pages     The number of EFI_PAGES.
+
+  @return  The number of bytes associated with the number of EFI_PAGEs specified
+           by Pages.
+**/
+STATIC
+UINT64
+EfiPagesToSize (
+  IN UINT64 Pages
+  )
+{
+  return LShiftU64 (Pages, EFI_PAGE_SHIFT);
+}
+
+/**
+  Converts a size, in bytes, to a number of EFI_PAGESs.
+
+  NOTE: Do not use EFI_SIZE_TO_PAGES because it handles UINTN only.
+
+  @param  Size      A size in bytes.
+
+  @return  The number of EFI_PAGESs associated with the number of bytes specified
+           by Size.
+
+**/
+STATIC
+UINT64
+EfiSizeToPages (
+  IN UINT64 Size
+  )
+{
+  return RShiftU64 (Size, EFI_PAGE_SHIFT) + ((((UINTN)Size) & EFI_PAGE_MASK) ? 1 : 0);
+}
+
+/**
+  Acquire memory lock on mMemoryAttributesTableLock.
+**/
+STATIC
+VOID
+CoreAcquiremMemoryAttributesTableLock (
+  VOID
+  )
+{
+  CoreAcquireLock (&mMemoryAttributesTableLock);
+}
+
+/**
+  Release memory lock on mMemoryAttributesTableLock.
+**/
+STATIC
+VOID
+CoreReleasemMemoryAttributesTableLock (
+  VOID
+  )
+{
+  CoreReleaseLock (&mMemoryAttributesTableLock);
+}
+
+/**
+  Sort memory map entries based upon PhysicalStart, from low to high.
+
+  @param  MemoryMap              A pointer to the buffer in which firmware places
+                                 the current memory map.
+  @param  MemoryMapSize          Size, in bytes, of the MemoryMap buffer.
+  @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
+**/
+STATIC
+VOID
+SortMemoryMap (
+  IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,
+  IN UINTN                      MemoryMapSize,
+  IN UINTN                      DescriptorSize
+  )
+{
+  EFI_MEMORY_DESCRIPTOR       *MemoryMapEntry;
+  EFI_MEMORY_DESCRIPTOR       *NextMemoryMapEntry;
+  EFI_MEMORY_DESCRIPTOR       *MemoryMapEnd;
+  EFI_MEMORY_DESCRIPTOR       TempMemoryMap;
+
+  MemoryMapEntry = MemoryMap;
+  NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
+  MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + MemoryMapSize);
+  while (MemoryMapEntry < MemoryMapEnd) {
+    while (NextMemoryMapEntry < MemoryMapEnd) {
+      if (MemoryMapEntry->PhysicalStart > NextMemoryMapEntry->PhysicalStart) {
+        CopyMem (&TempMemoryMap, MemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR));
+        CopyMem (MemoryMapEntry, NextMemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR));
+        CopyMem (NextMemoryMapEntry, &TempMemoryMap, sizeof(EFI_MEMORY_DESCRIPTOR));
+      }
+
+      NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize);
+    }
+
+    MemoryMapEntry      = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
+    NextMemoryMapEntry  = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
+  }
+
+  return ;
+}
+
+/**
+  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
+  )
+{
+  EFI_MEMORY_DESCRIPTOR       *MemoryMapEntry;
+  EFI_MEMORY_DESCRIPTOR       *MemoryMapEnd;
+  UINT64                      MemoryBlockLength;
+  EFI_MEMORY_DESCRIPTOR       *NewMemoryMapEntry;
+  EFI_MEMORY_DESCRIPTOR       *NextMemoryMapEntry;
+
+  MemoryMapEntry = MemoryMap;
+  NewMemoryMapEntry = MemoryMap;
+  MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + *MemoryMapSize);
+  while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) {
+    CopyMem (NewMemoryMapEntry, MemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR));
+    NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
+
+    do {
+      MergeGuardPages (NewMemoryMapEntry, NextMemoryMapEntry->PhysicalStart);
+      MemoryBlockLength = (UINT64) (EfiPagesToSize (NewMemoryMapEntry->NumberOfPages));
+      if (((UINTN)NextMemoryMapEntry < (UINTN)MemoryMapEnd) &&
+          (NewMemoryMapEntry->Type == NextMemoryMapEntry->Type) &&
+          (NewMemoryMapEntry->Attribute == NextMemoryMapEntry->Attribute) &&
+          ((NewMemoryMapEntry->PhysicalStart + MemoryBlockLength) == NextMemoryMapEntry->PhysicalStart)) {
+        NewMemoryMapEntry->NumberOfPages += NextMemoryMapEntry->NumberOfPages;
+        NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize);
+        continue;
+      } else {
+        MemoryMapEntry = PREVIOUS_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize);
+        break;
+      }
+    } while (TRUE);
+
+    MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
+    NewMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NewMemoryMapEntry, DescriptorSize);
+  }
+
+  *MemoryMapSize = (UINTN)NewMemoryMapEntry - (UINTN)MemoryMap;
+
+  return ;
+}
+
+/**
+  Enforce memory map attributes.
+  This function will set EfiRuntimeServicesData/EfiMemoryMappedIO/EfiMemoryMappedIOPortSpace to be EFI_MEMORY_XP.
+
+  @param  MemoryMap              A pointer to the buffer in which firmware places
+                                 the current memory map.
+  @param  MemoryMapSize          Size, in bytes, of the MemoryMap buffer.
+  @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
+**/
+STATIC
+VOID
+EnforceMemoryMapAttribute (
+  IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,
+  IN UINTN                      MemoryMapSize,
+  IN UINTN                      DescriptorSize
+  )
+{
+  EFI_MEMORY_DESCRIPTOR       *MemoryMapEntry;
+  EFI_MEMORY_DESCRIPTOR       *MemoryMapEnd;
+
+  MemoryMapEntry = MemoryMap;
+  MemoryMapEnd   = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + MemoryMapSize);
+  while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) {
+    switch (MemoryMapEntry->Type) {
+    case EfiRuntimeServicesCode:
+      // do nothing
+      break;
+    case EfiRuntimeServicesData:
+    case EfiMemoryMappedIO:
+    case EfiMemoryMappedIOPortSpace:
+      MemoryMapEntry->Attribute |= EFI_MEMORY_XP;
+      break;
+    case EfiReservedMemoryType:
+    case EfiACPIMemoryNVS:
+      break;
+    }
+
+    MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
+  }
+
+  return ;
+}
+
+/**
+  Return the first image record, whose [ImageBase, ImageSize] covered by [Buffer, Length].
+
+  @param Buffer  Start Address
+  @param Length  Address length
+
+  @return first image record covered by [buffer, length]
+**/
+STATIC
+IMAGE_PROPERTIES_RECORD *
+GetImageRecordByAddress (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64                Length
+  )
+{
+  IMAGE_PROPERTIES_RECORD    *ImageRecord;
+  LIST_ENTRY                 *ImageRecordLink;
+  LIST_ENTRY                 *ImageRecordList;
+
+  ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;
+
+  for (ImageRecordLink = ImageRecordList->ForwardLink;
+       ImageRecordLink != ImageRecordList;
+       ImageRecordLink = ImageRecordLink->ForwardLink) {
+    ImageRecord = CR (
+                    ImageRecordLink,
+                    IMAGE_PROPERTIES_RECORD,
+                    Link,
+                    IMAGE_PROPERTIES_RECORD_SIGNATURE
+                    );
+
+    if ((Buffer <= ImageRecord->ImageBase) &&
+        (Buffer + Length >= ImageRecord->ImageBase + ImageRecord->ImageSize)) {
+      return ImageRecord;
+    }
+  }
+
+  return NULL;
+}
+
+/**
+  Set the memory map to new entries, according to one old entry,
+  based upon PE code section and data section in image record
+
+  @param  ImageRecord            An image record whose [ImageBase, ImageSize] covered
+                                 by old memory map entry.
+  @param  NewRecord              A pointer to several new memory map entries.
+                                 The caller gurantee the buffer size be 1 +
+                                 (SplitRecordCount * DescriptorSize) calculated
+                                 below.
+  @param  OldRecord              A pointer to one old memory map entry.
+  @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
+**/
+STATIC
+UINTN
+SetNewRecord (
+  IN IMAGE_PROPERTIES_RECORD       *ImageRecord,
+  IN OUT EFI_MEMORY_DESCRIPTOR     *NewRecord,
+  IN EFI_MEMORY_DESCRIPTOR         *OldRecord,
+  IN UINTN                         DescriptorSize
+  )
+{
+  EFI_MEMORY_DESCRIPTOR                     TempRecord;
+  IMAGE_PROPERTIES_RECORD_CODE_SECTION      *ImageRecordCodeSection;
+  LIST_ENTRY                                *ImageRecordCodeSectionLink;
+  LIST_ENTRY                                *ImageRecordCodeSectionEndLink;
+  LIST_ENTRY                                *ImageRecordCodeSectionList;
+  UINTN                                     NewRecordCount;
+  UINT64                                    PhysicalEnd;
+  UINT64                                    ImageEnd;
+
+  CopyMem (&TempRecord, OldRecord, sizeof(EFI_MEMORY_DESCRIPTOR));
+  PhysicalEnd = TempRecord.PhysicalStart + EfiPagesToSize(TempRecord.NumberOfPages);
+  NewRecordCount = 0;
+
+  ImageRecordCodeSectionList = &ImageRecord->CodeSegmentList;
+
+  ImageRecordCodeSectionLink = ImageRecordCodeSectionList->ForwardLink;
+  ImageRecordCodeSectionEndLink = ImageRecordCodeSectionList;
+  while (ImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
+    ImageRecordCodeSection = CR (
+                               ImageRecordCodeSectionLink,
+                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,
+                               Link,
+                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
+                               );
+    ImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
+
+    if (TempRecord.PhysicalStart <= ImageRecordCodeSection->CodeSegmentBase) {
+      //
+      // DATA
+      //
+      NewRecord->Type          = TempRecord.Type;
+      NewRecord->PhysicalStart = TempRecord.PhysicalStart;
+      NewRecord->VirtualStart  = 0;
+      NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentBase - NewRecord->PhysicalStart);
+      NewRecord->Attribute     = TempRecord.Attribute | EFI_MEMORY_XP;
+      if (NewRecord->NumberOfPages != 0) {
+        NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
+        NewRecordCount ++;
+      }
+
+      //
+      // CODE
+      //
+      NewRecord->Type          = TempRecord.Type;
+      NewRecord->PhysicalStart = ImageRecordCodeSection->CodeSegmentBase;
+      NewRecord->VirtualStart  = 0;
+      NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentSize);
+      NewRecord->Attribute     = (TempRecord.Attribute & (~EFI_MEMORY_XP)) | EFI_MEMORY_RO;
+      if (NewRecord->NumberOfPages != 0) {
+        NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
+        NewRecordCount ++;
+      }
+
+      TempRecord.PhysicalStart = ImageRecordCodeSection->CodeSegmentBase + EfiPagesToSize (EfiSizeToPages(ImageRecordCodeSection->CodeSegmentSize));
+      TempRecord.NumberOfPages = EfiSizeToPages(PhysicalEnd - TempRecord.PhysicalStart);
+      if (TempRecord.NumberOfPages == 0) {
+        break;
+      }
+    }
+  }
+
+  ImageEnd = ImageRecord->ImageBase + ImageRecord->ImageSize;
+
+  //
+  // Final DATA
+  //
+  if (TempRecord.PhysicalStart < ImageEnd) {
+    NewRecord->Type          = TempRecord.Type;
+    NewRecord->PhysicalStart = TempRecord.PhysicalStart;
+    NewRecord->VirtualStart  = 0;
+    NewRecord->NumberOfPages = EfiSizeToPages (ImageEnd - TempRecord.PhysicalStart);
+    NewRecord->Attribute     = TempRecord.Attribute | EFI_MEMORY_XP;
+    NewRecordCount ++;
+  }
+
+  return NewRecordCount;
+}
+
+/**
+  Return the max number of new splitted entries, according to one old entry,
+  based upon PE code section and data section.
+
+  @param  OldRecord              A pointer to one old memory map entry.
+
+  @retval  0 no entry need to be splitted.
+  @return  the max number of new splitted entries
+**/
+STATIC
+UINTN
+GetMaxSplitRecordCount (
+  IN EFI_MEMORY_DESCRIPTOR *OldRecord
+  )
+{
+  IMAGE_PROPERTIES_RECORD *ImageRecord;
+  UINTN                   SplitRecordCount;
+  UINT64                  PhysicalStart;
+  UINT64                  PhysicalEnd;
+
+  SplitRecordCount = 0;
+  PhysicalStart = OldRecord->PhysicalStart;
+  PhysicalEnd = OldRecord->PhysicalStart + EfiPagesToSize(OldRecord->NumberOfPages);
+
+  do {
+    ImageRecord = GetImageRecordByAddress (PhysicalStart, PhysicalEnd - PhysicalStart);
+    if (ImageRecord == NULL) {
+      break;
+    }
+    SplitRecordCount += (2 * ImageRecord->CodeSegmentCount + 1);
+    PhysicalStart = ImageRecord->ImageBase + ImageRecord->ImageSize;
+  } while ((ImageRecord != NULL) && (PhysicalStart < PhysicalEnd));
+
+  if (SplitRecordCount != 0) {
+    SplitRecordCount--;
+  }
+
+  return SplitRecordCount;
+}
+
+/**
+  Split the memory map to new entries, according to one old entry,
+  based upon PE code section and data section.
+
+  @param  OldRecord              A pointer to one old memory map entry.
+  @param  NewRecord              A pointer to several new memory map entries.
+                                 The caller gurantee the buffer size be 1 +
+                                 (SplitRecordCount * DescriptorSize) calculated
+                                 below.
+  @param  MaxSplitRecordCount    The max number of splitted entries
+  @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
+
+  @retval  0 no entry is splitted.
+  @return  the real number of splitted record.
+**/
+STATIC
+UINTN
+SplitRecord (
+  IN EFI_MEMORY_DESCRIPTOR     *OldRecord,
+  IN OUT EFI_MEMORY_DESCRIPTOR *NewRecord,
+  IN UINTN                     MaxSplitRecordCount,
+  IN UINTN                     DescriptorSize
+  )
+{
+  EFI_MEMORY_DESCRIPTOR   TempRecord;
+  IMAGE_PROPERTIES_RECORD *ImageRecord;
+  IMAGE_PROPERTIES_RECORD *NewImageRecord;
+  UINT64                  PhysicalStart;
+  UINT64                  PhysicalEnd;
+  UINTN                   NewRecordCount;
+  UINTN                   TotalNewRecordCount;
+  BOOLEAN                 IsLastRecordData;
+
+  if (MaxSplitRecordCount == 0) {
+    CopyMem (NewRecord, OldRecord, DescriptorSize);
+    return 0;
+  }
+
+  TotalNewRecordCount = 0;
+
+  //
+  // Override previous record
+  //
+  CopyMem (&TempRecord, OldRecord, sizeof(EFI_MEMORY_DESCRIPTOR));
+  PhysicalStart = TempRecord.PhysicalStart;
+  PhysicalEnd = TempRecord.PhysicalStart + EfiPagesToSize(TempRecord.NumberOfPages);
+
+  ImageRecord = NULL;
+  do {
+    NewImageRecord = GetImageRecordByAddress (PhysicalStart, PhysicalEnd - PhysicalStart);
+    if (NewImageRecord == NULL) {
+      //
+      // No more image covered by this range, stop
+      //
+      if ((PhysicalEnd > PhysicalStart) && (ImageRecord != NULL)) {
+        //
+        // If this is still address in this record, need record.
+        //
+        NewRecord = PREVIOUS_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
+        IsLastRecordData = FALSE;
+        if ((NewRecord->Attribute & EFI_MEMORY_XP) != 0) {
+          IsLastRecordData = TRUE;
+        }
+        if (IsLastRecordData) {
+          //
+          // Last record is DATA, just merge it.
+          //
+          NewRecord->NumberOfPages = EfiSizeToPages(PhysicalEnd - NewRecord->PhysicalStart);
+        } else {
+          //
+          // Last record is CODE, create a new DATA entry.
+          //
+          NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
+          NewRecord->Type          = TempRecord.Type;
+          NewRecord->PhysicalStart = TempRecord.PhysicalStart;
+          NewRecord->VirtualStart  = 0;
+          NewRecord->NumberOfPages = TempRecord.NumberOfPages;
+          NewRecord->Attribute     = TempRecord.Attribute | EFI_MEMORY_XP;
+          TotalNewRecordCount ++;
+        }
+      }
+      break;
+    }
+    ImageRecord = NewImageRecord;
+
+    //
+    // Set new record
+    //
+    NewRecordCount = SetNewRecord (ImageRecord, NewRecord, &TempRecord, DescriptorSize);
+    TotalNewRecordCount += NewRecordCount;
+    NewRecord = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)NewRecord + NewRecordCount * DescriptorSize);
+
+    //
+    // Update PhysicalStart, in order to exclude the image buffer already splitted.
+    //
+    PhysicalStart = ImageRecord->ImageBase + ImageRecord->ImageSize;
+    TempRecord.PhysicalStart = PhysicalStart;
+    TempRecord.NumberOfPages = EfiSizeToPages (PhysicalEnd - PhysicalStart);
+  } while ((ImageRecord != NULL) && (PhysicalStart < PhysicalEnd));
+
+  //
+  // The logic in function SplitTable() ensures that TotalNewRecordCount will not be zero if the
+  // code reaches here.
+  //
+  ASSERT (TotalNewRecordCount != 0);
+  return TotalNewRecordCount - 1;
+}
+
+/**
+  Split the original memory map, and add more entries to describe PE code section and data section.
+  This function will set EfiRuntimeServicesData to be EFI_MEMORY_XP.
+  This function will merge entries with same attributes finally.
+
+  NOTE: It assumes PE code/data section are page aligned.
+  NOTE: It assumes enough entry is prepared for new memory map.
+
+  Split table:
+   +---------------+
+   | Record X      |
+   +---------------+
+   | Record RtCode |
+   +---------------+
+   | Record Y      |
+   +---------------+
+   ==>
+   +---------------+
+   | Record X      |
+   +---------------+ ----
+   | Record RtData |     |
+   +---------------+     |
+   | Record RtCode |     |-> PE/COFF1
+   +---------------+     |
+   | Record RtData |     |
+   +---------------+ ----
+   | Record RtData |     |
+   +---------------+     |
+   | Record RtCode |     |-> PE/COFF2
+   +---------------+     |
+   | Record RtData |     |
+   +---------------+ ----
+   | Record Y      |
+   +---------------+
+
+  @param  MemoryMapSize          A pointer to the size, in bytes, of the
+                                 MemoryMap buffer. On input, this is the size of
+                                 old MemoryMap before split. The actual buffer
+                                 size of MemoryMap is MemoryMapSize +
+                                 (AdditionalRecordCount * DescriptorSize) calculated
+                                 below. On output, it is the size of new MemoryMap
+                                 after split.
+  @param  MemoryMap              A pointer to the buffer in which firmware places
+                                 the current memory map.
+  @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
+**/
+STATIC
+VOID
+SplitTable (
+  IN OUT UINTN                  *MemoryMapSize,
+  IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,
+  IN UINTN                      DescriptorSize
+  )
+{
+  INTN        IndexOld;
+  INTN        IndexNew;
+  UINTN       MaxSplitRecordCount;
+  UINTN       RealSplitRecordCount;
+  UINTN       TotalSplitRecordCount;
+  UINTN       AdditionalRecordCount;
+
+  AdditionalRecordCount = (2 * mImagePropertiesPrivateData.CodeSegmentCountMax + 1) * mImagePropertiesPrivateData.ImageRecordCount;
+
+  TotalSplitRecordCount = 0;
+  //
+  // Let old record point to end of valid MemoryMap buffer.
+  //
+  IndexOld = ((*MemoryMapSize) / DescriptorSize) - 1;
+  //
+  // Let new record point to end of full MemoryMap buffer.
+  //
+  IndexNew = ((*MemoryMapSize) / DescriptorSize) - 1 + AdditionalRecordCount;
+  for (; IndexOld >= 0; IndexOld--) {
+    MaxSplitRecordCount = GetMaxSplitRecordCount ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + IndexOld * DescriptorSize));
+    //
+    // Split this MemoryMap record
+    //
+    IndexNew -= MaxSplitRecordCount;
+    RealSplitRecordCount = SplitRecord (
+                             (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + IndexOld * DescriptorSize),
+                             (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + IndexNew * DescriptorSize),
+                             MaxSplitRecordCount,
+                             DescriptorSize
+                             );
+    //
+    // Adjust IndexNew according to real split.
+    //
+    CopyMem (
+      ((UINT8 *)MemoryMap + (IndexNew + MaxSplitRecordCount - RealSplitRecordCount) * DescriptorSize),
+      ((UINT8 *)MemoryMap + IndexNew * DescriptorSize),
+      RealSplitRecordCount * DescriptorSize
+      );
+    IndexNew = IndexNew + MaxSplitRecordCount - RealSplitRecordCount;
+    TotalSplitRecordCount += RealSplitRecordCount;
+    IndexNew --;
+  }
+  //
+  // Move all records to the beginning.
+  //
+  CopyMem (
+    MemoryMap,
+    (UINT8 *)MemoryMap + (AdditionalRecordCount - TotalSplitRecordCount) * DescriptorSize,
+    (*MemoryMapSize) + TotalSplitRecordCount * DescriptorSize
+    );
+
+  *MemoryMapSize = (*MemoryMapSize) + DescriptorSize * TotalSplitRecordCount;
+
+  //
+  // Sort from low to high (Just in case)
+  //
+  SortMemoryMap (MemoryMap, *MemoryMapSize, DescriptorSize);
+
+  //
+  // Set RuntimeData to XP
+  //
+  EnforceMemoryMapAttribute (MemoryMap, *MemoryMapSize, DescriptorSize);
+
+  //
+  // Merge same type to save entry size
+  //
+  MergeMemoryMap (MemoryMap, MemoryMapSize, DescriptorSize);
+
+  return ;
+}
+
+/**
+  This function for GetMemoryMap() with properties table capability.
+
+  It calls original GetMemoryMap() to get the original memory map information. Then
+  plus the additional memory map entries for PE Code/Data seperation.
+
+  @param  MemoryMapSize          A pointer to the size, in bytes, of the
+                                 MemoryMap buffer. On input, this is the size of
+                                 the buffer allocated by the caller.  On output,
+                                 it is the size of the buffer returned by the
+                                 firmware  if the buffer was large enough, or the
+                                 size of the buffer needed  to contain the map if
+                                 the buffer was too small.
+  @param  MemoryMap              A pointer to the buffer in which firmware places
+                                 the current memory map.
+  @param  MapKey                 A pointer to the location in which firmware
+                                 returns the key for the current memory map.
+  @param  DescriptorSize         A pointer to the location in which firmware
+                                 returns the size, in bytes, of an individual
+                                 EFI_MEMORY_DESCRIPTOR.
+  @param  DescriptorVersion      A pointer to the location in which firmware
+                                 returns the version number associated with the
+                                 EFI_MEMORY_DESCRIPTOR.
+
+  @retval EFI_SUCCESS            The memory map was returned in the MemoryMap
+                                 buffer.
+  @retval EFI_BUFFER_TOO_SMALL   The MemoryMap buffer was too small. The current
+                                 buffer size needed to hold the memory map is
+                                 returned in MemoryMapSize.
+  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value.
+
+**/
+EFI_STATUS
+EFIAPI
+CoreGetMemoryMapWithSeparatedImageSection (
+  IN OUT UINTN                  *MemoryMapSize,
+  IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,
+  OUT UINTN                     *MapKey,
+  OUT UINTN                     *DescriptorSize,
+  OUT UINT32                    *DescriptorVersion
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       OldMemoryMapSize;
+  UINTN       AdditionalRecordCount;
+
+  //
+  // If PE code/data is not aligned, just return.
+  //
+  if (!mMemoryAttributesTableEnable) {
+    return CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey, DescriptorSize, DescriptorVersion);
+  }
+
+  if (MemoryMapSize == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  CoreAcquiremMemoryAttributesTableLock ();
+
+  AdditionalRecordCount = (2 * mImagePropertiesPrivateData.CodeSegmentCountMax + 1) * mImagePropertiesPrivateData.ImageRecordCount;
+
+  OldMemoryMapSize = *MemoryMapSize;
+  Status = CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey, DescriptorSize, DescriptorVersion);
+  if (Status == EFI_BUFFER_TOO_SMALL) {
+    *MemoryMapSize = *MemoryMapSize + (*DescriptorSize) * AdditionalRecordCount;
+  } else if (Status == EFI_SUCCESS) {
+    ASSERT (MemoryMap != NULL);
+    if (OldMemoryMapSize - *MemoryMapSize < (*DescriptorSize) * AdditionalRecordCount) {
+      *MemoryMapSize = *MemoryMapSize + (*DescriptorSize) * AdditionalRecordCount;
+      //
+      // Need update status to buffer too small
+      //
+      Status = EFI_BUFFER_TOO_SMALL;
+    } else {
+      //
+      // Split PE code/data
+      //
+      SplitTable (MemoryMapSize, MemoryMap, *DescriptorSize);
+    }
+  }
+
+  CoreReleasemMemoryAttributesTableLock ();
+  return Status;
+}
+
+//
+// Below functions are for ImageRecord
+//
+
+/**
+  Set MemoryAttributesTable according to PE/COFF image section alignment.
+
+  @param  SectionAlignment    PE/COFF section alignment
+**/
+STATIC
+VOID
+SetMemoryAttributesTableSectionAlignment (
+  IN UINT32  SectionAlignment
+  )
+{
+  if (((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) &&
+      mMemoryAttributesTableEnable) {
+    DEBUG ((EFI_D_VERBOSE, "SetMemoryAttributesTableSectionAlignment - Clear\n"));
+    mMemoryAttributesTableEnable = FALSE;
+  }
+}
+
+/**
+  Swap two code sections in image record.
+
+  @param  FirstImageRecordCodeSection    first code section in image record
+  @param  SecondImageRecordCodeSection   second code section in image record
+**/
+STATIC
+VOID
+SwapImageRecordCodeSection (
+  IN IMAGE_PROPERTIES_RECORD_CODE_SECTION      *FirstImageRecordCodeSection,
+  IN IMAGE_PROPERTIES_RECORD_CODE_SECTION      *SecondImageRecordCodeSection
+  )
+{
+  IMAGE_PROPERTIES_RECORD_CODE_SECTION      TempImageRecordCodeSection;
+
+  TempImageRecordCodeSection.CodeSegmentBase = FirstImageRecordCodeSection->CodeSegmentBase;
+  TempImageRecordCodeSection.CodeSegmentSize = FirstImageRecordCodeSection->CodeSegmentSize;
+
+  FirstImageRecordCodeSection->CodeSegmentBase = SecondImageRecordCodeSection->CodeSegmentBase;
+  FirstImageRecordCodeSection->CodeSegmentSize = SecondImageRecordCodeSection->CodeSegmentSize;
+
+  SecondImageRecordCodeSection->CodeSegmentBase = TempImageRecordCodeSection.CodeSegmentBase;
+  SecondImageRecordCodeSection->CodeSegmentSize = TempImageRecordCodeSection.CodeSegmentSize;
+}
+
+/**
+  Sort code section in image record, based upon CodeSegmentBase from low to high.
+
+  @param  ImageRecord    image record to be sorted
+**/
+VOID
+SortImageRecordCodeSection (
+  IN IMAGE_PROPERTIES_RECORD              *ImageRecord
+  )
+{
+  IMAGE_PROPERTIES_RECORD_CODE_SECTION      *ImageRecordCodeSection;
+  IMAGE_PROPERTIES_RECORD_CODE_SECTION      *NextImageRecordCodeSection;
+  LIST_ENTRY                                *ImageRecordCodeSectionLink;
+  LIST_ENTRY                                *NextImageRecordCodeSectionLink;
+  LIST_ENTRY                                *ImageRecordCodeSectionEndLink;
+  LIST_ENTRY                                *ImageRecordCodeSectionList;
+
+  ImageRecordCodeSectionList = &ImageRecord->CodeSegmentList;
+
+  ImageRecordCodeSectionLink = ImageRecordCodeSectionList->ForwardLink;
+  NextImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
+  ImageRecordCodeSectionEndLink = ImageRecordCodeSectionList;
+  while (ImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
+    ImageRecordCodeSection = CR (
+                               ImageRecordCodeSectionLink,
+                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,
+                               Link,
+                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
+                               );
+    while (NextImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
+      NextImageRecordCodeSection = CR (
+                                     NextImageRecordCodeSectionLink,
+                                     IMAGE_PROPERTIES_RECORD_CODE_SECTION,
+                                     Link,
+                                     IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
+                                     );
+      if (ImageRecordCodeSection->CodeSegmentBase > NextImageRecordCodeSection->CodeSegmentBase) {
+        SwapImageRecordCodeSection (ImageRecordCodeSection, NextImageRecordCodeSection);
+      }
+      NextImageRecordCodeSectionLink = NextImageRecordCodeSectionLink->ForwardLink;
+    }
+
+    ImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
+    NextImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
+  }
+}
+
+/**
+  Check if code section in image record is valid.
+
+  @param  ImageRecord    image record to be checked
+
+  @retval TRUE  image record is valid
+  @retval FALSE image record is invalid
+**/
+BOOLEAN
+IsImageRecordCodeSectionValid (
+  IN IMAGE_PROPERTIES_RECORD              *ImageRecord
+  )
+{
+  IMAGE_PROPERTIES_RECORD_CODE_SECTION      *ImageRecordCodeSection;
+  IMAGE_PROPERTIES_RECORD_CODE_SECTION      *LastImageRecordCodeSection;
+  LIST_ENTRY                                *ImageRecordCodeSectionLink;
+  LIST_ENTRY                                *ImageRecordCodeSectionEndLink;
+  LIST_ENTRY                                *ImageRecordCodeSectionList;
+
+  DEBUG ((EFI_D_VERBOSE, "ImageCode SegmentCount - 0x%x\n", ImageRecord->CodeSegmentCount));
+
+  ImageRecordCodeSectionList = &ImageRecord->CodeSegmentList;
+
+  ImageRecordCodeSectionLink = ImageRecordCodeSectionList->ForwardLink;
+  ImageRecordCodeSectionEndLink = ImageRecordCodeSectionList;
+  LastImageRecordCodeSection = NULL;
+  while (ImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
+    ImageRecordCodeSection = CR (
+                               ImageRecordCodeSectionLink,
+                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,
+                               Link,
+                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
+                               );
+    if (ImageRecordCodeSection->CodeSegmentSize == 0) {
+      return FALSE;
+    }
+    if (ImageRecordCodeSection->CodeSegmentBase < ImageRecord->ImageBase) {
+      return FALSE;
+    }
+    if (ImageRecordCodeSection->CodeSegmentBase >= MAX_ADDRESS - ImageRecordCodeSection->CodeSegmentSize) {
+      return FALSE;
+    }
+    if ((ImageRecordCodeSection->CodeSegmentBase + ImageRecordCodeSection->CodeSegmentSize) > (ImageRecord->ImageBase + ImageRecord->ImageSize)) {
+      return FALSE;
+    }
+    if (LastImageRecordCodeSection != NULL) {
+      if ((LastImageRecordCodeSection->CodeSegmentBase + LastImageRecordCodeSection->CodeSegmentSize) > ImageRecordCodeSection->CodeSegmentBase) {
+        return FALSE;
+      }
+    }
+
+    LastImageRecordCodeSection = ImageRecordCodeSection;
+    ImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
+  }
+
+  return TRUE;
+}
+
+/**
+  Swap two image records.
+
+  @param  FirstImageRecord   first image record.
+  @param  SecondImageRecord  second image record.
+**/
+STATIC
+VOID
+SwapImageRecord (
+  IN IMAGE_PROPERTIES_RECORD      *FirstImageRecord,
+  IN IMAGE_PROPERTIES_RECORD      *SecondImageRecord
+  )
+{
+  IMAGE_PROPERTIES_RECORD      TempImageRecord;
+
+  TempImageRecord.ImageBase = FirstImageRecord->ImageBase;
+  TempImageRecord.ImageSize = FirstImageRecord->ImageSize;
+  TempImageRecord.CodeSegmentCount = FirstImageRecord->CodeSegmentCount;
+
+  FirstImageRecord->ImageBase = SecondImageRecord->ImageBase;
+  FirstImageRecord->ImageSize = SecondImageRecord->ImageSize;
+  FirstImageRecord->CodeSegmentCount = SecondImageRecord->CodeSegmentCount;
+
+  SecondImageRecord->ImageBase = TempImageRecord.ImageBase;
+  SecondImageRecord->ImageSize = TempImageRecord.ImageSize;
+  SecondImageRecord->CodeSegmentCount = TempImageRecord.CodeSegmentCount;
+
+  SwapListEntries (&FirstImageRecord->CodeSegmentList, &SecondImageRecord->CodeSegmentList);
+}
+
+/**
+  Sort image record based upon the ImageBase from low to high.
+**/
+STATIC
+VOID
+SortImageRecord (
+  VOID
+  )
+{
+  IMAGE_PROPERTIES_RECORD      *ImageRecord;
+  IMAGE_PROPERTIES_RECORD      *NextImageRecord;
+  LIST_ENTRY                   *ImageRecordLink;
+  LIST_ENTRY                   *NextImageRecordLink;
+  LIST_ENTRY                   *ImageRecordEndLink;
+  LIST_ENTRY                   *ImageRecordList;
+
+  ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;
+
+  ImageRecordLink = ImageRecordList->ForwardLink;
+  NextImageRecordLink = ImageRecordLink->ForwardLink;
+  ImageRecordEndLink = ImageRecordList;
+  while (ImageRecordLink != ImageRecordEndLink) {
+    ImageRecord = CR (
+                    ImageRecordLink,
+                    IMAGE_PROPERTIES_RECORD,
+                    Link,
+                    IMAGE_PROPERTIES_RECORD_SIGNATURE
+                    );
+    while (NextImageRecordLink != ImageRecordEndLink) {
+      NextImageRecord = CR (
+                          NextImageRecordLink,
+                          IMAGE_PROPERTIES_RECORD,
+                          Link,
+                          IMAGE_PROPERTIES_RECORD_SIGNATURE
+                          );
+      if (ImageRecord->ImageBase > NextImageRecord->ImageBase) {
+        SwapImageRecord (ImageRecord, NextImageRecord);
+      }
+      NextImageRecordLink = NextImageRecordLink->ForwardLink;
+    }
+
+    ImageRecordLink = ImageRecordLink->ForwardLink;
+    NextImageRecordLink = ImageRecordLink->ForwardLink;
+  }
+}
+
+/**
+  Insert image record.
+
+  @param  RuntimeImage    Runtime image information
+**/
+VOID
+InsertImageRecord (
+  IN EFI_RUNTIME_IMAGE_ENTRY  *RuntimeImage
+  )
+{
+  VOID                                 *ImageAddress;
+  EFI_IMAGE_DOS_HEADER                 *DosHdr;
+  UINT32                               PeCoffHeaderOffset;
+  UINT32                               SectionAlignment;
+  EFI_IMAGE_SECTION_HEADER             *Section;
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr;
+  UINT8                                *Name;
+  UINTN                                Index;
+  IMAGE_PROPERTIES_RECORD              *ImageRecord;
+  CHAR8                                *PdbPointer;
+  IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection;
+
+  DEBUG ((EFI_D_VERBOSE, "InsertImageRecord - 0x%x\n", RuntimeImage));
+  DEBUG ((EFI_D_VERBOSE, "InsertImageRecord - 0x%016lx - 0x%016lx\n", (EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase, RuntimeImage->ImageSize));
+
+  if (mMemoryAttributesTableEndOfDxe) {
+    DEBUG ((DEBUG_INFO, "Do not insert runtime image record after EndOfDxe\n"));
+    return ;
+  }
+
+  ImageRecord = AllocatePool (sizeof(*ImageRecord));
+  if (ImageRecord == NULL) {
+    return ;
+  }
+  ImageRecord->Signature = IMAGE_PROPERTIES_RECORD_SIGNATURE;
+
+  DEBUG ((EFI_D_VERBOSE, "ImageRecordCount - 0x%x\n", mImagePropertiesPrivateData.ImageRecordCount));
+
+  //
+  // Step 1: record whole region
+  //
+  ImageRecord->ImageBase = (EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase;
+  ImageRecord->ImageSize = RuntimeImage->ImageSize;
+
+  ImageAddress = RuntimeImage->ImageBase;
+
+  PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);
+  if (PdbPointer != NULL) {
+    DEBUG ((EFI_D_VERBOSE, "  Image - %a\n", PdbPointer));
+  }
+
+  //
+  // Check PE/COFF image
+  //
+  DosHdr = (EFI_IMAGE_DOS_HEADER *) (UINTN) ImageAddress;
+  PeCoffHeaderOffset = 0;
+  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+    PeCoffHeaderOffset = DosHdr->e_lfanew;
+  }
+
+  Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINT8 *) (UINTN) ImageAddress + PeCoffHeaderOffset);
+  if (Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) {
+    DEBUG ((EFI_D_VERBOSE, "Hdr.Pe32->Signature invalid - 0x%x\n", Hdr.Pe32->Signature));
+    // It might be image in SMM.
+    goto Finish;
+  }
+
+  //
+  // Get SectionAlignment
+  //
+  if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+    SectionAlignment  = Hdr.Pe32->OptionalHeader.SectionAlignment;
+  } else {
+    SectionAlignment  = Hdr.Pe32Plus->OptionalHeader.SectionAlignment;
+  }
+
+  SetMemoryAttributesTableSectionAlignment (SectionAlignment);
+  if ((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) {
+    DEBUG ((EFI_D_WARN, "!!!!!!!!  InsertImageRecord - Section Alignment(0x%x) is not %dK  !!!!!!!!\n",
+      SectionAlignment, RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));
+    PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);
+    if (PdbPointer != NULL) {
+      DEBUG ((EFI_D_WARN, "!!!!!!!!  Image - %a  !!!!!!!!\n", PdbPointer));
+    }
+    goto Finish;
+  }
+
+  Section = (EFI_IMAGE_SECTION_HEADER *) (
+               (UINT8 *) (UINTN) ImageAddress +
+               PeCoffHeaderOffset +
+               sizeof(UINT32) +
+               sizeof(EFI_IMAGE_FILE_HEADER) +
+               Hdr.Pe32->FileHeader.SizeOfOptionalHeader
+               );
+  ImageRecord->CodeSegmentCount = 0;
+  InitializeListHead (&ImageRecord->CodeSegmentList);
+  for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {
+    Name = Section[Index].Name;
+    DEBUG ((
+      EFI_D_VERBOSE,
+      "  Section - '%c%c%c%c%c%c%c%c'\n",
+      Name[0],
+      Name[1],
+      Name[2],
+      Name[3],
+      Name[4],
+      Name[5],
+      Name[6],
+      Name[7]
+      ));
+
+    if ((Section[Index].Characteristics & EFI_IMAGE_SCN_CNT_CODE) != 0) {
+      DEBUG ((EFI_D_VERBOSE, "  VirtualSize          - 0x%08x\n", Section[Index].Misc.VirtualSize));
+      DEBUG ((EFI_D_VERBOSE, "  VirtualAddress       - 0x%08x\n", Section[Index].VirtualAddress));
+      DEBUG ((EFI_D_VERBOSE, "  SizeOfRawData        - 0x%08x\n", Section[Index].SizeOfRawData));
+      DEBUG ((EFI_D_VERBOSE, "  PointerToRawData     - 0x%08x\n", Section[Index].PointerToRawData));
+      DEBUG ((EFI_D_VERBOSE, "  PointerToRelocations - 0x%08x\n", Section[Index].PointerToRelocations));
+      DEBUG ((EFI_D_VERBOSE, "  PointerToLinenumbers - 0x%08x\n", Section[Index].PointerToLinenumbers));
+      DEBUG ((EFI_D_VERBOSE, "  NumberOfRelocations  - 0x%08x\n", Section[Index].NumberOfRelocations));
+      DEBUG ((EFI_D_VERBOSE, "  NumberOfLinenumbers  - 0x%08x\n", Section[Index].NumberOfLinenumbers));
+      DEBUG ((EFI_D_VERBOSE, "  Characteristics      - 0x%08x\n", Section[Index].Characteristics));
+
+      //
+      // Step 2: record code section
+      //
+      ImageRecordCodeSection = AllocatePool (sizeof(*ImageRecordCodeSection));
+      if (ImageRecordCodeSection == NULL) {
+        return ;
+      }
+      ImageRecordCodeSection->Signature = IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE;
+
+      ImageRecordCodeSection->CodeSegmentBase = (UINTN)ImageAddress + Section[Index].VirtualAddress;
+      ImageRecordCodeSection->CodeSegmentSize = Section[Index].SizeOfRawData;
+
+      DEBUG ((EFI_D_VERBOSE, "ImageCode: 0x%016lx - 0x%016lx\n", ImageRecordCodeSection->CodeSegmentBase, ImageRecordCodeSection->CodeSegmentSize));
+
+      InsertTailList (&ImageRecord->CodeSegmentList, &ImageRecordCodeSection->Link);
+      ImageRecord->CodeSegmentCount++;
+    }
+  }
+
+  if (ImageRecord->CodeSegmentCount == 0) {
+    SetMemoryAttributesTableSectionAlignment (1);
+    DEBUG ((EFI_D_ERROR, "!!!!!!!!  InsertImageRecord - CodeSegmentCount is 0  !!!!!!!!\n"));
+    PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);
+    if (PdbPointer != NULL) {
+      DEBUG ((EFI_D_ERROR, "!!!!!!!!  Image - %a  !!!!!!!!\n", PdbPointer));
+    }
+    goto Finish;
+  }
+
+  //
+  // Final
+  //
+  SortImageRecordCodeSection (ImageRecord);
+  //
+  // Check overlap all section in ImageBase/Size
+  //
+  if (!IsImageRecordCodeSectionValid (ImageRecord)) {
+    DEBUG ((EFI_D_ERROR, "IsImageRecordCodeSectionValid - FAIL\n"));
+    goto Finish;
+  }
+
+  InsertTailList (&mImagePropertiesPrivateData.ImageRecordList, &ImageRecord->Link);
+  mImagePropertiesPrivateData.ImageRecordCount++;
+
+  if (mImagePropertiesPrivateData.CodeSegmentCountMax < ImageRecord->CodeSegmentCount) {
+    mImagePropertiesPrivateData.CodeSegmentCountMax = ImageRecord->CodeSegmentCount;
+  }
+
+  SortImageRecord ();
+
+Finish:
+  return ;
+}
+
+/**
+  Find image record according to image base and size.
+
+  @param  ImageBase    Base of PE image
+  @param  ImageSize    Size of PE image
+
+  @return image record
+**/
+STATIC
+IMAGE_PROPERTIES_RECORD *
+FindImageRecord (
+  IN EFI_PHYSICAL_ADDRESS  ImageBase,
+  IN UINT64                ImageSize
+  )
+{
+  IMAGE_PROPERTIES_RECORD    *ImageRecord;
+  LIST_ENTRY                 *ImageRecordLink;
+  LIST_ENTRY                 *ImageRecordList;
+
+  ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;
+
+  for (ImageRecordLink = ImageRecordList->ForwardLink;
+       ImageRecordLink != ImageRecordList;
+       ImageRecordLink = ImageRecordLink->ForwardLink) {
+    ImageRecord = CR (
+                    ImageRecordLink,
+                    IMAGE_PROPERTIES_RECORD,
+                    Link,
+                    IMAGE_PROPERTIES_RECORD_SIGNATURE
+                    );
+
+    if ((ImageBase == ImageRecord->ImageBase) &&
+        (ImageSize == ImageRecord->ImageSize)) {
+      return ImageRecord;
+    }
+  }
+
+  return NULL;
+}
+
+/**
+  Remove Image record.
+
+  @param  RuntimeImage    Runtime image information
+**/
+VOID
+RemoveImageRecord (
+  IN EFI_RUNTIME_IMAGE_ENTRY  *RuntimeImage
+  )
+{
+  IMAGE_PROPERTIES_RECORD              *ImageRecord;
+  LIST_ENTRY                           *CodeSegmentListHead;
+  IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection;
+
+  DEBUG ((EFI_D_VERBOSE, "RemoveImageRecord - 0x%x\n", RuntimeImage));
+  DEBUG ((EFI_D_VERBOSE, "RemoveImageRecord - 0x%016lx - 0x%016lx\n", (EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase, RuntimeImage->ImageSize));
+
+  if (mMemoryAttributesTableEndOfDxe) {
+    DEBUG ((DEBUG_INFO, "Do not remove runtime image record after EndOfDxe\n"));
+    return ;
+  }
+
+  ImageRecord = FindImageRecord ((EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase, RuntimeImage->ImageSize);
+  if (ImageRecord == NULL) {
+    DEBUG ((EFI_D_ERROR, "!!!!!!!! ImageRecord not found !!!!!!!!\n"));
+    return ;
+  }
+
+  CodeSegmentListHead = &ImageRecord->CodeSegmentList;
+  while (!IsListEmpty (CodeSegmentListHead)) {
+    ImageRecordCodeSection = CR (
+                               CodeSegmentListHead->ForwardLink,
+                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,
+                               Link,
+                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
+                               );
+    RemoveEntryList (&ImageRecordCodeSection->Link);
+    FreePool (ImageRecordCodeSection);
+  }
+
+  RemoveEntryList (&ImageRecord->Link);
+  FreePool (ImageRecord);
+  mImagePropertiesPrivateData.ImageRecordCount--;
+}
diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
deleted file mode 100644
index 6ee8a8af9098..000000000000
--- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
+++ /dev/null
@@ -1,1288 +0,0 @@
-/** @file
-  UEFI PropertiesTable support
-
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <PiDxe.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiLib.h>
-#include <Library/PcdLib.h>
-
-#include <Guid/EventGroup.h>
-#include <Protocol/DxeSmmReadyToLock.h>
-
-#include <Library/PeCoffLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Protocol/Runtime.h>
-
-#include "DxeMain.h"
-#include "HeapGuard.h"
-
-#define PREVIOUS_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
-  ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size)))
-
-#define IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('I','P','P','D')
-
-typedef struct {
-  UINT32                 Signature;
-  UINTN                  ImageRecordCount;
-  UINTN                  CodeSegmentCountMax;
-  LIST_ENTRY             ImageRecordList;
-} IMAGE_PROPERTIES_PRIVATE_DATA;
-
-IMAGE_PROPERTIES_PRIVATE_DATA  mImagePropertiesPrivateData = {
-  IMAGE_PROPERTIES_PRIVATE_DATA_SIGNATURE,
-  0,
-  0,
-  INITIALIZE_LIST_HEAD_VARIABLE (mImagePropertiesPrivateData.ImageRecordList)
-};
-
-EFI_LOCK           mPropertiesTableLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
-
-BOOLEAN            mPropertiesTableEndOfDxe = FALSE;
-
-extern BOOLEAN     mMemoryAttributesTableEnable;
-
-//
-// Below functions are for MemoryMap
-//
-
-/**
-  Converts a number of EFI_PAGEs to a size in bytes.
-
-  NOTE: Do not use EFI_PAGES_TO_SIZE because it handles UINTN only.
-
-  @param  Pages     The number of EFI_PAGES.
-
-  @return  The number of bytes associated with the number of EFI_PAGEs specified
-           by Pages.
-**/
-STATIC
-UINT64
-EfiPagesToSize (
-  IN UINT64 Pages
-  )
-{
-  return LShiftU64 (Pages, EFI_PAGE_SHIFT);
-}
-
-/**
-  Converts a size, in bytes, to a number of EFI_PAGESs.
-
-  NOTE: Do not use EFI_SIZE_TO_PAGES because it handles UINTN only.
-
-  @param  Size      A size in bytes.
-
-  @return  The number of EFI_PAGESs associated with the number of bytes specified
-           by Size.
-
-**/
-STATIC
-UINT64
-EfiSizeToPages (
-  IN UINT64 Size
-  )
-{
-  return RShiftU64 (Size, EFI_PAGE_SHIFT) + ((((UINTN)Size) & EFI_PAGE_MASK) ? 1 : 0);
-}
-
-/**
-  Acquire memory lock on mPropertiesTableLock.
-**/
-STATIC
-VOID
-CoreAcquirePropertiesTableLock (
-  VOID
-  )
-{
-  CoreAcquireLock (&mPropertiesTableLock);
-}
-
-/**
-  Release memory lock on mPropertiesTableLock.
-**/
-STATIC
-VOID
-CoreReleasePropertiesTableLock (
-  VOID
-  )
-{
-  CoreReleaseLock (&mPropertiesTableLock);
-}
-
-/**
-  Sort memory map entries based upon PhysicalStart, from low to high.
-
-  @param  MemoryMap              A pointer to the buffer in which firmware places
-                                 the current memory map.
-  @param  MemoryMapSize          Size, in bytes, of the MemoryMap buffer.
-  @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
-**/
-STATIC
-VOID
-SortMemoryMap (
-  IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,
-  IN UINTN                      MemoryMapSize,
-  IN UINTN                      DescriptorSize
-  )
-{
-  EFI_MEMORY_DESCRIPTOR       *MemoryMapEntry;
-  EFI_MEMORY_DESCRIPTOR       *NextMemoryMapEntry;
-  EFI_MEMORY_DESCRIPTOR       *MemoryMapEnd;
-  EFI_MEMORY_DESCRIPTOR       TempMemoryMap;
-
-  MemoryMapEntry = MemoryMap;
-  NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
-  MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + MemoryMapSize);
-  while (MemoryMapEntry < MemoryMapEnd) {
-    while (NextMemoryMapEntry < MemoryMapEnd) {
-      if (MemoryMapEntry->PhysicalStart > NextMemoryMapEntry->PhysicalStart) {
-        CopyMem (&TempMemoryMap, MemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR));
-        CopyMem (MemoryMapEntry, NextMemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR));
-        CopyMem (NextMemoryMapEntry, &TempMemoryMap, sizeof(EFI_MEMORY_DESCRIPTOR));
-      }
-
-      NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize);
-    }
-
-    MemoryMapEntry      = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
-    NextMemoryMapEntry  = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
-  }
-
-  return ;
-}
-
-/**
-  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
-  )
-{
-  EFI_MEMORY_DESCRIPTOR       *MemoryMapEntry;
-  EFI_MEMORY_DESCRIPTOR       *MemoryMapEnd;
-  UINT64                      MemoryBlockLength;
-  EFI_MEMORY_DESCRIPTOR       *NewMemoryMapEntry;
-  EFI_MEMORY_DESCRIPTOR       *NextMemoryMapEntry;
-
-  MemoryMapEntry = MemoryMap;
-  NewMemoryMapEntry = MemoryMap;
-  MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + *MemoryMapSize);
-  while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) {
-    CopyMem (NewMemoryMapEntry, MemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR));
-    NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
-
-    do {
-      MergeGuardPages (NewMemoryMapEntry, NextMemoryMapEntry->PhysicalStart);
-      MemoryBlockLength = (UINT64) (EfiPagesToSize (NewMemoryMapEntry->NumberOfPages));
-      if (((UINTN)NextMemoryMapEntry < (UINTN)MemoryMapEnd) &&
-          (NewMemoryMapEntry->Type == NextMemoryMapEntry->Type) &&
-          (NewMemoryMapEntry->Attribute == NextMemoryMapEntry->Attribute) &&
-          ((NewMemoryMapEntry->PhysicalStart + MemoryBlockLength) == NextMemoryMapEntry->PhysicalStart)) {
-        NewMemoryMapEntry->NumberOfPages += NextMemoryMapEntry->NumberOfPages;
-        NextMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize);
-        continue;
-      } else {
-        MemoryMapEntry = PREVIOUS_MEMORY_DESCRIPTOR (NextMemoryMapEntry, DescriptorSize);
-        break;
-      }
-    } while (TRUE);
-
-    MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
-    NewMemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (NewMemoryMapEntry, DescriptorSize);
-  }
-
-  *MemoryMapSize = (UINTN)NewMemoryMapEntry - (UINTN)MemoryMap;
-
-  return ;
-}
-
-/**
-  Enforce memory map attributes.
-  This function will set EfiRuntimeServicesData/EfiMemoryMappedIO/EfiMemoryMappedIOPortSpace to be EFI_MEMORY_XP.
-
-  @param  MemoryMap              A pointer to the buffer in which firmware places
-                                 the current memory map.
-  @param  MemoryMapSize          Size, in bytes, of the MemoryMap buffer.
-  @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
-**/
-STATIC
-VOID
-EnforceMemoryMapAttribute (
-  IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,
-  IN UINTN                      MemoryMapSize,
-  IN UINTN                      DescriptorSize
-  )
-{
-  EFI_MEMORY_DESCRIPTOR       *MemoryMapEntry;
-  EFI_MEMORY_DESCRIPTOR       *MemoryMapEnd;
-
-  MemoryMapEntry = MemoryMap;
-  MemoryMapEnd   = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + MemoryMapSize);
-  while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) {
-    switch (MemoryMapEntry->Type) {
-    case EfiRuntimeServicesCode:
-      // do nothing
-      break;
-    case EfiRuntimeServicesData:
-    case EfiMemoryMappedIO:
-    case EfiMemoryMappedIOPortSpace:
-      MemoryMapEntry->Attribute |= EFI_MEMORY_XP;
-      break;
-    case EfiReservedMemoryType:
-    case EfiACPIMemoryNVS:
-      break;
-    }
-
-    MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
-  }
-
-  return ;
-}
-
-/**
-  Return the first image record, whose [ImageBase, ImageSize] covered by [Buffer, Length].
-
-  @param Buffer  Start Address
-  @param Length  Address length
-
-  @return first image record covered by [buffer, length]
-**/
-STATIC
-IMAGE_PROPERTIES_RECORD *
-GetImageRecordByAddress (
-  IN EFI_PHYSICAL_ADDRESS  Buffer,
-  IN UINT64                Length
-  )
-{
-  IMAGE_PROPERTIES_RECORD    *ImageRecord;
-  LIST_ENTRY                 *ImageRecordLink;
-  LIST_ENTRY                 *ImageRecordList;
-
-  ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;
-
-  for (ImageRecordLink = ImageRecordList->ForwardLink;
-       ImageRecordLink != ImageRecordList;
-       ImageRecordLink = ImageRecordLink->ForwardLink) {
-    ImageRecord = CR (
-                    ImageRecordLink,
-                    IMAGE_PROPERTIES_RECORD,
-                    Link,
-                    IMAGE_PROPERTIES_RECORD_SIGNATURE
-                    );
-
-    if ((Buffer <= ImageRecord->ImageBase) &&
-        (Buffer + Length >= ImageRecord->ImageBase + ImageRecord->ImageSize)) {
-      return ImageRecord;
-    }
-  }
-
-  return NULL;
-}
-
-/**
-  Set the memory map to new entries, according to one old entry,
-  based upon PE code section and data section in image record
-
-  @param  ImageRecord            An image record whose [ImageBase, ImageSize] covered
-                                 by old memory map entry.
-  @param  NewRecord              A pointer to several new memory map entries.
-                                 The caller gurantee the buffer size be 1 +
-                                 (SplitRecordCount * DescriptorSize) calculated
-                                 below.
-  @param  OldRecord              A pointer to one old memory map entry.
-  @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
-**/
-STATIC
-UINTN
-SetNewRecord (
-  IN IMAGE_PROPERTIES_RECORD       *ImageRecord,
-  IN OUT EFI_MEMORY_DESCRIPTOR     *NewRecord,
-  IN EFI_MEMORY_DESCRIPTOR         *OldRecord,
-  IN UINTN                         DescriptorSize
-  )
-{
-  EFI_MEMORY_DESCRIPTOR                     TempRecord;
-  IMAGE_PROPERTIES_RECORD_CODE_SECTION      *ImageRecordCodeSection;
-  LIST_ENTRY                                *ImageRecordCodeSectionLink;
-  LIST_ENTRY                                *ImageRecordCodeSectionEndLink;
-  LIST_ENTRY                                *ImageRecordCodeSectionList;
-  UINTN                                     NewRecordCount;
-  UINT64                                    PhysicalEnd;
-  UINT64                                    ImageEnd;
-
-  CopyMem (&TempRecord, OldRecord, sizeof(EFI_MEMORY_DESCRIPTOR));
-  PhysicalEnd = TempRecord.PhysicalStart + EfiPagesToSize(TempRecord.NumberOfPages);
-  NewRecordCount = 0;
-
-  ImageRecordCodeSectionList = &ImageRecord->CodeSegmentList;
-
-  ImageRecordCodeSectionLink = ImageRecordCodeSectionList->ForwardLink;
-  ImageRecordCodeSectionEndLink = ImageRecordCodeSectionList;
-  while (ImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
-    ImageRecordCodeSection = CR (
-                               ImageRecordCodeSectionLink,
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,
-                               Link,
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
-                               );
-    ImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
-
-    if (TempRecord.PhysicalStart <= ImageRecordCodeSection->CodeSegmentBase) {
-      //
-      // DATA
-      //
-      NewRecord->Type          = TempRecord.Type;
-      NewRecord->PhysicalStart = TempRecord.PhysicalStart;
-      NewRecord->VirtualStart  = 0;
-      NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentBase - NewRecord->PhysicalStart);
-      NewRecord->Attribute     = TempRecord.Attribute | EFI_MEMORY_XP;
-      if (NewRecord->NumberOfPages != 0) {
-        NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
-        NewRecordCount ++;
-      }
-
-      //
-      // CODE
-      //
-      NewRecord->Type          = TempRecord.Type;
-      NewRecord->PhysicalStart = ImageRecordCodeSection->CodeSegmentBase;
-      NewRecord->VirtualStart  = 0;
-      NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentSize);
-      NewRecord->Attribute     = (TempRecord.Attribute & (~EFI_MEMORY_XP)) | EFI_MEMORY_RO;
-      if (NewRecord->NumberOfPages != 0) {
-        NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
-        NewRecordCount ++;
-      }
-
-      TempRecord.PhysicalStart = ImageRecordCodeSection->CodeSegmentBase + EfiPagesToSize (EfiSizeToPages(ImageRecordCodeSection->CodeSegmentSize));
-      TempRecord.NumberOfPages = EfiSizeToPages(PhysicalEnd - TempRecord.PhysicalStart);
-      if (TempRecord.NumberOfPages == 0) {
-        break;
-      }
-    }
-  }
-
-  ImageEnd = ImageRecord->ImageBase + ImageRecord->ImageSize;
-
-  //
-  // Final DATA
-  //
-  if (TempRecord.PhysicalStart < ImageEnd) {
-    NewRecord->Type          = TempRecord.Type;
-    NewRecord->PhysicalStart = TempRecord.PhysicalStart;
-    NewRecord->VirtualStart  = 0;
-    NewRecord->NumberOfPages = EfiSizeToPages (ImageEnd - TempRecord.PhysicalStart);
-    NewRecord->Attribute     = TempRecord.Attribute | EFI_MEMORY_XP;
-    NewRecordCount ++;
-  }
-
-  return NewRecordCount;
-}
-
-/**
-  Return the max number of new splitted entries, according to one old entry,
-  based upon PE code section and data section.
-
-  @param  OldRecord              A pointer to one old memory map entry.
-
-  @retval  0 no entry need to be splitted.
-  @return  the max number of new splitted entries
-**/
-STATIC
-UINTN
-GetMaxSplitRecordCount (
-  IN EFI_MEMORY_DESCRIPTOR *OldRecord
-  )
-{
-  IMAGE_PROPERTIES_RECORD *ImageRecord;
-  UINTN                   SplitRecordCount;
-  UINT64                  PhysicalStart;
-  UINT64                  PhysicalEnd;
-
-  SplitRecordCount = 0;
-  PhysicalStart = OldRecord->PhysicalStart;
-  PhysicalEnd = OldRecord->PhysicalStart + EfiPagesToSize(OldRecord->NumberOfPages);
-
-  do {
-    ImageRecord = GetImageRecordByAddress (PhysicalStart, PhysicalEnd - PhysicalStart);
-    if (ImageRecord == NULL) {
-      break;
-    }
-    SplitRecordCount += (2 * ImageRecord->CodeSegmentCount + 1);
-    PhysicalStart = ImageRecord->ImageBase + ImageRecord->ImageSize;
-  } while ((ImageRecord != NULL) && (PhysicalStart < PhysicalEnd));
-
-  if (SplitRecordCount != 0) {
-    SplitRecordCount--;
-  }
-
-  return SplitRecordCount;
-}
-
-/**
-  Split the memory map to new entries, according to one old entry,
-  based upon PE code section and data section.
-
-  @param  OldRecord              A pointer to one old memory map entry.
-  @param  NewRecord              A pointer to several new memory map entries.
-                                 The caller gurantee the buffer size be 1 +
-                                 (SplitRecordCount * DescriptorSize) calculated
-                                 below.
-  @param  MaxSplitRecordCount    The max number of splitted entries
-  @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
-
-  @retval  0 no entry is splitted.
-  @return  the real number of splitted record.
-**/
-STATIC
-UINTN
-SplitRecord (
-  IN EFI_MEMORY_DESCRIPTOR     *OldRecord,
-  IN OUT EFI_MEMORY_DESCRIPTOR *NewRecord,
-  IN UINTN                     MaxSplitRecordCount,
-  IN UINTN                     DescriptorSize
-  )
-{
-  EFI_MEMORY_DESCRIPTOR   TempRecord;
-  IMAGE_PROPERTIES_RECORD *ImageRecord;
-  IMAGE_PROPERTIES_RECORD *NewImageRecord;
-  UINT64                  PhysicalStart;
-  UINT64                  PhysicalEnd;
-  UINTN                   NewRecordCount;
-  UINTN                   TotalNewRecordCount;
-  BOOLEAN                 IsLastRecordData;
-
-  if (MaxSplitRecordCount == 0) {
-    CopyMem (NewRecord, OldRecord, DescriptorSize);
-    return 0;
-  }
-
-  TotalNewRecordCount = 0;
-
-  //
-  // Override previous record
-  //
-  CopyMem (&TempRecord, OldRecord, sizeof(EFI_MEMORY_DESCRIPTOR));
-  PhysicalStart = TempRecord.PhysicalStart;
-  PhysicalEnd = TempRecord.PhysicalStart + EfiPagesToSize(TempRecord.NumberOfPages);
-
-  ImageRecord = NULL;
-  do {
-    NewImageRecord = GetImageRecordByAddress (PhysicalStart, PhysicalEnd - PhysicalStart);
-    if (NewImageRecord == NULL) {
-      //
-      // No more image covered by this range, stop
-      //
-      if ((PhysicalEnd > PhysicalStart) && (ImageRecord != NULL)) {
-        //
-        // If this is still address in this record, need record.
-        //
-        NewRecord = PREVIOUS_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
-        IsLastRecordData = FALSE;
-        if ((NewRecord->Attribute & EFI_MEMORY_XP) != 0) {
-          IsLastRecordData = TRUE;
-        }
-        if (IsLastRecordData) {
-          //
-          // Last record is DATA, just merge it.
-          //
-          NewRecord->NumberOfPages = EfiSizeToPages(PhysicalEnd - NewRecord->PhysicalStart);
-        } else {
-          //
-          // Last record is CODE, create a new DATA entry.
-          //
-          NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);
-          NewRecord->Type          = TempRecord.Type;
-          NewRecord->PhysicalStart = TempRecord.PhysicalStart;
-          NewRecord->VirtualStart  = 0;
-          NewRecord->NumberOfPages = TempRecord.NumberOfPages;
-          NewRecord->Attribute     = TempRecord.Attribute | EFI_MEMORY_XP;
-          TotalNewRecordCount ++;
-        }
-      }
-      break;
-    }
-    ImageRecord = NewImageRecord;
-
-    //
-    // Set new record
-    //
-    NewRecordCount = SetNewRecord (ImageRecord, NewRecord, &TempRecord, DescriptorSize);
-    TotalNewRecordCount += NewRecordCount;
-    NewRecord = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)NewRecord + NewRecordCount * DescriptorSize);
-
-    //
-    // Update PhysicalStart, in order to exclude the image buffer already splitted.
-    //
-    PhysicalStart = ImageRecord->ImageBase + ImageRecord->ImageSize;
-    TempRecord.PhysicalStart = PhysicalStart;
-    TempRecord.NumberOfPages = EfiSizeToPages (PhysicalEnd - PhysicalStart);
-  } while ((ImageRecord != NULL) && (PhysicalStart < PhysicalEnd));
-
-  //
-  // The logic in function SplitTable() ensures that TotalNewRecordCount will not be zero if the
-  // code reaches here.
-  //
-  ASSERT (TotalNewRecordCount != 0);
-  return TotalNewRecordCount - 1;
-}
-
-/**
-  Split the original memory map, and add more entries to describe PE code section and data section.
-  This function will set EfiRuntimeServicesData to be EFI_MEMORY_XP.
-  This function will merge entries with same attributes finally.
-
-  NOTE: It assumes PE code/data section are page aligned.
-  NOTE: It assumes enough entry is prepared for new memory map.
-
-  Split table:
-   +---------------+
-   | Record X      |
-   +---------------+
-   | Record RtCode |
-   +---------------+
-   | Record Y      |
-   +---------------+
-   ==>
-   +---------------+
-   | Record X      |
-   +---------------+ ----
-   | Record RtData |     |
-   +---------------+     |
-   | Record RtCode |     |-> PE/COFF1
-   +---------------+     |
-   | Record RtData |     |
-   +---------------+ ----
-   | Record RtData |     |
-   +---------------+     |
-   | Record RtCode |     |-> PE/COFF2
-   +---------------+     |
-   | Record RtData |     |
-   +---------------+ ----
-   | Record Y      |
-   +---------------+
-
-  @param  MemoryMapSize          A pointer to the size, in bytes, of the
-                                 MemoryMap buffer. On input, this is the size of
-                                 old MemoryMap before split. The actual buffer
-                                 size of MemoryMap is MemoryMapSize +
-                                 (AdditionalRecordCount * DescriptorSize) calculated
-                                 below. On output, it is the size of new MemoryMap
-                                 after split.
-  @param  MemoryMap              A pointer to the buffer in which firmware places
-                                 the current memory map.
-  @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
-**/
-STATIC
-VOID
-SplitTable (
-  IN OUT UINTN                  *MemoryMapSize,
-  IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,
-  IN UINTN                      DescriptorSize
-  )
-{
-  INTN        IndexOld;
-  INTN        IndexNew;
-  UINTN       MaxSplitRecordCount;
-  UINTN       RealSplitRecordCount;
-  UINTN       TotalSplitRecordCount;
-  UINTN       AdditionalRecordCount;
-
-  AdditionalRecordCount = (2 * mImagePropertiesPrivateData.CodeSegmentCountMax + 1) * mImagePropertiesPrivateData.ImageRecordCount;
-
-  TotalSplitRecordCount = 0;
-  //
-  // Let old record point to end of valid MemoryMap buffer.
-  //
-  IndexOld = ((*MemoryMapSize) / DescriptorSize) - 1;
-  //
-  // Let new record point to end of full MemoryMap buffer.
-  //
-  IndexNew = ((*MemoryMapSize) / DescriptorSize) - 1 + AdditionalRecordCount;
-  for (; IndexOld >= 0; IndexOld--) {
-    MaxSplitRecordCount = GetMaxSplitRecordCount ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + IndexOld * DescriptorSize));
-    //
-    // Split this MemoryMap record
-    //
-    IndexNew -= MaxSplitRecordCount;
-    RealSplitRecordCount = SplitRecord (
-                             (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + IndexOld * DescriptorSize),
-                             (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + IndexNew * DescriptorSize),
-                             MaxSplitRecordCount,
-                             DescriptorSize
-                             );
-    //
-    // Adjust IndexNew according to real split.
-    //
-    CopyMem (
-      ((UINT8 *)MemoryMap + (IndexNew + MaxSplitRecordCount - RealSplitRecordCount) * DescriptorSize),
-      ((UINT8 *)MemoryMap + IndexNew * DescriptorSize),
-      RealSplitRecordCount * DescriptorSize
-      );
-    IndexNew = IndexNew + MaxSplitRecordCount - RealSplitRecordCount;
-    TotalSplitRecordCount += RealSplitRecordCount;
-    IndexNew --;
-  }
-  //
-  // Move all records to the beginning.
-  //
-  CopyMem (
-    MemoryMap,
-    (UINT8 *)MemoryMap + (AdditionalRecordCount - TotalSplitRecordCount) * DescriptorSize,
-    (*MemoryMapSize) + TotalSplitRecordCount * DescriptorSize
-    );
-
-  *MemoryMapSize = (*MemoryMapSize) + DescriptorSize * TotalSplitRecordCount;
-
-  //
-  // Sort from low to high (Just in case)
-  //
-  SortMemoryMap (MemoryMap, *MemoryMapSize, DescriptorSize);
-
-  //
-  // Set RuntimeData to XP
-  //
-  EnforceMemoryMapAttribute (MemoryMap, *MemoryMapSize, DescriptorSize);
-
-  //
-  // Merge same type to save entry size
-  //
-  MergeMemoryMap (MemoryMap, MemoryMapSize, DescriptorSize);
-
-  return ;
-}
-
-/**
-  This function for GetMemoryMap() with properties table capability.
-
-  It calls original GetMemoryMap() to get the original memory map information. Then
-  plus the additional memory map entries for PE Code/Data seperation.
-
-  @param  MemoryMapSize          A pointer to the size, in bytes, of the
-                                 MemoryMap buffer. On input, this is the size of
-                                 the buffer allocated by the caller.  On output,
-                                 it is the size of the buffer returned by the
-                                 firmware  if the buffer was large enough, or the
-                                 size of the buffer needed  to contain the map if
-                                 the buffer was too small.
-  @param  MemoryMap              A pointer to the buffer in which firmware places
-                                 the current memory map.
-  @param  MapKey                 A pointer to the location in which firmware
-                                 returns the key for the current memory map.
-  @param  DescriptorSize         A pointer to the location in which firmware
-                                 returns the size, in bytes, of an individual
-                                 EFI_MEMORY_DESCRIPTOR.
-  @param  DescriptorVersion      A pointer to the location in which firmware
-                                 returns the version number associated with the
-                                 EFI_MEMORY_DESCRIPTOR.
-
-  @retval EFI_SUCCESS            The memory map was returned in the MemoryMap
-                                 buffer.
-  @retval EFI_BUFFER_TOO_SMALL   The MemoryMap buffer was too small. The current
-                                 buffer size needed to hold the memory map is
-                                 returned in MemoryMapSize.
-  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value.
-
-**/
-EFI_STATUS
-EFIAPI
-CoreGetMemoryMapWithSeparatedImageSection (
-  IN OUT UINTN                  *MemoryMapSize,
-  IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,
-  OUT UINTN                     *MapKey,
-  OUT UINTN                     *DescriptorSize,
-  OUT UINT32                    *DescriptorVersion
-  )
-{
-  EFI_STATUS  Status;
-  UINTN       OldMemoryMapSize;
-  UINTN       AdditionalRecordCount;
-
-  //
-  // If PE code/data is not aligned, just return.
-  //
-  if (!mMemoryAttributesTableEnable) {
-    return CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey, DescriptorSize, DescriptorVersion);
-  }
-
-  if (MemoryMapSize == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  CoreAcquirePropertiesTableLock ();
-
-  AdditionalRecordCount = (2 * mImagePropertiesPrivateData.CodeSegmentCountMax + 1) * mImagePropertiesPrivateData.ImageRecordCount;
-
-  OldMemoryMapSize = *MemoryMapSize;
-  Status = CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey, DescriptorSize, DescriptorVersion);
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-    *MemoryMapSize = *MemoryMapSize + (*DescriptorSize) * AdditionalRecordCount;
-  } else if (Status == EFI_SUCCESS) {
-    ASSERT (MemoryMap != NULL);
-    if (OldMemoryMapSize - *MemoryMapSize < (*DescriptorSize) * AdditionalRecordCount) {
-      *MemoryMapSize = *MemoryMapSize + (*DescriptorSize) * AdditionalRecordCount;
-      //
-      // Need update status to buffer too small
-      //
-      Status = EFI_BUFFER_TOO_SMALL;
-    } else {
-      //
-      // Split PE code/data
-      //
-      SplitTable (MemoryMapSize, MemoryMap, *DescriptorSize);
-    }
-  }
-
-  CoreReleasePropertiesTableLock ();
-  return Status;
-}
-
-//
-// Below functions are for ImageRecord
-//
-
-/**
-  Set PropertiesTable according to PE/COFF image section alignment.
-
-  @param  SectionAlignment    PE/COFF section alignment
-**/
-STATIC
-VOID
-SetPropertiesTableSectionAlignment (
-  IN UINT32  SectionAlignment
-  )
-{
-  if (((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) &&
-      mMemoryAttributesTableEnable) {
-    DEBUG ((EFI_D_VERBOSE, "SetPropertiesTableSectionAlignment - Clear\n"));
-    mMemoryAttributesTableEnable = FALSE;
-  }
-}
-
-/**
-  Swap two code sections in image record.
-
-  @param  FirstImageRecordCodeSection    first code section in image record
-  @param  SecondImageRecordCodeSection   second code section in image record
-**/
-STATIC
-VOID
-SwapImageRecordCodeSection (
-  IN IMAGE_PROPERTIES_RECORD_CODE_SECTION      *FirstImageRecordCodeSection,
-  IN IMAGE_PROPERTIES_RECORD_CODE_SECTION      *SecondImageRecordCodeSection
-  )
-{
-  IMAGE_PROPERTIES_RECORD_CODE_SECTION      TempImageRecordCodeSection;
-
-  TempImageRecordCodeSection.CodeSegmentBase = FirstImageRecordCodeSection->CodeSegmentBase;
-  TempImageRecordCodeSection.CodeSegmentSize = FirstImageRecordCodeSection->CodeSegmentSize;
-
-  FirstImageRecordCodeSection->CodeSegmentBase = SecondImageRecordCodeSection->CodeSegmentBase;
-  FirstImageRecordCodeSection->CodeSegmentSize = SecondImageRecordCodeSection->CodeSegmentSize;
-
-  SecondImageRecordCodeSection->CodeSegmentBase = TempImageRecordCodeSection.CodeSegmentBase;
-  SecondImageRecordCodeSection->CodeSegmentSize = TempImageRecordCodeSection.CodeSegmentSize;
-}
-
-/**
-  Sort code section in image record, based upon CodeSegmentBase from low to high.
-
-  @param  ImageRecord    image record to be sorted
-**/
-VOID
-SortImageRecordCodeSection (
-  IN IMAGE_PROPERTIES_RECORD              *ImageRecord
-  )
-{
-  IMAGE_PROPERTIES_RECORD_CODE_SECTION      *ImageRecordCodeSection;
-  IMAGE_PROPERTIES_RECORD_CODE_SECTION      *NextImageRecordCodeSection;
-  LIST_ENTRY                                *ImageRecordCodeSectionLink;
-  LIST_ENTRY                                *NextImageRecordCodeSectionLink;
-  LIST_ENTRY                                *ImageRecordCodeSectionEndLink;
-  LIST_ENTRY                                *ImageRecordCodeSectionList;
-
-  ImageRecordCodeSectionList = &ImageRecord->CodeSegmentList;
-
-  ImageRecordCodeSectionLink = ImageRecordCodeSectionList->ForwardLink;
-  NextImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
-  ImageRecordCodeSectionEndLink = ImageRecordCodeSectionList;
-  while (ImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
-    ImageRecordCodeSection = CR (
-                               ImageRecordCodeSectionLink,
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,
-                               Link,
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
-                               );
-    while (NextImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
-      NextImageRecordCodeSection = CR (
-                                     NextImageRecordCodeSectionLink,
-                                     IMAGE_PROPERTIES_RECORD_CODE_SECTION,
-                                     Link,
-                                     IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
-                                     );
-      if (ImageRecordCodeSection->CodeSegmentBase > NextImageRecordCodeSection->CodeSegmentBase) {
-        SwapImageRecordCodeSection (ImageRecordCodeSection, NextImageRecordCodeSection);
-      }
-      NextImageRecordCodeSectionLink = NextImageRecordCodeSectionLink->ForwardLink;
-    }
-
-    ImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
-    NextImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
-  }
-}
-
-/**
-  Check if code section in image record is valid.
-
-  @param  ImageRecord    image record to be checked
-
-  @retval TRUE  image record is valid
-  @retval FALSE image record is invalid
-**/
-BOOLEAN
-IsImageRecordCodeSectionValid (
-  IN IMAGE_PROPERTIES_RECORD              *ImageRecord
-  )
-{
-  IMAGE_PROPERTIES_RECORD_CODE_SECTION      *ImageRecordCodeSection;
-  IMAGE_PROPERTIES_RECORD_CODE_SECTION      *LastImageRecordCodeSection;
-  LIST_ENTRY                                *ImageRecordCodeSectionLink;
-  LIST_ENTRY                                *ImageRecordCodeSectionEndLink;
-  LIST_ENTRY                                *ImageRecordCodeSectionList;
-
-  DEBUG ((EFI_D_VERBOSE, "ImageCode SegmentCount - 0x%x\n", ImageRecord->CodeSegmentCount));
-
-  ImageRecordCodeSectionList = &ImageRecord->CodeSegmentList;
-
-  ImageRecordCodeSectionLink = ImageRecordCodeSectionList->ForwardLink;
-  ImageRecordCodeSectionEndLink = ImageRecordCodeSectionList;
-  LastImageRecordCodeSection = NULL;
-  while (ImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) {
-    ImageRecordCodeSection = CR (
-                               ImageRecordCodeSectionLink,
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,
-                               Link,
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
-                               );
-    if (ImageRecordCodeSection->CodeSegmentSize == 0) {
-      return FALSE;
-    }
-    if (ImageRecordCodeSection->CodeSegmentBase < ImageRecord->ImageBase) {
-      return FALSE;
-    }
-    if (ImageRecordCodeSection->CodeSegmentBase >= MAX_ADDRESS - ImageRecordCodeSection->CodeSegmentSize) {
-      return FALSE;
-    }
-    if ((ImageRecordCodeSection->CodeSegmentBase + ImageRecordCodeSection->CodeSegmentSize) > (ImageRecord->ImageBase + ImageRecord->ImageSize)) {
-      return FALSE;
-    }
-    if (LastImageRecordCodeSection != NULL) {
-      if ((LastImageRecordCodeSection->CodeSegmentBase + LastImageRecordCodeSection->CodeSegmentSize) > ImageRecordCodeSection->CodeSegmentBase) {
-        return FALSE;
-      }
-    }
-
-    LastImageRecordCodeSection = ImageRecordCodeSection;
-    ImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink;
-  }
-
-  return TRUE;
-}
-
-/**
-  Swap two image records.
-
-  @param  FirstImageRecord   first image record.
-  @param  SecondImageRecord  second image record.
-**/
-STATIC
-VOID
-SwapImageRecord (
-  IN IMAGE_PROPERTIES_RECORD      *FirstImageRecord,
-  IN IMAGE_PROPERTIES_RECORD      *SecondImageRecord
-  )
-{
-  IMAGE_PROPERTIES_RECORD      TempImageRecord;
-
-  TempImageRecord.ImageBase = FirstImageRecord->ImageBase;
-  TempImageRecord.ImageSize = FirstImageRecord->ImageSize;
-  TempImageRecord.CodeSegmentCount = FirstImageRecord->CodeSegmentCount;
-
-  FirstImageRecord->ImageBase = SecondImageRecord->ImageBase;
-  FirstImageRecord->ImageSize = SecondImageRecord->ImageSize;
-  FirstImageRecord->CodeSegmentCount = SecondImageRecord->CodeSegmentCount;
-
-  SecondImageRecord->ImageBase = TempImageRecord.ImageBase;
-  SecondImageRecord->ImageSize = TempImageRecord.ImageSize;
-  SecondImageRecord->CodeSegmentCount = TempImageRecord.CodeSegmentCount;
-
-  SwapListEntries (&FirstImageRecord->CodeSegmentList, &SecondImageRecord->CodeSegmentList);
-}
-
-/**
-  Sort image record based upon the ImageBase from low to high.
-**/
-STATIC
-VOID
-SortImageRecord (
-  VOID
-  )
-{
-  IMAGE_PROPERTIES_RECORD      *ImageRecord;
-  IMAGE_PROPERTIES_RECORD      *NextImageRecord;
-  LIST_ENTRY                   *ImageRecordLink;
-  LIST_ENTRY                   *NextImageRecordLink;
-  LIST_ENTRY                   *ImageRecordEndLink;
-  LIST_ENTRY                   *ImageRecordList;
-
-  ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;
-
-  ImageRecordLink = ImageRecordList->ForwardLink;
-  NextImageRecordLink = ImageRecordLink->ForwardLink;
-  ImageRecordEndLink = ImageRecordList;
-  while (ImageRecordLink != ImageRecordEndLink) {
-    ImageRecord = CR (
-                    ImageRecordLink,
-                    IMAGE_PROPERTIES_RECORD,
-                    Link,
-                    IMAGE_PROPERTIES_RECORD_SIGNATURE
-                    );
-    while (NextImageRecordLink != ImageRecordEndLink) {
-      NextImageRecord = CR (
-                          NextImageRecordLink,
-                          IMAGE_PROPERTIES_RECORD,
-                          Link,
-                          IMAGE_PROPERTIES_RECORD_SIGNATURE
-                          );
-      if (ImageRecord->ImageBase > NextImageRecord->ImageBase) {
-        SwapImageRecord (ImageRecord, NextImageRecord);
-      }
-      NextImageRecordLink = NextImageRecordLink->ForwardLink;
-    }
-
-    ImageRecordLink = ImageRecordLink->ForwardLink;
-    NextImageRecordLink = ImageRecordLink->ForwardLink;
-  }
-}
-
-/**
-  Insert image record.
-
-  @param  RuntimeImage    Runtime image information
-**/
-VOID
-InsertImageRecord (
-  IN EFI_RUNTIME_IMAGE_ENTRY  *RuntimeImage
-  )
-{
-  VOID                                 *ImageAddress;
-  EFI_IMAGE_DOS_HEADER                 *DosHdr;
-  UINT32                               PeCoffHeaderOffset;
-  UINT32                               SectionAlignment;
-  EFI_IMAGE_SECTION_HEADER             *Section;
-  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr;
-  UINT8                                *Name;
-  UINTN                                Index;
-  IMAGE_PROPERTIES_RECORD              *ImageRecord;
-  CHAR8                                *PdbPointer;
-  IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection;
-
-  DEBUG ((EFI_D_VERBOSE, "InsertImageRecord - 0x%x\n", RuntimeImage));
-  DEBUG ((EFI_D_VERBOSE, "InsertImageRecord - 0x%016lx - 0x%016lx\n", (EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase, RuntimeImage->ImageSize));
-
-  if (mPropertiesTableEndOfDxe) {
-    DEBUG ((DEBUG_INFO, "Do not insert runtime image record after EndOfDxe\n"));
-    return ;
-  }
-
-  ImageRecord = AllocatePool (sizeof(*ImageRecord));
-  if (ImageRecord == NULL) {
-    return ;
-  }
-  ImageRecord->Signature = IMAGE_PROPERTIES_RECORD_SIGNATURE;
-
-  DEBUG ((EFI_D_VERBOSE, "ImageRecordCount - 0x%x\n", mImagePropertiesPrivateData.ImageRecordCount));
-
-  //
-  // Step 1: record whole region
-  //
-  ImageRecord->ImageBase = (EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase;
-  ImageRecord->ImageSize = RuntimeImage->ImageSize;
-
-  ImageAddress = RuntimeImage->ImageBase;
-
-  PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);
-  if (PdbPointer != NULL) {
-    DEBUG ((EFI_D_VERBOSE, "  Image - %a\n", PdbPointer));
-  }
-
-  //
-  // Check PE/COFF image
-  //
-  DosHdr = (EFI_IMAGE_DOS_HEADER *) (UINTN) ImageAddress;
-  PeCoffHeaderOffset = 0;
-  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
-    PeCoffHeaderOffset = DosHdr->e_lfanew;
-  }
-
-  Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINT8 *) (UINTN) ImageAddress + PeCoffHeaderOffset);
-  if (Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) {
-    DEBUG ((EFI_D_VERBOSE, "Hdr.Pe32->Signature invalid - 0x%x\n", Hdr.Pe32->Signature));
-    // It might be image in SMM.
-    goto Finish;
-  }
-
-  //
-  // Get SectionAlignment
-  //
-  if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
-    SectionAlignment  = Hdr.Pe32->OptionalHeader.SectionAlignment;
-  } else {
-    SectionAlignment  = Hdr.Pe32Plus->OptionalHeader.SectionAlignment;
-  }
-
-  SetPropertiesTableSectionAlignment (SectionAlignment);
-  if ((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) {
-    DEBUG ((EFI_D_WARN, "!!!!!!!!  InsertImageRecord - Section Alignment(0x%x) is not %dK  !!!!!!!!\n",
-      SectionAlignment, RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));
-    PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);
-    if (PdbPointer != NULL) {
-      DEBUG ((EFI_D_WARN, "!!!!!!!!  Image - %a  !!!!!!!!\n", PdbPointer));
-    }
-    goto Finish;
-  }
-
-  Section = (EFI_IMAGE_SECTION_HEADER *) (
-               (UINT8 *) (UINTN) ImageAddress +
-               PeCoffHeaderOffset +
-               sizeof(UINT32) +
-               sizeof(EFI_IMAGE_FILE_HEADER) +
-               Hdr.Pe32->FileHeader.SizeOfOptionalHeader
-               );
-  ImageRecord->CodeSegmentCount = 0;
-  InitializeListHead (&ImageRecord->CodeSegmentList);
-  for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {
-    Name = Section[Index].Name;
-    DEBUG ((
-      EFI_D_VERBOSE,
-      "  Section - '%c%c%c%c%c%c%c%c'\n",
-      Name[0],
-      Name[1],
-      Name[2],
-      Name[3],
-      Name[4],
-      Name[5],
-      Name[6],
-      Name[7]
-      ));
-
-    if ((Section[Index].Characteristics & EFI_IMAGE_SCN_CNT_CODE) != 0) {
-      DEBUG ((EFI_D_VERBOSE, "  VirtualSize          - 0x%08x\n", Section[Index].Misc.VirtualSize));
-      DEBUG ((EFI_D_VERBOSE, "  VirtualAddress       - 0x%08x\n", Section[Index].VirtualAddress));
-      DEBUG ((EFI_D_VERBOSE, "  SizeOfRawData        - 0x%08x\n", Section[Index].SizeOfRawData));
-      DEBUG ((EFI_D_VERBOSE, "  PointerToRawData     - 0x%08x\n", Section[Index].PointerToRawData));
-      DEBUG ((EFI_D_VERBOSE, "  PointerToRelocations - 0x%08x\n", Section[Index].PointerToRelocations));
-      DEBUG ((EFI_D_VERBOSE, "  PointerToLinenumbers - 0x%08x\n", Section[Index].PointerToLinenumbers));
-      DEBUG ((EFI_D_VERBOSE, "  NumberOfRelocations  - 0x%08x\n", Section[Index].NumberOfRelocations));
-      DEBUG ((EFI_D_VERBOSE, "  NumberOfLinenumbers  - 0x%08x\n", Section[Index].NumberOfLinenumbers));
-      DEBUG ((EFI_D_VERBOSE, "  Characteristics      - 0x%08x\n", Section[Index].Characteristics));
-
-      //
-      // Step 2: record code section
-      //
-      ImageRecordCodeSection = AllocatePool (sizeof(*ImageRecordCodeSection));
-      if (ImageRecordCodeSection == NULL) {
-        return ;
-      }
-      ImageRecordCodeSection->Signature = IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE;
-
-      ImageRecordCodeSection->CodeSegmentBase = (UINTN)ImageAddress + Section[Index].VirtualAddress;
-      ImageRecordCodeSection->CodeSegmentSize = Section[Index].SizeOfRawData;
-
-      DEBUG ((EFI_D_VERBOSE, "ImageCode: 0x%016lx - 0x%016lx\n", ImageRecordCodeSection->CodeSegmentBase, ImageRecordCodeSection->CodeSegmentSize));
-
-      InsertTailList (&ImageRecord->CodeSegmentList, &ImageRecordCodeSection->Link);
-      ImageRecord->CodeSegmentCount++;
-    }
-  }
-
-  if (ImageRecord->CodeSegmentCount == 0) {
-    SetPropertiesTableSectionAlignment (1);
-    DEBUG ((EFI_D_ERROR, "!!!!!!!!  InsertImageRecord - CodeSegmentCount is 0  !!!!!!!!\n"));
-    PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);
-    if (PdbPointer != NULL) {
-      DEBUG ((EFI_D_ERROR, "!!!!!!!!  Image - %a  !!!!!!!!\n", PdbPointer));
-    }
-    goto Finish;
-  }
-
-  //
-  // Final
-  //
-  SortImageRecordCodeSection (ImageRecord);
-  //
-  // Check overlap all section in ImageBase/Size
-  //
-  if (!IsImageRecordCodeSectionValid (ImageRecord)) {
-    DEBUG ((EFI_D_ERROR, "IsImageRecordCodeSectionValid - FAIL\n"));
-    goto Finish;
-  }
-
-  InsertTailList (&mImagePropertiesPrivateData.ImageRecordList, &ImageRecord->Link);
-  mImagePropertiesPrivateData.ImageRecordCount++;
-
-  if (mImagePropertiesPrivateData.CodeSegmentCountMax < ImageRecord->CodeSegmentCount) {
-    mImagePropertiesPrivateData.CodeSegmentCountMax = ImageRecord->CodeSegmentCount;
-  }
-
-  SortImageRecord ();
-
-Finish:
-  return ;
-}
-
-/**
-  Find image record according to image base and size.
-
-  @param  ImageBase    Base of PE image
-  @param  ImageSize    Size of PE image
-
-  @return image record
-**/
-STATIC
-IMAGE_PROPERTIES_RECORD *
-FindImageRecord (
-  IN EFI_PHYSICAL_ADDRESS  ImageBase,
-  IN UINT64                ImageSize
-  )
-{
-  IMAGE_PROPERTIES_RECORD    *ImageRecord;
-  LIST_ENTRY                 *ImageRecordLink;
-  LIST_ENTRY                 *ImageRecordList;
-
-  ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;
-
-  for (ImageRecordLink = ImageRecordList->ForwardLink;
-       ImageRecordLink != ImageRecordList;
-       ImageRecordLink = ImageRecordLink->ForwardLink) {
-    ImageRecord = CR (
-                    ImageRecordLink,
-                    IMAGE_PROPERTIES_RECORD,
-                    Link,
-                    IMAGE_PROPERTIES_RECORD_SIGNATURE
-                    );
-
-    if ((ImageBase == ImageRecord->ImageBase) &&
-        (ImageSize == ImageRecord->ImageSize)) {
-      return ImageRecord;
-    }
-  }
-
-  return NULL;
-}
-
-/**
-  Remove Image record.
-
-  @param  RuntimeImage    Runtime image information
-**/
-VOID
-RemoveImageRecord (
-  IN EFI_RUNTIME_IMAGE_ENTRY  *RuntimeImage
-  )
-{
-  IMAGE_PROPERTIES_RECORD              *ImageRecord;
-  LIST_ENTRY                           *CodeSegmentListHead;
-  IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection;
-
-  DEBUG ((EFI_D_VERBOSE, "RemoveImageRecord - 0x%x\n", RuntimeImage));
-  DEBUG ((EFI_D_VERBOSE, "RemoveImageRecord - 0x%016lx - 0x%016lx\n", (EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase, RuntimeImage->ImageSize));
-
-  if (mPropertiesTableEndOfDxe) {
-    DEBUG ((DEBUG_INFO, "Do not remove runtime image record after EndOfDxe\n"));
-    return ;
-  }
-
-  ImageRecord = FindImageRecord ((EFI_PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase, RuntimeImage->ImageSize);
-  if (ImageRecord == NULL) {
-    DEBUG ((EFI_D_ERROR, "!!!!!!!! ImageRecord not found !!!!!!!!\n"));
-    return ;
-  }
-
-  CodeSegmentListHead = &ImageRecord->CodeSegmentList;
-  while (!IsListEmpty (CodeSegmentListHead)) {
-    ImageRecordCodeSection = CR (
-                               CodeSegmentListHead->ForwardLink,
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,
-                               Link,
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
-                               );
-    RemoveEntryList (&ImageRecordCodeSection->Link);
-    FreePool (ImageRecordCodeSection);
-  }
-
-  RemoveEntryList (&ImageRecord->Link);
-  FreePool (ImageRecord);
-  mImagePropertiesPrivateData.ImageRecordCount--;
-}
-
-
-/**
-  Install PropertiesTable.
-
-  @param[in]  Event     The Event this notify function registered to.
-  @param[in]  Context   Pointer to the context data registered to the Event.
-**/
-VOID
-EFIAPI
-InstallPropertiesTable (
-  EFI_EVENT                               Event,
-  VOID                                    *Context
-  )
-{
-  mPropertiesTableEndOfDxe = TRUE;
-}
-
-/**
-  Initialize PropertiesTable support.
-**/
-VOID
-EFIAPI
-CoreInitializePropertiesTable (
-  VOID
-  )
-{
-  EFI_STATUS  Status;
-  EFI_EVENT   EndOfDxeEvent;
-
-  Status = gBS->CreateEventEx (
-                  EVT_NOTIFY_SIGNAL,
-                  TPL_NOTIFY,
-                  InstallPropertiesTable,
-                  NULL,
-                  &gEfiEndOfDxeEventGroupGuid,
-                  &EndOfDxeEvent
-                  );
-  ASSERT_EFI_ERROR (Status);
-  return ;
-}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [EXTERNAL] [PATCH 3/4] MdePkg: remove PropertiesTable GUID
  2020-03-26 10:24 ` [PATCH 3/4] MdePkg: remove PropertiesTable GUID Ard Biesheuvel
@ 2020-03-27  1:02   ` Bret Barkelew
  2020-03-27  9:16     ` Ard Biesheuvel
  0 siblings, 1 reply; 16+ messages in thread
From: Bret Barkelew @ 2020-03-27  1:02 UTC (permalink / raw)
  To: Ard Biesheuvel, devel@edk2.groups.io
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Kinney, Michael D,
	Ray Ni, Jiewen Yao

[-- Attachment #1: Type: text/plain, Size: 2861 bytes --]

Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>

- Bret

________________________________
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Sent: Thursday, March 26, 2020 3:24:42 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ray Ni <ray.ni@intel.com>; Jiewen Yao <jiewen.yao@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
Subject: [EXTERNAL] [PATCH 3/4] MdePkg: remove PropertiesTable GUID

Remove the GUID definition that describes the deprecated properties table,
which is no longer generated by the DXE core.

Link: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2633&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7C0c14ed320c7f416c975908d7d16feb9a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637208150931667814&amp;sdata=PE0Hy4H60WnykMk4MpFE5mCmD1Ucm6I7Byl1yS33ei0%3D&amp;reserved=0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdePkg/Include/Guid/PropertiesTable.h | 31 --------------------
 MdePkg/MdePkg.dec                     |  3 --
 2 files changed, 34 deletions(-)

diff --git a/MdePkg/Include/Guid/PropertiesTable.h b/MdePkg/Include/Guid/PropertiesTable.h
deleted file mode 100644
index 56dbc7f96138..000000000000
--- a/MdePkg/Include/Guid/PropertiesTable.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/** @file
-  GUIDs used for UEFI Properties Table in the UEFI 2.5 specification.
-
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __EFI_PROPERTIES_TABLE_H__
-#define __EFI_PROPERTIES_TABLE_H__
-
-#define EFI_PROPERTIES_TABLE_GUID {\
-  0x880aaca3, 0x4adc, 0x4a04, {0x90, 0x79, 0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5} \
-}
-
-typedef struct {
-  UINT32    Version;
-  UINT32    Length;
-  UINT64    MemoryProtectionAttribute;
-} EFI_PROPERTIES_TABLE;
-
-#define EFI_PROPERTIES_TABLE_VERSION  0x00010000
-
-//
-// Memory attribute (Not defined bit is reserved)
-//
-#define EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA        0x1
-
-extern EFI_GUID gEfiPropertiesTableGuid;
-
-#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index ac1f5339af06..6c37c2181c62 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -578,9 +578,6 @@ [Guids]
   # GUIDs defined in UEFI2.5
   #

-  ## Include/Guid/PropertiesTable.h
-  gEfiPropertiesTableGuid        = { 0x880aaca3, 0x4adc, 0x4a04, {0x90, 0x79, 0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5 }}
-
   ## Include/Guid/SystemResourceTable.h
   gEfiSystemResourceTableGuid    = { 0xb122a263, 0x3661, 0x4f68, {0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 }}

--
2.17.1


[-- Attachment #2: Type: text/html, Size: 5562 bytes --]

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/4] remove generation of EFI properties table
  2020-03-26 10:24 [PATCH 0/4] remove generation of EFI properties table Ard Biesheuvel
                   ` (3 preceding siblings ...)
  2020-03-26 10:24 ` [PATCH 4/4] MdeModulePkg/DxeCore: merge properties table routines into MAT handling Ard Biesheuvel
@ 2020-03-27  5:00 ` Yao, Jiewen
  2020-03-30 13:42   ` [edk2-devel] " Liming Gao
  2020-04-03  2:22 ` Dandan Bi
  5 siblings, 1 reply; 16+ messages in thread
From: Yao, Jiewen @ 2020-03-27  5:00 UTC (permalink / raw)
  To: Ard Biesheuvel, devel@edk2.groups.io
  Cc: Laszlo Ersek, Leif Lindholm, Kinney, Michael D, Ni, Ray,
	Bret Barkelew

Acked-by: Jiewen Yao <Jiewen.yao@intel.com>

I cannot remember if there is windows OS still using the properties table.
Maybe Microsoft people can comment.

If no, I agree we can remove the old code.



> -----Original Message-----
> From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Sent: Thursday, March 26, 2020 6:25 PM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Ni, Ray <ray.ni@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> Subject: [PATCH 0/4] remove generation of EFI properties table
> 
> The EFI properties table is broken by design, deprecated, and seems to be
> causing confusion as it is unclear to some how it differs from the memory
> attributes table (which supersedes it). So let's get rid of the code that
> generates it entirely, along with the GUID definitions, PCDs etc.
> 
> Due to how the two implementations are intertwined, patch #2 makes the
> minimal changes required to stop producing the table (and to allow patch
> #3 to remove the associated definitions from MdePkg). Patch #4 is optional
> and merges the code together.
> 
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> 
> Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633
> 
> Ard Biesheuvel (4):
>   OvmfPkg: remove handling of properties table
>   MdeModulePkg: disable properties table generation but retain the code
>   MdePkg: remove PropertiesTable GUID
>   MdeModulePkg/DxeCore: merge properties table routines into MAT
>     handling
> 
>  MdeModulePkg/Core/Dxe/DxeMain.h               |    9 -
>  MdeModulePkg/Core/Dxe/DxeMain.inf             |    3 -
>  MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c       |    1 -
>  .../Core/Dxe/Misc/MemoryAttributesTable.c     | 1226 ++++++++++++++-
>  MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c |    1 -
>  MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c  | 1373 -----------------
>  MdeModulePkg/MdeModulePkg.dec                 |   24 -
>  MdeModulePkg/MdeModulePkg.uni                 |   21 -
>  MdePkg/Include/Guid/PropertiesTable.h         |   31 -
>  MdePkg/MdePkg.dec                             |    3 -
>  OvmfPkg/OvmfPkgIa32.dsc                       |    1 -
>  OvmfPkg/OvmfPkgIa32X64.dsc                    |    1 -
>  OvmfPkg/OvmfPkgX64.dsc                        |    1 -
>  OvmfPkg/OvmfXen.dsc                           |    1 -
>  OvmfPkg/PlatformPei/Platform.c                |    1 -
>  OvmfPkg/PlatformPei/PlatformPei.inf           |    1 -
>  16 files changed, 1222 insertions(+), 1476 deletions(-)
>  delete mode 100644 MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
>  delete mode 100644 MdePkg/Include/Guid/PropertiesTable.h
> 
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [EXTERNAL] [PATCH 3/4] MdePkg: remove PropertiesTable GUID
  2020-03-27  1:02   ` [EXTERNAL] " Bret Barkelew
@ 2020-03-27  9:16     ` Ard Biesheuvel
  0 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2020-03-27  9:16 UTC (permalink / raw)
  To: Bret Barkelew
  Cc: devel@edk2.groups.io, Laszlo Ersek, Leif Lindholm,
	Kinney, Michael D, Ray Ni, Jiewen Yao

On Fri, 27 Mar 2020 at 02:02, Bret Barkelew <Bret.Barkelew@microsoft.com> wrote:
>
> Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
>

Thanks Bret

Does this apply only to this 3rd patch? Or to the whole series?


>
>
> ________________________________
> From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Sent: Thursday, March 26, 2020 3:24:42 AM
> To: devel@edk2.groups.io <devel@edk2.groups.io>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ray Ni <ray.ni@intel.com>; Jiewen Yao <jiewen.yao@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> Subject: [EXTERNAL] [PATCH 3/4] MdePkg: remove PropertiesTable GUID
>
> Remove the GUID definition that describes the deprecated properties table,
> which is no longer generated by the DXE core.
>
> Link: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2633&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7C0c14ed320c7f416c975908d7d16feb9a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637208150931667814&amp;sdata=PE0Hy4H60WnykMk4MpFE5mCmD1Ucm6I7Byl1yS33ei0%3D&amp;reserved=0
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  MdePkg/Include/Guid/PropertiesTable.h | 31 --------------------
>  MdePkg/MdePkg.dec                     |  3 --
>  2 files changed, 34 deletions(-)
>
> diff --git a/MdePkg/Include/Guid/PropertiesTable.h b/MdePkg/Include/Guid/PropertiesTable.h
> deleted file mode 100644
> index 56dbc7f96138..000000000000
> --- a/MdePkg/Include/Guid/PropertiesTable.h
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -/** @file
> -  GUIDs used for UEFI Properties Table in the UEFI 2.5 specification.
> -
> -  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
> -  SPDX-License-Identifier: BSD-2-Clause-Patent
> -
> -**/
> -
> -#ifndef __EFI_PROPERTIES_TABLE_H__
> -#define __EFI_PROPERTIES_TABLE_H__
> -
> -#define EFI_PROPERTIES_TABLE_GUID {\
> -  0x880aaca3, 0x4adc, 0x4a04, {0x90, 0x79, 0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5} \
> -}
> -
> -typedef struct {
> -  UINT32    Version;
> -  UINT32    Length;
> -  UINT64    MemoryProtectionAttribute;
> -} EFI_PROPERTIES_TABLE;
> -
> -#define EFI_PROPERTIES_TABLE_VERSION  0x00010000
> -
> -//
> -// Memory attribute (Not defined bit is reserved)
> -//
> -#define EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA        0x1
> -
> -extern EFI_GUID gEfiPropertiesTableGuid;
> -
> -#endif
> diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
> index ac1f5339af06..6c37c2181c62 100644
> --- a/MdePkg/MdePkg.dec
> +++ b/MdePkg/MdePkg.dec
> @@ -578,9 +578,6 @@ [Guids]
>    # GUIDs defined in UEFI2.5
>    #
>
> -  ## Include/Guid/PropertiesTable.h
> -  gEfiPropertiesTableGuid        = { 0x880aaca3, 0x4adc, 0x4a04, {0x90, 0x79, 0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5 }}
> -
>    ## Include/Guid/SystemResourceTable.h
>    gEfiSystemResourceTableGuid    = { 0xb122a263, 0x3661, 0x4f68, {0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 }}
>
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [PATCH 1/4] OvmfPkg: remove handling of properties table
  2020-03-26 10:24 ` [PATCH 1/4] OvmfPkg: remove handling of " Ard Biesheuvel
@ 2020-03-27 14:01   ` Laszlo Ersek
  0 siblings, 0 replies; 16+ messages in thread
From: Laszlo Ersek @ 2020-03-27 14:01 UTC (permalink / raw)
  To: devel, ard.biesheuvel
  Cc: Leif Lindholm, Michael D Kinney, Ray Ni, Jiewen Yao,
	Bret Barkelew

On 03/26/20 11:24, Ard Biesheuvel wrote:
> The UEFI properties table and the associated memory protection feature was
> severely broken from the start, and has been deprecated for a while. Let's
> drop all references to it from OVMF so we can safely remove it from the
> DXE core as well.
> 
> Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  OvmfPkg/OvmfPkgIa32.dsc             | 1 -
>  OvmfPkg/OvmfPkgIa32X64.dsc          | 1 -
>  OvmfPkg/OvmfPkgX64.dsc              | 1 -
>  OvmfPkg/OvmfXen.dsc                 | 1 -
>  OvmfPkg/PlatformPei/Platform.c      | 1 -
>  OvmfPkg/PlatformPei/PlatformPei.inf | 1 -
>  6 files changed, 6 deletions(-)
> 
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 02ca17db8b2a..47926ac9e235 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -570,7 +570,6 @@ [PcdsDynamicDefault]
>  
>    # Noexec settings for DXE.
>    gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
>  
>    # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
>    gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index d08cf558c6aa..37943624dc72 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -581,7 +581,6 @@ [PcdsDynamicDefault]
>  
>    # Noexec settings for DXE.
>    gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
>  
>    # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
>    gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index b2dccc40a865..f41ebb95d717 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -580,7 +580,6 @@ [PcdsDynamicDefault]
>  
>    # Noexec settings for DXE.
>    gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
>  
>    # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
>    gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64
> diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
> index 85fe39f7896c..67b95d7b788c 100644
> --- a/OvmfPkg/OvmfXen.dsc
> +++ b/OvmfPkg/OvmfXen.dsc
> @@ -483,7 +483,6 @@ [PcdsDynamicDefault]
>  
>    # Noexec settings for DXE.
>    gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
>  
>    # Set memory encryption mask
>    gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index 587ca68fc210..088e616a980c 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -315,7 +315,6 @@ NoexecDxeInitialization (
>    VOID
>    )
>  {
> -  UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdPropertiesTableEnable);
>    UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdSetNxForStack);
>  }
>  
> diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
> index 8531c63995c1..19f2424981bc 100644
> --- a/OvmfPkg/PlatformPei/PlatformPei.inf
> +++ b/OvmfPkg/PlatformPei/PlatformPei.inf
> @@ -94,7 +94,6 @@ [Pcd]
>    gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
>    gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
>    gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable
>    gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
>    gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask
>    gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy
> 

Given that the DEC default for PcdPropertiesTableEnable is FALSE, this
change is safe, regarding a bisection on a virtual machine configuration
where the PCD is not enabled explicitly. (IOW, if a VM configuration
does not care about this knob, then building OVMF right after this patch
will not cause the PCD to flip on.)

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thanks!
Laszlo


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
  2020-03-27  5:00 ` [PATCH 0/4] remove generation of EFI properties table Yao, Jiewen
@ 2020-03-30 13:42   ` Liming Gao
  2020-03-30 17:57     ` Ard Biesheuvel
  0 siblings, 1 reply; 16+ messages in thread
From: Liming Gao @ 2020-03-30 13:42 UTC (permalink / raw)
  To: devel@edk2.groups.io, Yao, Jiewen, Ard Biesheuvel
  Cc: Laszlo Ersek, Leif Lindholm, Kinney, Michael D, Ni, Ray,
	Bret Barkelew

Ack-by: Liming Gao <liming.gao@intel.com> 

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yao, Jiewen
> Sent: Friday, March 27, 2020 1:01 PM
> To: Ard Biesheuvel <ard.biesheuvel@linaro.org>; devel@edk2.groups.io
> Cc: Laszlo Ersek <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ray
> <ray.ni@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> Subject: Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
> 
> Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
> 
> I cannot remember if there is windows OS still using the properties table.
> Maybe Microsoft people can comment.
> 
> If no, I agree we can remove the old code.
> 
> 
> 
> > -----Original Message-----
> > From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > Sent: Thursday, March 26, 2020 6:25 PM
> > To: devel@edk2.groups.io
> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> > <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Kinney, Michael D
> > <michael.d.kinney@intel.com>; Ni, Ray <ray.ni@intel.com>; Yao, Jiewen
> > <jiewen.yao@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> > Subject: [PATCH 0/4] remove generation of EFI properties table
> >
> > The EFI properties table is broken by design, deprecated, and seems to be
> > causing confusion as it is unclear to some how it differs from the memory
> > attributes table (which supersedes it). So let's get rid of the code that
> > generates it entirely, along with the GUID definitions, PCDs etc.
> >
> > Due to how the two implementations are intertwined, patch #2 makes the
> > minimal changes required to stop producing the table (and to allow patch
> > #3 to remove the associated definitions from MdePkg). Patch #4 is optional
> > and merges the code together.
> >
> > Cc: Laszlo Ersek <lersek@redhat.com>
> > Cc: Leif Lindholm <leif@nuviainc.com>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> >
> > Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633
> >
> > Ard Biesheuvel (4):
> >   OvmfPkg: remove handling of properties table
> >   MdeModulePkg: disable properties table generation but retain the code
> >   MdePkg: remove PropertiesTable GUID
> >   MdeModulePkg/DxeCore: merge properties table routines into MAT
> >     handling
> >
> >  MdeModulePkg/Core/Dxe/DxeMain.h               |    9 -
> >  MdeModulePkg/Core/Dxe/DxeMain.inf             |    3 -
> >  MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c       |    1 -
> >  .../Core/Dxe/Misc/MemoryAttributesTable.c     | 1226 ++++++++++++++-
> >  MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c |    1 -
> >  MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c  | 1373 -----------------
> >  MdeModulePkg/MdeModulePkg.dec                 |   24 -
> >  MdeModulePkg/MdeModulePkg.uni                 |   21 -
> >  MdePkg/Include/Guid/PropertiesTable.h         |   31 -
> >  MdePkg/MdePkg.dec                             |    3 -
> >  OvmfPkg/OvmfPkgIa32.dsc                       |    1 -
> >  OvmfPkg/OvmfPkgIa32X64.dsc                    |    1 -
> >  OvmfPkg/OvmfPkgX64.dsc                        |    1 -
> >  OvmfPkg/OvmfXen.dsc                           |    1 -
> >  OvmfPkg/PlatformPei/Platform.c                |    1 -
> >  OvmfPkg/PlatformPei/PlatformPei.inf           |    1 -
> >  16 files changed, 1222 insertions(+), 1476 deletions(-)
> >  delete mode 100644 MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
> >  delete mode 100644 MdePkg/Include/Guid/PropertiesTable.h
> >
> > --
> > 2.17.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
  2020-03-30 13:42   ` [edk2-devel] " Liming Gao
@ 2020-03-30 17:57     ` Ard Biesheuvel
  2020-04-01 17:17       ` Ard Biesheuvel
  0 siblings, 1 reply; 16+ messages in thread
From: Ard Biesheuvel @ 2020-03-30 17:57 UTC (permalink / raw)
  To: Gao, Liming, Wu, Hao A, Jian J Wang
  Cc: devel@edk2.groups.io, Yao, Jiewen, Laszlo Ersek, Leif Lindholm,
	Kinney, Michael D, Ni, Ray, Bret Barkelew

(adding Jian and Hao)

Thanks for the acks, and apologies for failing to cc the MdeModulePkg
maintainers.

Jian, Hao, do you have any opinion on this series?




On Mon, 30 Mar 2020 at 15:42, Gao, Liming <liming.gao@intel.com> wrote:
>
> Ack-by: Liming Gao <liming.gao@intel.com>
>
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yao, Jiewen
> > Sent: Friday, March 27, 2020 1:01 PM
> > To: Ard Biesheuvel <ard.biesheuvel@linaro.org>; devel@edk2.groups.io
> > Cc: Laszlo Ersek <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ray
> > <ray.ni@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> > Subject: Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
> >
> > Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
> >
> > I cannot remember if there is windows OS still using the properties table.
> > Maybe Microsoft people can comment.
> >
> > If no, I agree we can remove the old code.
> >
> >
> >
> > > -----Original Message-----
> > > From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > > Sent: Thursday, March 26, 2020 6:25 PM
> > > To: devel@edk2.groups.io
> > > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> > > <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Kinney, Michael D
> > > <michael.d.kinney@intel.com>; Ni, Ray <ray.ni@intel.com>; Yao, Jiewen
> > > <jiewen.yao@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> > > Subject: [PATCH 0/4] remove generation of EFI properties table
> > >
> > > The EFI properties table is broken by design, deprecated, and seems to be
> > > causing confusion as it is unclear to some how it differs from the memory
> > > attributes table (which supersedes it). So let's get rid of the code that
> > > generates it entirely, along with the GUID definitions, PCDs etc.
> > >
> > > Due to how the two implementations are intertwined, patch #2 makes the
> > > minimal changes required to stop producing the table (and to allow patch
> > > #3 to remove the associated definitions from MdePkg). Patch #4 is optional
> > > and merges the code together.
> > >
> > > Cc: Laszlo Ersek <lersek@redhat.com>
> > > Cc: Leif Lindholm <leif@nuviainc.com>
> > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > Cc: Ray Ni <ray.ni@intel.com>
> > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > >
> > > Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633
> > >
> > > Ard Biesheuvel (4):
> > >   OvmfPkg: remove handling of properties table
> > >   MdeModulePkg: disable properties table generation but retain the code
> > >   MdePkg: remove PropertiesTable GUID
> > >   MdeModulePkg/DxeCore: merge properties table routines into MAT
> > >     handling
> > >
> > >  MdeModulePkg/Core/Dxe/DxeMain.h               |    9 -
> > >  MdeModulePkg/Core/Dxe/DxeMain.inf             |    3 -
> > >  MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c       |    1 -
> > >  .../Core/Dxe/Misc/MemoryAttributesTable.c     | 1226 ++++++++++++++-
> > >  MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c |    1 -
> > >  MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c  | 1373 -----------------
> > >  MdeModulePkg/MdeModulePkg.dec                 |   24 -
> > >  MdeModulePkg/MdeModulePkg.uni                 |   21 -
> > >  MdePkg/Include/Guid/PropertiesTable.h         |   31 -
> > >  MdePkg/MdePkg.dec                             |    3 -
> > >  OvmfPkg/OvmfPkgIa32.dsc                       |    1 -
> > >  OvmfPkg/OvmfPkgIa32X64.dsc                    |    1 -
> > >  OvmfPkg/OvmfPkgX64.dsc                        |    1 -
> > >  OvmfPkg/OvmfXen.dsc                           |    1 -
> > >  OvmfPkg/PlatformPei/Platform.c                |    1 -
> > >  OvmfPkg/PlatformPei/PlatformPei.inf           |    1 -
> > >  16 files changed, 1222 insertions(+), 1476 deletions(-)
> > >  delete mode 100644 MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
> > >  delete mode 100644 MdePkg/Include/Guid/PropertiesTable.h
> > >
> > > --
> > > 2.17.1
> >
> >
> > 
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
  2020-03-30 17:57     ` Ard Biesheuvel
@ 2020-04-01 17:17       ` Ard Biesheuvel
  0 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2020-04-01 17:17 UTC (permalink / raw)
  To: Gao, Liming, Wu, Hao A, Jian J Wang, Kinney, Michael D
  Cc: devel@edk2.groups.io, Yao, Jiewen, Laszlo Ersek, Leif Lindholm,
	Ni, Ray, Bret Barkelew

On Mon, 30 Mar 2020 at 19:57, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> (adding Jian and Hao)
>
> Thanks for the acks, and apologies for failing to cc the MdeModulePkg
> maintainers.
>
> Jian, Hao, do you have any opinion on this series?
>

Jian, Hao, Liming, Michael,

It is not always clear to me how you at Intel divide up the maintainer
duties between yourselves.

Liming and Jiewen have acked this entire series, but they are not the
MdeModulePkg maintainers, so I assume either Jian or Hao should
approve it as well before i can proceed with it.

If this is the case, could Jian and Hao please acknowledge that they
read this email, and perhaps indicate a timeframe within which they
will be able to give their verdict on these changes?

Thanks,
Ard.





>
>
> On Mon, 30 Mar 2020 at 15:42, Gao, Liming <liming.gao@intel.com> wrote:
> >
> > Ack-by: Liming Gao <liming.gao@intel.com>
> >
> > > -----Original Message-----
> > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yao, Jiewen
> > > Sent: Friday, March 27, 2020 1:01 PM
> > > To: Ard Biesheuvel <ard.biesheuvel@linaro.org>; devel@edk2.groups.io
> > > Cc: Laszlo Ersek <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ray
> > > <ray.ni@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> > > Subject: Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
> > >
> > > Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
> > >
> > > I cannot remember if there is windows OS still using the properties table.
> > > Maybe Microsoft people can comment.
> > >
> > > If no, I agree we can remove the old code.
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > > > Sent: Thursday, March 26, 2020 6:25 PM
> > > > To: devel@edk2.groups.io
> > > > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> > > > <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Kinney, Michael D
> > > > <michael.d.kinney@intel.com>; Ni, Ray <ray.ni@intel.com>; Yao, Jiewen
> > > > <jiewen.yao@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> > > > Subject: [PATCH 0/4] remove generation of EFI properties table
> > > >
> > > > The EFI properties table is broken by design, deprecated, and seems to be
> > > > causing confusion as it is unclear to some how it differs from the memory
> > > > attributes table (which supersedes it). So let's get rid of the code that
> > > > generates it entirely, along with the GUID definitions, PCDs etc.
> > > >
> > > > Due to how the two implementations are intertwined, patch #2 makes the
> > > > minimal changes required to stop producing the table (and to allow patch
> > > > #3 to remove the associated definitions from MdePkg). Patch #4 is optional
> > > > and merges the code together.
> > > >
> > > > Cc: Laszlo Ersek <lersek@redhat.com>
> > > > Cc: Leif Lindholm <leif@nuviainc.com>
> > > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > > Cc: Ray Ni <ray.ni@intel.com>
> > > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > > >
> > > > Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633
> > > >
> > > > Ard Biesheuvel (4):
> > > >   OvmfPkg: remove handling of properties table
> > > >   MdeModulePkg: disable properties table generation but retain the code
> > > >   MdePkg: remove PropertiesTable GUID
> > > >   MdeModulePkg/DxeCore: merge properties table routines into MAT
> > > >     handling
> > > >
> > > >  MdeModulePkg/Core/Dxe/DxeMain.h               |    9 -
> > > >  MdeModulePkg/Core/Dxe/DxeMain.inf             |    3 -
> > > >  MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c       |    1 -
> > > >  .../Core/Dxe/Misc/MemoryAttributesTable.c     | 1226 ++++++++++++++-
> > > >  MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c |    1 -
> > > >  MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c  | 1373 -----------------
> > > >  MdeModulePkg/MdeModulePkg.dec                 |   24 -
> > > >  MdeModulePkg/MdeModulePkg.uni                 |   21 -
> > > >  MdePkg/Include/Guid/PropertiesTable.h         |   31 -
> > > >  MdePkg/MdePkg.dec                             |    3 -
> > > >  OvmfPkg/OvmfPkgIa32.dsc                       |    1 -
> > > >  OvmfPkg/OvmfPkgIa32X64.dsc                    |    1 -
> > > >  OvmfPkg/OvmfPkgX64.dsc                        |    1 -
> > > >  OvmfPkg/OvmfXen.dsc                           |    1 -
> > > >  OvmfPkg/PlatformPei/Platform.c                |    1 -
> > > >  OvmfPkg/PlatformPei/PlatformPei.inf           |    1 -
> > > >  16 files changed, 1222 insertions(+), 1476 deletions(-)
> > > >  delete mode 100644 MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
> > > >  delete mode 100644 MdePkg/Include/Guid/PropertiesTable.h
> > > >
> > > > --
> > > > 2.17.1
> > >
> > >
> > > 
> >

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
  2020-03-26 10:24 [PATCH 0/4] remove generation of EFI properties table Ard Biesheuvel
                   ` (4 preceding siblings ...)
  2020-03-27  5:00 ` [PATCH 0/4] remove generation of EFI properties table Yao, Jiewen
@ 2020-04-03  2:22 ` Dandan Bi
  2020-04-06 11:42   ` Ard Biesheuvel
  5 siblings, 1 reply; 16+ messages in thread
From: Dandan Bi @ 2020-04-03  2:22 UTC (permalink / raw)
  To: devel@edk2.groups.io, ard.biesheuvel@linaro.org
  Cc: Laszlo Ersek, Leif Lindholm, Kinney, Michael D, Ni, Ray,
	Yao, Jiewen, Bret Barkelew

For the functionality, it is the same with before for platforms which set PcdPropertiesTableEnable to false by default.
Reviewed-by: Dandan Bi <dandan.bi@intel.com> for patch [PATCH 2/4] [PATCH 3/4] [PATCH 4/4].


If anyone still has the use case of enabling PcdPropertiesTableEnable, please comment.


Thanks,
Dandan
> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Ard Biesheuvel
> Sent: Thursday, March 26, 2020 6:25 PM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Kinney, Michael
> D <michael.d.kinney@intel.com>; Ni, Ray <ray.ni@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> Subject: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
> 
> The EFI properties table is broken by design, deprecated, and seems to be
> causing confusion as it is unclear to some how it differs from the memory
> attributes table (which supersedes it). So let's get rid of the code that
> generates it entirely, along with the GUID definitions, PCDs etc.
> 
> Due to how the two implementations are intertwined, patch #2 makes the
> minimal changes required to stop producing the table (and to allow patch
> #3 to remove the associated definitions from MdePkg). Patch #4 is optional
> and merges the code together.
> 
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> 
> Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2633
> 
> Ard Biesheuvel (4):
>   OvmfPkg: remove handling of properties table
>   MdeModulePkg: disable properties table generation but retain the code
>   MdePkg: remove PropertiesTable GUID
>   MdeModulePkg/DxeCore: merge properties table routines into MAT
>     handling
> 
>  MdeModulePkg/Core/Dxe/DxeMain.h               |    9 -
>  MdeModulePkg/Core/Dxe/DxeMain.inf             |    3 -
>  MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c       |    1 -
>  .../Core/Dxe/Misc/MemoryAttributesTable.c     | 1226 ++++++++++++++-
>  MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c |    1 -
>  MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c  | 1373 -----------------
>  MdeModulePkg/MdeModulePkg.dec                 |   24 -
>  MdeModulePkg/MdeModulePkg.uni                 |   21 -
>  MdePkg/Include/Guid/PropertiesTable.h         |   31 -
>  MdePkg/MdePkg.dec                             |    3 -
>  OvmfPkg/OvmfPkgIa32.dsc                       |    1 -
>  OvmfPkg/OvmfPkgIa32X64.dsc                    |    1 -
>  OvmfPkg/OvmfPkgX64.dsc                        |    1 -
>  OvmfPkg/OvmfXen.dsc                           |    1 -
>  OvmfPkg/PlatformPei/Platform.c                |    1 -
>  OvmfPkg/PlatformPei/PlatformPei.inf           |    1 -
>  16 files changed, 1222 insertions(+), 1476 deletions(-)  delete mode 100644
> MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
>  delete mode 100644 MdePkg/Include/Guid/PropertiesTable.h
> 
> --
> 2.17.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
  2020-04-03  2:22 ` Dandan Bi
@ 2020-04-06 11:42   ` Ard Biesheuvel
  2020-04-07  7:27     ` Wang, Jian J
  0 siblings, 1 reply; 16+ messages in thread
From: Ard Biesheuvel @ 2020-04-06 11:42 UTC (permalink / raw)
  To: Bi, Dandan, Jian J Wang, Wu, Hao A
  Cc: devel@edk2.groups.io, Laszlo Ersek, Leif Lindholm,
	Kinney, Michael D, Ni, Ray, Yao, Jiewen, Bret Barkelew

On Fri, 3 Apr 2020 at 04:22, Bi, Dandan <dandan.bi@intel.com> wrote:
>
> For the functionality, it is the same with before for platforms which set PcdPropertiesTableEnable to false by default.
> Reviewed-by: Dandan Bi <dandan.bi@intel.com> for patch [PATCH 2/4] [PATCH 3/4] [PATCH 4/4].
>
>
> If anyone still has the use case of enabling PcdPropertiesTableEnable, please comment.
>

Thank you Dandan.

Jian, Hao, do you have any comments on this series? If you are too
busy to have a closer look immediately, could you please indicate so
instead of not responding at all? Thanks.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
  2020-04-06 11:42   ` Ard Biesheuvel
@ 2020-04-07  7:27     ` Wang, Jian J
  2020-04-07  8:22       ` Ard Biesheuvel
  0 siblings, 1 reply; 16+ messages in thread
From: Wang, Jian J @ 2020-04-07  7:27 UTC (permalink / raw)
  To: Ard Biesheuvel, Bi, Dandan, Wu, Hao A
  Cc: devel@edk2.groups.io, Laszlo Ersek, Leif Lindholm,
	Kinney, Michael D, Ni, Ray, Yao, Jiewen, Bret Barkelew

Ard,

My apologies. I was indeed working desperately to catch some deadlines recently.
I agree to remove the properties table.

For the whole series, 

Reviewed-by: Jian J Wang <jian.j.wang@intel.com>

Regards,
Jian

> -----Original Message-----
> From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Sent: Monday, April 06, 2020 7:42 PM
> To: Bi, Dandan <dandan.bi@intel.com>; Wang, Jian J <jian.j.wang@intel.com>;
> Wu, Hao A <hao.a.wu@intel.com>
> Cc: devel@edk2.groups.io; Laszlo Ersek <lersek@redhat.com>; Leif Lindholm
> <leif@nuviainc.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ray
> <ray.ni@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>
> Subject: Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
> 
> On Fri, 3 Apr 2020 at 04:22, Bi, Dandan <dandan.bi@intel.com> wrote:
> >
> > For the functionality, it is the same with before for platforms which set
> PcdPropertiesTableEnable to false by default.
> > Reviewed-by: Dandan Bi <dandan.bi@intel.com> for patch [PATCH 2/4]
> [PATCH 3/4] [PATCH 4/4].
> >
> >
> > If anyone still has the use case of enabling PcdPropertiesTableEnable, please
> comment.
> >
> 
> Thank you Dandan.
> 
> Jian, Hao, do you have any comments on this series? If you are too
> busy to have a closer look immediately, could you please indicate so
> instead of not responding at all? Thanks.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [PATCH 0/4] remove generation of EFI properties table
  2020-04-07  7:27     ` Wang, Jian J
@ 2020-04-07  8:22       ` Ard Biesheuvel
  0 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2020-04-07  8:22 UTC (permalink / raw)
  To: devel, jian.j.wang, Ard Biesheuvel, Bi, Dandan, Wu, Hao A
  Cc: Laszlo Ersek, Leif Lindholm, Kinney, Michael D, Ni, Ray,
	Yao, Jiewen, Bret Barkelew

On 4/7/20 9:27 AM, Wang, Jian J via groups.io wrote:
> Ard,
> 
> My apologies. I was indeed working desperately to catch some deadlines recently.
> I agree to remove the properties table.
> 
> For the whole series,
> 
> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
> 

Thanks all.

Merged into edk2/master.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-04-07  8:22 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-26 10:24 [PATCH 0/4] remove generation of EFI properties table Ard Biesheuvel
2020-03-26 10:24 ` [PATCH 1/4] OvmfPkg: remove handling of " Ard Biesheuvel
2020-03-27 14:01   ` [edk2-devel] " Laszlo Ersek
2020-03-26 10:24 ` [PATCH 2/4] MdeModulePkg: disable properties table generation but retain the code Ard Biesheuvel
2020-03-26 10:24 ` [PATCH 3/4] MdePkg: remove PropertiesTable GUID Ard Biesheuvel
2020-03-27  1:02   ` [EXTERNAL] " Bret Barkelew
2020-03-27  9:16     ` Ard Biesheuvel
2020-03-26 10:24 ` [PATCH 4/4] MdeModulePkg/DxeCore: merge properties table routines into MAT handling Ard Biesheuvel
2020-03-27  5:00 ` [PATCH 0/4] remove generation of EFI properties table Yao, Jiewen
2020-03-30 13:42   ` [edk2-devel] " Liming Gao
2020-03-30 17:57     ` Ard Biesheuvel
2020-04-01 17:17       ` Ard Biesheuvel
2020-04-03  2:22 ` Dandan Bi
2020-04-06 11:42   ` Ard Biesheuvel
2020-04-07  7:27     ` Wang, Jian J
2020-04-07  8:22       ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox