From d12a2ecb2abff46611fc39480c06e6311c0e542e Mon Sep 17 00:00:00 2001 From: vanjeff Date: Thu, 18 Aug 2011 02:05:46 +0000 Subject: Updated GCD implementation to consume the correct EFI Resources Attributes(Capabilities) instead of the wrong EFI Resources Attributes(Settings). ASSERT() if memory resource HOB includes protect memory setting but not included the corresponding protect memory capabilities Signed-off-by: vanjeff Reviewed-by: rsun3 Reviewed-by: mdkinney git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12158 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c index 05f711d..5292d36 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -86,9 +86,9 @@ GCD_ATTRIBUTE_CONVERSION_ENTRY mAttributeConversionTable[] = { { EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE, EFI_MEMORY_WC, TRUE }, { EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE, EFI_MEMORY_WT, TRUE }, { EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE, EFI_MEMORY_WB, TRUE }, - { EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED, EFI_MEMORY_RP, TRUE }, - { EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED, EFI_MEMORY_WP, TRUE }, - { EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED, EFI_MEMORY_XP, TRUE }, + { EFI_RESOURCE_ATTRIBUTE_READ_PROTECTABLE, EFI_MEMORY_RP, TRUE }, + { EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTABLE, EFI_MEMORY_WP, TRUE }, + { EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTABLE, EFI_MEMORY_XP, TRUE }, { EFI_RESOURCE_ATTRIBUTE_PRESENT, EFI_MEMORY_PRESENT, FALSE }, { EFI_RESOURCE_ATTRIBUTE_INITIALIZED, EFI_MEMORY_INITIALIZED, FALSE }, { EFI_RESOURCE_ATTRIBUTE_TESTED, EFI_MEMORY_TESTED, FALSE }, @@ -211,7 +211,27 @@ CoreDumpGcdIoSpaceMap ( ); } +/** + Validate resource descriptor HOB's attributes. + + If Attributes includes some memory resource's settings, it should include + the corresponding capabilites also. + @param Attributes Resource descriptor HOB attributes. + +**/ +VOID +CoreValidateResourceDescriptorHobAttributes ( + IN UINT64 Attributes + ) +{ + ASSERT (((Attributes & EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED) == 0) || + ((Attributes & EFI_RESOURCE_ATTRIBUTE_READ_PROTECTABLE) != 0)); + ASSERT (((Attributes & EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED) == 0) || + ((Attributes & EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTABLE) != 0)); + ASSERT (((Attributes & EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED) == 0) || + ((Attributes & EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTABLE) != 0)); +} /** Acquire memory lock on mGcdMemorySpaceLock. @@ -2279,6 +2299,11 @@ CoreInitializeGcdServices ( if (GcdMemoryType != EfiGcdMemoryTypeNonExistent) { // + // Validate the Resource HOB Attributes + // + CoreValidateResourceDescriptorHobAttributes (ResourceHob->ResourceAttribute); + + // // Convert the Resource HOB Attributes to an EFI Memory Capabilities mask // Capabilities = CoreConvertResourceDescriptorHobAttributesToCapabilities ( -- cgit v1.1