Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion UefiCpuPkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,18 @@ UpdateRegionMappingRecursive (
}

EntryValue = SetPpnToPte (EntryValue, RegionStart);
EntryValue = SetValidPte (EntryValue);

//
// Unmapped memory regions must have the 'valid' bit cleared.
// This is because entries with 'valid' set and RWX clear are considered as "table entries"
// (non-leaves), and trigger the ASSERT above for reaching the leaf-level with a non-leaf.
//
if ((AttributeClearMask == PTE_ATTRIBUTES_MASK) && (AttributeSetMask == 0)) {
Comment thread
benjamindoron marked this conversation as resolved.
EntryValue &= ~RISCV_PG_V;
} else {
EntryValue = SetValidPte (EntryValue);
}

ReplaceTableEntry (Entry, EntryValue, RegionStart, TableIsLive);
}
}
Expand Down Expand Up @@ -521,6 +532,10 @@ GcdAttributeToPageAttribute (
}

// Determine protection attributes
if ((GcdAttributes & EFI_MEMORY_RP) != 0) {
*RiscVAttributes &= ~(UINT64)(RISCV_PG_R);
}

if ((GcdAttributes & EFI_MEMORY_RO) != 0) {
*RiscVAttributes &= ~(UINT64)(RISCV_PG_W);
}
Expand Down
Loading