Skip to content

Commit f645e88

Browse files
brooniectmarinas
authored andcommitted
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 <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 9ab515b commit f645e88

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

arch/arm64/include/asm/mman.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,17 @@ static inline bool arch_validate_prot(unsigned long prot,
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

0 commit comments

Comments
 (0)