mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-02 23:56:42 +07:00
c812c7d8f1
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>
54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
#ifndef __ASM_POWERPC_CPUFEATURES_H
|
|
#define __ASM_POWERPC_CPUFEATURES_H
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#include <linux/bug.h>
|
|
#include <asm/cputable.h>
|
|
|
|
static inline bool early_cpu_has_feature(unsigned long feature)
|
|
{
|
|
return !!((CPU_FTRS_ALWAYS & feature) ||
|
|
(CPU_FTRS_POSSIBLE & cur_cpu_spec->cpu_features & feature));
|
|
}
|
|
|
|
#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECKS
|
|
#include <linux/jump_label.h>
|
|
|
|
#define NUM_CPU_FTR_KEYS 64
|
|
|
|
extern struct static_key_true cpu_feature_keys[NUM_CPU_FTR_KEYS];
|
|
|
|
static __always_inline bool cpu_has_feature(unsigned long feature)
|
|
{
|
|
int i;
|
|
|
|
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;
|
|
|
|
if (!(CPU_FTRS_POSSIBLE & feature))
|
|
return false;
|
|
|
|
i = __builtin_ctzl(feature);
|
|
return static_branch_likely(&cpu_feature_keys[i]);
|
|
}
|
|
#else
|
|
static inline bool cpu_has_feature(unsigned long feature)
|
|
{
|
|
return early_cpu_has_feature(feature);
|
|
}
|
|
#endif
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
#endif /* __ASM_POWERPC_CPUFEATURE_H */
|