[PATCH v4] arm64: mte: avoid clearing PSTATE.TCO on entry unless necessary
Will Deacon
will at kernel.org
Tue Feb 15 14:51:53 PST 2022
On Mon, Jan 24, 2022 at 04:58:50PM -0800, Peter Collingbourne wrote:
> On some microarchitectures, clearing PSTATE.TCO is expensive. Clearing
> TCO is only necessary if in-kernel MTE is enabled, or if MTE is
> enabled in the userspace process in synchronous (or, soon, asymmetric)
> mode, because we do not report uaccess faults to userspace in none
> or asynchronous modes. Therefore, adjust the kernel entry code to
> clear TCO only if necessary.
>
> Because it is now possible to switch to a task in which TCO needs to
> be clear from a task in which TCO is set, we also need to do the same
> thing on task switch.
>
> Signed-off-by: Peter Collingbourne <pcc at google.com>
> Link: https://linux-review.googlesource.com/id/I52d82a580bd0500d420be501af2c35fa8c90729e
> Reviewed-by: Catalin Marinas <catalin.marinas at arm.com>
> ---
> v4:
> - some changes suggested by Catalin
>
> v3:
> - switch to a C implementation
>
> v2:
> - do the same thing in cpu_switch_to()
>
> arch/arm64/include/asm/mte.h | 22 ++++++++++++++++++++++
> arch/arm64/kernel/entry-common.c | 3 +++
> arch/arm64/kernel/entry.S | 7 -------
> arch/arm64/kernel/mte.c | 3 +++
> 4 files changed, 28 insertions(+), 7 deletions(-)
I applied this, but it broke the 'allmodconfig' build so I had to drop it:
| In file included from ./arch/arm64/include/asm/pgtable.h:12,
| from ./include/linux/pgtable.h:6,
| from ./include/linux/kasan.h:30,
| from ./include/linux/slab.h:136,
| from ./include/linux/resource_ext.h:11,
| from ./include/linux/acpi.h:14,
| from ./include/acpi/apei.h:9,
| from ./include/acpi/ghes.h:5,
| from ./include/linux/arm_sdei.h:8,
| from arch/arm64/kernel/asm-offsets.c:10:
| ./arch/arm64/include/asm/mte.h: In function ‘mte_disable_tco_entry’:
| ./arch/arm64/include/asm/mte.h:106:6: error: implicit declaration of function ‘kasan_hw_tags_enabled’ [-Werror=implicit-function-declaration]
| 106 | if (kasan_hw_tags_enabled() ||
| | ^~~~~~~~~~~~~~~~~~~~~
| In file included from ./include/linux/slab.h:136,
| from ./include/linux/resource_ext.h:11,
| from ./include/linux/acpi.h:14,
| from ./include/acpi/apei.h:9,
| from ./include/acpi/ghes.h:5,
| from ./include/linux/arm_sdei.h:8,
| from arch/arm64/kernel/asm-offsets.c:10:
| ./include/linux/kasan.h: At top level:
| ./include/linux/kasan.h:108:20: error: conflicting types for ‘kasan_hw_tags_enabled’
| 108 | static inline bool kasan_hw_tags_enabled(void)
| | ^~~~~~~~~~~~~~~~~~~~~
| In file included from ./arch/arm64/include/asm/pgtable.h:12,
| from ./include/linux/pgtable.h:6,
| from ./include/linux/kasan.h:30,
| from ./include/linux/slab.h:136,
| from ./include/linux/resource_ext.h:11,
| from ./include/linux/acpi.h:14,
| from ./include/acpi/apei.h:9,
| from ./include/acpi/ghes.h:5,
| from ./include/linux/arm_sdei.h:8,
| from arch/arm64/kernel/asm-offsets.c:10:
| ./arch/arm64/include/asm/mte.h:106:6: note: previous implicit declaration of ‘kasan_hw_tags_enabled’ was here
| 106 | if (kasan_hw_tags_enabled() ||
| | ^~~~~~~~~~~~~~~~~~~~~
| cc1: all warnings being treated as errors
| make[1]: *** [scripts/Makefile.build:121: arch/arm64/kernel/asm-offsets.s] Error 1
| make: *** [Makefile:1191: prepare0] Error 2
Will
More information about the linux-arm-kernel
mailing list