Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * This program is free software; you can redistribute it and/or | |
3 | * modify it under the terms of the GNU General Public License | |
4 | * as published by the Free Software Foundation; either version | |
5 | * 2 of the License, or (at your option) any later version. | |
6 | */ | |
c3617f72 DH |
7 | #ifndef _ASM_POWERPC_MMAN_H |
8 | #define _ASM_POWERPC_MMAN_H | |
1da177e4 | 9 | |
c3617f72 | 10 | #include <uapi/asm/mman.h> |
1da177e4 | 11 | |
ef3d3246 | 12 | #ifdef CONFIG_PPC64 |
b3fcaaa8 SR |
13 | |
14 | #include <asm/cputable.h> | |
15 | #include <linux/mm.h> | |
013a91b3 | 16 | #include <linux/pkeys.h> |
b92a226e | 17 | #include <asm/cpu_has_feature.h> |
b3fcaaa8 | 18 | |
ef3d3246 DK |
19 | /* |
20 | * This file is included by linux/mman.h, so we can't use cacl_vm_prot_bits() | |
21 | * here. How important is the optimization? | |
22 | */ | |
e6bfb709 DH |
23 | static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, |
24 | unsigned long pkey) | |
ef3d3246 | 25 | { |
013a91b3 RP |
26 | #ifdef CONFIG_PPC_MEM_KEYS |
27 | return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey)); | |
28 | #else | |
29 | return ((prot & PROT_SAO) ? VM_SAO : 0); | |
30 | #endif | |
ef3d3246 | 31 | } |
e6bfb709 | 32 | #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey) |
ef3d3246 DK |
33 | |
34 | static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags) | |
35 | { | |
eb95d016 RP |
36 | #ifdef CONFIG_PPC_MEM_KEYS |
37 | return (vm_flags & VM_SAO) ? | |
38 | __pgprot(_PAGE_SAO | vmflag_to_pte_pkey_bits(vm_flags)) : | |
39 | __pgprot(0 | vmflag_to_pte_pkey_bits(vm_flags)); | |
40 | #else | |
f5ea64dc | 41 | return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0); |
eb95d016 | 42 | #endif |
ef3d3246 DK |
43 | } |
44 | #define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags) | |
45 | ||
9035cf9a | 46 | static inline bool arch_validate_prot(unsigned long prot, unsigned long addr) |
ef3d3246 DK |
47 | { |
48 | if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO)) | |
949bed2f | 49 | return false; |
ef3d3246 | 50 | if ((prot & PROT_SAO) && !cpu_has_feature(CPU_FTR_SAO)) |
949bed2f CG |
51 | return false; |
52 | return true; | |
ef3d3246 | 53 | } |
9035cf9a | 54 | #define arch_validate_prot arch_validate_prot |
ef3d3246 DK |
55 | |
56 | #endif /* CONFIG_PPC64 */ | |
a37c8875 | 57 | #endif /* _ASM_POWERPC_MMAN_H */ |