@@ -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
@@ -22,6 +22,13 @@ static __always_inline bool cpu_has_feature(unsigned long feature)
{
int i;
+#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 __cpu_has_feature(feature);
+ }
+#endif
if (CPU_FTRS_ALWAYS & feature)
return true;
@@ -153,6 +153,13 @@ static __always_inline bool mmu_has_feature(unsigned long feature)
{
int i;
+#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 __mmu_has_feature(feature);
+ }
+#endif
if (!(MMU_FTRS_POSSIBLE & feature))
return false;
@@ -164,6 +171,13 @@ static inline void mmu_clear_feature(unsigned long feature)
{
int i;
+#ifdef CONFIG_FEATURE_FIXUP_DEBUG
+ if (!static_key_initialized) {
+ WARN_ON(1);
+ cur_cpu_spec->mmu_features &= ~feature;
+ return;
+ }
+#endif
i = __builtin_ctzl(feature);
cur_cpu_spec->mmu_features &= ~feature;
static_branch_disable(&mmu_feature_keys[i]);