diff options
author | Oliver Smith-Denny <osde@linux.microsoft.com> | 2024-08-07 14:44:03 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-08-29 12:30:12 +0000 |
commit | 01735bbe4a46a6fb7d5d739d0fc5a14897ad18da (patch) | |
tree | d540484788fa199607fe243cdb3ef7c3729e87e4 /MdeModulePkg | |
parent | bb248a95091ab542440053d9c289a97e80eb6630 (diff) | |
download | edk2-01735bbe4a46a6fb7d5d739d0fc5a14897ad18da.tar.gz |
MdeModulePkg: Gcd: Only Update gMemoryMap Attributes if Correct GCD Type
Currently whenever gDS->SetMemorySpaceCapabilities() is called, it
attempts to set the corresponding attributes in the gMemoryMap
descriptor. However, gMemoryMap only contains entries from GCD types
EfiGcdMemoryTypeSystemMemory and EfiGcdMemoryTypeMoreReliable, so
for all other types a failure is reported in the code. This is a
failure that is expected, so it does not provide value and can
lead to real failures being ignored.
This patch updates the gDS->SetMemorySpaceCapabilities() code to
only call into updating gMemoryMap if the GCD type is SystemMemory
or MoreReliable, to avoid spurious errors being reported. This
also avoids the expensive operation of searching through gMemoryMap
for entries we know we will fail to find.
Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c index 99364508cd..6ea89fbc8b 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -989,6 +989,20 @@ CoreConvertSpace ( //
case GCD_SET_CAPABILITIES_MEMORY_OPERATION:
Entry->Capabilities = Capabilities;
+
+ // Only SystemMemory and MoreReliable memory is in gMemoryMap
+ // so only attempt to update the attributes there if this is
+ // a relevant GCD type
+ if ((Entry->GcdMemoryType == EfiGcdMemoryTypeSystemMemory) ||
+ (Entry->GcdMemoryType == EfiGcdMemoryTypeMoreReliable))
+ {
+ CoreUpdateMemoryAttributes (
+ BaseAddress,
+ RShiftU64 (Length, EFI_PAGE_SHIFT),
+ Capabilities & (~EFI_MEMORY_RUNTIME)
+ );
+ }
+
break;
}
@@ -1700,17 +1714,10 @@ CoreSetMemorySpaceCapabilities ( IN UINT64 Capabilities
)
{
- EFI_STATUS Status;
-
DEBUG ((DEBUG_GCD, "GCD:CoreSetMemorySpaceCapabilities(Base=%016lx,Length=%016lx)\n", BaseAddress, Length));
DEBUG ((DEBUG_GCD, " Capabilities = %016lx\n", Capabilities));
- Status = CoreConvertSpace (GCD_SET_CAPABILITIES_MEMORY_OPERATION, (EFI_GCD_MEMORY_TYPE)0, (EFI_GCD_IO_TYPE)0, BaseAddress, Length, Capabilities, 0);
- if (!EFI_ERROR (Status)) {
- CoreUpdateMemoryAttributes (BaseAddress, RShiftU64 (Length, EFI_PAGE_SHIFT), Capabilities & (~EFI_MEMORY_RUNTIME));
- }
-
- return Status;
+ return CoreConvertSpace (GCD_SET_CAPABILITIES_MEMORY_OPERATION, (EFI_GCD_MEMORY_TYPE)0, (EFI_GCD_IO_TYPE)0, BaseAddress, Length, Capabilities, 0);
}
/**
|