From patchwork Tue Sep 14 21:54:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12494941 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, 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 7CC0BC43217 for ; Tue, 14 Sep 2021 21:56:35 +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 4FB8160F11 for ; Tue, 14 Sep 2021 21:56:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4FB8160F11 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=NbIJu6iJiWe88QSFftoZjyLKS2jSU4DBZqi4blp2PsM=; b=giy o1AEhBxN3PgxTRAuye0YmQ+UdMHf8/mVQ0lSYgIheyDSPHvaa+ugpLgfrliyhJtJmEZw1PgCV+WrN XoKd1zMPC8e5QKMIycXeD4BZsjbyzh3dBeTi3A09saP4ClwVVtW7kYDIkoQid3nygJFYDRUbPji2g jz08i+nSm36uK2Bag00Fhzt6ILTrUjTAL6fQCnpP9ndo9SyWY+erhupXUSNjnwQPJ7r4Rp3WFKSrP ZvjlIcGxWjfPIlFoZsvJLY5yKs0rGoQzoO+X4nCpUuQfdVol6oD6z35LqoX1MvIXbvkNJLvBZNB8k hNplao+5xkdVdJmU23JgGH+sBwwbgmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQGOD-007DJZ-8q; Tue, 14 Sep 2021 21:54:53 +0000 Received: from mail-qk1-x749.google.com ([2607:f8b0:4864:20::749]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQGNy-007DHj-R2 for linux-arm-kernel@lists.infradead.org; Tue, 14 Sep 2021 21:54:40 +0000 Received: by mail-qk1-x749.google.com with SMTP id 21-20020a370815000000b003d5a81a4d12so1131237qki.3 for ; Tue, 14 Sep 2021 14:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=xPlG6dLB0Zr7ZndM7pbYeT0mbKa4AGO4kFvUu4nI8Xg=; b=bCwwdpW4KGRnetlGaX70AioutZDimfi+E6jqZoAesoM9Lep1OR6033pI1Yb1TSDzT3 touyL6cvZcniMBGvfP3W/Tn/rZImZjtJLZ/rnxOQGn0l6Ycq0ANbOGEy0iLAhE6y3rVA hJmIFwuNlyScxpyWkXOZ4uhCbgqXaySe7wKfMP9l4GJiRca/xcusGgDUBVOT1n63s4eJ hXp2m3ihlxePyCYLYkdbv1yG/Q04x/A735QrrY9e4rzwkgs8kZvLX7wNOhwu3PUrgsK0 iJqdYtTC6EAHnAuHD5TJ+eWN02/j55uXS39BpwtLw2PrfZN/H1odVJBWKHFuMuHKiv4s +9xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=xPlG6dLB0Zr7ZndM7pbYeT0mbKa4AGO4kFvUu4nI8Xg=; b=VjEmWjwBVrxg/dA1u+G84PTJWUcIQIfXzb8VQQYyAc5HK6VlBTctIoHZ2iutHsykuH as7A1VDxLA3RdW6un67YmIVFfXVXZJK1ldghcTVAoGQbrVHxeaBHT771+hnZtWbV7eWK ARe1IaWSvdS0nFrYRQ9Ky+1CnuGNXhH+WTlPBInCplNEIK81frGKplG2pEluUPowamQf CPdOsGXeR+rAYn9UZcBwBdGFjlQ9RixMsnwlQPuGTdDlc/f6iRkiMODAMntLdxCsx6QN O/okI6GxIKq/u9+2wCTgYdYpp6Ll9GuBvdKGi5W8GOgK7lVrm9iyr15aAbEOWupmUqWQ mBmg== X-Gm-Message-State: AOAM533a0QwIn43w7ndyOUHTKS23ITCVt4Y1Polqu3UUB2fw7WPMNj6O PLsStqsduyJmc8lmUaqU0+WmSUg= X-Google-Smtp-Source: ABdhPJxw/XepP+Z80QEYWVP5/wFDpPYgWrp7WDLEfjpyoq7HnewEh5sGx/R/Kf5rTM+NCaRDF+PLxvI= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:42fd:ba5d:d2c8:ab5]) (user=pcc job=sendgmr) by 2002:a05:6214:734:: with SMTP id c20mr7823648qvz.13.1631656476573; Tue, 14 Sep 2021 14:54:36 -0700 (PDT) Date: Tue, 14 Sep 2021 14:54:28 -0700 Message-Id: <20210914215429.745849-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v2 1/2] arm64: add an MTE support check to the top of mte_thread_switch() From: Peter Collingbourne To: Catalin Marinas , Vincenzo Frascino , Will Deacon , Andrey Konovalov Cc: Peter Collingbourne , Evgenii Stepanov , linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210914_145438_913604_24E5FA9A X-CRM114-Status: GOOD ( 11.43 ) 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 This lets us avoid doing unnecessary work on hardware that does not support MTE, and will allow us to freely use MTE instructions in the code called by mte_thread_switch(). Signed-off-by: Peter Collingbourne Link: https://linux-review.googlesource.com/id/I02fd000d1ef2c86c7d2952a7f099b254ec227a5d --- arch/arm64/kernel/mte.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c index 9d314a3bad3b..8fc2d90eeb00 100644 --- a/arch/arm64/kernel/mte.c +++ b/arch/arm64/kernel/mte.c @@ -199,6 +199,9 @@ void mte_thread_init_user(void) void mte_thread_switch(struct task_struct *next) { + if (!system_supports_mte()) + return; + mte_update_sctlr_user(next); /*