diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2016-07-23 05:12:43 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-07-31 21:15:06 -0400 |
commit | c812c7d8f1470ac9c8aa6d7e29b56e5845ee05fc (patch) | |
tree | 9df953d954d85946488f41cbd202865535805eb4 /arch/powerpc | |
parent | c12e6f24d4137822d5019c1f78ac65bd27a3447d (diff) |
powerpc/mm: Catch usage of cpu/mmu_has_feature() before jump label init
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>
Diffstat (limited to 'arch/powerpc')
-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 | |||
69 | feature checks. This should generate more optimal code for those | 69 | feature checks. This should generate more optimal code for those |
70 | checks. | 70 | checks. |
71 | 71 | ||
72 | config JUMP_LABEL_FEATURE_CHECK_DEBUG | ||
73 | bool "Do extra check on feature fixup calls" | ||
74 | depends on DEBUG_KERNEL && JUMP_LABEL_FEATURE_CHECKS | ||
75 | default n | ||
76 | help | ||
77 | This tries to catch incorrect usage of cpu_has_feature() and | ||
78 | mmu_has_feature() in the code. | ||
79 | |||
80 | If you don't know what this means, say N. | ||
81 | |||
72 | config FTR_FIXUP_SELFTEST | 82 | config FTR_FIXUP_SELFTEST |
73 | bool "Run self-tests of the feature-fixup code" | 83 | bool "Run self-tests of the feature-fixup code" |
74 | depends on DEBUG_KERNEL | 84 | 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) | |||
25 | 25 | ||
26 | BUILD_BUG_ON(!__builtin_constant_p(feature)); | 26 | BUILD_BUG_ON(!__builtin_constant_p(feature)); |
27 | 27 | ||
28 | #ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG | ||
29 | if (!static_key_initialized) { | ||
30 | printk("Warning! cpu_has_feature() used prior to jump label init!\n"); | ||
31 | dump_stack(); | ||
32 | return early_cpu_has_feature(feature); | ||
33 | } | ||
34 | #endif | ||
35 | |||
28 | if (CPU_FTRS_ALWAYS & feature) | 36 | if (CPU_FTRS_ALWAYS & feature) |
29 | return true; | 37 | return true; |
30 | 38 | ||
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) | |||
156 | 156 | ||
157 | BUILD_BUG_ON(!__builtin_constant_p(feature)); | 157 | BUILD_BUG_ON(!__builtin_constant_p(feature)); |
158 | 158 | ||
159 | #ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG | ||
160 | if (!static_key_initialized) { | ||
161 | printk("Warning! mmu_has_feature() used prior to jump label init!\n"); | ||
162 | dump_stack(); | ||
163 | return early_mmu_has_feature(feature); | ||
164 | } | ||
165 | #endif | ||
166 | |||
159 | if (!(MMU_FTRS_POSSIBLE & feature)) | 167 | if (!(MMU_FTRS_POSSIBLE & feature)) |
160 | return false; | 168 | return false; |
161 | 169 | ||