This source file includes following definitions.
- arch_calc_vm_prot_bits
- arch_vm_get_page_prot
- arch_validate_prot
1
2
3
4 #ifndef _ASM_POWERPC_MMAN_H
5 #define _ASM_POWERPC_MMAN_H
6
7 #include <uapi/asm/mman.h>
8
9 #ifdef CONFIG_PPC64
10
11 #include <asm/cputable.h>
12 #include <linux/mm.h>
13 #include <linux/pkeys.h>
14 #include <asm/cpu_has_feature.h>
15
16
17
18
19
20 static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
21 unsigned long pkey)
22 {
23 #ifdef CONFIG_PPC_MEM_KEYS
24 return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey));
25 #else
26 return ((prot & PROT_SAO) ? VM_SAO : 0);
27 #endif
28 }
29 #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
30
31 static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
32 {
33 #ifdef CONFIG_PPC_MEM_KEYS
34 return (vm_flags & VM_SAO) ?
35 __pgprot(_PAGE_SAO | vmflag_to_pte_pkey_bits(vm_flags)) :
36 __pgprot(0 | vmflag_to_pte_pkey_bits(vm_flags));
37 #else
38 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
39 #endif
40 }
41 #define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
42
43 static inline bool arch_validate_prot(unsigned long prot, unsigned long addr)
44 {
45 if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO))
46 return false;
47 if ((prot & PROT_SAO) && !cpu_has_feature(CPU_FTR_SAO))
48 return false;
49 return true;
50 }
51 #define arch_validate_prot arch_validate_prot
52
53 #endif
54 #endif