From 254641f342ac3c1991e0e4d32c0ea9c8cfc723f3 Mon Sep 17 00:00:00 2001 From: Oliver Smith-Denny Date: Mon, 26 Aug 2024 10:18:04 -0700 Subject: [PATCH] MdeModulePkg: MAT: Do Not Set EfiMemoryMappedIo[PortSpace] Attrs Per UEFI spec 2.10 section 4.6.3 EFI_MEMORY_ATTRIBUTES_TABLE, "The Memory Attributes Table is currently used to describe memory protections that may be applied to the EFI Runtime code and data by an operating system or hypervisor. Consumers of this table must currently ignore entries containing any values for Type except for EfiRuntimeServicesData and EfiRuntimeServicesCode to ensure compatibility with future uses of this table." However, the current MAT code also enforces attributes for EfiMemoryMappedIo and EfiMemoryMappedIoPortSpace, which it should not be. Per https://edk2.groups.io/g/devel/topic/patch_v1_mdemodulepkg/105570114?p=,,,20,0,0,0::recentpostdate/sticky,,,20,2,0,105570114, it was suggested to remove these types from the MAT logic. This patch removes EfiMemoryMappedIo and EfiMemoryMappedIoPortSpace from the MAT logic in accordance with the UEFI spec. Signed-off-by: Oliver Smith-Denny --- MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c index e9343a2c4e..5fe285c48b 100644 --- a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c @@ -426,7 +426,7 @@ MergeMemoryMap ( /** Enforce memory map attributes. - This function will set EfiRuntimeServicesData/EfiMemoryMappedIO/EfiMemoryMappedIOPortSpace to be EFI_MEMORY_XP. + This function will set EfiRuntimeServicesData to be EFI_MEMORY_XP. @param MemoryMap A pointer to the buffer in which firmware places the current memory map. @@ -452,8 +452,6 @@ EnforceMemoryMapAttribute ( // do nothing break; case EfiRuntimeServicesData: - case EfiMemoryMappedIO: - case EfiMemoryMappedIOPortSpace: MemoryMapEntry->Attribute |= EFI_MEMORY_XP; break; case EfiReservedMemoryType: