arm64: alternative: Introduce feature for GICv3 CPU interface
authorMarc Zyngier <marc.zyngier@arm.com>
Fri, 12 Jun 2015 11:06:36 +0000 (12:06 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 12 Jun 2015 14:11:50 +0000 (15:11 +0100)
Add a new item to the feature set (ARM64_HAS_SYSREG_GIC_CPUIF)
to indicate that we have a system register GIC CPU interface

This will help KVM switching to alternative instruction patching.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/cpufeature.h
arch/arm64/kernel/cpufeature.c

index 82cb9f98ba1a3632ffbc87bff8681cb8a7eb24ff..c1044218a63a1598051d3d02b58d3241ec810cc1 100644 (file)
@@ -24,8 +24,9 @@
 #define ARM64_WORKAROUND_CLEAN_CACHE           0
 #define ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE   1
 #define ARM64_WORKAROUND_845719                        2
+#define ARM64_HAS_SYSREG_GIC_CPUIF             3
 
-#define ARM64_NCAPS                            3
+#define ARM64_NCAPS                            4
 
 #ifndef __ASSEMBLY__
 
@@ -38,6 +39,11 @@ struct arm64_cpu_capabilities {
                        u32 midr_model;
                        u32 midr_range_min, midr_range_max;
                };
+
+               struct {        /* Feature register checking */
+                       u64 register_mask;
+                       u64 register_value;
+               };
        };
 };
 
index 3d9967e43d896f7b2224952b007663d78a1b700b..5ad86ceac010167870ac8b3354f2711094b3864f 100644 (file)
 #include <asm/cpu.h>
 #include <asm/cpufeature.h>
 
+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;
+}
+
 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),
+       },
        {},
 };