]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blame - arch/powerpc/include/asm/mman.h
UBUNTU: Ubuntu-5.4.0-117.132
[mirror_ubuntu-focal-kernel.git] / arch / powerpc / include / asm / mman.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
1da177e4 2/*
1da177e4 3 */
c3617f72
DH
4#ifndef _ASM_POWERPC_MMAN_H
5#define _ASM_POWERPC_MMAN_H
1da177e4 6
c3617f72 7#include <uapi/asm/mman.h>
1da177e4 8
ef3d3246 9#ifdef CONFIG_PPC64
b3fcaaa8
SR
10
11#include <asm/cputable.h>
12#include <linux/mm.h>
013a91b3 13#include <linux/pkeys.h>
b92a226e 14#include <asm/cpu_has_feature.h>
b3fcaaa8 15
ef3d3246
DK
16/*
17 * This file is included by linux/mman.h, so we can't use cacl_vm_prot_bits()
18 * here. How important is the optimization?
19 */
e6bfb709
DH
20static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
21 unsigned long pkey)
ef3d3246 22{
013a91b3
RP
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
ef3d3246 28}
e6bfb709 29#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
ef3d3246
DK
30
31static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
32{
eb95d016
RP
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
f5ea64dc 38 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
eb95d016 39#endif
ef3d3246
DK
40}
41#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
42
9035cf9a 43static inline bool arch_validate_prot(unsigned long prot, unsigned long addr)
ef3d3246
DK
44{
45 if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO))
949bed2f 46 return false;
ef3d3246 47 if ((prot & PROT_SAO) && !cpu_has_feature(CPU_FTR_SAO))
949bed2f
CG
48 return false;
49 return true;
ef3d3246 50}
9035cf9a 51#define arch_validate_prot arch_validate_prot
ef3d3246
DK
52
53#endif /* CONFIG_PPC64 */
a37c8875 54#endif /* _ASM_POWERPC_MMAN_H */