mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
![Anshuman Khandual](/assets/img/avatar_default.png)
This defines and exports a platform specific custom vm_get_page_prot() via subscribing ARCH_HAS_VM_GET_PAGE_PROT. While here, this also localizes arch_vm_get_page_prot() as __vm_get_page_prot() and moves it near vm_get_page_prot(). Link: https://lkml.kernel.org/r/20220414062125.609297-3-anshuman.khandual@arm.com Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Paul Mackerras <paulus@samba.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: David S. Miller <davem@davemloft.net> Cc: Ingo Molnar <mingo@redhat.com> Cc: Khalid Aziz <khalid.aziz@oracle.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
43 lines
1.1 KiB
C
43 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
*/
|
|
#ifndef _ASM_POWERPC_MMAN_H
|
|
#define _ASM_POWERPC_MMAN_H
|
|
|
|
#include <uapi/asm/mman.h>
|
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
#include <asm/cputable.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/pkeys.h>
|
|
#include <asm/cpu_has_feature.h>
|
|
|
|
static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
|
|
unsigned long pkey)
|
|
{
|
|
#ifdef CONFIG_PPC_MEM_KEYS
|
|
return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey));
|
|
#else
|
|
return ((prot & PROT_SAO) ? VM_SAO : 0);
|
|
#endif
|
|
}
|
|
#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
|
|
|
|
static inline bool arch_validate_prot(unsigned long prot, unsigned long addr)
|
|
{
|
|
if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO))
|
|
return false;
|
|
if (prot & PROT_SAO) {
|
|
if (!cpu_has_feature(CPU_FTR_SAO))
|
|
return false;
|
|
if (firmware_has_feature(FW_FEATURE_LPAR) &&
|
|
!IS_ENABLED(CONFIG_PPC_PROT_SAO_LPAR))
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
#define arch_validate_prot arch_validate_prot
|
|
|
|
#endif /* CONFIG_PPC64 */
|
|
#endif /* _ASM_POWERPC_MMAN_H */
|