]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
powerpc/mm: Catch usage of cpu/mmu_has_feature() before jump label init
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Sat, 23 Jul 2016 09:12:43 +0000 (14:42 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 1 Aug 2016 01:15:06 +0000 (11:15 +1000)
This allows us to catch incorrect usage of cpu_has_feature() and
mmu_has_feature() prior to jump labels being initialised.

mpe: Use printk() and dump_stack() rather than WARN_ON(), because
WARN_ON() may not work this early in boot. Rename the Kconfig.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/Kconfig.debug
arch/powerpc/include/asm/cpu_has_feature.h
arch/powerpc/include/asm/mmu.h

index 36d7e345f5996e8de5e97fe0c9d3e4ac3c6f35a4..63292f64b25a384f716ae7aaf08f90d927765ca5 100644 (file)
@@ -69,6 +69,16 @@ config JUMP_LABEL_FEATURE_CHECKS
          feature checks. This should generate more optimal code for those
          checks.
 
+config JUMP_LABEL_FEATURE_CHECK_DEBUG
+       bool "Do extra check on feature fixup calls"
+       depends on DEBUG_KERNEL && JUMP_LABEL_FEATURE_CHECKS
+       default n
+       help
+         This tries to catch incorrect usage of cpu_has_feature() and
+         mmu_has_feature() in the code.
+
+         If you don't know what this means, say N.
+
 config FTR_FIXUP_SELFTEST
        bool "Run self-tests of the feature-fixup code"
        depends on DEBUG_KERNEL
index 039c011b4252ea75827a56e8f2b5ad68cfa5afc0..2ef55f8968a2b1fba3f34ce7312e07ce8eb42287 100644 (file)
@@ -25,6 +25,14 @@ static __always_inline bool cpu_has_feature(unsigned long feature)
 
        BUILD_BUG_ON(!__builtin_constant_p(feature));
 
+#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG
+       if (!static_key_initialized) {
+               printk("Warning! cpu_has_feature() used prior to jump label init!\n");
+               dump_stack();
+               return early_cpu_has_feature(feature);
+       }
+#endif
+
        if (CPU_FTRS_ALWAYS & feature)
                return true;
 
index 1bf919aafd50f1912d54d56fd50756280302f48c..e2fb408f83983617591e3fe3511f9691b76f0b3d 100644 (file)
@@ -156,6 +156,14 @@ static __always_inline bool mmu_has_feature(unsigned long feature)
 
        BUILD_BUG_ON(!__builtin_constant_p(feature));
 
+#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG
+       if (!static_key_initialized) {
+               printk("Warning! mmu_has_feature() used prior to jump label init!\n");
+               dump_stack();
+               return early_mmu_has_feature(feature);
+       }
+#endif
+
        if (!(MMU_FTRS_POSSIBLE & feature))
                return false;