From mboxrd@z Thu Jan 1 00:00:00 1970 From: Catalin Marinas Subject: Re: [PATCH v7 18/29] arm64: mte: Allow user control of the tag check mode via prctl() Date: Wed, 22 Jul 2020 11:28:47 +0100 Message-ID: <20200722102845.GA27540@gaia> References: <20200715170844.30064-1-catalin.marinas@arm.com> <20200715170844.30064-19-catalin.marinas@arm.com> <20200720170050.GJ30452@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mail.kernel.org ([198.145.29.99]:42866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730417AbgGVK2v (ORCPT ); Wed, 22 Jul 2020 06:28:51 -0400 Content-Disposition: inline In-Reply-To: <20200720170050.GJ30452@arm.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Dave Martin Cc: Kevin Brodsky , linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, Szabolcs Nagy , Andrey Konovalov , Peter Collingbourne , linux-mm@kvack.org, Andrew Morton , Vincenzo Frascino , Will Deacon On Mon, Jul 20, 2020 at 06:00:50PM +0100, Dave P Martin wrote: > 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. > > Out of interest, do we have a nice way of testing for a kernel thread > now? > > I remember fpsimd_thread_switch() used to check for task->mm, but we > seem to have got rid of that at some point. set_mm() can defeat this, > and anyway the heavy lifting for FPSIMD is now deferred until returning > to userspace. I think a better way is (current->flags & PF_KTHREAD). kthread_use_mm() indeed changes current->mm. -- Catalin