diff mbox

[edk2] ArmPkg/AArch64Mmu: don't let table entries inherit XN permission bits

Message ID 1461140380-19345-1-git-send-email-ard.biesheuvel@linaro.org
State Accepted
Commit d1ec2b2f78b752b9dfc06843f994cbfad134ea63
Headers show

Commit Message

Ard Biesheuvel April 20, 2016, 8:19 a.m. UTC
When we split a block entry into a table entry, the UXN/PXN/XN permission
attributes are inherited both by the new table entry and by the new block
entries at the next level down. Unlike the NS bit, which only affects the
next level of lookup, the XN table bits supersede the permissions of the
final translation, and setting the permissions at multiple levels is not
only redundant, it also prevents us from lifting XN restrictions on a
subregion of the original block entry by simply clearing the appropriate
bits at the lowest level.

So drop the code that sets the UXN/PXN/XN bits on the table entries.

Reported-by: "Oliyil Kunnil, Vishal" <vishalo@qti.qualcomm.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c | 7 -------
 1 file changed, 7 deletions(-)

-- 
2.5.0

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

Comments

Leif Lindholm May 9, 2016, 7:52 p.m. UTC | #1
On Wed, Apr 20, 2016 at 10:19:40AM +0200, Ard Biesheuvel wrote:
> When we split a block entry into a table entry, the UXN/PXN/XN permission

> attributes are inherited both by the new table entry and by the new block

> entries at the next level down. Unlike the NS bit, which only affects the

> next level of lookup, the XN table bits supersede the permissions of the

> final translation, and setting the permissions at multiple levels is not

> only redundant, it also prevents us from lifting XN restrictions on a

> subregion of the original block entry by simply clearing the appropriate

> bits at the lowest level.

> 

> So drop the code that sets the UXN/PXN/XN bits on the table entries.

> 

> Reported-by: "Oliyil Kunnil, Vishal" <vishalo@qti.qualcomm.com>

> Contributed-under: TianoCore Contribution Agreement 1.0

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


Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>


> ---

>  ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c | 7 -------

>  1 file changed, 7 deletions(-)

> 

> diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

> index 48ca8271849c..cf9b7222b47b 100644

> --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

> +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

> @@ -306,13 +306,6 @@ GetBlockEntryListFromAddress (

>  

>          // Convert the block entry attributes into Table descriptor attributes

>          TableAttributes = TT_TABLE_AP_NO_PERMISSION;

> -        if (Attributes & TT_PXN_MASK) {

> -          TableAttributes = TT_TABLE_PXN;

> -        }

> -        // XN maps to UXN in the EL1&0 translation regime

> -        if (Attributes & TT_XN_MASK) {

> -          TableAttributes = TT_TABLE_XN;

> -        }

>          if (Attributes & TT_NS) {

>            TableAttributes = TT_TABLE_NS;

>          }

> -- 

> 2.5.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 48ca8271849c..cf9b7222b47b 100644
--- a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
+++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
@@ -306,13 +306,6 @@  GetBlockEntryListFromAddress (
 
         // Convert the block entry attributes into Table descriptor attributes
         TableAttributes = TT_TABLE_AP_NO_PERMISSION;
-        if (Attributes & TT_PXN_MASK) {
-          TableAttributes = TT_TABLE_PXN;
-        }
-        // XN maps to UXN in the EL1&0 translation regime
-        if (Attributes & TT_XN_MASK) {
-          TableAttributes = TT_TABLE_XN;
-        }
         if (Attributes & TT_NS) {
           TableAttributes = TT_TABLE_NS;
         }