Merge tag 'arm64-perf' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[linux-2.6-block.git] / arch / arm64 / kernel / cpu_errata.c
index 06afd04e02c0d05f1e0546230a5d446b8bb06b60..d42789499f17eb322a47da83046ca0119e643c75 100644 (file)
 #include <asm/cpufeature.h>
 
 static bool __maybe_unused
-is_affected_midr_range(const struct arm64_cpu_capabilities *entry)
+is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope)
 {
+       WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
        return MIDR_IS_CPU_MODEL_RANGE(read_cpuid_id(), entry->midr_model,
                                       entry->midr_range_min,
                                       entry->midr_range_max);
 }
 
 #define MIDR_RANGE(model, min, max) \
+       .def_scope = SCOPE_LOCAL_CPU, \
        .matches = is_affected_midr_range, \
        .midr_model = model, \
        .midr_range_min = min, \
@@ -101,6 +103,26 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
        }
 };
 
+/*
+ * The CPU Errata work arounds are detected and applied at boot time
+ * and the related information is freed soon after. If the new CPU requires
+ * an errata not detected at boot, fail this CPU.
+ */
+void verify_local_cpu_errata(void)
+{
+       const struct arm64_cpu_capabilities *caps = arm64_errata;
+
+       for (; caps->matches; caps++)
+               if (!cpus_have_cap(caps->capability) &&
+                       caps->matches(caps, SCOPE_LOCAL_CPU)) {
+                       pr_crit("CPU%d: Requires work around for %s, not detected"
+                                       " at boot time\n",
+                               smp_processor_id(),
+                               caps->desc ? : "an erratum");
+                       cpu_die_early();
+               }
+}
+
 void check_local_cpu_errata(void)
 {
        update_cpu_capabilities(arm64_errata, "enabling workaround for");