Skip to content

Commit

Permalink
PrmPkg: Don't Set Access Attributes of Runtime MMIO Ranges
Browse files Browse the repository at this point in the history
Passing in access attributes to SetMemorySpaceAttributes() will cause
the existing attributes to be overwritten. The MMIO region should have
the appropriate attributes applied during memory protection
initialization and the attributes of the memory space descriptor are
inaccurate. Don't pass in any CPU arch attributes so
SetMemorySpaceAttributes() doesn't subsequently call
gCpu->SetMemoryAttributes().

Signed-off-by: Oliver Smith-Denny <[email protected]>
  • Loading branch information
TaylorBeebe authored and mergify[bot] committed Jul 24, 2024
1 parent a7abb77 commit a96d2a8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion PrmPkg/PrmConfigDxe/PrmConfigDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,15 @@ SetRuntimeMemoryRangeAttributes (
continue;
}

// The memory space descriptor access attributes are not accurate. Don't pass
// in access attributes so SetMemorySpaceAttributes() doesn't update them.
// EFI_MEMORY_RUNTIME is not a CPU arch attribute, so calling
// SetMemorySpaceAttributes() with only it set will not clear existing page table
// attributes for this region, such as EFI_MEMORY_XP
Status = gDS->SetMemorySpaceAttributes (
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
(UINT64)RuntimeMmioRanges->Range[Index].Length,
Descriptor.Attributes | EFI_MEMORY_RUNTIME
EFI_MEMORY_RUNTIME
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
Expand Down

0 comments on commit a96d2a8

Please sign in to comment.