summaryrefslogtreecommitdiff
path: root/arch/powerpc/include/asm/pkeys.h
diff options
context:
space:
mode:
authorRam Pai <linuxram@us.ibm.com>2018-01-19 04:50:37 +0300
committerMichael Ellerman <mpe@ellerman.id.au>2018-01-20 14:59:03 +0300
commitf2407ef3ba225665ee24965f69bc84435fb590cf (patch)
tree5883038293a5e98317f3cd8bf161f62493cd6926 /arch/powerpc/include/asm/pkeys.h
parenta6590ca55f1f49912e17e4811ccae9a51bda8859 (diff)
downloadlinux-f2407ef3ba225665ee24965f69bc84435fb590cf.tar.xz
powerpc: helper to validate key-access permissions of a pte
helper function that checks if the read/write/execute is allowed on the pte. Signed-off-by: Ram Pai <linuxram@us.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/include/asm/pkeys.h')
-rw-r--r--arch/powerpc/include/asm/pkeys.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h
index a8ef7fa5360e..2298771b066b 100644
--- a/arch/powerpc/include/asm/pkeys.h
+++ b/arch/powerpc/include/asm/pkeys.h
@@ -71,6 +71,15 @@ static inline u64 pte_to_hpte_pkey_bits(u64 pteflags)
((pteflags & H_PTE_PKEY_BIT4) ? HPTE_R_KEY_BIT4 : 0x0UL));
}
+static inline u16 pte_to_pkey_bits(u64 pteflags)
+{
+ return (((pteflags & H_PTE_PKEY_BIT0) ? 0x10 : 0x0UL) |
+ ((pteflags & H_PTE_PKEY_BIT1) ? 0x8 : 0x0UL) |
+ ((pteflags & H_PTE_PKEY_BIT2) ? 0x4 : 0x0UL) |
+ ((pteflags & H_PTE_PKEY_BIT3) ? 0x2 : 0x0UL) |
+ ((pteflags & H_PTE_PKEY_BIT4) ? 0x1 : 0x0UL));
+}
+
#define pkey_alloc_mask(pkey) (0x1 << pkey)
#define mm_pkey_allocation_map(mm) (mm->context.pkey_allocation_map)