From patchwork Fri Jul 2 19:41:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12356437 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.1 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 7F5B0C07E96 for ; Fri, 2 Jul 2021 19:43:41 +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 50264613EB for ; Fri, 2 Jul 2021 19:43:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50264613EB Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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: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=kdmaHNoZupzbT44PsiU2VMF2neJ/ePM6cUTLLxn3rD4=; b=kXP TNFUHKFJ/5XQeRA59vrTXKfxQIGnP6nWjSSqSnmtVBr3d8iNiEfPL1QckisjCABU6IFE5Esd34ySc KgrbqtTtzSVSj78W7kZ2VIN8C7b6kC4j5Jv7LQ38aCt0jHT1n8p38rketDHnZPtftY5Ijrsx2biAj WkXE1A1lhxyJLgYWGq2ABYhPhuiHgHx33lYBpDcST5sO+tNAxOVp9C8Psss2gvjub92fnRVOdTKUs sKp7dCmjAJEs+MDs9BdoESIC5PWiepgeGEJpDBkJjqjjAHVWWzh+OCIhWXY8jjin45bkYwZgCpSwn Hzhyen9WAajSCGBUY51NeBXzwBAFQOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzP2S-003tQN-Jh; Fri, 02 Jul 2021 19:41:24 +0000 Received: from mail-qk1-x74a.google.com ([2607:f8b0:4864:20::74a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzP2P-003tPW-DC for linux-arm-kernel@lists.infradead.org; Fri, 02 Jul 2021 19:41:22 +0000 Received: by mail-qk1-x74a.google.com with SMTP id r190-20020a375dc70000b02903acea04c19fso7518574qkb.8 for ; Fri, 02 Jul 2021 12:41:19 -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=Kaq/Lhi5EcELL7+FmfN1bYvV+Bg3xpd4vNm8p9aSezY=; b=jNbaCoD8ZZsgc+2cavudNJ7HWfQM/N7U+N/BSB9c95VyM0TpN/Zt8fr+JMiMXZM5In fNdT2szxcAXqamEVWF/T+/MUCwkLYgvAu9kI/wzmigj+N+/4V9XWHEKDdjUxt5z/ZhwE tI0MM/0PbbtokqjP0rmTKMK9WCmdZJeDNBS7gYI7JlSJPDKrdK+zJ4Cnaz9CwnfcG3yR JZ8PvE7UT7ryRKfoTI0ojlhmr7qKzjt/SsL+IoTtCINMb6Z5dcVVLr3y3RoHpqQKu0W2 0FOJo7nXanaIIod/sG1WRiErhfwubs5bHxMEDJx2j96VSWUN9MR8DRj4vm3GQIBuecvL a8BQ== 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=Kaq/Lhi5EcELL7+FmfN1bYvV+Bg3xpd4vNm8p9aSezY=; b=Ug01VyfqpAbjXA268gb2T5as3QogBQ1nFQcZInpe5EfaNzfNoinA/3T/N8k5YkKf6v +OKI1pw7Q0P4HVR/US0bhr2IS/f9c22c6kSJcxr6Yx9+gE3l2K/IS8Dgb87H9pZJS0J0 kVBJWeQbPefdjKlZqNiLs/Ipjeq/e5BqD6AAbvlBTn19GbcllEUNs37qKUlmywuoN/nr 2QEiF0rTIjzWa5k9vMrN8d3VkW55B7M0wwDZuXFwC/OnCp/dzH3Qn0LlSNP8Pkvh/Uy6 TkMhbA48g9QfmiocSuuPUROVMaO9v2Rz/iKhMsWNKR1HxaqVQ0iMIkgyoXLI669KvtE7 JkWQ== X-Gm-Message-State: AOAM533mpFUjhAD8Yhh2tfabdeI3DwD4/odGfHRMuhlBeZidKD6cjZgB BdVw+jk/StHiPI9ldhTyQMiM9is= X-Google-Smtp-Source: ABdhPJy8/8dSCKbPLHIrqCUo85v7LwchEJ8aUSMLc6HDzRQpuMET6N4eN72sGk7W2WNthK5Qtq6VIOU= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:7c5b:5407:a2db:c8fb]) (user=pcc job=sendgmr) by 2002:ad4:4682:: with SMTP id bq2mr1179848qvb.34.1625254878433; Fri, 02 Jul 2021 12:41:18 -0700 (PDT) Date: Fri, 2 Jul 2021 12:41:06 -0700 Message-Id: <20210702194110.2045282-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog Subject: [PATCH v9 0/4] 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-20210702_124121_511677_2FDBB108 X-CRM114-Status: GOOD ( 18.88 ) 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 (4): arm64: mte: rename gcr_user_excl to mte_ctrl arm64: mte: change ASYNC and SYNC TCF settings into bitfields arm64: mte: introduce a per-CPU tag checking mode preference Documentation: document the preferred tag checking mode feature .../ABI/testing/sysfs-devices-system-cpu | 16 ++ .../arm64/memory-tagging-extension.rst | 48 +++++- arch/arm64/include/asm/processor.h | 8 +- arch/arm64/kernel/asm-offsets.c | 2 +- arch/arm64/kernel/entry.S | 4 +- arch/arm64/kernel/mte.c | 149 ++++++++++++------ include/uapi/linux/prctl.h | 11 +- 7 files changed, 178 insertions(+), 60 deletions(-)