Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20241001-arm64-gcs-v13-3-222b78d87eee@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Mark Brown and committed by
Catalin Marinas
f645e888 9ab515b1

+10 -4
+10 -4
arch/arm64/include/asm/mman.h
··· 62 62 63 63 static inline bool arch_validate_flags(unsigned long vm_flags) 64 64 { 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 + } 67 73 68 - /* only allow VM_MTE if VM_MTE_ALLOWED has been set previously */ 69 - return !(vm_flags & VM_MTE) || (vm_flags & VM_MTE_ALLOWED); 74 + return true; 75 + 70 76 } 71 77 #define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags) 72 78