From: Ard Biesheuvel Date: Fri, 30 Nov 2018 11:28:27 +0000 (+0100) Subject: ArmPkg/ArmMmuLib ARM: handle unmapped sections when updating permissions X-Git-Tag: edk2-stable201903~531 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=aa1097921d7581a8a9c527d5beb3d9d97c731f7e ArmPkg/ArmMmuLib ARM: handle unmapped sections when updating permissions The ARM ArmMmuLib code currently does not take into account that setting permissions on a region should take into account that a region may not be mapped yet to begin with. So when updating a section descriptor whose old value is zero, pass in the address explicitly. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c index ec51e072ab..889b22867d 100644 --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c @@ -695,8 +695,12 @@ UpdateSectionEntries ( } else { // still a section entry - // mask off appropriate fields - Descriptor = CurrentDescriptor & ~EntryMask; + if (CurrentDescriptor != 0) { + // mask off appropriate fields + Descriptor = CurrentDescriptor & ~EntryMask; + } else { + Descriptor = ((UINTN)FirstLevelIdx + i) << TT_DESCRIPTOR_SECTION_BASE_SHIFT; + } // mask in new attributes and/or permissions Descriptor |= EntryValue;