diff mbox

[edk2] ArmPkg: Fix XN attribute for device memory

Message ID 1460625887-8600-1-git-send-email-heyi.guo@linaro.org
State Accepted
Commit 40e06cad13787d8397949a9c5dd3e41f2cf3caed
Headers show

Commit Message

gary guo April 14, 2016, 9:24 a.m. UTC
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 <heyi.guo@linaro.org>

Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.7.0

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Ard Biesheuvel April 14, 2016, 9:40 a.m. UTC | #1
On 14 April 2016 at 11:24, Heyi Guo <heyi.guo@linaro.org> wrote:
> 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 <heyi.guo@linaro.org>

> Cc: Leif Lindholm <leif.lindholm@linaro.org>

> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>


Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>


Pushed as 40e06cad137

Thanks!

> ---

>  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 b7d23c6..918957d 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.7.0

>

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
index b7d23c6..918957d 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;
   }
 }