0001
0002 #ifndef __ASM_MMAN_H__
0003 #define __ASM_MMAN_H__
0004
0005 #include <linux/compiler.h>
0006 #include <linux/types.h>
0007 #include <uapi/asm/mman.h>
0008
0009 static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
0010 unsigned long pkey __always_unused)
0011 {
0012 unsigned long ret = 0;
0013
0014 if (system_supports_bti() && (prot & PROT_BTI))
0015 ret |= VM_ARM64_BTI;
0016
0017 if (system_supports_mte() && (prot & PROT_MTE))
0018 ret |= VM_MTE;
0019
0020 return ret;
0021 }
0022 #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
0023
0024 static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
0025 {
0026
0027
0028
0029
0030
0031 if (system_supports_mte() && (flags & MAP_ANONYMOUS))
0032 return VM_MTE_ALLOWED;
0033
0034 return 0;
0035 }
0036 #define arch_calc_vm_flag_bits(flags) arch_calc_vm_flag_bits(flags)
0037
0038 static inline bool arch_validate_prot(unsigned long prot,
0039 unsigned long addr __always_unused)
0040 {
0041 unsigned long supported = PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM;
0042
0043 if (system_supports_bti())
0044 supported |= PROT_BTI;
0045
0046 if (system_supports_mte())
0047 supported |= PROT_MTE;
0048
0049 return (prot & ~supported) == 0;
0050 }
0051 #define arch_validate_prot(prot, addr) arch_validate_prot(prot, addr)
0052
0053 static inline bool arch_validate_flags(unsigned long vm_flags)
0054 {
0055 if (!system_supports_mte())
0056 return true;
0057
0058
0059 return !(vm_flags & VM_MTE) || (vm_flags & VM_MTE_ALLOWED);
0060 }
0061 #define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags)
0062
0063 #endif