All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Murzin <vladimir.murzin@arm.com>
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	[thread overview]
Message-ID: <20220131170654.62381-3-vladimir.murzin@arm.com> (raw)
In-Reply-To: <20220131170654.62381-1-vladimir.murzin@arm.com>

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 <vladimir.murzin@arm.com>
---
 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 */
 
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-01-31 17:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-31 17:06 [PATCH v2 0/4] arm64: Support of PAuth QARMA3 architected algorithm Vladimir Murzin
2022-01-31 17:06 ` [PATCH v2 1/4] arm64: cpufeature: Account min_field_value when cheking secondaries for PAuth Vladimir Murzin
2022-02-04 18:13   ` Catalin Marinas
2022-01-31 17:06 ` Vladimir Murzin [this message]
2022-02-04 18:16   ` [PATCH v2 2/4] arm64: cpufeature: Warn if mutually exclusive PAuth algorithms detected Catalin Marinas
2022-01-31 17:06 ` [PATCH v2 3/4] arm64: cpufeature: Mark existing PAuth architected algorithm as QARMA5 Vladimir Murzin
2022-02-04 18:18   ` Catalin Marinas
2022-01-31 17:06 ` [PATCH v2 4/4] arm64: Add support of PAuth QARMA3 architected algorithm Vladimir Murzin
2022-02-04 18:42   ` Catalin Marinas
2022-02-15 18:21   ` Will Deacon
2022-02-21 14:47     ` Vladimir Murzin
2022-02-22 21:50       ` Will Deacon
2022-02-23 11:20         ` Vladimir Murzin
2022-02-24  9:49           ` Will Deacon
2022-01-31 17:38 ` [PATCH v2 0/4] arm64: Support " Vladimir Murzin
2022-02-05 10:27 ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220131170654.62381-3-vladimir.murzin@arm.com \
    --to=vladimir.murzin@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.