aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2019-02-10 19:20:01 -0500
committerMichael Ellerman <mpe@ellerman.id.au>2019-02-21 08:10:15 -0500
commit8cfaf106918a8c13abb24c641556172afbb9545c (patch)
tree183583a54fc6ce283d9d3adcd8e7c58a362ce9b2
parent6fe243fe5157076f3b8d88a02f064b41a4b7eec2 (diff)
powerpc/64s: Fix logic when handling unknown CPU features
In cpufeatures_process_feature(), if a provided CPU feature is unknown and enable_unknown is false, we erroneously print that the feature is being enabled and return true, even though no feature has been enabled, and may also set feature bits based on the last entry in the match table. Fix this so that we only set feature bits from the match table if we have actually enabled a feature from that table, and when failing to enable an unknown feature, always print the "not enabling" message and return false. Coincidentally, some older gccs (<GCC 7), when invoked with -fsanitize-coverage=trace-pc, cause a spurious uninitialised variable warning in this function: arch/powerpc/kernel/dt_cpu_ftrs.c: In function ‘cpufeatures_process_feature’: arch/powerpc/kernel/dt_cpu_ftrs.c:686:7: warning: ‘m’ may be used uninitialized in this function [-Wmaybe-uninitialized] if (m->cpu_ftr_bit_mask) An upcoming patch will enable support for kcov, which requires this option. This patch avoids the warning. Fixes: 5a61ef74f269 ("powerpc/64s: Support new device tree binding for discovering CPU features") Reported-by: Segher Boessenkool <segher@kernel.crashing.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> [ajd: add commit message] Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
-rw-r--r--arch/powerpc/kernel/dt_cpu_ftrs.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/arch/powerpc/kernel/dt_cpu_ftrs.c b/arch/powerpc/kernel/dt_cpu_ftrs.c
index 8be3721d9302..e49bd5efcfe6 100644
--- a/arch/powerpc/kernel/dt_cpu_ftrs.c
+++ b/arch/powerpc/kernel/dt_cpu_ftrs.c
@@ -666,8 +666,10 @@ static bool __init cpufeatures_process_feature(struct dt_cpu_feature *f)
666 m = &dt_cpu_feature_match_table[i]; 666 m = &dt_cpu_feature_match_table[i];
667 if (!strcmp(f->name, m->name)) { 667 if (!strcmp(f->name, m->name)) {
668 known = true; 668 known = true;
669 if (m->enable(f)) 669 if (m->enable(f)) {
670 cur_cpu_spec->cpu_features |= m->cpu_ftr_bit_mask;
670 break; 671 break;
672 }
671 673
672 pr_info("not enabling: %s (disabled or unsupported by kernel)\n", 674 pr_info("not enabling: %s (disabled or unsupported by kernel)\n",
673 f->name); 675 f->name);
@@ -675,17 +677,12 @@ static bool __init cpufeatures_process_feature(struct dt_cpu_feature *f)
675 } 677 }
676 } 678 }
677 679
678 if (!known && enable_unknown) { 680 if (!known && (!enable_unknown || !feat_try_enable_unknown(f))) {
679 if (!feat_try_enable_unknown(f)) { 681 pr_info("not enabling: %s (unknown and unsupported by kernel)\n",
680 pr_info("not enabling: %s (unknown and unsupported by kernel)\n", 682 f->name);
681 f->name); 683 return false;
682 return false;
683 }
684 } 684 }
685 685
686 if (m->cpu_ftr_bit_mask)
687 cur_cpu_spec->cpu_features |= m->cpu_ftr_bit_mask;
688
689 if (known) 686 if (known)
690 pr_debug("enabling: %s\n", f->name); 687 pr_debug("enabling: %s\n", f->name);
691 else 688 else