Discussion:
[edk2] [PATCH 0/5] MdeModulePkg: clean up Properties Table implementation and adapt it to AArch64
Ard Biesheuvel
2015-06-30 13:17:30 UTC
Permalink
This series applies some cleanups to the Properties Table feature implementation,
and updates it so that it may be used on AArch64 without violating the alignment
restrictions imposed by the architecture (i.e., runtime regions should be 64 KB
aligned)

Ard Biesheuvel (5):
MdeModulePkg: remove unused functions from
Core/Dxe/Misc/PropertiesTable.c
MdeModulePkg: make internal functions STATIC in
Core/Dxe/Misc/PropertiesTable.c
MdeModulePkg: rename PropertiesTableEnable to PcdPropertiesTableEnable
MdeModulePkg: move arch-specific allocation granularity defines to
DxeMain.h
MdeModulePkg: enforce arch-specific alignment for split regions

MdeModulePkg/Core/Dxe/DxeMain.h | 25 +++++
MdeModulePkg/Core/Dxe/DxeMain.inf | 2 +-
MdeModulePkg/Core/Dxe/Mem/Imem.h | 25 -----
MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 112 +++++---------------
MdeModulePkg/MdeModulePkg.dec | 2 +-
5 files changed, 53 insertions(+), 113 deletions(-)
--
1.9.1
Ard Biesheuvel
2015-06-30 13:17:31 UTC
Permalink
This removes the functions RevertRuntimeMemoryMap () and
DumpMemoryMap () which are not referenced anywhere in the code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <***@linaro.org>
---
MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 82 --------------------
1 file changed, 82 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
index 351599311281..24240113659d 100644
--- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
@@ -144,35 +144,6 @@ CoreReleasePropertiesTableLock (
}

/**
- Dump memory map.
-
- @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.
-**/
-VOID
-DumpMemoryMap (
- IN EFI_MEMORY_DESCRIPTOR *MemoryMap,
- IN UINTN MemoryMapSize,
- IN UINTN DescriptorSize
- )
-{
- EFI_MEMORY_DESCRIPTOR *MemoryMapEntry;
- EFI_MEMORY_DESCRIPTOR *MemoryMapEnd;
- UINT64 MemoryBlockLength;
-
- DEBUG ((EFI_D_VERBOSE, " MemoryMap:\n"));
- MemoryMapEntry = MemoryMap;
- MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + MemoryMapSize);
- while (MemoryMapEntry < MemoryMapEnd) {
- MemoryBlockLength = (UINT64) (EfiPagesToSize (MemoryMapEntry->NumberOfPages));
- DEBUG ((EFI_D_VERBOSE, " Entry(0x%02x) 0x%016lx - 0x%016lx (0x%016lx)\n", MemoryMapEntry->Type, MemoryMapEntry->PhysicalStart, MemoryMapEntry->PhysicalStart + MemoryBlockLength, MemoryMapEntry->Attribute));
- MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
- }
-}
-
-/**
Sort memory map entries based upon PhysicalStart, from low to high.

@param MemoryMap A pointer to the buffer in which firmware places
@@ -305,59 +276,6 @@ EnforceMemoryMapAttribute (
}

/**
- Sort memory map entries whose type is EfiRuntimeServicesCode/EfiRuntimeServicesData,
- from high to low.
- This function assumes memory map is already from low to high, so it just reverts them.
-
- @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.
-**/
-VOID
-RevertRuntimeMemoryMap (
- IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
- IN UINTN MemoryMapSize,
- IN UINTN DescriptorSize
- )
-{
- EFI_MEMORY_DESCRIPTOR *MemoryMapEntry;
- EFI_MEMORY_DESCRIPTOR *MemoryMapEnd;
- EFI_MEMORY_DESCRIPTOR TempMemoryMap;
-
- EFI_MEMORY_DESCRIPTOR *RuntimeMapEntryBegin;
- EFI_MEMORY_DESCRIPTOR *RuntimeMapEntryEnd;
-
- MemoryMapEntry = MemoryMap;
- RuntimeMapEntryBegin = NULL;
- RuntimeMapEntryEnd = NULL;
- MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) MemoryMap + MemoryMapSize);
- while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) {
- if ((MemoryMapEntry->Type == EfiRuntimeServicesCode) ||
- (MemoryMapEntry->Type == EfiRuntimeServicesData)) {
- if (RuntimeMapEntryBegin == NULL) {
- RuntimeMapEntryBegin = MemoryMapEntry;
- }
- RuntimeMapEntryEnd = MemoryMapEntry;
- }
- MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
- }
-
- MemoryMapEntry = RuntimeMapEntryBegin;
- MemoryMapEnd = RuntimeMapEntryEnd;
- while (MemoryMapEntry < MemoryMapEnd) {
- CopyMem (&TempMemoryMap, MemoryMapEntry, sizeof(EFI_MEMORY_DESCRIPTOR));
- CopyMem (MemoryMapEntry, MemoryMapEnd, sizeof(EFI_MEMORY_DESCRIPTOR));
- CopyMem (MemoryMapEnd, &TempMemoryMap, sizeof(EFI_MEMORY_DESCRIPTOR));
-
- MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize);
- MemoryMapEnd = PREVIOUS_MEMORY_DESCRIPTOR (MemoryMapEnd, DescriptorSize);
- }
-
- return ;
-}
-
-/**
Return the first image record, whose [ImageBase, ImageSize] covered by [Buffer, Length].

@param Buffer Start Address
--
1.9.1
Ard Biesheuvel
2015-06-30 13:17:33 UTC
Permalink
PCD names should start with 'Pcd' so rename PropertiesTableEnable
to PcdPropertiesTableEnable.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <***@linaro.org>
---
MdeModulePkg/Core/Dxe/DxeMain.inf | 2 +-
MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 2 +-
MdeModulePkg/MdeModulePkg.dec | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf
index 9afae4e8eeec..7ebf0d7abfe1 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -185,7 +185,7 @@ [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxEfiSystemTablePointerAddress ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PropertiesTableEnable ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable ## CONSUMES

# [Hob]
# RESOURCE_DESCRIPTOR ## CONSUMES
diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
index 9459c6bda337..0232a3ce7d93 100644
--- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
@@ -1311,7 +1311,7 @@ InstallPropertiesTable (
VOID *Context
)
{
- if (PcdGetBool (PropertiesTableEnable)) {
+ if (PcdGetBool (PcdPropertiesTableEnable)) {
EFI_STATUS Status;

Status = gBS->InstallConfigurationTable (&gEfiPropertiesTableGuid, &mPropertiesTable);
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 14e27a27702e..f4763bbe6c34 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1299,7 +1299,7 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
# section. If PE code/data sections are merged, the result is unpredictable.
#
# @Prompt Publish UEFI PropertiesTable.
- gEfiMdeModulePkgTokenSpaceGuid.PropertiesTableEnable|TRUE|BOOLEAN|0x0000006e
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|TRUE|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.
--
1.9.1
Yao, Jiewen
2015-06-30 13:52:51 UTC
Permalink
Looks good.

Reviewed by: Yao, Jiewen <***@intel.com>



-----Original Message-----
From: Ard Biesheuvel [mailto:***@linaro.org]
Sent: Tuesday, June 30, 2015 9:18 PM
To: edk2-***@lists.sourceforge.net; ***@redhat.com; Yao, Jiewen
Cc: Tian, Feng; Fleming, Matt; Ard Biesheuvel
Subject: [PATCH 3/5] MdeModulePkg: rename PropertiesTableEnable to PcdPropertiesTableEnable

PCD names should start with 'Pcd' so rename PropertiesTableEnable to PcdPropertiesTableEnable.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <***@linaro.org>
---
MdeModulePkg/Core/Dxe/DxeMain.inf | 2 +-
MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 2 +-
MdeModulePkg/MdeModulePkg.dec | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf
index 9afae4e8eeec..7ebf0d7abfe1 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -185,7 +185,7 @@ [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxEfiSystemTablePointerAddress ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PropertiesTableEnable ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable ## CONSUMES

# [Hob]
# RESOURCE_DESCRIPTOR ## CONSUMES
diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
index 9459c6bda337..0232a3ce7d93 100644
--- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
@@ -1311,7 +1311,7 @@ InstallPropertiesTable (
VOID *Context
)
{
- if (PcdGetBool (PropertiesTableEnable)) {
+ if (PcdGetBool (PcdPropertiesTableEnable)) {
EFI_STATUS Status;

Status = gBS->InstallConfigurationTable (&gEfiPropertiesTableGuid, &mPropertiesTable); diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 14e27a27702e..f4763bbe6c34 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1299,7 +1299,7 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
# section. If PE code/data sections are merged, the result is unpredictable.
#
# @Prompt Publish UEFI PropertiesTable.
- gEfiMdeModulePkgTokenSpaceGuid.PropertiesTableEnable|TRUE|BOOLEAN|0x0000006e
+
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|TRUE|BOOLEAN|0
+ x0000006e

## 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.
--
1.9.1
Ard Biesheuvel
2015-06-30 13:17:32 UTC
Permalink
Add STATIC to functions that are only used internally.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <***@linaro.org>
---
MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 21 ++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
index 24240113659d..9459c6bda337 100644
--- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
@@ -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
by Pages.
**/
+STATIC
UINT64
EfiPagesToSize (
IN UINT64 Pages
@@ -113,6 +114,7 @@ EfiPagesToSize (
by Size.

**/
+STATIC
UINT64
EfiSizeToPages (
IN UINT64 Size
@@ -124,6 +126,7 @@ EfiSizeToPages (
/**
Acquire memory lock on mPropertiesTableLock.
**/
+STATIC
VOID
CoreAcquirePropertiesTableLock (
VOID
@@ -135,6 +138,7 @@ CoreAcquirePropertiesTableLock (
/**
Release memory lock on mPropertiesTableLock.
**/
+STATIC
VOID
CoreReleasePropertiesTableLock (
VOID
@@ -151,6 +155,7 @@ CoreReleasePropertiesTableLock (
@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,
@@ -195,6 +200,7 @@ SortMemoryMap (
it is the size of new memory map after merge.
@param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
**/
+STATIC
VOID
MergeMemoryMap (
IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
@@ -242,6 +248,7 @@ MergeMemoryMap (
@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,
@@ -283,6 +290,7 @@ EnforceMemoryMapAttribute (

@return first image record covered by [buffer, length]
**/
+STATIC
IMAGE_PROPERTIES_RECORD *
GetImageRecordByAddress (
IN EFI_PHYSICAL_ADDRESS Buffer,
@@ -327,6 +335,7 @@ GetImageRecordByAddress (
@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,
@@ -422,6 +431,7 @@ SetNewRecord (
@retval 0 no entry need to be splitted.
@return the max number of new splitted entries
**/
+STATIC
UINTN
GetMaxSplitRecordCount (
IN EFI_MEMORY_DESCRIPTOR *OldRecord
@@ -467,6 +477,7 @@ GetMaxSplitRecordCount (
@retval 0 no entry is splitted.
@return the real number of splitted record.
**/
+STATIC
UINTN
SplitRecord (
IN EFI_MEMORY_DESCRIPTOR *OldRecord,
@@ -595,6 +606,7 @@ SplitRecord (
the current memory map.
@param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
**/
+STATIC
VOID
SplitTable (
IN OUT UINTN *MemoryMapSize,
@@ -705,6 +717,7 @@ SplitTable (
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.

**/
+STATIC
EFI_STATUS
EFIAPI
CoreGetMemoryMapPropertiesTable (
@@ -766,6 +779,7 @@ CoreGetMemoryMapPropertiesTable (

@param SectionAlignment PE/COFF section alignment
**/
+STATIC
VOID
SetPropertiesTableSectionAlignment (
IN UINT32 SectionAlignment
@@ -787,6 +801,7 @@ SetPropertiesTableSectionAlignment (
@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,
@@ -810,6 +825,7 @@ SwapImageRecordCodeSection (

@param ImageRecord image record to be sorted
**/
+STATIC
VOID
SortImageRecordCodeSection (
IN IMAGE_PROPERTIES_RECORD *ImageRecord
@@ -860,6 +876,7 @@ SortImageRecordCodeSection (
@retval TRUE image record is valid
@retval FALSE image record is invalid
**/
+STATIC
BOOLEAN
IsImageRecordCodeSectionValid (
IN IMAGE_PROPERTIES_RECORD *ImageRecord
@@ -916,6 +933,7 @@ IsImageRecordCodeSectionValid (
@param FirstImageRecord first image record.
@param SecondImageRecord second image record.
**/
+STATIC
VOID
SwapImageRecord (
IN IMAGE_PROPERTIES_RECORD *FirstImageRecord,
@@ -942,6 +960,7 @@ SwapImageRecord (
/**
Sort image record based upon the ImageBase from low to high.
**/
+STATIC
VOID
SortImageRecord (
VOID
@@ -987,6 +1006,7 @@ SortImageRecord (
/**
Dump image record.
**/
+STATIC
VOID
DumpImageRecord (
VOID
@@ -1205,6 +1225,7 @@ Finish:

@return image record
**/
+STATIC
IMAGE_PROPERTIES_RECORD *
FindImageRecord (
IN EFI_PHYSICAL_ADDRESS ImageBase,
--
1.9.1
Carsey, Jaben
2015-06-30 14:19:31 UTC
Permalink
Post by Yao, Jiewen
-----Original Message-----
Sent: Tuesday, June 30, 2015 6:18 AM
Cc: Fleming, Matt
Subject: [edk2] [PATCH 2/5] MdeModulePkg: make internal functions STATIC in Core/Dxe/Misc/PropertiesTable.c
Add STATIC to functions that are only used internally.
Contributed-under: TianoCore Contribution Agreement 1.0
---
MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 21 ++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
index 24240113659d..9459c6bda337 100644
--- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
@@ -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
by Pages.
**/
+STATIC
UINT64
EfiPagesToSize (
IN UINT64 Pages
@@ -113,6 +114,7 @@ EfiPagesToSize (
by Size.
**/
+STATIC
UINT64
EfiSizeToPages (
IN UINT64 Size
@@ -124,6 +126,7 @@ EfiSizeToPages (
/**
Acquire memory lock on mPropertiesTableLock.
**/
+STATIC
VOID
CoreAcquirePropertiesTableLock (
VOID
@@ -135,6 +138,7 @@ CoreAcquirePropertiesTableLock (
/**
Release memory lock on mPropertiesTableLock.
**/
+STATIC
VOID
CoreReleasePropertiesTableLock (
VOID
@@ -151,6 +155,7 @@ CoreReleasePropertiesTableLock (
@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,
@@ -195,6 +200,7 @@ SortMemoryMap (
it is the size of new memory map after merge.
@param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
**/
+STATIC
VOID
MergeMemoryMap (
IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
@@ -242,6 +248,7 @@ MergeMemoryMap (
@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,
@@ -283,6 +290,7 @@ EnforceMemoryMapAttribute (
@return first image record covered by [buffer, length]
**/
+STATIC
IMAGE_PROPERTIES_RECORD *
GetImageRecordByAddress (
IN EFI_PHYSICAL_ADDRESS Buffer,
@@ -327,6 +335,7 @@ GetImageRecordByAddress (
@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,
@@ -422,6 +431,7 @@ SetNewRecord (
@retval 0 no entry need to be splitted.
@return the max number of new splitted entries
**/
+STATIC
UINTN
GetMaxSplitRecordCount (
IN EFI_MEMORY_DESCRIPTOR *OldRecord
@@ -467,6 +477,7 @@ GetMaxSplitRecordCount (
@retval 0 no entry is splitted.
@return the real number of splitted record.
**/
+STATIC
UINTN
SplitRecord (
IN EFI_MEMORY_DESCRIPTOR *OldRecord,
@@ -595,6 +606,7 @@ SplitRecord (
the current memory map.
@param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
**/
+STATIC
VOID
SplitTable (
IN OUT UINTN *MemoryMapSize,
@@ -705,6 +717,7 @@ SplitTable (
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
**/
+STATIC
EFI_STATUS
EFIAPI
CoreGetMemoryMapPropertiesTable (
@@ -766,6 +779,7 @@ CoreGetMemoryMapPropertiesTable (
@param SectionAlignment PE/COFF section alignment
**/
+STATIC
VOID
SetPropertiesTableSectionAlignment (
IN UINT32 SectionAlignment
@@ -787,6 +801,7 @@ SetPropertiesTableSectionAlignment (
@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,
@@ -810,6 +825,7 @@ SwapImageRecordCodeSection (
@param ImageRecord image record to be sorted
**/
+STATIC
VOID
SortImageRecordCodeSection (
IN IMAGE_PROPERTIES_RECORD *ImageRecord
@@ -860,6 +876,7 @@ SortImageRecordCodeSection (
@retval TRUE image record is valid
@retval FALSE image record is invalid
**/
+STATIC
BOOLEAN
IsImageRecordCodeSectionValid (
IN IMAGE_PROPERTIES_RECORD *ImageRecord
@@ -916,6 +933,7 @@ IsImageRecordCodeSectionValid (
@param FirstImageRecord first image record.
@param SecondImageRecord second image record.
**/
+STATIC
VOID
SwapImageRecord (
IN IMAGE_PROPERTIES_RECORD *FirstImageRecord,
@@ -942,6 +960,7 @@ SwapImageRecord (
/**
Sort image record based upon the ImageBase from low to high.
**/
+STATIC
VOID
SortImageRecord (
VOID
@@ -987,6 +1006,7 @@ SortImageRecord (
/**
Dump image record.
**/
+STATIC
VOID
DumpImageRecord (
VOID
@return image record
**/
+STATIC
IMAGE_PROPERTIES_RECORD *
FindImageRecord (
IN EFI_PHYSICAL_ADDRESS ImageBase,
--
1.9.1
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Ard Biesheuvel
2015-06-30 13:17:34 UTC
Permalink
Move the definitions of EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT and
DEFAULT_PAGE_ALLOCATION to DxeMain.h to make them available explicitly
to all parts of DxeCore.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <***@linaro.org>
---
MdeModulePkg/Core/Dxe/DxeMain.h | 25 ++++++++++++++++++++
MdeModulePkg/Core/Dxe/Mem/Imem.h | 25 --------------------
2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index 31277ca3629f..06b865c8fb1d 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -124,6 +124,31 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
///
#define DEPEX_STACK_SIZE_INCREMENT 0x1000

+#if defined (MDE_CPU_IPF)
+///
+/// For Itanium machines make the default allocations 8K aligned
+///
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)
+#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)
+
+#elif defined (MDE_CPU_AARCH64)
+///
+/// 64-bit ARM systems allow the OS to execute with 64 KB page size,
+/// so for improved interoperability with the firmware, align the
+/// runtime regions to 64 KB as well
+///
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (SIZE_64KB)
+#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
+
+#else
+///
+/// For genric EFI machines make the default allocations 4K aligned
+///
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
+#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
+
+#endif
+
typedef struct {
EFI_GUID *ProtocolGuid;
VOID **Protocol;
diff --git a/MdeModulePkg/Core/Dxe/Mem/Imem.h b/MdeModulePkg/Core/Dxe/Mem/Imem.h
index 7f906832182d..a76ae2fe67ac 100644
--- a/MdeModulePkg/Core/Dxe/Mem/Imem.h
+++ b/MdeModulePkg/Core/Dxe/Mem/Imem.h
@@ -15,31 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef _IMEM_H_
#define _IMEM_H_

-#if defined (MDE_CPU_IPF)
-///
-/// For Itanium machines make the default allocations 8K aligned
-///
-#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)
-#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)
-
-#elif defined (MDE_CPU_AARCH64)
-///
-/// 64-bit ARM systems allow the OS to execute with 64 KB page size,
-/// so for improved interoperability with the firmware, align the
-/// runtime regions to 64 KB as well
-///
-#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (SIZE_64KB)
-#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
-
-#else
-///
-/// For genric EFI machines make the default allocations 4K aligned
-///
-#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
-#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
-
-#endif
-
//
// +---------------------------------------------------+
// | 0..(EfiMaxMemoryType - 1) - Normal memory type |
--
1.9.1
Ard Biesheuvel
2015-06-30 13:17:35 UTC
Permalink
The splitting of memory regions into code and data regions violates
architecture specific alignment rules by using a fixed alignment
of 4 KB. Replace it with EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT,
which is defined appropriately on each architecture.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <***@linaro.org>
---
MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
index 0232a3ce7d93..01ecca64ab0a 100644
--- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
@@ -785,7 +785,7 @@ SetPropertiesTableSectionAlignment (
IN UINT32 SectionAlignment
)
{
- if (((SectionAlignment & (SIZE_4KB - 1)) != 0) &&
+ if (((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) &&
((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) != 0)) {
DEBUG ((EFI_D_VERBOSE, "SetPropertiesTableSectionAlignment - Clear\n"));
mPropertiesTable.MemoryProtectionAttribute &= ~EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA;
@@ -1119,8 +1119,9 @@ InsertImageRecord (
}

SetPropertiesTableSectionAlignment (SectionAlignment);
- if ((SectionAlignment & (SIZE_4KB - 1)) != 0) {
- DEBUG ((EFI_D_ERROR, "!!!!!!!! InsertImageRecord - Section Alignment(0x%x) is not 4K !!!!!!!!\n", SectionAlignment));
+ if ((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) {
+ DEBUG ((EFI_D_ERROR, "!!!!!!!! InsertImageRecord - Section Alignment(0x%x) is not %dK !!!!!!!!\n",
+ SectionAlignment, EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10));
PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);
if (PdbPointer != NULL) {
DEBUG ((EFI_D_ERROR, "!!!!!!!! Image - %a !!!!!!!!\n", PdbPointer));
--
1.9.1
Carsey, Jaben
2015-06-30 14:37:49 UTC
Permalink
Post by Yao, Jiewen
-----Original Message-----
Sent: Tuesday, June 30, 2015 6:18 AM
Cc: Fleming, Matt
Subject: [edk2] [PATCH 5/5] MdeModulePkg: enforce arch-specific alignment for split regions
The splitting of memory regions into code and data regions violates
architecture specific alignment rules by using a fixed alignment
of 4 KB. Replace it with EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT,
which is defined appropriately on each architecture.
Contributed-under: TianoCore Contribution Agreement 1.0
---
MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
index 0232a3ce7d93..01ecca64ab0a 100644
--- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
+++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
@@ -785,7 +785,7 @@ SetPropertiesTableSectionAlignment (
IN UINT32 SectionAlignment
)
{
- if (((SectionAlignment & (SIZE_4KB - 1)) != 0) &&
+ if (((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) &&
((mPropertiesTable.MemoryProtectionAttribute &
EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) != 0)) {
DEBUG ((EFI_D_VERBOSE, "SetPropertiesTableSectionAlignment - Clear\n"));
mPropertiesTable.MemoryProtectionAttribute &=
~EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA;
@@ -1119,8 +1119,9 @@ InsertImageRecord (
}
SetPropertiesTableSectionAlignment (SectionAlignment);
- if ((SectionAlignment & (SIZE_4KB - 1)) != 0) {
- DEBUG ((EFI_D_ERROR, "!!!!!!!! InsertImageRecord - Section Alignment(0x%x) is not 4K !!!!!!!!\n", SectionAlignment));
+ if ((SectionAlignment & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) {
+ DEBUG ((EFI_D_ERROR, "!!!!!!!! InsertImageRecord - Section Alignment(0x%x) is not %dK !!!!!!!!\n",
+ SectionAlignment, EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10));
PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageAddress);
if (PdbPointer != NULL) {
DEBUG ((EFI_D_ERROR, "!!!!!!!! Image - %a !!!!!!!!\n", PdbPointer));
--
1.9.1
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Loading...