powerpc: implementation for arch_override_mprotect_pkey()

arch independent code calls arch_override_mprotect_pkey()
to return a pkey that best matches the requested protection.

This patch provides the implementation.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
Ram Pai
2018-01-18 17:50:34 -08:00
committed by Michael Ellerman
parent 013a91b39c
commit 87bbabbed8
3 changed files with 61 additions and 1 deletions

View File

@@ -41,6 +41,13 @@ static inline u64 pkey_to_vmflag_bits(u16 pkey)
return (((u64)pkey << VM_PKEY_SHIFT) & ARCH_VM_PKEY_FLAGS);
}
static inline int vma_pkey(struct vm_area_struct *vma)
{
if (static_branch_likely(&pkey_disabled))
return 0;
return (vma->vm_flags & ARCH_VM_PKEY_FLAGS) >> VM_PKEY_SHIFT;
}
#define arch_max_pkey() pkeys_total
#define pkey_alloc_mask(pkey) (0x1 << pkey)
@@ -137,10 +144,22 @@ static inline int execute_only_pkey(struct mm_struct *mm)
return __execute_only_pkey(mm);
}
extern int __arch_override_mprotect_pkey(struct vm_area_struct *vma,
int prot, int pkey);
static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma,
int prot, int pkey)
{
return 0;
if (static_branch_likely(&pkey_disabled))
return 0;
/*
* Is this an mprotect_pkey() call? If so, never override the value that
* came from the user.
*/
if (pkey != -1)
return pkey;
return __arch_override_mprotect_pkey(vma, prot, pkey);
}
extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,