]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: disable properties table generation but retain the code
authorArd Biesheuvel <ard.biesheuvel@arm.com>
Tue, 7 Apr 2020 07:48:19 +0000 (09:48 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 7 Apr 2020 08:15:46 +0000 (08:15 +0000)
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@arm.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Acked-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
MdeModulePkg/Core/Dxe/DxeMain.inf
MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/MdeModulePkg.uni

index 61161bee28e14dff335aa6162ef331d00a5605bb..75e0a968f0cfcfa30d55e1dd279aad8cd7f24910 100644 (file)
   gEventExitBootServicesFailedGuid              ## SOMETIMES_PRODUCES   ## Event\r
   gEfiVectorHandoffTableGuid                    ## SOMETIMES_PRODUCES   ## SystemTable\r
   gEdkiiMemoryProfileGuid                       ## SOMETIMES_PRODUCES   ## GUID # Install protocol\r
-  gEfiPropertiesTableGuid                       ## SOMETIMES_PRODUCES   ## SystemTable\r
   gEfiMemoryAttributesTableGuid                 ## SOMETIMES_PRODUCES   ## SystemTable\r
   gEfiEndOfDxeEventGroupGuid                    ## SOMETIMES_CONSUMES   ## Event\r
   gEfiHobMemoryAllocStackGuid                   ## SOMETIMES_CONSUMES   ## SystemTable\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType                 ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask               ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath                 ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable                   ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy                   ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy             ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask        ## CONSUMES\r
index ebdeb35079a2b5ec9688196a53c7cbfc08178e15..4a2b4a82a6e2d9e4b9506adc61e94d54ee8fc46f 100644 (file)
@@ -18,7 +18,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Guid/EventGroup.h>\r
 \r
 #include <Guid/MemoryAttributesTable.h>\r
-#include <Guid/PropertiesTable.h>\r
 \r
 #include "DxeMain.h"\r
 \r
@@ -64,7 +63,7 @@ CoreGetMemoryMapWithSeparatedImageSection (
   OUT UINT32                    *DescriptorVersion\r
   );\r
 \r
-extern EFI_PROPERTIES_TABLE  mPropertiesTable;\r
+BOOLEAN                      mMemoryAttributesTableEnable = TRUE;\r
 EFI_MEMORY_ATTRIBUTES_TABLE  *mMemoryAttributesTable = NULL;\r
 BOOLEAN                      mMemoryAttributesTableReadyToBoot = FALSE;\r
 \r
@@ -96,8 +95,8 @@ InstallMemoryAttributesTable (
     return;\r
   }\r
 \r
-  if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {\r
-    DEBUG ((EFI_D_VERBOSE, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DATA is not set, "));\r
+  if (!mMemoryAttributesTableEnable) {\r
+    DEBUG ((DEBUG_VERBOSE, "Cannot install Memory Attributes Table "));\r
     DEBUG ((EFI_D_VERBOSE, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));\r
     return ;\r
   }\r
index 47edf86dfbf300e602993fa42fcb0ecf48b7b6e2..92a442f517b23ff006811f152232b5b60b17e727 100644 (file)
@@ -35,7 +35,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 \r
 #include <Guid/EventGroup.h>\r
 #include <Guid/MemoryAttributesTable.h>\r
-#include <Guid/PropertiesTable.h>\r
 \r
 #include <Protocol/FirmwareVolume2.h>\r
 #include <Protocol/SimpleFileSystem.h>\r
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
index 73ff1774345a9346732c25b1be70e6519ce7eb3e..497574cb087022cdcc8b865c3d352e4da6d3ea5f 100644 (file)
   # @Prompt Flag to request system reboot after processing capsule.\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSystemRebootAfterCapsuleProcessFlag|0x0001|UINT16|0x0000006d\r
 \r
-  ## Publish PropertiesTable or not.\r
-  #\r
-  # If this PCD is TRUE, DxeCore publishs PropertiesTable.\r
-  # DxeCore evaluates if all runtime drivers has 4K aligned PE sections. If all\r
-  # PE sections in runtime drivers are 4K aligned, DxeCore sets BIT0 in\r
-  # PropertiesTable. Or DxeCore clears BIT0 in PropertiesTable.\r
-  # If this PCD is FALSE, DxeCore does not publish PropertiesTable.\r
-  #\r
-  # If PropertiesTable has BIT0 set, DxeCore uses below policy in UEFI memory map:\r
-  #   1) Use EfiRuntimeServicesCode for runtime driver PE image code section and\r
-  #      use EfiRuntimeServicesData for runtime driver PE image header and other section.\r
-  #   2) Set EfiRuntimeServicesCode to be EFI_MEMORY_RO.\r
-  #   3) Set EfiRuntimeServicesData to be EFI_MEMORY_XP.\r
-  #   4) Set EfiMemoryMappedIO and EfiMemoryMappedIOPortSpace to be EFI_MEMORY_XP.\r
-  #\r
-  # NOTE: Platform need gurantee this PCD is set correctly. Platform should set\r
-  # this PCD to be TURE if and only if all runtime driver has seperated Code/Data\r
-  # section. If PE code/data sections are merged, the result is unpredictable.\r
-  #\r
-  # UEFI 2.6 specification does not recommend to use this BIT0 attribute.\r
-  #\r
-  # @Prompt Publish UEFI PropertiesTable.\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE|BOOLEAN|0x0000006e\r
-\r
   ## Default OEM ID for ACPI table creation, its length must be 0x6 bytes to follow ACPI specification.\r
   # @Prompt Default OEM ID for ACPI table creation.\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId|"INTEL "|VOID*|0x30001034\r
index 2c856ed07333129fb7c2f858df8a756add633be2..2007e0596c4fdffdbec87377cf5dfaebd0eda88e 100644 (file)
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdFrontPageFormSetGuid_HELP  #language en-US "This PCD points to the front page formset GUID\n"\r
                                                                                          "Compare the FormsetGuid or ClassGuid with this PCD value can detect whether in front page"\r
 \r
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPropertiesTableEnable_PROMPT  #language en-US "Publish UEFI PropertiesTable."\r
-\r
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPropertiesTableEnable_HELP  #language en-US "Publish PropertiesTable or not.\n"\r
-                                                                                          "\n"\r
-                                                                                          "If this PCD is TRUE, DxeCore publishs PropertiesTable.\n"\r
-                                                                                          "DxeCore evaluates if all runtime drivers has 4K aligned PE sections. If all\n"\r
-                                                                                          "PE sections in runtime drivers are 4K aligned, DxeCore sets BIT0 in\n"\r
-                                                                                          "PropertiesTable. Or DxeCore clears BIT0 in PropertiesTable.\n"\r
-                                                                                          "If this PCD is FALSE, DxeCore does not publish PropertiesTable.\n"\r
-                                                                                          "\n"\r
-                                                                                          "If PropertiesTable has BIT0 set, DxeCore uses below policy in UEFI memory map:\n"\r
-                                                                                          "1) Use EfiRuntimeServicesCode for runtime driver PE image code section and\n"\r
-                                                                                          "use EfiRuntimeServicesData for runtime driver PE image header and other section.\n"\r
-                                                                                          "2) Set EfiRuntimeServicesCode to be EFI_MEMORY_RO.\n"\r
-                                                                                          "3) Set EfiRuntimeServicesData to be EFI_MEMORY_XP.\n"\r
-                                                                                          "4) Set EfiMemoryMappedIO and EfiMemoryMappedIOPortSpace to be EFI_MEMORY_XP.\n"\r
-                                                                                          "\n"\r
-                                                                                          "NOTE: Platform need gurantee this PCD is set correctly. Platform should set\n"\r
-                                                                                          "this PCD to be TURE if and only if all runtime driver has seperated Code/Data\n"\r
-                                                                                          "section. If PE code/data sections are merged, the result is unpredictable.\n"\r
-\r
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdShadowPeimOnBoot_HELP  #language en-US "Indicates if to shadow PEIM and PeiCore after memory is ready.<BR><BR>\n"\r
                                                                                      "This PCD is used on other boot path except for S3 boot.\n"\r
                                                                                      "TRUE  - Shadow PEIM and PeiCore after memory is ready.<BR>\n"\r