[PATCH v7 18/29] arm64: mte: Allow user control of the tag check mode via prctl()
Catalin Marinas
catalin.marinas at arm.com
Wed Jul 22 07:09:51 EDT 2020
On Mon, Jul 20, 2020 at 04:30:35PM +0100, Kevin Brodsky wrote:
> On 15/07/2020 18:08, Catalin Marinas wrote:
> > +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
More information about the linux-arm-kernel
mailing list