Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  */
0004 #ifndef _ASM_POWERPC_MMAN_H
0005 #define _ASM_POWERPC_MMAN_H
0006 
0007 #include <uapi/asm/mman.h>
0008 
0009 #ifdef CONFIG_PPC64
0010 
0011 #include <asm/cputable.h>
0012 #include <linux/mm.h>
0013 #include <linux/pkeys.h>
0014 #include <asm/cpu_has_feature.h>
0015 #include <asm/firmware.h>
0016 
0017 static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
0018         unsigned long pkey)
0019 {
0020 #ifdef CONFIG_PPC_MEM_KEYS
0021     return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey));
0022 #else
0023     return ((prot & PROT_SAO) ? VM_SAO : 0);
0024 #endif
0025 }
0026 #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
0027 
0028 static inline bool arch_validate_prot(unsigned long prot, unsigned long addr)
0029 {
0030     if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO))
0031         return false;
0032     if (prot & PROT_SAO) {
0033         if (!cpu_has_feature(CPU_FTR_SAO))
0034             return false;
0035         if (firmware_has_feature(FW_FEATURE_LPAR) &&
0036             !IS_ENABLED(CONFIG_PPC_PROT_SAO_LPAR))
0037             return false;
0038     }
0039     return true;
0040 }
0041 #define arch_validate_prot arch_validate_prot
0042 
0043 #endif /* CONFIG_PPC64 */
0044 #endif  /* _ASM_POWERPC_MMAN_H */