xref: /openbmc/linux/arch/arm64/include/asm/mman.h (revision 82df5b73)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_MMAN_H__
3 #define __ASM_MMAN_H__
4 
5 #include <linux/compiler.h>
6 #include <linux/types.h>
7 #include <uapi/asm/mman.h>
8 
9 static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
10 	unsigned long pkey __always_unused)
11 {
12 	if (system_supports_bti() && (prot & PROT_BTI))
13 		return VM_ARM64_BTI;
14 
15 	return 0;
16 }
17 #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
18 
19 static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
20 {
21 	return (vm_flags & VM_ARM64_BTI) ? __pgprot(PTE_GP) : __pgprot(0);
22 }
23 #define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
24 
25 static inline bool arch_validate_prot(unsigned long prot,
26 	unsigned long addr __always_unused)
27 {
28 	unsigned long supported = PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM;
29 
30 	if (system_supports_bti())
31 		supported |= PROT_BTI;
32 
33 	return (prot & ~supported) == 0;
34 }
35 #define arch_validate_prot(prot, addr) arch_validate_prot(prot, addr)
36 
37 #endif /* ! __ASM_MMAN_H__ */
38