History

arm64/mm: Restructure arch_validate_flags() for extensibility

Currently arch_validate_flags() is written in a very non-extensible fashion, returning immediately if MTE is not supported and writing the MTE check as a direct return. Since we will want to add more checks for GCS refactor the existing code to be more extensible, no functional change intended.

Mark Brown committed 2 years ago

Commit f645e881 parent 9ab515b1 file · +10 −4Browse files

Unified · Split

arch/arm64/include/asm/mman.h+10−4
@@ -62,11 +62,17 @@ static inline bool arch_validate_prot(unsigned long prot, · 61 unmodified lines
62 62
63static inline bool arch_validate_flags(unsigned long vm_flags)63static inline bool arch_validate_flags(unsigned long vm_flags)
64{64{
65 if (!system_supports_mte())65 if (system_supports_mte()) {
66 return true;66 /*
67 * only allow VM_MTE if VM_MTE_ALLOWED has been set
68 * previously
69 */
70 if ((vm_flags & VM_MTE) && !(vm_flags & VM_MTE_ALLOWED))
71 return false;
72 }
73
74 return true;
67 75
68 /* only allow VM_MTE if VM_MTE_ALLOWED has been set previously */
69 return !(vm_flags & VM_MTE) || (vm_flags & VM_MTE_ALLOWED);
70}76}
71#define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags)77#define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags)
72 78