From patchwork Tue Jul 27 20:52:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12403603 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=-12.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 A7458C4338F for ; Tue, 27 Jul 2021 20:55:26 +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 7861860F6C for ; Tue, 27 Jul 2021 20:55:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7861860F6C Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=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:Cc:To:From:Subject:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=oBlxQoKTjWj9XT1y5IhDedyOb66pDTE5R1EIcS2EJMA=; b=DH7 t4T0FrChxfA5xTUBPHrmshPP92Ho8kZoekeNl6sM4A87WQVgO8iXlJGrXprIzmzbZLUq4aUr29uSw A12hKfTZK4Bf/3o76rM3bbgpmsdfSJ07kKArpHdeYSIcweodRULs4dyagYsD9MyARf3cFxilKUoKz yZ2KgLTuFCZBSLf7LBXJlx9EI89V77fv4JeZ2zTcOdeQ+/3eNTzSPluUfaCJ2oN/yhsBEl8/5k3qG Mhq/1dsY6P74YfOXcAafekZARDzPpk47A82sIGg43T+JkGVxAN1CffbmKopbhBGccKOf+Ewp2JH1N zaAcahZmyFN3NIvSdswhJ5gB8i9MV4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8U4c-00GHNj-6F; Tue, 27 Jul 2021 20:53:10 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8U4Y-00GHMY-Bc for linux-arm-kernel@lists.infradead.org; Tue, 27 Jul 2021 20:53:07 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 16-20020a250b100000b029055791ebe1e6so79728ybl.20 for ; Tue, 27 Jul 2021 13:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=zSOPv7VXwurfPqCC6XQEUdLKqHkekrSYK+kbb6HkpL0=; b=r+LSYyAtgWwbbrJmOW/nGVUiaI7/wpKb9C8mchocm4Oo6caEV3zpDFYbMOFsYfgUbI br4V23D9UO+ZKRcLRhOCYycVMHX+smb7Udvr3VKZ1O19Hl7k+e/JEtS6/pABHpiDVjq/ uur75T29xO2RGH+wEjZynml2Boc5Lv9On7hnIbuWTh5FymZtmsEAzpUfImviMtMk1FZC xIHKMHwvdr7LQEQGHq39fgKJhCW1JtuMxpStJ5dJbYLsLvEFfK4rIFFoijansR81zOs+ fYlM/2Pu/r5NMS0uaEL96mYPUncXtNOXgixuPvEcqTLtAerW9c70Xechprplx7TkLfU9 aWBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=zSOPv7VXwurfPqCC6XQEUdLKqHkekrSYK+kbb6HkpL0=; b=cc8jApZetTf73CAQcmDUH3sc994W8YIuLYs1zeUY2QAPyA0K2Qtx/iyheHCO7olrrf sxr+7qOtz0KpWZGDJEFHshqTmlKyfH2M0+LiwUthfHjMpPSxNInEGaP9VSpaxNT6MS8O m9vvlKC9cecKEIOiQf/TGBgNCaOiPDhG9umDyl5Fzb6af8JVod9FzKmJwl3wQf35jbU6 Q2/5MnFoSzdiyKmX9ppuZ2S6U+sF/6hO0O2UWfyNcLrO5+kYvCNrviufJ68hLqcBhv1v kg128+v2jbGq1sE0cJgxRhB5O+9JFXt/oy3W1uEtvYfH/Nyyzr9OoXsu7ZYrjgeqQCCb PNsQ== X-Gm-Message-State: AOAM533mxZZd89lVuHzCSmRuEy30biqjBsAXWtPSedTOTlEWF9vb9p8R Ef73hKwHSK6Fs27+45RGqqiNr3M= X-Google-Smtp-Source: ABdhPJzP+dYVstmZ753Tc6awkJYO78BHm/fcixY1HQz7VE/EEEt3YSmzWUNHMeg5JgvMXgolj/z/Mg0= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:538:aa52:9b59:413b]) (user=pcc job=sendgmr) by 2002:a25:2fce:: with SMTP id v197mr23481278ybv.427.1627419184247; Tue, 27 Jul 2021 13:53:04 -0700 (PDT) Date: Tue, 27 Jul 2021 13:52:54 -0700 Message-Id: <20210727205300.2554659-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog Subject: [PATCH v11 0/5] arm64: mte: allow async MTE to be upgraded to sync on a per-CPU basis From: Peter Collingbourne To: Catalin Marinas , Vincenzo Frascino , Will Deacon Cc: Peter Collingbourne , Evgenii Stepanov , Szabolcs Nagy , Tejas Belagod , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210727_135306_477100_1806B584 X-CRM114-Status: GOOD ( 19.04 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. This is done by introducing a notion of a preferred TCF mode, which is controlled on a per-CPU basis by a sysfs node. The existing SYNC and ASYNC TCF settings are repurposed as bitfields that specify a set of possible modes. If the preferred TCF mode for a particular CPU is in the user-provided mode set (this will always be the case for mode sets containing more than one mode because the kernel only supports two tag checking modes, but future kernels may support more modes) then that mode is used when running on that CPU, otherwise one of the modes in the task's mode set will be selected in a currently unspecified manner. v8: - split into multiple patches - remove MTE_CTRL_TCF_NONE - improve documentation - disable preemption and add comment to mte_update_sctlr_user - bring back PR_MTE_TCF_SHIFT for source compatibility - address formatting nit v7: - switch to new API proposed on list v6: - switch to strings in sysfs nodes instead of TCF values 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 Peter Collingbourne (5): arm64: mte: rename gcr_user_excl to mte_ctrl arm64: mte: change ASYNC and SYNC TCF settings into bitfields arm64: move preemption disablement to prctl handlers arm64: mte: introduce a per-CPU tag checking mode preference Documentation: document the preferred tag checking mode feature .../ABI/testing/sysfs-devices-system-cpu | 18 +++ .../arm64/memory-tagging-extension.rst | 48 +++++- arch/arm64/include/asm/pointer_auth.h | 12 +- arch/arm64/include/asm/processor.h | 10 +- arch/arm64/kernel/asm-offsets.c | 2 +- arch/arm64/kernel/entry.S | 4 +- arch/arm64/kernel/mte.c | 139 ++++++++++++------ arch/arm64/kernel/pointer_auth.c | 10 +- arch/arm64/kernel/process.c | 21 +-- include/uapi/linux/prctl.h | 11 +- 10 files changed, 189 insertions(+), 86 deletions(-)