From patchwork Tue May 28 22:51:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13677520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 58F59C25B78 for ; Tue, 28 May 2024 22:51:50 +0000 (UTC) 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=60N3sEBC5wmMW56Wy0PFxQ6WKc5AnOYT6/6ruxZMntk=; b=ueq 7K017nOEoFesiiwzqUQ1/vnd+bBnOY2Dl2YM784r6qnn6Bez2lYniZaIih+xKuj7180xlPLkVHzHY xEfRA4BSJXvGddEXMpGTW/K9Bl8LO/bC3RIflcsYVpgyylfkJv/BV+2CCgh8NDBE9NRt6CrBmNuDA 9p8+shbXrAtPLJvUMfhXVGJnLICY75leD/ZUvKJctpfcnyiYt323ZV+Xoq7q2qeH5G7o1PvhbqdsO J6vZ/0Y01nQJR+JcA/ASStj2vpBS6e5jghh058RvmCCc3xcK9ulWW3bCBvRDO1hdMmabv42mlZivz kqbIm/FJHcufKhpV531eI7Z9HFdDIbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sC5fQ-00000002FQ4-0lEY; Tue, 28 May 2024 22:51:40 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sC5fN-00000002FPL-0JIs for linux-arm-kernel@lists.infradead.org; Tue, 28 May 2024 22:51:38 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-df7719a8e7dso2312826276.1 for ; Tue, 28 May 2024 15:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716936694; x=1717541494; darn=lists.infradead.org; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=L4GE3SwrPmlJTaR9vDiMzLafNPpwwIWwF3DHkgMnQME=; b=ZR2+BC9XaAyLSaICRT4CA380P/gF1JcWV2hnRojDReu5FIFHZan4eaUQfahSMFeKdV jFH4WFI28e/tMff7ihr0Ex75gYD/onRSd4b2ycAiwDQRzs8CllrpmQKnrpyMZHLvca3Q hCKYcFdvIG90WI+vi17eI5CF8UKhmiNNm19/QIyN8Dyx+Z2VqPXYdCsOvI+CvKTZmY3/ 9YCITE2KWpQTMBxjiCZhaMIQFx1VQyvwb3q007+hMuNGMQ0Qq4AnfUvq/SvqD0lD+oFp OTEZ0zhL8vtRXOxbbX/pynfMH1jlSaTzIHXj/HlfBTyS4VfgdjUgJcU77zNOHutRLCPm 8kxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716936694; x=1717541494; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=L4GE3SwrPmlJTaR9vDiMzLafNPpwwIWwF3DHkgMnQME=; b=ctvSEqJiu1wIUDJ5XJXdVW1RXWqV0KC1cgZz5A1fx5mK+6qBK4plUL/oSAkKAQqj0m KUr4qxivg70wEhlKtW7hu9Mz6nUYnZ3LVeR21uI7pMfC7BizrwY96XTqUElDOyyivew3 8dnEP9hmrDY7gHmqGIhuOCRUPYvFbm6J9AErnUoccjtAtwRrkwapLWfO3wlJopgGxjFY tkLk8GAeQKDdwOCQFEAIDPjUkDE8+Ml6IeDm7SbBR8N/rziDkNvMTB8EnkCkk5WQNo2r vXnhLQr/QnOGdlSpftFinIEn0Z84dYzQFlyW3E55y0CtOa5acY/PSAZSzE8eV8Y7hpc3 /rvg== X-Forwarded-Encrypted: i=1; AJvYcCUHNRfFftFXRIdZ7HR2QmmWyOUuA1hPT2ZnDBIRs95p5Dq5T6Y6Y2s11Pr64meJOY5ffc1cVfk0hObFvTais1/ppAG9BBs+nIUNOF2X/Gp7TGU0ilk= X-Gm-Message-State: AOJu0YwXzUePjf3g8ZaijzCndqOMMPg3mNUOOBfm1OU27HRXWnHrQl/v jvjlHEVDJ5H1j2CSEHjIA5qggO9s6mEV8wmPUY+2Yi/jIm3ObDbuAgInKw1kMdZ+pg== X-Google-Smtp-Source: AGHT+IGm98TFKUM4Mqe7aMPrEY7vWkP/jBjtmsuaQQzH+sGkFkofy8vqtXkOppzrCVgQh6mkr6MFFW0= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:af23:b8ba:4733:d752]) (user=pcc job=sendgmr) by 2002:a25:2d10:0:b0:deb:cad4:723c with SMTP id 3f1490d57ef6-df77219fe10mr3833931276.7.1716936694362; Tue, 28 May 2024 15:51:34 -0700 (PDT) Date: Tue, 28 May 2024 15:51:30 -0700 Message-Id: <20240528225131.3577704-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Subject: [PATCH] arm64: mte: Make mte_check_tfsr_*() conditional on KASAN instead of MTE From: Peter Collingbourne To: Catalin Marinas , Will Deacon Cc: Peter Collingbourne , linux-arm-kernel@lists.infradead.org, Evgenii Stepanov , Alexandru Elisei X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240528_155137_143371_07104F5F X-CRM114-Status: GOOD ( 14.86 ) 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 The check in mte_check_tfsr_el1() is only necessary if HW tag based KASAN is enabled. However, we were also executing the check if MTE is enabled and KASAN is enabled at build time but disabled at runtime. This turned out to cause a measurable increase in power consumption on a specific microarchitecture after enabling MTE. Moreover, on the same system, an increase in invalid syscall latency (as measured by [1]) of around 20-30% (depending on the cluster) was observed after enabling MTE; this almost entirely goes away after removing this check. Therefore, make the check conditional on whether KASAN is enabled rather than on whether MTE is enabled. [1] https://lore.kernel.org/all/CAMn1gO4MwRV8bmFJ_SeY5tsYNPn2ZP56LjAhafygjFaKuu5ouw@mail.gmail.com/ Signed-off-by: Peter Collingbourne Link: https://linux-review.googlesource.com/id/I22d98d1483dd400a95595946552b769a5a1ad7bd Reviewed-by: Alexandru Elisei --- arch/arm64/include/asm/mte.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/mte.h b/arch/arm64/include/asm/mte.h index 91fbd5c8a3911..0f84518632b4a 100644 --- a/arch/arm64/include/asm/mte.h +++ b/arch/arm64/include/asm/mte.h @@ -182,7 +182,7 @@ void mte_check_tfsr_el1(void); static inline void mte_check_tfsr_entry(void) { - if (!system_supports_mte()) + if (!kasan_hw_tags_enabled()) return; mte_check_tfsr_el1(); @@ -190,7 +190,7 @@ static inline void mte_check_tfsr_entry(void) static inline void mte_check_tfsr_exit(void) { - if (!system_supports_mte()) + if (!kasan_hw_tags_enabled()) return; /*