All of lore.kernel.org
 help / color / mirror / Atom feed
From: james.morse@arm.com (James Morse)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 4/6] arm64: kernel: Add min_register_value and use '>=' for feature detection
Date: Fri, 17 Jul 2015 18:30:19 +0100	[thread overview]
Message-ID: <1437154221-5736-5-git-send-email-james.morse@arm.com> (raw)
In-Reply-To: <1437154221-5736-1-git-send-email-james.morse@arm.com>

When a new cpu feature is available, the cpu feature bits will have some
initial value, which is incremented when the feature is updated.
This patch changes 'register_value' to be 'min_register_value', and checks
the feature bits value (interpreted as a signed int) is greater than this
minimum.

Signed-off-by: James Morse <james.morse@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/cpufeature.h |  4 ++--
 arch/arm64/kernel/cpufeature.c      | 14 +++++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 7456fc44bee1..ef38e21ed719 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -42,8 +42,8 @@ struct arm64_cpu_capabilities {
 		};
 
 		struct {	/* Feature register checking */
-			u64 register_mask;
-			u64 register_value;
+			u8 register_shift;
+			u8 min_register_value;
 		};
 	};
 };
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 650ffc28bedc..cc26d6c6520b 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -23,12 +23,20 @@
 #include <asm/cpufeature.h>
 
 static bool
+feature_matches(u64 reg, const struct arm64_cpu_capabilities *entry)
+{
+	int val = cpuid_feature_extract_field(reg, entry->register_shift);
+
+	return (val >= entry->min_register_value);
+}
+
+static bool
 has_id_aa64pfr0_feature(const struct arm64_cpu_capabilities *entry)
 {
 	u64 val;
 
 	val = read_cpuid(id_aa64pfr0_el1);
-	return (val & entry->register_mask) == entry->register_value;
+	return feature_matches(val, entry);
 }
 
 static const struct arm64_cpu_capabilities arm64_features[] = {
@@ -36,8 +44,8 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		.desc = "GIC system register CPU interface",
 		.capability = ARM64_HAS_SYSREG_GIC_CPUIF,
 		.matches = has_id_aa64pfr0_feature,
-		.register_mask = (0xf << 24),
-		.register_value = (1 << 24),
+		.register_shift = 24,
+		.min_register_value = 1,
 	},
 	{},
 };
-- 
2.1.4

  parent reply	other threads:[~2015-07-17 17:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17 17:30 [PATCH v2 0/6] arm64: kernel: Add support for Privileged Access Never James Morse
2015-07-17 17:30 ` [PATCH v2 1/6] arm64: kernel: Add cpuid_feature_extract_field() for 4bit sign extension James Morse
2015-07-20 11:32   ` Catalin Marinas
2015-07-20 13:20     ` Catalin Marinas
2015-07-17 17:30 ` [PATCH v2 2/6] arm64: kernel: preparatory: Move config_sctlr_el1 James Morse
2015-07-17 17:30 ` [PATCH v2 3/6] arm64: kernel: Add cpufeature 'enable' callback James Morse
2015-07-17 17:30 ` James Morse [this message]
2015-07-20 13:53   ` [PATCH v2 4/6] arm64: kernel: Add min_register_value and use '>=' for feature detection Catalin Marinas
2015-07-17 17:30 ` [PATCH v2 5/6] arm64: kernel: Add optional CONFIG_ parameter to ALTERNATIVE() James Morse
2015-07-17 17:30 ` [PATCH v2 6/6] arm64: kernel: Add support for Privileged Access Never James Morse
2015-07-20 14:01   ` Catalin Marinas
2015-07-21 10:30   ` Suzuki K. Poulose
2015-07-21 11:37     ` Catalin Marinas
2015-07-22  9:54       ` [PATCH] arm64: sys_reg() : Fix encoding of system registers Suzuki K. Poulose
2015-07-22 10:07         ` Catalin Marinas
2015-07-22 10:20           ` Suzuki K. Poulose
2015-07-22 10:38           ` [PATCH] arm64: Generalise msr_s/mrs_s operations Suzuki K. Poulose
2015-07-20 11:02 ` [PATCH v2 0/6] arm64: kernel: Add support for Privileged Access Never Vladimir Murzin
2015-07-20 11:17   ` Catalin Marinas

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=1437154221-5736-5-git-send-email-james.morse@arm.com \
    --to=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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.