Skip to content

Commit

Permalink
From patchwork series 402038
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox Snowpatch committed Apr 8, 2024
1 parent 4db4221 commit bc3b184
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/cpu_has_feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static __always_inline bool cpu_has_feature(unsigned long feature)
#endif

#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG
if (!static_key_initialized) {
if (!static_key_feature_checks_initialized) {
printk("Warning! cpu_has_feature() used prior to jump label init!\n");
dump_stack();
return early_cpu_has_feature(feature);
Expand Down
2 changes: 2 additions & 0 deletions arch/powerpc/include/asm/feature-fixups.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ extern long __start___rfi_flush_fixup, __stop___rfi_flush_fixup;
extern long __start___barrier_nospec_fixup, __stop___barrier_nospec_fixup;
extern long __start__btb_flush_fixup, __stop__btb_flush_fixup;

extern bool static_key_feature_checks_initialized;

void apply_feature_fixups(void);
void update_mmu_feature_fixups(unsigned long mask);
void setup_feature_keys(void);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static __always_inline bool mmu_has_feature(unsigned long feature)
#endif

#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG
if (!static_key_initialized) {
if (!static_key_feature_checks_initialized) {
printk("Warning! mmu_has_feature() used prior to jump label init!\n");
dump_stack();
return early_mmu_has_feature(feature);
Expand Down
8 changes: 8 additions & 0 deletions arch/powerpc/lib/feature-fixups.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
#include <asm/firmware.h>
#include <asm/inst.h>

/*
* Used to generate warnings if mmu or cpu feature check functions that
* use static keys before they are initialized.
*/
bool static_key_feature_checks_initialized __read_mostly;
EXPORT_SYMBOL_GPL(static_key_feature_checks_initialized);

struct fixup_entry {
unsigned long mask;
unsigned long value;
Expand Down Expand Up @@ -679,6 +686,7 @@ void __init setup_feature_keys(void)
jump_label_init();
cpu_feature_keys_init();
mmu_feature_keys_init();
static_key_feature_checks_initialized = true;
}

static int __init check_features(void)
Expand Down

0 comments on commit bc3b184

Please sign in to comment.