Revision: 18889
http://sourceforge.net/p/edk2/code/18889
Author: abiesheuvel
Date: 2015-11-18 11:50:33 +0000 (Wed, 18 Nov 2015)
Log Message:
-----------
ArmVirtPkg/ArmVirtPlatformLib: map executable NOR region as normal memory
The ARM architecture version 7 and later mandates that device mappings
have the XN (non-executable) bit set, to prevent speculative instruction
fetches from read-sensitive regions. This implies that we should not map
regions as device if we want to execute from them, so the NOR region that
contains our FD image should be mapped as normal memory instead.
The MMU code deals correctly with overlapping ARM_MEMORY_REGION_DESCRIPTOR
entries, and later entries in the array take precedence over earlier ones.
So simply add an entry to the end of the array that overrides the mapping
attributes of the FD image, wherever it resides.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <[email protected]>
Reviewed-by: Laszlo Ersek <[email protected]>
Modified Paths:
--------------
trunk/edk2/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
Modified: trunk/edk2/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
===================================================================
--- trunk/edk2/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c 2015-11-18
11:50:12 UTC (rev 18888)
+++ trunk/edk2/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c 2015-11-18
11:50:33 UTC (rev 18889)
@@ -22,7 +22,7 @@
#include <ArmPlatform.h>
// Number of Virtual Memory Map Descriptors
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 4
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
// DDR attributes
#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
@@ -100,8 +100,14 @@
VirtualMemoryTable[2].Length = ArmGetPhysAddrTop () -
VirtualMemoryTable[2].PhysicalBase;
VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
+ // Remap the FD region as normal executable memory
+ VirtualMemoryTable[3].PhysicalBase = FixedPcdGet64 (PcdFdBaseAddress);
+ VirtualMemoryTable[3].VirtualBase = VirtualMemoryTable[3].PhysicalBase;
+ VirtualMemoryTable[3].Length = FixedPcdGet32 (PcdFdSize);
+ VirtualMemoryTable[3].Attributes = CacheAttributes;
+
// End of Table
- ZeroMem (&VirtualMemoryTable[3], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
+ ZeroMem (&VirtualMemoryTable[4], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
*VirtualMemoryMap = VirtualMemoryTable;
}
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits