diff options
author | Ard Biesheuvel <ard.biesheuvel@arm.com> | 2020-04-07 09:48:19 +0200 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2020-04-07 08:15:46 +0000 |
commit | d2c46681fa003eefb187878658e049ff92e85705 (patch) | |
tree | a549856dc6b10d3fbaf392a80c2e48337dc2efd9 /MdeModulePkg/Core | |
parent | af4ee6953c2fc7a506e8d2dc7b1156d5a5f7de6a (diff) | |
download | edk2-d2c46681fa003eefb187878658e049ff92e85705.tar.gz edk2-d2c46681fa003eefb187878658e049ff92e85705.tar.bz2 edk2-d2c46681fa003eefb187878658e049ff92e85705.zip |
MdeModulePkg: disable properties table generation but retain the code
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>
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r-- | MdeModulePkg/Core/Dxe/DxeMain.inf | 2 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c | 7 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 1 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 107 |
4 files changed, 14 insertions, 103 deletions
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf index 61161bee28..75e0a968f0 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -120,7 +120,6 @@ 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 @@ 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 ebdeb35079..4a2b4a82a6 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 ((DEBUG_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 47edf86dfb..92a442f517 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 53bb6b7c91..6ee8a8af90 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;
}
}
@@ -1019,35 +986,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.
@param RuntimeImage Runtime image information
@@ -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;
- }
}
/**
|