Re: [PATCH v2 1/2] kasan/hw-tags: introduce kasan.store_only option
From: Catalin Marinas <catalin.marinas@arm.com>
Date: 2025-08-15 17:45:00
Also in:
linux-doc, linux-mm, lkml, workflows
On Fri, Aug 15, 2025 at 04:10:59PM +0100, Yeoreum Yun wrote:
quoted
quoted
Like we do in mte_enable_kernel_asymm(), if the feature is not available just fall back to checking both reads and writes in the chosen async/sync/asymm way. You can add some pr_info() to inform the user of the chosen kasan mode. It's really mostly an performance choice.But MTE_STORE_ONLY is defined as a SYSTEM_FEATURE. This means that when it is called from kasan_init_hw_tags_cpu(), the store_only mode is never set in system_capability, so it cannot be checked using cpus_have_cap(). Although the MTE_STORE_ONLY capability is verified by directly reading the ID register (seems ugly), my concern is the potential for an inconsistent state across CPUs. For example, in the case of ASYMM, which is a BOOT_CPU_FEATURE, all CPUs operate in the same mode — if ASYMM is not supported, either all CPUs run in synchronous mode, or all run in asymmetric mode. However, for MTE_STORE_ONLY, CPUs that support the feature will run in store-only mode, while those that do not will run with full checking for all operations. If we want to enable MTE_STORE_ONLY in kasan_init_hw_tags_cpu(), I believe it should be reclassified as a BOOT_CPU_FEATURE.x Otherwise, the cpu_enable_mte_store_only() function should still be called as the enable callback for the MTE_STORE_ONLY feature. In that case, kasan_enable_store_only() should be invoked (remove late init), and if it returns an error, stop_machine() should be called to disable the STORE_ONLY feature on all other CPUs if any CPU is found to lack support for MTE_STORE_ONLY. Am I missing something?
Good point.
So, IMHO like the ASYMM feature, it would be good to change MTE_STORE_ONLY as BOOT_CPU_FEATURE. That would makes everything as easiler and clear.
Yeah, let's do this. If people mix different features, we'll revisit at that time. The asymmetric tag checking is also a boot CPU feature. -- Catalin