[PATCH RFC v3 21/35] arm64: mte: Disable dynamic tag storage management if HW KASAN is enabled
From: Alexandru Elisei
Date: Thu Jan 25 2024 - 11:52:41 EST
To be able to reserve the tag storage associated with a tagged page
requires that the tag storage can be migrated, if it's in use for data.
The kernel allocates pages in non-preemptible contexts, which makes
migration impossible. The only user of tagged pages in the kernel is HW
KASAN, so don't use tag storage pages if HW KASAN is enabled.
Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx>
---
Changes since rfc v2:
* Expanded commit message (David Hildenbrand)
arch/arm64/kernel/mte_tag_storage.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/arm64/kernel/mte_tag_storage.c b/arch/arm64/kernel/mte_tag_storage.c
index 90b157132efa..9a1a8a45171e 100644
--- a/arch/arm64/kernel/mte_tag_storage.c
+++ b/arch/arm64/kernel/mte_tag_storage.c
@@ -256,6 +256,16 @@ void __init mte_init_tag_storage(void)
goto out_disabled;
}
+ /*
+ * The kernel allocates memory in non-preemptible contexts, which makes
+ * migration impossible when reserving the associated tag storage. The
+ * only in-kernel user of tagged pages is HW KASAN.
+ */
+ if (kasan_hw_tags_enabled()) {
+ pr_info("KASAN HW tags incompatible with MTE tag storage management");
+ goto out_disabled;
+ }
+
/*
* Check that tag storage is addressable by the kernel.
* cma_init_reserved_mem(), unlike cma_declare_contiguous_nid(), doesn't
--
2.43.0