]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
MdeModulePkg: disable properties table generation but retain the code
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Misc / PropertiesTable.c
index 53bb6b7c912c1a3828d0526265ecce43356ca672..6ee8a8af9098e6e8416a8360729678ba2fff7d6f 100644 (file)
@@ -23,8 +23,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/PeCoffGetEntryPointLib.h>\r
 #include <Protocol/Runtime.h>\r
 \r
-#include <Guid/PropertiesTable.h>\r
-\r
 #include "DxeMain.h"\r
 #include "HeapGuard.h"\r
 \r
@@ -47,18 +45,12 @@ IMAGE_PROPERTIES_PRIVATE_DATA  mImagePropertiesPrivateData = {
   INITIALIZE_LIST_HEAD_VARIABLE (mImagePropertiesPrivateData.ImageRecordList)\r
 };\r
 \r
-EFI_PROPERTIES_TABLE  mPropertiesTable = {\r
-  EFI_PROPERTIES_TABLE_VERSION,\r
-  sizeof(EFI_PROPERTIES_TABLE),\r
-  EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA\r
-};\r
-\r
 EFI_LOCK           mPropertiesTableLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);\r
 \r
-BOOLEAN            mPropertiesTableEnable;\r
-\r
 BOOLEAN            mPropertiesTableEndOfDxe = FALSE;\r
 \r
+extern BOOLEAN     mMemoryAttributesTableEnable;\r
+\r
 //\r
 // Below functions are for MemoryMap\r
 //\r
@@ -359,11 +351,7 @@ SetNewRecord (
       //\r
       // DATA\r
       //\r
-      if (!mPropertiesTableEnable) {\r
-        NewRecord->Type = TempRecord.Type;\r
-      } else {\r
-        NewRecord->Type = EfiRuntimeServicesData;\r
-      }\r
+      NewRecord->Type          = TempRecord.Type;\r
       NewRecord->PhysicalStart = TempRecord.PhysicalStart;\r
       NewRecord->VirtualStart  = 0;\r
       NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentBase - NewRecord->PhysicalStart);\r
@@ -376,11 +364,7 @@ SetNewRecord (
       //\r
       // CODE\r
       //\r
-      if (!mPropertiesTableEnable) {\r
-        NewRecord->Type = TempRecord.Type;\r
-      } else {\r
-        NewRecord->Type = EfiRuntimeServicesCode;\r
-      }\r
+      NewRecord->Type          = TempRecord.Type;\r
       NewRecord->PhysicalStart = ImageRecordCodeSection->CodeSegmentBase;\r
       NewRecord->VirtualStart  = 0;\r
       NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentSize);\r
@@ -404,11 +388,7 @@ SetNewRecord (
   // Final DATA\r
   //\r
   if (TempRecord.PhysicalStart < ImageEnd) {\r
-    if (!mPropertiesTableEnable) {\r
-      NewRecord->Type = TempRecord.Type;\r
-    } else {\r
-      NewRecord->Type = EfiRuntimeServicesData;\r
-    }\r
+    NewRecord->Type          = TempRecord.Type;\r
     NewRecord->PhysicalStart = TempRecord.PhysicalStart;\r
     NewRecord->VirtualStart  = 0;\r
     NewRecord->NumberOfPages = EfiSizeToPages (ImageEnd - TempRecord.PhysicalStart);\r
@@ -519,14 +499,8 @@ SplitRecord (
         //\r
         NewRecord = PREVIOUS_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);\r
         IsLastRecordData = FALSE;\r
-        if (!mPropertiesTableEnable) {\r
-          if ((NewRecord->Attribute & EFI_MEMORY_XP) != 0) {\r
-            IsLastRecordData = TRUE;\r
-          }\r
-        } else {\r
-          if (NewRecord->Type == EfiRuntimeServicesData) {\r
-            IsLastRecordData = TRUE;\r
-          }\r
+        if ((NewRecord->Attribute & EFI_MEMORY_XP) != 0) {\r
+          IsLastRecordData = TRUE;\r
         }\r
         if (IsLastRecordData) {\r
           //\r
@@ -538,11 +512,7 @@ SplitRecord (
           // Last record is CODE, create a new DATA entry.\r
           //\r
           NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize);\r
-          if (!mPropertiesTableEnable) {\r
-            NewRecord->Type = TempRecord.Type;\r
-          } else {\r
-            NewRecord->Type = EfiRuntimeServicesData;\r
-          }\r
+          NewRecord->Type          = TempRecord.Type;\r
           NewRecord->PhysicalStart = TempRecord.PhysicalStart;\r
           NewRecord->VirtualStart  = 0;\r
           NewRecord->NumberOfPages = TempRecord.NumberOfPages;\r
@@ -751,7 +721,7 @@ CoreGetMemoryMapWithSeparatedImageSection (
   //\r
   // If PE code/data is not aligned, just return.\r
   //\r
-  if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {\r
+  if (!mMemoryAttributesTableEnable) {\r
     return CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey, DescriptorSize, DescriptorVersion);\r
   }\r
 \r
@@ -803,12 +773,9 @@ SetPropertiesTableSectionAlignment (
   )\r
 {\r
   if (((SectionAlignment & (RUNTIME_PAGE_ALLOCATION_GRANULARITY - 1)) != 0) &&\r
-      ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) != 0)) {\r
+      mMemoryAttributesTableEnable) {\r
     DEBUG ((EFI_D_VERBOSE, "SetPropertiesTableSectionAlignment - Clear\n"));\r
-    mPropertiesTable.MemoryProtectionAttribute &= ~((UINT64)EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA);\r
-    gBS->GetMemoryMap = CoreGetMemoryMap;\r
-    gBS->Hdr.CRC32 = 0;\r
-    gBS->CalculateCrc32 ((UINT8 *)gBS, gBS->Hdr.HeaderSize, &gBS->Hdr.CRC32);\r
+    mMemoryAttributesTableEnable = FALSE;\r
   }\r
 }\r
 \r
@@ -1018,35 +985,6 @@ SortImageRecord (
   }\r
 }\r
 \r
-/**\r
-  Dump image record.\r
-**/\r
-STATIC\r
-VOID\r
-DumpImageRecord (\r
-  VOID\r
-  )\r
-{\r
-  IMAGE_PROPERTIES_RECORD      *ImageRecord;\r
-  LIST_ENTRY                   *ImageRecordLink;\r
-  LIST_ENTRY                   *ImageRecordList;\r
-  UINTN                        Index;\r
-\r
-  ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;\r
-\r
-  for (ImageRecordLink = ImageRecordList->ForwardLink, Index= 0;\r
-       ImageRecordLink != ImageRecordList;\r
-       ImageRecordLink = ImageRecordLink->ForwardLink, Index++) {\r
-    ImageRecord = CR (\r
-                    ImageRecordLink,\r
-                    IMAGE_PROPERTIES_RECORD,\r
-                    Link,\r
-                    IMAGE_PROPERTIES_RECORD_SIGNATURE\r
-                    );\r
-    DEBUG ((EFI_D_VERBOSE, "  Image[%d]: 0x%016lx - 0x%016lx\n", Index, ImageRecord->ImageBase, ImageRecord->ImageSize));\r
-  }\r
-}\r
-\r
 /**\r
   Insert image record.\r
 \r
@@ -1323,29 +1261,6 @@ InstallPropertiesTable (
   )\r
 {\r
   mPropertiesTableEndOfDxe = TRUE;\r
-  if (PcdGetBool (PcdPropertiesTableEnable)) {\r
-    EFI_STATUS  Status;\r
-\r
-    Status = gBS->InstallConfigurationTable (&gEfiPropertiesTableGuid, &mPropertiesTable);\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    DEBUG ((EFI_D_INFO, "MemoryProtectionAttribute - 0x%016lx\n", mPropertiesTable.MemoryProtectionAttribute));\r
-    if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {\r
-      DEBUG ((EFI_D_ERROR, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DATA is not set, "));\r
-      DEBUG ((EFI_D_ERROR, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));\r
-      return ;\r
-    }\r
-\r
-    gBS->GetMemoryMap = CoreGetMemoryMapWithSeparatedImageSection;\r
-    gBS->Hdr.CRC32 = 0;\r
-    gBS->CalculateCrc32 ((UINT8 *)gBS, gBS->Hdr.HeaderSize, &gBS->Hdr.CRC32);\r
-\r
-    DEBUG ((EFI_D_VERBOSE, "Total Image Count - 0x%x\n", mImagePropertiesPrivateData.ImageRecordCount));\r
-    DEBUG ((EFI_D_VERBOSE, "Dump ImageRecord:\n"));\r
-    DumpImageRecord ();\r
-\r
-    mPropertiesTableEnable = TRUE;\r
-  }\r
 }\r
 \r
 /**\r