From 40e06cad13787d8397949a9c5dd3e41f2cf3caed Mon Sep 17 00:00:00 2001 From: Heyi Guo Date: Thu, 14 Apr 2016 17:24:47 +0800 Subject: [PATCH] ArmPkg/AArch64Mmu: Fix XN attribute for device memory Now XN attribute will be set automatically if the region is declared as device memory. However, the function ArmMemoryAttributeToPageAttribute is to get attribute for block and page descriptors, not for table descriptors, so attribute TT_TABLE_*XN does not really take effect. Need to use TT_*XN_MASK instead. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Heyi Guo Reviewed-by: Ard Biesheuvel --- ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c index b7d23c6f32..918957d4ff 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c @@ -51,9 +51,9 @@ ArmMemoryAttributeToPageAttribute ( case ARM_MEMORY_REGION_ATTRIBUTE_DEVICE: case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE: if (ArmReadCurrentEL () == AARCH64_EL2) - return TT_ATTR_INDX_DEVICE_MEMORY | TT_TABLE_XN; + return TT_ATTR_INDX_DEVICE_MEMORY | TT_XN_MASK; else - return TT_ATTR_INDX_DEVICE_MEMORY | TT_TABLE_UXN | TT_TABLE_PXN; + return TT_ATTR_INDX_DEVICE_MEMORY | TT_UXN_MASK | TT_PXN_MASK; } } -- 2.39.2