Path: blob/master/arch/powerpc/include/asm/cpu_has_feature.h
26481 views
/* SPDX-License-Identifier: GPL-2.0 */1#ifndef __ASM_POWERPC_CPU_HAS_FEATURE_H2#define __ASM_POWERPC_CPU_HAS_FEATURE_H34#ifndef __ASSEMBLY__56#include <linux/bug.h>7#include <asm/cputable.h>89static __always_inline bool early_cpu_has_feature(unsigned long feature)10{11return !!((CPU_FTRS_ALWAYS & feature) ||12(CPU_FTRS_POSSIBLE & cur_cpu_spec->cpu_features & feature));13}1415#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECKS16#include <linux/jump_label.h>1718#define NUM_CPU_FTR_KEYS BITS_PER_LONG1920extern struct static_key_true cpu_feature_keys[NUM_CPU_FTR_KEYS];2122static __always_inline bool cpu_has_feature(unsigned long feature)23{24int i;2526BUILD_BUG_ON(!__builtin_constant_p(feature));27BUILD_BUG_ON(__builtin_popcountl(feature) > 1);2829#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG30if (!static_key_feature_checks_initialized) {31printk("Warning! cpu_has_feature() used prior to jump label init!\n");32dump_stack();33return early_cpu_has_feature(feature);34}35#endif3637if (CPU_FTRS_ALWAYS & feature)38return true;3940if (!(CPU_FTRS_POSSIBLE & feature))41return false;4243i = __builtin_ctzl(feature);44return static_branch_likely(&cpu_feature_keys[i]);45}46#else47static __always_inline bool cpu_has_feature(unsigned long feature)48{49return early_cpu_has_feature(feature);50}51#endif5253#endif /* __ASSEMBLY__ */54#endif /* __ASM_POWERPC_CPU_HAS_FEATURE_H */555657