powerpc: track allocation status of all pkeys
RFC v7 2/25 powerpc: track allocation status of all pkeys
Total 32 keys are available on power7 and above. However pkey 0,1 are reserved. So effectively we have 30 pkeys.
On 4K kernels, we do not have 5 bits in the PTE to represent all the keys; we only have 3bits.Two of those keys are reserved; pkey 0 and pkey 1. So effectively we have 6 pkeys.
This patch keeps track of reserved keys, allocated keys and keys that are currently free.
Also it adds skeletal functions and macros, that the architecture-independent code expects to be available.
Signed-off-by Ram Pai <[email protected]>
--- arch/powerpc/include/asm/book3s/64/mmu.h | 9 +++ arch/powerpc/include/asm/mmu_context.h | 1 + arch/powerpc/include/asm/pkeys.h | 98 ++++++++++++++++++++++++++++- arch/powerpc/mm/mmu_context_book3s64.c | 2 + arch/powerpc/mm/pkeys.c | 2 + 5 files changed, 108 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +9 -0
@@ -108,6 +108,15 @@ struct patb_entry {#ifdef CONFIG_SPAPR_TCE_IOMMU struct list_head iommu_group_mem_list;#endif + +#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS +/* +* Each bit represents one protection key. +* bit set -> key allocated +* bit unset -> key available for allocation +*/ +u32 pkey_allocation_map; +#endif } mm_context_t;/*
arch/powerpc/include/asm/mmu_context.h +1 -0
@@ -184,6 +184,7 @@ static inline bool arch_vma_access_permitted(struct vm_area_struct *vma,#ifndef CONFIG_PPC64_MEMORY_PROTECTION_KEYS #define pkey_initialize () +#define pkey_mm_init (mm)#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */ #endif /* __KERNEL__ */
arch/powerpc/include/asm/pkeys.h +94 -4
133 lines not on this page · raw message
arch/powerpc/mm/mmu_context_book3s64.c +2 -0
@@ -16,6 +16,7 @@#include <linux/string.h> #include <linux/types.h> #include <linux/mm.h> +#include <linux/pkeys.h> #include <linux/spinlock.h> #include <linux/idr.h> #include <linux/export.h>
@@ -120,6 +121,7 @@ static int hash__init_new_context(struct mm_struct *mm)subpage_prot_init_new_context (mm); +pkey_mm_init (mm);return index; }
arch/powerpc/mm/pkeys.c +2 -0
@@ -16,3 +16,5 @@#include <linux/pkeys.h> /* PKEY_* */ bool pkey_inited; +int pkeys_total;/* total pkeys as per device tree */ +u32 initial_allocation_mask;/* bits set for reserved keys */
Signature · 1 line
1.7.1