arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE
[linux-2.6-block.git] / arch / arm64 / lib / mte.S
CommitLineData
34bfeea4
CM
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2020 ARM Ltd.
4 */
5#include <linux/linkage.h>
6
7#include <asm/assembler.h>
8#include <asm/sysreg.h>
9
10 .arch armv8.5-a+memtag
11
12/*
13 * multitag_transfer_size - set \reg to the block size that is accessed by the
14 * LDGM/STGM instructions.
15 */
16 .macro multitag_transfer_size, reg, tmp
17 mrs_s \reg, SYS_GMID_EL1
18 ubfx \reg, \reg, #SYS_GMID_EL1_BS_SHIFT, #SYS_GMID_EL1_BS_SIZE
19 mov \tmp, #4
20 lsl \reg, \tmp, \reg
21 .endm
22
23/*
24 * Clear the tags in a page
25 * x0 - address of the page to be cleared
26 */
27SYM_FUNC_START(mte_clear_page_tags)
28 multitag_transfer_size x1, x2
291: stgm xzr, [x0]
30 add x0, x0, x1
31 tst x0, #(PAGE_SIZE - 1)
32 b.ne 1b
33 ret
34SYM_FUNC_END(mte_clear_page_tags)