blob: 2563c435a4b166593e71812086baa791a01de43b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Howellsc3617f72012-10-09 09:47:26 +01007#ifndef _ASM_POWERPC_MMAN_H
8#define _ASM_POWERPC_MMAN_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
David Howellsc3617f72012-10-09 09:47:26 +010010#include <uapi/asm/mman.h>
Dave Kleikampaba46c52008-07-08 00:28:52 +100011
Dave Kleikampef3d3242008-07-08 00:28:54 +100012#ifdef CONFIG_PPC64
Stephen Rothwellb3fcaaa2008-07-14 19:25:57 +100013
14#include <asm/cputable.h>
15#include <linux/mm.h>
16
Dave Kleikampef3d3242008-07-08 00:28:54 +100017/*
18 * This file is included by linux/mman.h, so we can't use cacl_vm_prot_bits()
19 * here. How important is the optimization?
20 */
Dave Hansene6bfb702016-02-12 13:02:31 -080021static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
22 unsigned long pkey)
Dave Kleikampef3d3242008-07-08 00:28:54 +100023{
24 return (prot & PROT_SAO) ? VM_SAO : 0;
25}
Dave Hansene6bfb702016-02-12 13:02:31 -080026#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
Dave Kleikampef3d3242008-07-08 00:28:54 +100027
28static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
29{
David Gibsonf5ea64d2008-10-12 17:54:24 +000030 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
Dave Kleikampef3d3242008-07-08 00:28:54 +100031}
32#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
33
34static inline int arch_validate_prot(unsigned long prot)
35{
36 if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO))
37 return 0;
38 if ((prot & PROT_SAO) && !cpu_has_feature(CPU_FTR_SAO))
39 return 0;
40 return 1;
41}
42#define arch_validate_prot(prot) arch_validate_prot(prot)
43
44#endif /* CONFIG_PPC64 */
jdl@freescale.coma37c8872005-09-07 15:27:09 -050045#endif /* _ASM_POWERPC_MMAN_H */