arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE
authorCatalin Marinas <catalin.marinas@arm.com>
Mon, 4 May 2020 13:42:36 +0000 (14:42 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 4 Sep 2020 11:46:06 +0000 (12:46 +0100)
commit34bfeea4a9e9cdae713637541f240c3adfdfede3
treeb4e13c4df48e00547764673d4d6ceec187ecf5b3
parent72e6afa08e988744822f9bf18043fc04c4df2178
arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE

Pages allocated by the kernel are not guaranteed to have the tags
zeroed, especially as the kernel does not (yet) use MTE itself. To
ensure the user can still access such pages when mapped into its address
space, clear the tags via set_pte_at(). A new page flag - PG_mte_tagged
(PG_arch_2) - is used to track pages with valid allocation tags.

Since the zero page is mapped as pte_special(), it won't be covered by
the above set_pte_at() mechanism. Clear its tags during early MTE
initialisation.

Co-developed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
arch/arm64/include/asm/mte.h
arch/arm64/include/asm/pgtable.h
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/mte.c
arch/arm64/lib/Makefile
arch/arm64/lib/mte.S [new file with mode: 0644]