-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arm64: mte: Clear the tags when a page is mapped in user-space with P…
…ROT_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>
- Loading branch information
Catalin Marinas
committed
Sep 4, 2020
1 parent
72e6afa
commit 34bfeea
Showing
6 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* Copyright (C) 2020 ARM Ltd. | ||
*/ | ||
#include <linux/linkage.h> | ||
|
||
#include <asm/assembler.h> | ||
#include <asm/sysreg.h> | ||
|
||
.arch armv8.5-a+memtag | ||
|
||
/* | ||
* multitag_transfer_size - set \reg to the block size that is accessed by the | ||
* LDGM/STGM instructions. | ||
*/ | ||
.macro multitag_transfer_size, reg, tmp | ||
mrs_s \reg, SYS_GMID_EL1 | ||
ubfx \reg, \reg, #SYS_GMID_EL1_BS_SHIFT, #SYS_GMID_EL1_BS_SIZE | ||
mov \tmp, #4 | ||
lsl \reg, \tmp, \reg | ||
.endm | ||
|
||
/* | ||
* Clear the tags in a page | ||
* x0 - address of the page to be cleared | ||
*/ | ||
SYM_FUNC_START(mte_clear_page_tags) | ||
multitag_transfer_size x1, x2 | ||
1: stgm xzr, [x0] | ||
add x0, x0, x1 | ||
tst x0, #(PAGE_SIZE - 1) | ||
b.ne 1b | ||
ret | ||
SYM_FUNC_END(mte_clear_page_tags) |