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=-15.7 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 57B49C2B9F4 for ; Thu, 17 Jun 2021 22:00:13 +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 088116113C for ; Thu, 17 Jun 2021 22:00:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 088116113C 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=g/qsF00aiGBRcadG6qjimjFQZK0KjjLdXLiy830S+bo=; b=A7a1zbPdMhBlhB Xg/i3AV0XUVR/QYkDn2DBzU1gQwCPtlhL97QDdy2P9rQN8XxAbaGpCDHdSDno4vFjY/T/GQSCRj+i myUhgELxre0jHPpgBP+61Plo1mY6ZsHk/gjmKZkR5rzWYahQM9I0Aaf2HsuVndkFsj5Kw/iHselck fVZIHNATlT2df3ceJsak/2aW31OWASNll/x7/7LUD6GHxLHiTF5itMumXg9BvrY95mvIF0ZfhZCQI qmZcOGVmLwA8x+TE4cyMQi+Rs5k39AqtRQqQZ7ZmGapYRYvXZOTgqoYYUNBJKr61tOfeLTXP6zgJa lUibclR3BfeuCgDDDiEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lu022-00BtHu-Rj; Thu, 17 Jun 2021 21:58:38 +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 1lu01y-00BtHU-Fz for linux-arm-kernel@lists.infradead.org; Thu, 17 Jun 2021 21:58:36 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2526E61249; Thu, 17 Jun 2021 21:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623967114; bh=jJPdxCPthe/nYisdJ6WMbisU1c8+XuR03IxDgbR4lPw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OvRsUWsT8kFVKoneOxG3pe9wl2QxN3FKOiafYdCBeKwNhTR82BmIinqIPEqZOY70H FpB6z5cMvKrAfPoxfv/OQYDda6RYsrp2VPTW/EUBB4UJtNe4x4gg25fS8jCe//jPcx hhMEVhm8Ee96vmGktv7AhgxSesxklSrzueP1mL2PMlTQDKsemUHMncNWh4pS+DBrf1 yySUTqGNN1L7+5bsNw+4cUYQo7/o+s3qUu5mmnlLSx0taNrQQm7vJhc7fr9ISvrI+3 xUftFypUY62iHeLz+Fx//ZCH2o9mh82fhdwe5nCRj3lZ2WigyNMoL1jgbjjlNtEmOg 0phSHn+3oVtFg== Date: Thu, 17 Jun 2021 22:58:30 +0100 From: Will Deacon To: Peter Collingbourne Cc: Catalin Marinas , Vincenzo Frascino , Evgenii Stepanov , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5] arm64: mte: allow async MTE to be upgraded to sync on a per-CPU basis Message-ID: <20210617215829.GD25403@willie-the-truck> References: <20210615203807.3582804-1-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210615203807.3582804-1-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-20210617_145834_630186_3DF599A3 X-CRM114-Status: GOOD ( 31.42 ) 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 Hi Peter, On Tue, Jun 15, 2021 at 01:38:07PM -0700, Peter Collingbourne wrote: > On some CPUs the performance of MTE in synchronous mode is similar > to that of asynchronous mode. This makes it worthwhile to enable > synchronous mode on those CPUs when asynchronous mode is requested, > in order to gain the error detection benefits of synchronous mode > without the performance downsides. Therefore, make it possible for > user programs to opt into upgrading to synchronous mode on those CPUs > via a new prctl flag. The flag is orthogonal to the existing TCF modes > in order to accommodate upgrading from other TCF modes in the future. > > The feature is controlled on a per-CPU basis via sysfs. > > Signed-off-by: Peter Collingbourne > Link: https://linux-review.googlesource.com/id/Id6f95b71fde6e701dd30b5e108126af7286147e8 > --- > v5: > - updated documentation > - address some nits in mte.c > > v4: > - switch to new mte_ctrl field > - make register_mte_upgrade_async_sysctl return an int > - change the sysctl to take 0 or 1 instead of raw TCF values > - "same as" -> "similar to" > > v3: > - drop the device tree support > - add documentation > - add static_assert to ensure no overlap with real HW bits > - move per-CPU variable initialization to mte.c > - use smp_call_function_single instead of stop_machine > > v2: > - make it an opt-in behavior > - change the format of the device tree node > - also allow controlling the feature via sysfs > > .../arm64/memory-tagging-extension.rst | 20 +++ > arch/arm64/include/asm/mte.h | 4 + > arch/arm64/include/asm/processor.h | 14 +- > arch/arm64/kernel/asm-offsets.c | 2 +- > arch/arm64/kernel/entry.S | 4 +- > arch/arm64/kernel/mte.c | 151 ++++++++++++++---- > arch/arm64/kernel/process.c | 2 +- > include/uapi/linux/prctl.h | 2 + > 8 files changed, 162 insertions(+), 37 deletions(-) > > diff --git a/Documentation/arm64/memory-tagging-extension.rst b/Documentation/arm64/memory-tagging-extension.rst > index b540178a93f8..5375d5efd18c 100644 > --- a/Documentation/arm64/memory-tagging-extension.rst > +++ b/Documentation/arm64/memory-tagging-extension.rst > @@ -120,6 +120,25 @@ in the ``PR_MTE_TAG_MASK`` bit-field. > interface provides an include mask. An include mask of ``0`` (exclusion > mask ``0xffff``) results in the CPU always generating tag ``0``. > > +Upgrading to stricter tag checking modes > +---------------------------------------- > + > +On some CPUs the performance of MTE in stricter tag checking modes > +is similar to that of less strict tag checking modes. This makes it > +worthwhile to enable stricter checks on those CPUs when a less strict > +checking mode is requested, in order to gain the error detection > +benefits of the stricter checks without the performance downsides. To > +opt into upgrading to a stricter checking mode on those CPUs, the user > +can set the ``PR_MTE_DYNAMIC_TCF`` flag bit in the ``flags`` argument > +to the ``prctl(PR_SET_TAGGED_ADDR_CTRL, flags, 0, 0, 0)`` system call. > + > +This feature is currently only supported for upgrading from > +asynchronous mode. To configure a CPU to upgrade from asynchronous mode > +to synchronous mode, a privileged user may write the value ``1`` to > +``/sys/devices/system/cpu/cpu/mte_upgrade_async``, and to disable > +upgrading they may write the value ``0``. By default the feature is > +disabled on all CPUs. > + > Initial process state > --------------------- > > @@ -128,6 +147,7 @@ On ``execve()``, the new process has the following configuration: > - ``PR_TAGGED_ADDR_ENABLE`` set to 0 (disabled) > - Tag checking mode set to ``PR_MTE_TCF_NONE`` > - ``PR_MTE_TAG_MASK`` set to 0 (all tags excluded) > +- ``PR_MTE_DYNAMIC_TCF`` set to 0 (disabled) > - ``PSTATE.TCO`` set to 0 > - ``PROT_MTE`` not set on any of the initial memory maps Something about this doesn't sit right with me, as we're mixing a per-task interface with a per-cpu interface for selecting async/sync MTE and the priorities are somewhat confusing. I think a better interface would be for the sysfs entry for each CPU to allow selection between: task : Honour the prctl() (current behaviour) async : Force async for tasks using MTE sync : Force sync for tasks using MTE none : MTE disabled i.e. the per-cpu setting is an override. Would that give you what you need? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel