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 <osde@linux.microsoft.com>
This commit is contained in:
Oliver Smith-Denny 2024-08-26 10:18:04 -07:00 committed by mergify[bot]
parent 31f0225005
commit 254641f342

View File

@ -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: