Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
David Howells | c3617f7 | 2012-10-09 09:47:26 +0100 | [diff] [blame] | 7 | #ifndef _ASM_POWERPC_MMAN_H |
| 8 | #define _ASM_POWERPC_MMAN_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
David Howells | c3617f7 | 2012-10-09 09:47:26 +0100 | [diff] [blame] | 10 | #include <uapi/asm/mman.h> |
Dave Kleikamp | aba46c5 | 2008-07-08 00:28:52 +1000 | [diff] [blame] | 11 | |
Dave Kleikamp | ef3d324 | 2008-07-08 00:28:54 +1000 | [diff] [blame] | 12 | #ifdef CONFIG_PPC64 |
Stephen Rothwell | b3fcaaa | 2008-07-14 19:25:57 +1000 | [diff] [blame] | 13 | |
| 14 | #include <asm/cputable.h> |
| 15 | #include <linux/mm.h> |
Kevin Hao | b92a226 | 2016-07-23 14:42:40 +0530 | [diff] [blame] | 16 | #include <asm/cpu_has_feature.h> |
Stephen Rothwell | b3fcaaa | 2008-07-14 19:25:57 +1000 | [diff] [blame] | 17 | |
Dave Kleikamp | ef3d324 | 2008-07-08 00:28:54 +1000 | [diff] [blame] | 18 | /* |
| 19 | * This file is included by linux/mman.h, so we can't use cacl_vm_prot_bits() |
| 20 | * here. How important is the optimization? |
| 21 | */ |
Dave Hansen | e6bfb70 | 2016-02-12 13:02:31 -0800 | [diff] [blame] | 22 | static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, |
| 23 | unsigned long pkey) |
Dave Kleikamp | ef3d324 | 2008-07-08 00:28:54 +1000 | [diff] [blame] | 24 | { |
| 25 | return (prot & PROT_SAO) ? VM_SAO : 0; |
| 26 | } |
Dave Hansen | e6bfb70 | 2016-02-12 13:02:31 -0800 | [diff] [blame] | 27 | #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey) |
Dave Kleikamp | ef3d324 | 2008-07-08 00:28:54 +1000 | [diff] [blame] | 28 | |
| 29 | static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags) |
| 30 | { |
David Gibson | f5ea64d | 2008-10-12 17:54:24 +0000 | [diff] [blame] | 31 | return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0); |
Dave Kleikamp | ef3d324 | 2008-07-08 00:28:54 +1000 | [diff] [blame] | 32 | } |
| 33 | #define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags) |
| 34 | |
Chen Gang | 949bed2 | 2016-08-02 14:03:42 -0700 | [diff] [blame] | 35 | static inline bool arch_validate_prot(unsigned long prot) |
Dave Kleikamp | ef3d324 | 2008-07-08 00:28:54 +1000 | [diff] [blame] | 36 | { |
| 37 | if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO)) |
Chen Gang | 949bed2 | 2016-08-02 14:03:42 -0700 | [diff] [blame] | 38 | return false; |
Dave Kleikamp | ef3d324 | 2008-07-08 00:28:54 +1000 | [diff] [blame] | 39 | if ((prot & PROT_SAO) && !cpu_has_feature(CPU_FTR_SAO)) |
Chen Gang | 949bed2 | 2016-08-02 14:03:42 -0700 | [diff] [blame] | 40 | return false; |
| 41 | return true; |
Dave Kleikamp | ef3d324 | 2008-07-08 00:28:54 +1000 | [diff] [blame] | 42 | } |
| 43 | #define arch_validate_prot(prot) arch_validate_prot(prot) |
| 44 | |
| 45 | #endif /* CONFIG_PPC64 */ |
jdl@freescale.com | a37c887 | 2005-09-07 15:27:09 -0500 | [diff] [blame] | 46 | #endif /* _ASM_POWERPC_MMAN_H */ |