arm64: add MTE supported check to thread switching and syscall entry/exit
PATCH 1/1 arm64: add MTE supported check to thread switching and syscall entry/exit
From: Peter Collingbourne <[email protected]>
commit 8c8a3b5bd960cd88f7655b5251dc28741e11f139 upstream.
This lets us avoid doing unnecessary work on hardware that does not support MTE, and will allow us to freely use MTE instructions in the code called by mte_thread_switch().
Since this would mean that we do a redundant check in mte_check_tfsr_el1(), remove it and add two checks now required in its callers. This also avoids an unnecessary DSB+ISB sequence on the syscall exit path for hardware not supporting MTE.
--- arch/arm64/include/asm/mte.h | 6 ++++++ arch/arm64/kernel/mte.c | 10 ++++------ 2 files changed, 10 insertions(+), 6 deletions(-)
arch/arm64/include/asm/mte.h +6 -0
@@ -105,11 +105,17 @@ void mte_check_tfsr_el1(void);static inline void mte_check_tfsr_entry (void ) { +if (!system_supports_mte ()) +return ; +mte_check_tfsr_el1 (); }static inline void mte_check_tfsr_exit (void ) { +if (!system_supports_mte ()) +return ; +/* * The asynchronous faults are sync'ed automatically with * TFSR_EL1 on kernel entry but for exit an explicit dsb()
arch/arm64/kernel/mte.c +4 -6
@@ -173,12 +173,7 @@ bool mte_report_once(void)#ifdef CONFIG_KASAN_HW_TAGS void mte_check_tfsr_el1 (void ) { -u64 tfsr_el1; - -if (!system_supports_mte ()) -return ; - - tfsr_el1 =read_sysreg_s (SYS_TFSR_EL1 ); +u64 tfsr_el1 =read_sysreg_s (SYS_TFSR_EL1 );if (unlikely (tfsr_el1 &SYS_TFSR_EL1_TF1 )) {/*
@@ -221,6 +216,9 @@ void mte_thread_init_user(void)void mte_thread_switch (struct task_struct *next) { +if (!system_supports_mte ()) +return ; +/* * Check if an async tag exception occurred at EL1. *
Greg Kroah-Hartman
maintainerQuoted 20 lines · Catalin Marinas
From: Peter Collingbourne <[email protected]>
commit
8c8a3b5bd960cd88f7655b5251dc28741e11f139upstream.This lets us avoid doing unnecessary work on hardware that does not support MTE, and will allow us to freely use MTE instructions in the code called by
mte_thread_switch().Since this would mean that we do a redundant check in
mte_check_tfsr_el1(), remove it and add two checks now required in its callers. This also avoids an unnecessary DSB+ISB sequence on the syscall exit path for hardware not supporting MTE.Fixes 65812c6921cc ("arm64: mte: Enable async tag check fault")Cc <[email protected]> # 5.13.xSigned-off-by Peter Collingbourne <[email protected]>[[email protected]: adjust the commit log slightly]Signed-off-by Catalin Marinas <[email protected]>
Quoted 4 lines
--- arch/arm64/include/asm/mte.h | 6 ++++++ arch/arm64/kernel/mte.c | 10 ++++------ 2 files changed, 10 insertions(+), 6 deletions(-)
Now queued up, thanks.
greg k-h