From: Vincenzo Frascino <vincenzo.frascino@xxxxxxx> When the Memory Tagging Extension is enabled, the tags need to be set to zero a page is cleared as they are visible to the user. Introduce an MTE-aware clear_page() which clears the tags in addition to data. Signed-off-by: Vincenzo Frascino <vincenzo.frascino@xxxxxxx> Co-developed-by: Catalin Marinas <catalin.marinas@xxxxxxx> Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx> --- arch/arm64/lib/clear_page.S | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm64/lib/clear_page.S b/arch/arm64/lib/clear_page.S index 78a9ef66288a..575cea03f68a 100644 --- a/arch/arm64/lib/clear_page.S +++ b/arch/arm64/lib/clear_page.S @@ -5,7 +5,9 @@ #include <linux/linkage.h> #include <linux/const.h> +#include <asm/alternative.h> #include <asm/assembler.h> +#include <asm/cpufeature.h> #include <asm/page.h> /* @@ -19,8 +21,9 @@ ENTRY(clear_page) and w1, w1, #0xf mov x2, #4 lsl x1, x2, x1 - -1: dc zva, x0 +1: +alternative_insn "dc zva, x0", "stzgm xzr, [x0]", \ + ARM64_MTE, IS_ENABLED(CONFIG_ARM64_MTE), 1 add x0, x0, x1 tst x0, #(PAGE_SIZE - 1) b.ne 1b