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
6262
6363 static inline bool arch_validate_flags(unsigned long vm_flags)
6464 {
65− if (!system_supports_mte())
66− return true;
65+ if (system_supports_mte()) {
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;
6775
68− /* only allow VM_MTE if VM_MTE_ALLOWED has been set previously */
69− return !(vm_flags & VM_MTE) || (vm_flags & VM_MTE_ALLOWED);
7076 }
7177 #define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags)
7278