From patchwork Mon Jan 31 17:06:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Murzin X-Patchwork-Id: 12730954 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 A0709C433EF for ; Mon, 31 Jan 2022 17:31:22 +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=cvE+DK2V3UvKWM 9mW6RnxQCP0G6X8RfMqZnONsnOIFw5wMpV2LznPHnD7zGn7v7yTClYNfgtFjpzBQud8iK8quWYs7q g5htEiQYM04W7rnR7wDoiyYCszuH5lh/b/n9ZgkX6CAcRC1KkrI/8R3eTs2fFc4zzcTLGwnxq1Hh+ 2Pfn5BnVxic+YzpdFufwGOAK9wVIfthGef3OD224hg2+WtdvsqASRd5+Rkx16r8qiJ2buhWsMRs1P nfLhlQFyGCL6+4s5CBQ6qWAiFC61wreKWhf5BCnezRAh0Jkpb3TneWd1kDlcsxDbCV9H3c9OaN+c+ fPD/KhFx8S9j7MUYyG0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nEaUk-00A7j8-Ea; Mon, 31 Jan 2022 17:29:40 +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 1nEa93-00A052-Qd for linux-arm-kernel@lists.infradead.org; Mon, 31 Jan 2022 17:07:17 +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 D9FF013D5; Mon, 31 Jan 2022 09:07:10 -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 1BDA93F73B; Mon, 31 Jan 2022 09:07:10 -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 v2 2/4] arm64: cpufeature: Warn if mutually exclusive PAuth algorithms detected Date: Mon, 31 Jan 2022 17:06:52 +0000 Message-Id: <20220131170654.62381-3-vladimir.murzin@arm.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20220131170654.62381-1-vladimir.murzin@arm.com> References: <20220131170654.62381-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-20220131_090713_966792_179E5BBF X-CRM114-Status: UNSURE ( 8.69 ) 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 Acked-by: Catalin Marinas --- 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 */