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