mman.h (9f3419315f3cdc41a7318e4d50ba18a592b30c8c) | mman.h (0042090548740921951f31fc0c20dcdb96638cb0) |
---|---|
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 --- 35 unchanged lines hidden (view full) --- 44 45 /* 46 * There are two conditions required for returning a Normal Tagged 47 * memory type: (1) the user requested it via PROT_MTE passed to 48 * mmap() or mprotect() and (2) the corresponding vma supports MTE. We 49 * register (1) as VM_MTE in the vma->vm_flags and (2) as 50 * VM_MTE_ALLOWED. Note that the latter can only be set during the 51 * mmap() call since mprotect() does not accept MAP_* flags. | 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 --- 35 unchanged lines hidden (view full) --- 44 45 /* 46 * There are two conditions required for returning a Normal Tagged 47 * memory type: (1) the user requested it via PROT_MTE passed to 48 * mmap() or mprotect() and (2) the corresponding vma supports MTE. We 49 * register (1) as VM_MTE in the vma->vm_flags and (2) as 50 * VM_MTE_ALLOWED. Note that the latter can only be set during the 51 * mmap() call since mprotect() does not accept MAP_* flags. |
52 * Checking for VM_MTE only is sufficient since arch_validate_flags() 53 * does not permit (VM_MTE & !VM_MTE_ALLOWED). |
|
52 */ | 54 */ |
53 if ((vm_flags & VM_MTE) && (vm_flags & VM_MTE_ALLOWED)) | 55 if (vm_flags & VM_MTE) |
54 prot |= PTE_ATTRINDX(MT_NORMAL_TAGGED); 55 56 return __pgprot(prot); 57} 58#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags) 59 60static inline bool arch_validate_prot(unsigned long prot, 61 unsigned long addr __always_unused) --- 5 unchanged lines hidden (view full) --- 67 68 if (system_supports_mte()) 69 supported |= PROT_MTE; 70 71 return (prot & ~supported) == 0; 72} 73#define arch_validate_prot(prot, addr) arch_validate_prot(prot, addr) 74 | 56 prot |= PTE_ATTRINDX(MT_NORMAL_TAGGED); 57 58 return __pgprot(prot); 59} 60#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags) 61 62static inline bool arch_validate_prot(unsigned long prot, 63 unsigned long addr __always_unused) --- 5 unchanged lines hidden (view full) --- 69 70 if (system_supports_mte()) 71 supported |= PROT_MTE; 72 73 return (prot & ~supported) == 0; 74} 75#define arch_validate_prot(prot, addr) arch_validate_prot(prot, addr) 76 |
77static inline bool arch_validate_flags(unsigned long vm_flags) 78{ 79 if (!system_supports_mte()) 80 return true; 81 82 /* only allow VM_MTE if VM_MTE_ALLOWED has been set previously */ 83 return !(vm_flags & VM_MTE) || (vm_flags & VM_MTE_ALLOWED); 84} 85#define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags) 86 |
|
75#endif /* ! __ASM_MMAN_H__ */ | 87#endif /* ! __ASM_MMAN_H__ */ |