summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonnyHansen <62409975+RonnyHansen@users.noreply.github.com>2025-03-11 11:12:15 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-03-12 19:59:59 +0000
commit842c4c8afd306baeeb0a0e4799c172803375f5d2 (patch)
treebef8e1d7e82a15a5ea98a566f21be0d4977b1965
parent168180aa0432dc5a4f0b81c77bb7c6f42a84ade8 (diff)
downloadedk2-842c4c8afd306baeeb0a0e4799c172803375f5d2.zip
edk2-842c4c8afd306baeeb0a0e4799c172803375f5d2.tar.gz
edk2-842c4c8afd306baeeb0a0e4799c172803375f5d2.tar.bz2
PrmPkg: PRM support for non-existent MMIO ranges
This is regarding PRM modules that are describing MMIO ranges. When PrmConfigDxe is calling GetMemorySpaceDescriptor() with a memory range that is visible to the boot processor but has not been added to the memory map GetMemorySpaceDescriptor() will return EFI_SUCCESS and then return a memory descriptor indicating that the region is non-existent. This causes SetRuntimeMemoryRangeAttributes() to believe that the region has already been added to the memory map and will eventually cause an ASSERT. This PR allows for SetRuntimeMemoryRangeAttributes() to treat a non-existent MMIO range the same as a range that triggered a EFI_NOT_FOUND error response from GetMemorySpaceDescriptor(). Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
-rw-r--r--PrmPkg/PrmConfigDxe/PrmConfigDxe.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c
index 7a3913e..f919435 100644
--- a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c
+++ b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c
@@ -100,12 +100,17 @@ SetRuntimeMemoryRangeAttributes (
Status2 = EFI_NOT_FOUND;
Status = gDS->GetMemorySpaceDescriptor (RuntimeMmioRanges->Range[Index].PhysicalBaseAddress, &Descriptor);
- if (!EFI_ERROR (Status) &&
- (
- ((Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) && (Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved)) ||
- ((Descriptor.Length & EFI_PAGE_MASK) != 0)
- )
- )
+ if (!EFI_ERROR (Status) && (Descriptor.GcdMemoryType == EfiGcdMemoryTypeNonExistent)) {
+ // The MMIO range was found in the GCD, but is non-existent. We need to add this MMIO range to the GCD so that
+ // the PRM module can use it. As such, mark it as not found, as the behavior we want is the same as in that
+ // case.
+ Status = EFI_NOT_FOUND;
+ } else if (!EFI_ERROR (Status) &&
+ (
+ ((Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) && (Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved)) ||
+ ((Descriptor.Length & EFI_PAGE_MASK) != 0)
+ )
+ )
{
Status2 = gDS->RemoveMemorySpace (
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,