]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
MdeModulePkg: enforce arch-specific alignment for split regions
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Misc / PropertiesTable.c
index 24240113659dd1bf03aae02612d6ba97ff6a31e9..01ecca64ab0a4a698fa919882c19d482d96b820a 100644 (file)
@@ -94,6 +94,7 @@ EFI_LOCK           mPropertiesTableLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTI
   @return  The number of bytes associated with the number of EFI_PAGEs specified\r
            by Pages.\r
 **/\r
+STATIC\r
 UINT64\r
 EfiPagesToSize (\r
   IN UINT64 Pages\r
@@ -113,6 +114,7 @@ EfiPagesToSize (
            by Size.\r
 \r
 **/\r
+STATIC\r
 UINT64\r
 EfiSizeToPages (\r
   IN UINT64 Size\r
@@ -124,6 +126,7 @@ EfiSizeToPages (
 /**\r
   Acquire memory lock on mPropertiesTableLock.\r
 **/\r
+STATIC\r
 VOID\r
 CoreAcquirePropertiesTableLock (\r
   VOID\r
@@ -135,6 +138,7 @@ CoreAcquirePropertiesTableLock (
 /**\r
   Release memory lock on mPropertiesTableLock.\r
 **/\r
+STATIC\r
 VOID\r
 CoreReleasePropertiesTableLock (\r
   VOID\r
@@ -151,6 +155,7 @@ CoreReleasePropertiesTableLock (
   @param  MemoryMapSize          Size, in bytes, of the MemoryMap buffer.\r
   @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.\r
 **/\r
+STATIC\r
 VOID\r
 SortMemoryMap (\r
   IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,\r
@@ -195,6 +200,7 @@ SortMemoryMap (
                                  it is the size of new memory map after merge.\r
   @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.\r
 **/\r
+STATIC\r
 VOID\r
 MergeMemoryMap (\r
   IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,\r
@@ -242,6 +248,7 @@ MergeMemoryMap (
   @param  MemoryMapSize          Size, in bytes, of the MemoryMap buffer.\r
   @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.\r
 **/\r
+STATIC\r
 VOID\r
 EnforceMemoryMapAttribute (\r
   IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,\r
@@ -283,6 +290,7 @@ EnforceMemoryMapAttribute (
 \r
   @return first image record covered by [buffer, length]\r
 **/\r
+STATIC\r
 IMAGE_PROPERTIES_RECORD *\r
 GetImageRecordByAddress (\r
   IN EFI_PHYSICAL_ADDRESS  Buffer,\r
@@ -327,6 +335,7 @@ GetImageRecordByAddress (
   @param  OldRecord              A pointer to one old memory map entry.\r
   @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.\r
 **/\r
+STATIC\r
 UINTN\r
 SetNewRecord (\r
   IN IMAGE_PROPERTIES_RECORD       *ImageRecord,\r
@@ -422,6 +431,7 @@ SetNewRecord (
   @retval  0 no entry need to be splitted.\r
   @return  the max number of new splitted entries\r
 **/\r
+STATIC\r
 UINTN\r
 GetMaxSplitRecordCount (\r
   IN EFI_MEMORY_DESCRIPTOR *OldRecord\r
@@ -467,6 +477,7 @@ GetMaxSplitRecordCount (
   @retval  0 no entry is splitted.\r
   @return  the real number of splitted record.\r
 **/\r
+STATIC\r
 UINTN\r
 SplitRecord (\r
   IN EFI_MEMORY_DESCRIPTOR     *OldRecord,\r
@@ -595,6 +606,7 @@ SplitRecord (
                                  the current memory map.\r
   @param  DescriptorSize         Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.\r
 **/\r
+STATIC\r
 VOID\r
 SplitTable (\r
   IN OUT UINTN                  *MemoryMapSize,\r
@@ -705,6 +717,7 @@ SplitTable (
   @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value.\r
 \r
 **/\r
+STATIC\r
 EFI_STATUS\r
 EFIAPI\r
 CoreGetMemoryMapPropertiesTable (\r
@@ -766,12 +779,13 @@ CoreGetMemoryMapPropertiesTable (
 \r
   @param  SectionAlignment    PE/COFF section alignment\r
 **/\r
+STATIC\r
 VOID\r
 SetPropertiesTableSectionAlignment (\r
   IN UINT32  SectionAlignment\r
   )\r
 {\r
-  if (((SectionAlignment & (SIZE_4KB - 1)) != 0) &&\r
+  if (((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) &&\r
       ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) != 0)) {\r
     DEBUG ((EFI_D_VERBOSE, "SetPropertiesTableSectionAlignment - Clear\n"));\r
     mPropertiesTable.MemoryProtectionAttribute &= ~EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA;\r
@@ -787,6 +801,7 @@ SetPropertiesTableSectionAlignment (
   @param  FirstImageRecordCodeSection    first code section in image record\r
   @param  SecondImageRecordCodeSection   second code section in image record\r
 **/\r
+STATIC\r
 VOID\r
 SwapImageRecordCodeSection (\r
   IN IMAGE_PROPERTIES_RECORD_CODE_SECTION      *FirstImageRecordCodeSection,\r
@@ -810,6 +825,7 @@ SwapImageRecordCodeSection (
 \r
   @param  ImageRecord    image record to be sorted\r
 **/\r
+STATIC\r
 VOID\r
 SortImageRecordCodeSection (\r
   IN IMAGE_PROPERTIES_RECORD              *ImageRecord\r
@@ -860,6 +876,7 @@ SortImageRecordCodeSection (
   @retval TRUE  image record is valid\r
   @retval FALSE image record is invalid\r
 **/\r
+STATIC\r
 BOOLEAN\r
 IsImageRecordCodeSectionValid (\r
   IN IMAGE_PROPERTIES_RECORD              *ImageRecord\r
@@ -916,6 +933,7 @@ IsImageRecordCodeSectionValid (
   @param  FirstImageRecord   first image record.\r
   @param  SecondImageRecord  second image record.\r
 **/\r
+STATIC\r
 VOID\r
 SwapImageRecord (\r
   IN IMAGE_PROPERTIES_RECORD      *FirstImageRecord,\r
@@ -942,6 +960,7 @@ SwapImageRecord (
 /**\r
   Sort image record based upon the ImageBase from low to high.\r
 **/\r
+STATIC\r
 VOID\r
 SortImageRecord (\r
   VOID\r
@@ -987,6 +1006,7 @@ SortImageRecord (
 /**\r
   Dump image record.\r
 **/\r
+STATIC\r
 VOID\r
 DumpImageRecord (\r
   VOID\r
@@ -1099,8 +1119,9 @@ InsertImageRecord (
   }\r
 \r
   SetPropertiesTableSectionAlignment (SectionAlignment);\r
-  if ((SectionAlignment & (SIZE_4KB - 1)) != 0) {\r
-    DEBUG ((EFI_D_ERROR, "!!!!!!!!  InsertImageRecord - Section Alignment(0x%x) is not 4K  !!!!!!!!\n", SectionAlignment));\r
+  if ((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) {\r
+    DEBUG ((EFI_D_ERROR, "!!!!!!!!  InsertImageRecord - Section Alignment(0x%x) is not %dK  !!!!!!!!\n",\r
+      SectionAlignment, EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10));\r
     PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);\r
     if (PdbPointer != NULL) {\r
       DEBUG ((EFI_D_ERROR, "!!!!!!!!  Image - %a  !!!!!!!!\n", PdbPointer));\r
@@ -1205,6 +1226,7 @@ Finish:
 \r
   @return image record\r
 **/\r
+STATIC\r
 IMAGE_PROPERTIES_RECORD *\r
 FindImageRecord (\r
   IN EFI_PHYSICAL_ADDRESS  ImageBase,\r
@@ -1290,7 +1312,7 @@ InstallPropertiesTable (
   VOID                                    *Context\r
   )\r
 {\r
-  if (PcdGetBool (PropertiesTableEnable)) {\r
+  if (PcdGetBool (PcdPropertiesTableEnable)) {\r
     EFI_STATUS  Status;\r
 \r
     Status = gBS->InstallConfigurationTable (&gEfiPropertiesTableGuid, &mPropertiesTable);\r