1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 #ifndef _ASM_POWERPC_MMAN_H
5 #define _ASM_POWERPC_MMAN_H
7 #include <uapi/asm/mman.h>
11 #include <asm/cputable.h>
13 #include <linux/pkeys.h>
14 #include <asm/cpu_has_feature.h>
16 static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot
,
19 #ifdef CONFIG_PPC_MEM_KEYS
20 return (((prot
& PROT_SAO
) ? VM_SAO
: 0) | pkey_to_vmflag_bits(pkey
));
22 return ((prot
& PROT_SAO
) ? VM_SAO
: 0);
25 #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
27 static inline pgprot_t
arch_vm_get_page_prot(unsigned long vm_flags
)
29 #ifdef CONFIG_PPC_MEM_KEYS
30 return (vm_flags
& VM_SAO
) ?
31 __pgprot(_PAGE_SAO
| vmflag_to_pte_pkey_bits(vm_flags
)) :
32 __pgprot(0 | vmflag_to_pte_pkey_bits(vm_flags
));
34 return (vm_flags
& VM_SAO
) ? __pgprot(_PAGE_SAO
) : __pgprot(0);
37 #define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
39 static inline bool arch_validate_prot(unsigned long prot
, unsigned long addr
)
41 if (prot
& ~(PROT_READ
| PROT_WRITE
| PROT_EXEC
| PROT_SEM
| PROT_SAO
))
43 if (prot
& PROT_SAO
) {
44 if (!cpu_has_feature(CPU_FTR_SAO
))
46 if (firmware_has_feature(FW_FEATURE_LPAR
) &&
47 !IS_ENABLED(CONFIG_PPC_PROT_SAO_LPAR
))
52 #define arch_validate_prot arch_validate_prot
54 #endif /* CONFIG_PPC64 */
55 #endif /* _ASM_POWERPC_MMAN_H */