mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 23:52:08 +02:00
powerpc/book3s64/pkeys: pkeys are supported only on hash on book3s.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200709032946.881753-4-aneesh.kumar@linux.ibm.com
This commit is contained in:
parent
33699023f5
commit
b9658f83e7
32
arch/powerpc/include/asm/book3s/64/hash-pkey.h
Normal file
32
arch/powerpc/include/asm/book3s/64/hash-pkey.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef _ASM_POWERPC_BOOK3S_64_HASH_PKEY_H
|
||||
#define _ASM_POWERPC_BOOK3S_64_HASH_PKEY_H
|
||||
|
||||
static inline u64 hash__vmflag_to_pte_pkey_bits(u64 vm_flags)
|
||||
{
|
||||
return (((vm_flags & VM_PKEY_BIT0) ? H_PTE_PKEY_BIT0 : 0x0UL) |
|
||||
((vm_flags & VM_PKEY_BIT1) ? H_PTE_PKEY_BIT1 : 0x0UL) |
|
||||
((vm_flags & VM_PKEY_BIT2) ? H_PTE_PKEY_BIT2 : 0x0UL) |
|
||||
((vm_flags & VM_PKEY_BIT3) ? H_PTE_PKEY_BIT3 : 0x0UL) |
|
||||
((vm_flags & VM_PKEY_BIT4) ? H_PTE_PKEY_BIT4 : 0x0UL));
|
||||
}
|
||||
|
||||
static inline u64 pte_to_hpte_pkey_bits(u64 pteflags)
|
||||
{
|
||||
return (((pteflags & H_PTE_PKEY_BIT4) ? HPTE_R_KEY_BIT4 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT3) ? HPTE_R_KEY_BIT3 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT2) ? HPTE_R_KEY_BIT2 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT1) ? HPTE_R_KEY_BIT1 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT0) ? HPTE_R_KEY_BIT0 : 0x0UL));
|
||||
}
|
||||
|
||||
static inline u16 hash__pte_to_pkey_bits(u64 pteflags)
|
||||
{
|
||||
return (((pteflags & H_PTE_PKEY_BIT4) ? 0x10 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT3) ? 0x8 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT2) ? 0x4 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT1) ? 0x2 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT0) ? 0x1 : 0x0UL));
|
||||
}
|
||||
|
||||
#endif
|
||||
25
arch/powerpc/include/asm/book3s/64/pkeys.h
Normal file
25
arch/powerpc/include/asm/book3s/64/pkeys.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
|
||||
#ifndef _ASM_POWERPC_BOOK3S_64_PKEYS_H
|
||||
#define _ASM_POWERPC_BOOK3S_64_PKEYS_H
|
||||
|
||||
#include <asm/book3s/64/hash-pkey.h>
|
||||
|
||||
static inline u64 vmflag_to_pte_pkey_bits(u64 vm_flags)
|
||||
{
|
||||
if (static_branch_likely(&pkey_disabled))
|
||||
return 0x0UL;
|
||||
|
||||
if (radix_enabled())
|
||||
BUG();
|
||||
return hash__vmflag_to_pte_pkey_bits(vm_flags);
|
||||
}
|
||||
|
||||
static inline u16 pte_to_pkey_bits(u64 pteflags)
|
||||
{
|
||||
if (radix_enabled())
|
||||
BUG();
|
||||
return hash__pte_to_pkey_bits(pteflags);
|
||||
}
|
||||
|
||||
#endif /*_ASM_POWERPC_KEYS_H */
|
||||
|
|
@ -25,23 +25,18 @@ extern u32 reserved_allocation_mask; /* bits set for reserved keys */
|
|||
PKEY_DISABLE_WRITE | \
|
||||
PKEY_DISABLE_EXECUTE)
|
||||
|
||||
#ifdef CONFIG_PPC_BOOK3S_64
|
||||
#include <asm/book3s/64/pkeys.h>
|
||||
#else
|
||||
#error "Not supported"
|
||||
#endif
|
||||
|
||||
|
||||
static inline u64 pkey_to_vmflag_bits(u16 pkey)
|
||||
{
|
||||
return (((u64)pkey << VM_PKEY_SHIFT) & ARCH_VM_PKEY_FLAGS);
|
||||
}
|
||||
|
||||
static inline u64 vmflag_to_pte_pkey_bits(u64 vm_flags)
|
||||
{
|
||||
if (static_branch_likely(&pkey_disabled))
|
||||
return 0x0UL;
|
||||
|
||||
return (((vm_flags & VM_PKEY_BIT0) ? H_PTE_PKEY_BIT0 : 0x0UL) |
|
||||
((vm_flags & VM_PKEY_BIT1) ? H_PTE_PKEY_BIT1 : 0x0UL) |
|
||||
((vm_flags & VM_PKEY_BIT2) ? H_PTE_PKEY_BIT2 : 0x0UL) |
|
||||
((vm_flags & VM_PKEY_BIT3) ? H_PTE_PKEY_BIT3 : 0x0UL) |
|
||||
((vm_flags & VM_PKEY_BIT4) ? H_PTE_PKEY_BIT4 : 0x0UL));
|
||||
}
|
||||
|
||||
static inline int vma_pkey(struct vm_area_struct *vma)
|
||||
{
|
||||
if (static_branch_likely(&pkey_disabled))
|
||||
|
|
@ -51,24 +46,6 @@ static inline int vma_pkey(struct vm_area_struct *vma)
|
|||
|
||||
#define arch_max_pkey() pkeys_total
|
||||
|
||||
static inline u64 pte_to_hpte_pkey_bits(u64 pteflags)
|
||||
{
|
||||
return (((pteflags & H_PTE_PKEY_BIT4) ? HPTE_R_KEY_BIT4 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT3) ? HPTE_R_KEY_BIT3 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT2) ? HPTE_R_KEY_BIT2 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT1) ? HPTE_R_KEY_BIT1 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT0) ? HPTE_R_KEY_BIT0 : 0x0UL));
|
||||
}
|
||||
|
||||
static inline u16 pte_to_pkey_bits(u64 pteflags)
|
||||
{
|
||||
return (((pteflags & H_PTE_PKEY_BIT4) ? 0x10 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT3) ? 0x8 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT2) ? 0x4 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT1) ? 0x2 : 0x0UL) |
|
||||
((pteflags & H_PTE_PKEY_BIT0) ? 0x1 : 0x0UL));
|
||||
}
|
||||
|
||||
#define pkey_alloc_mask(pkey) (0x1 << pkey)
|
||||
|
||||
#define mm_pkey_allocation_map(mm) (mm->context.pkey_allocation_map)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user