From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B656C07E95 for ; Wed, 7 Jul 2021 11:12:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2668561C90 for ; Wed, 7 Jul 2021 11:12:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2668561C90 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TcbNw22mwJsqbdAAspeq19/rgxmyNT6g9Ihs8KX4rTE=; b=fLmQKZA0GX3n5h /r80KrQgJsCSu9XszDtnxVADOloGay5l3AgkBqW1Q+njCatUZs+95UB0+xFMRNwv9FMEol03kpC0G 1PKL8cGAnPVhPymROxH6OHoHdJKqQeN/EFSf24f49NojCOQjeGBnZnaAVWj+zUb/IQpC8VjL/2lmV sBs2sbkcDximr56dgKRKdQEilRib31jutKhgiRSuW1NxatBDWDbwWBvaJ9aWg+m2qaTwc5P3YQVFx 6jeNrpleaPe4AkHckgh/yf0iBr31gko/Q3rS97842NSjARSenzn+GE4NM9Oie1B4UzoTiR6xHZLHI akpCuRnm2ARD9wiFVygg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m15SJ-00EdK9-V0; Wed, 07 Jul 2021 11:11:04 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m15SG-00EdJe-1a for linux-arm-kernel@lists.infradead.org; Wed, 07 Jul 2021 11:11:01 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 11D2061C90; Wed, 7 Jul 2021 11:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625656259; bh=+37x6Mrz7Ku9BdJlR3Mf/YPMH80ax9MLixTXYu/JVmg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fhXLfh9oPQjUVDQhHkvQ60RTUAH81SB4Araeiz+zDtdjZekIhCXg+zuV5VT7/scDl O27GIMMCphhTl66Tf4yvJWh1sIYGNwjFW649qPKsQ3GA6ilF3JuBeV1D+nFBv5bmzW +LX718QNMnAqNIEthdzoTv8+1hVjwsnGZvIdP8GuCsRq/001/3EGzO+r4D9qyCtoWj jQzAR4RclrLxtFQ2S6GEe1XQ7vJBkSEH4pev34E0vlBU+fOoWIS21dCP9ircN8UHMV yls+DME+TQubxWhekAU45niCUC7wMJfGaB/ozm7UjK+ZUV9Mu2VVRK/r3fZ25MeEt3 17NUsb31GN5wQ== Date: Wed, 7 Jul 2021 12:10:54 +0100 From: Will Deacon To: Peter Collingbourne Cc: Catalin Marinas , Vincenzo Frascino , Evgenii Stepanov , Szabolcs Nagy , Tejas Belagod , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman Subject: Re: [PATCH v9 2/4] arm64: mte: change ASYNC and SYNC TCF settings into bitfields Message-ID: <20210707111054.GA21926@willie-the-truck> References: <20210702194110.2045282-1-pcc@google.com> <20210702194110.2045282-3-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210702194110.2045282-3-pcc@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210707_041100_148965_70018CB4 X-CRM114-Status: GOOD ( 17.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jul 02, 2021 at 12:41:08PM -0700, Peter Collingbourne wrote: > Allow the user program to specify both ASYNC and SYNC TCF modes by > repurposing the existing constants as bitfields. This will allow the > kernel to select one of the modes on behalf of the user program. With > this patch the kernel will always select async mode, but a subsequent > patch will make this configurable. > > Link: https://linux-review.googlesource.com/id/Icc5923c85a8ea284588cc399ae74fd19ec291230 > Signed-off-by: Peter Collingbourne > Reviewed-by: Catalin Marinas > --- > v9: > - make mte_update_sctlr_user static > > arch/arm64/include/asm/processor.h | 3 ++ > arch/arm64/kernel/mte.c | 70 ++++++++++++------------------ > include/uapi/linux/prctl.h | 11 ++--- > 3 files changed, 37 insertions(+), 47 deletions(-) ... > long set_mte_ctrl(struct task_struct *task, unsigned long arg) > { > - u64 sctlr = task->thread.sctlr_user & ~SCTLR_EL1_TCF0_MASK; > u64 mte_ctrl = (~((arg & PR_MTE_TAG_MASK) >> PR_MTE_TAG_SHIFT) & > SYS_GCR_EL1_EXCL_MASK) << MTE_CTRL_GCR_USER_EXCL_SHIFT; > > if (!system_supports_mte()) > return 0; > > - switch (arg & PR_MTE_TCF_MASK) { > - case PR_MTE_TCF_NONE: > - sctlr |= SCTLR_EL1_TCF0_NONE; > - break; > - case PR_MTE_TCF_SYNC: > - sctlr |= SCTLR_EL1_TCF0_SYNC; > - break; > - case PR_MTE_TCF_ASYNC: > - sctlr |= SCTLR_EL1_TCF0_ASYNC; > - break; > - default: > - return -EINVAL; > - } > + if (arg & PR_MTE_TCF_ASYNC) > + mte_ctrl |= MTE_CTRL_TCF_ASYNC; > + if (arg & PR_MTE_TCF_SYNC) > + mte_ctrl |= MTE_CTRL_TCF_SYNC; > > - if (task != current) { > - task->thread.sctlr_user = sctlr; > - task->thread.mte_ctrl = mte_ctrl; > - } else { > - set_task_sctlr_el1(sctlr); > - set_gcr_el1_excl(mte_ctrl); > + task->thread.mte_ctrl = mte_ctrl; > + if (task == current) { > + mte_update_sctlr_user(task); In conjunction with the next patch, what happens if we migrate at this point? I worry that we can install a stale sctlr_user value. > + set_task_sctlr_el1(task->thread.sctlr_user); Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel