From patchwork Thu Jan 27 13:40:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Murzin X-Patchwork-Id: 12726816 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 9646AC433F5 for ; Thu, 27 Jan 2022 13:42:45 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gwsBaFZqviaGols8EYjdD3S5ynvgRL+emzies3wOdZU=; b=T2X0N1a0h9Sg01 KYaiIPu58AUe2fnvcn+5OpJcqHrOVP3C/g5dNOv/eXy7uWt8xXFRYKmoNEIXP0T9aeRY/GQXG474Q M+YtG+r7tF2BbIZv3PI7b0DRXanw2MoBVg0uGU7s2pZns6b2lGgX6h8ijDqmWuv50EqUQGPvP8dm4 pHBGFcw2aNf0Z8gnEat7qF47FluGBBvDZCsG2Hup12qY6ZpNmsxdhlGhqRQ+ul/0ROerdGCsxPi2o FzNYu/LrH79nBkuM5eiRnkOacxZDiOShUjXlY32BjEB/EWJ5jnm9wghUU4uBtULf8cRP2fAjxQEzQ H3wPsMjQhHJ4G327x/vA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nD51g-00FwMI-0Z; Thu, 27 Jan 2022 13:41:24 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nD513-00FwCJ-1z for linux-arm-kernel@lists.infradead.org; Thu, 27 Jan 2022 13:40:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AAD2F11D4; Thu, 27 Jan 2022 05:40:41 -0800 (PST) Received: from login2.euhpc.arm.com (login2.euhpc.arm.com [10.6.27.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E05BD3F766; Thu, 27 Jan 2022 05:40:40 -0800 (PST) From: Vladimir Murzin To: linux-arm-kernel@lists.infradead.org Cc: maz@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, will@kernel.org Subject: [PATCH 2/4] arm64: cpufeature: Warn if mutually exclusive PAuth algorithms detected Date: Thu, 27 Jan 2022 13:40:18 +0000 Message-Id: <20220127134020.62787-3-vladimir.murzin@arm.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20220127134020.62787-1-vladimir.murzin@arm.com> References: <20220127134020.62787-1-vladimir.murzin@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220127_054045_186771_7DE5E191 X-CRM114-Status: UNSURE ( 8.05 ) X-CRM114-Notice: Please train this message. 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 ARM ARM states for address authentication algorithms APA, bits [7:4] If the value of ID_AA64ISAR1_EL1.API is non-zero, this field must have the value 0b0000. API, bits [11:8] If the value of ID_AA64ISAR1_EL1.APA is non-zero, this field must have the value 0b0000. Similarly for generic code authentication algorithms GPA, bits [27:24] If the value of ID_AA64ISAR1_EL1.GPI is non-zero, this field must have the value 0b0000. GPI, bits [31:28] If the value of ID_AA64ISAR1_EL1.GPA is non-zero, this field must have the value 0b0000. Let's add a warning if that not true. Signed-off-by: Vladimir Murzin --- arch/arm64/kernel/cpufeature.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index b0ec125..9dad0a3 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1832,15 +1832,23 @@ static bool has_address_auth_cpucap(const struct arm64_cpu_capabilities *entry, static bool has_address_auth_metacap(const struct arm64_cpu_capabilities *entry, int scope) { - return has_address_auth_cpucap(cpu_hwcaps_ptrs[ARM64_HAS_ADDRESS_AUTH_ARCH], scope) || - has_address_auth_cpucap(cpu_hwcaps_ptrs[ARM64_HAS_ADDRESS_AUTH_IMP_DEF], scope); + bool api = has_address_auth_cpucap(cpu_hwcaps_ptrs[ARM64_HAS_ADDRESS_AUTH_IMP_DEF], scope); + bool apa = has_address_auth_cpucap(cpu_hwcaps_ptrs[ARM64_HAS_ADDRESS_AUTH_ARCH], scope); + + WARN_ON(apa && api); + + return apa || api; } static bool has_generic_auth(const struct arm64_cpu_capabilities *entry, int __unused) { - return __system_matches_cap(ARM64_HAS_GENERIC_AUTH_ARCH) || - __system_matches_cap(ARM64_HAS_GENERIC_AUTH_IMP_DEF); + bool gpi = __system_matches_cap(ARM64_HAS_GENERIC_AUTH_IMP_DEF); + bool gpa = __system_matches_cap(ARM64_HAS_GENERIC_AUTH_ARCH); + + WARN_ON(gpa && gpi); + + return gpa || gpi; } #endif /* CONFIG_ARM64_PTR_AUTH */