Thread (5 messages) 5 messages, 3 authors, 2020-07-23

Re: [PATCH v7 18/29] arm64: mte: Allow user control of the tag check mode via prctl()

From: Catalin Marinas <catalin.marinas@arm.com>
Date: 2020-07-22 11:09:58
Also in: linux-arch, linux-mm

On Mon, Jul 20, 2020 at 04:30:35PM +0100, Kevin Brodsky wrote:
On 15/07/2020 18:08, Catalin Marinas wrote:
quoted
+void mte_thread_switch(struct task_struct *next)
+{
+	if (!system_supports_mte())
+		return;
+
+	/* avoid expensive SCTLR_EL1 accesses if no change */
+	if (current->thread.sctlr_tcf0 != next->thread.sctlr_tcf0)
I think this could be improved by checking whether `next` is a kernel
thread, in which case thread.sctlr_tcf0 is 0 but there is no point in
setting SCTLR_EL1.TCF0, since there should not be any access via TTBR0.
It's not about kernel or user thread here. kthread_use_mm() (just
use_mm() in older kernels) would set an mm on a kernel thread,
temporarily making it behave as a user one. Since the sctlr_tcf0 is per
thread, not per mm, we need to switch to the default TCF0 for kthreads
so that user accesses (if use_mm() is called) don't generate any tag
check faults. Note that switch_mm() does not touch TCF0.

If we did allow a global, per-mm TCF0 setting, such kthreads could only
handle synchronous faults and no SIGSEGV generated (as we do with
copy_{from,to}_user() for normal threads).

If we want to revisit per-thread vs per-mm TCF0 setting, now is the
time.

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help