diff options
-rw-r--r-- | arch/powerpc/Kconfig.debug | 10 | ||||
-rw-r--r-- | arch/powerpc/include/asm/cpu_has_feature.h | 8 | ||||
-rw-r--r-- | arch/powerpc/include/asm/mmu.h | 8 |
3 files changed, 26 insertions, 0 deletions
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug index 36d7e345f599..63292f64b25a 100644 --- a/arch/powerpc/Kconfig.debug +++ b/arch/powerpc/Kconfig.debug @@ -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 diff --git a/arch/powerpc/include/asm/cpu_has_feature.h b/arch/powerpc/include/asm/cpu_has_feature.h index 039c011b4252..2ef55f8968a2 100644 --- a/arch/powerpc/include/asm/cpu_has_feature.h +++ b/arch/powerpc/include/asm/cpu_has_feature.h @@ -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; diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index 1bf919aafd50..e2fb408f8398 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h @@ -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; |