arm64: cpucap cleanup
Mark Rutland
reviewerv2 cover arm64: cpucap cleanup
Currently arm64 uses inconsistent terminology when handling cpucaps, with different places in the code referring to these as "capabilities", "features", "cpufeatures", "hwcaps", and "cpu_hwcaps" with the latter two easily being confused with the ELF hwcaps.
Similarly, the bitmaps used to store the boot and system cpucaps are named "boot_capabilities" and "cpu_hwcaps" respectively.
All of this is unnecessarily confusing.
This series tries to apply a consistent "cpucap" naming scheme, following the example of "asm/cpucaps.h" where the cpucap values are defined. This clearly separates these from the ELF hwcaps, and makes it easier to understand the code.
I've split this out from a larger rework of the cpucap logic, as that larger rework isn't yet ready and I think this stands on its own as a nice cleanup.
There should be no functional change as a result of this series.
Thanks,
Mark.
Since v1 [1]:
* Fold in Reviewed-by tags
* Move mmu_context.h comment change to patch 1
[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/
Mark Rutland (4):
arm64: standardise cpucap bitmap names
arm64: alternatives: use cpucap naming
arm64: cpufeature: use cpucap naming
arm64: cpufeature: fold cpus_set_cap() into update_cpu_capabilities()
arch/arm64/include/asm/alternative-macros.h | 54 ++++++++++----------- arch/arm64/include/asm/alternative.h | 4 +- arch/arm64/include/asm/cpufeature.h | 24 +++------ arch/arm64/include/asm/irqflags.h | 2 +- arch/arm64/include/asm/lse.h | 2 +- arch/arm64/include/asm/mmu_context.h | 2 +- arch/arm64/kernel/alternative.c | 23 +++++---- arch/arm64/kernel/cpufeature.c | 53 ++++++++++---------- 8 files changed, 77 insertions(+), 87 deletions(-)
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mark Rutland
reviewerPATCH v2 1/4 arm64: standardise cpucap bitmap names
The 'cpu_hwcaps' and 'boot_capabilities' bitmaps are bitmaps have the same enumerated bits, but are named wildly differently for no good reason. The terms 'hwcaps' and 'capabilities' have become ambiguous over time (e.g. due to clashes with ELF hwcaps and the structures used to manage feature detection), and it would be nicer to use 'cpucaps', matching the <asm/cpucaps.h> header the enumerated bit indices are defined in.
While this isn't a functional problem, it makes the code harder than necessary to understand, and hard to extend with related functionality (e.g. per-cpu cpucap bitmaps).
To that end, this patch renames boot_capabilities to boot_cpucaps and cpu_hwcaps to system_cpucaps. This more clearly indicates the relationship between the two and aligns with terminology used elsewhere in our feature management code.
This change was scripted with:
| find . -type f -name '*.[chS]' -print0 | \ | xargs -0 sed -i 's/\<boot_capabilities\>/boot_cpucaps/' | find . -type f -name '*.[chS]' -print0 | \ | xargs -0 sed -i 's/\<cpu_hwcaps\>/system_cpucaps/'
... and the instance of "cpu_hwcap" (without a trailing "s") in <asm/mmu_context.h> corrected manually to "system_cpucaps".
Subsequent patches will adjust the naming of related functions to better align with the cpucap naming.
There should be no functional change as a result of this patch; this is purely a renaming exercise.
--- arch/arm64/include/asm/cpufeature.h | 12 ++++++------ arch/arm64/include/asm/mmu_context.h | 2 +- arch/arm64/kernel/alternative.c | 6 +++--- arch/arm64/kernel/cpufeature.c | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-)
arch/arm64/include/asm/cpufeature.h +6 -6
@@ -107,7 +107,7 @@ extern struct arm64_ftr_reg arm64_ftr_reg_ctrel0;* CPU capabilities: * * We use arm64_cpu_capabilities to represent system features, errata work -* arounds (both used internally by kernel and tracked in cpu_hwcaps) and +* arounds (both used internally by kernel and tracked in system_cpucaps) and * ELF HWCAPs (which are exposed to user). * * To support systems with heterogeneous CPUs, we need to make sure that we
@@ -419,12 +419,12 @@ static __always_inline bool is_hyp_code(void)return is_vhe_hyp_code () ||is_nvhe_hyp_code (); } -extern DECLARE_BITMAP(cpu_hwcaps, ARM64_NCAPS); +extern DECLARE_BITMAP(system_cpucaps, ARM64_NCAPS); -extern DECLARE_BITMAP(boot_capabilities, ARM64_NCAPS); +extern DECLARE_BITMAP(boot_cpucaps, ARM64_NCAPS);#define for_each_available_cap (cap) \ - for_each_set_bit(cap, cpu_hwcaps, ARM64_NCAPS) + for_each_set_bit(cap, system_cpucaps, ARM64_NCAPS)bool this_cpu_has_cap (unsigned int cap);void cpu_set_feature (unsigned int num);
@@ -449,7 +449,7 @@ static __always_inline bool cpus_have_cap(unsigned int num) {if (num >=ARM64_NCAPS )return false; -return arch_test_bit (num, cpu_hwcaps); +return arch_test_bit (num, system_cpucaps); }/*
@@ -510,7 +510,7 @@ static inline void cpus_set_cap(unsigned int num)pr_warn ("Attempt to set an illegal CPU capability (%d >= %d)\n" , num,ARM64_NCAPS ); }else { -__set_bit (num, cpu_hwcaps); +__set_bit (num, system_cpucaps); } }
arch/arm64/include/asm/mmu_context.h +1 -1
@@ -164,7 +164,7 @@ static inline void cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap)* up (i.e. cpufeature framework is not up yet) and * latter only when we enable CNP via cpufeature's * enable() callback. -* Also we rely on the cpu_hwcap bit being set before +* Also we rely on the system_cpucaps bit being set before * calling the enable() function. */ ttbr1 |=TTBR_CNP_BIT ;
arch/arm64/kernel/alternative.c +3 -3
@@ -192,7 +192,7 @@ static void __apply_alternatives(const struct alt_region *region,bitmap_or (applied_alternatives, applied_alternatives, feature_mask,ARM64_NCAPS );bitmap_and (applied_alternatives, applied_alternatives, - cpu_hwcaps,ARM64_NCAPS ); + system_cpucaps,ARM64_NCAPS ); } }
@@ -239,7 +239,7 @@ static int __init __apply_alternatives_multi_stop(void *unused) }else {DECLARE_BITMAP (remaining_capabilities,ARM64_NCAPS ); -bitmap_complement (remaining_capabilities, boot_capabilities, +bitmap_complement (remaining_capabilities, boot_cpucaps,ARM64_NCAPS );BUG_ON (all_alternatives_applied);
@@ -274,7 +274,7 @@ void __init apply_boot_alternatives(void)pr_info ("applying boot alternatives\n" );__apply_alternatives (&kernel_alternatives, false, - &boot_capabilities[0 ]); + &boot_cpucaps[0 ]); }#ifdef CONFIG_MODULES
arch/arm64/kernel/cpufeature.c +6 -6
@@ -105,11 +105,11 @@ unsigned int compat_elf_hwcap __read_mostly = COMPAT_ELF_HWCAP_DEFAULT;unsigned int compat_elf_hwcap2__read_mostly ;#endif -DECLARE_BITMAP (cpu_hwcaps,ARM64_NCAPS ); -EXPORT_SYMBOL (cpu_hwcaps); +DECLARE_BITMAP (system_cpucaps,ARM64_NCAPS ); +EXPORT_SYMBOL (system_cpucaps);static struct arm64_cpu_capabilities const __ro_after_init *cpu_hwcaps_ptrs[ARM64_NCAPS ]; -DECLARE_BITMAP (boot_capabilities,ARM64_NCAPS ); +DECLARE_BITMAP (boot_cpucaps,ARM64_NCAPS );bool arm64_use_ng_mappings = false;EXPORT_SYMBOL (arm64_use_ng_mappings);
@@ -137,7 +137,7 @@ static cpumask_var_t cpu_32bit_el0_mask __cpumask_var_read_mostly;void dump_cpu_features (void ) {/* file-wide pr_fmt adds "CPU features: " prefix */ -pr_emerg ("0x%*pb\n" ,ARM64_NCAPS , &cpu_hwcaps); +pr_emerg ("0x%*pb\n" ,ARM64_NCAPS , &system_cpucaps); }#define ARM64_CPUID_FIELDS (reg, field, min_value) \
@@ -2906,7 +2906,7 @@ static void update_cpu_capabilities(u16 scope_mask)cpus_set_cap (caps->capability);if ((scope_mask &SCOPE_BOOT_CPU ) && (caps->type &SCOPE_BOOT_CPU )) -set_bit (caps->capability, boot_capabilities); +set_bit (caps->capability, boot_cpucaps); } }
@@ -3207,7 +3207,7 @@ EXPORT_SYMBOL_GPL(this_cpu_has_cap);/* * This helper function is used in a narrow window when, * - The system wide safe registers are set with all the SMP CPUs and, -* - The SYSTEM_FEATURE cpu_hwcaps may not have been set. +* - The SYSTEM_FEATURE system_cpucaps may not have been set. * In all other cases cpus_have_{const_}cap() should be used. */ static bool __maybe_unused __system_matches_cap (unsigned int n)
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mark Rutland
reviewerPATCH v2 2/4 arm64: alternatives: use cpucap naming
In reply to Mark RutlandTo more clearly align the various users of the cpucap enumeration, this patch changes the alternative code to use the term cpucap in favour of feature. The alternative_has_feature_{likely,unlikely}() functions are renamed to alternative_has_cap_<likely,unlikely}() to more clearly align with the cpus_have_{const_,}cap() helpers.
At the same time remove the stale comment referring to the "ARM64_CB bit", which is evidently a typo for ARM64_CB_PATCH, which was removed in commit:
4c0bd995d73ed889 ("arm64: alternatives: have callbacks take a cap")
There should be no functional change as a result of this patch; this is purely a renaming exercise.
--- arch/arm64/include/asm/alternative-macros.h | 54 ++++++++++----------- arch/arm64/include/asm/alternative.h | 4 +- arch/arm64/include/asm/cpufeature.h | 4 +- arch/arm64/include/asm/irqflags.h | 2 +- arch/arm64/include/asm/lse.h | 2 +- arch/arm64/kernel/alternative.c | 17 +++---- 6 files changed, 41 insertions(+), 42 deletions(-)
arch/arm64/include/asm/alternative-macros.h +27 -27
@@ -23,17 +23,17 @@#include <linux/stringify.h> -#define ALTINSTR_ENTRY (feature) \ +#define ALTINSTR_ENTRY (cpucap) \ " .word 661b - .\n"/* label */ \" .word 663f - .\n" /* new instruction */ \ - " .hword " __stringify(feature) "\n" /* feature bit */ \ + " .hword " __stringify(cpucap) "\n" /* cpucap */ \" .byte 662b-661b\n" /* source len */ \ " .byte 664f-663f\n" /* replacement len */ -#define ALTINSTR_ENTRY_CB (feature, cb) \ +#define ALTINSTR_ENTRY_CB (cpucap, cb) \ " .word 661b - .\n"/* label */ \ - " .word " __stringify(cb) "- .\n" /* callback */ \ - " .hword " __stringify(feature) "\n" /* feature bit */ \ + " .word " __stringify(cb) "- .\n" /* callback */ \ + " .hword " __stringify(cpucap) "\n" /* cpucap */ \" .byte 662b-661b\n" /* source len */ \" .byte 664f-663f\n" /* replacement len */
@@ -53,13 +53,13 @@* * Alternatives with callbacks do not generate replacement instructions. */ -#define __ALTERNATIVE_CFG (oldinstr, newinstr, feature, cfg_enabled) \ +#define __ALTERNATIVE_CFG (oldinstr, newinstr, cpucap, cfg_enabled) \ ".if "__stringify(cfg_enabled)" == 1\n" \ "661:\n\t" \ oldinstr "\n" \ "662:\n" \ ".pushsection .altinstructions,\"a\"\n" \ - ALTINSTR_ENTRY(feature) \ + ALTINSTR_ENTRY(cpucap) \ ".popsection\n" \ ".subsection 1\n" \ "663:\n\t" \
@@ -70,31 +70,31 @@".previous\n" \ ".endif\n" -#define __ALTERNATIVE_CFG_CB (oldinstr, feature, cfg_enabled, cb) \ +#define __ALTERNATIVE_CFG_CB (oldinstr, cpucap, cfg_enabled, cb) \ ".if "__stringify(cfg_enabled)" == 1\n" \ "661:\n\t" \ oldinstr "\n" \ "662:\n" \ ".pushsection .altinstructions,\"a\"\n" \ - ALTINSTR_ENTRY_CB(feature, cb) \ + ALTINSTR_ENTRY_CB(cpucap, cb) \ ".popsection\n" \ "663:\n\t" \ "664:\n\t" \ ".endif\n" -#define _ALTERNATIVE_CFG (oldinstr, newinstr, feature, cfg, ...) \ - __ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg)) +#define _ALTERNATIVE_CFG (oldinstr, newinstr, cpucap, cfg, ...) \ + __ALTERNATIVE_CFG(oldinstr, newinstr, cpucap, IS_ENABLED(cfg)) -#define ALTERNATIVE_CB (oldinstr, feature, cb) \ - __ALTERNATIVE_CFG_CB(oldinstr, (1 << ARM64_CB_SHIFT) | (feature), 1, cb) +#define ALTERNATIVE_CB (oldinstr, cpucap, cb) \ + __ALTERNATIVE_CFG_CB(oldinstr, (1 << ARM64_CB_SHIFT) | (cpucap), 1, cb)#else #include <asm/assembler.h> -.macro altinstruction_entry orig_offset alt_offset feature orig_len alt_len +.macro altinstruction_entry orig_offset alt_offset cpucap orig_len alt_len .word \orig_offset - . .word \alt_offset - . - .hword (\feature) + .hword (\cpucap) .byte \orig_len .byte \alt_len .endm
@@ -210,9 +210,9 @@ alternative_endif#endif /* __ASSEMBLY__ */ /* -* Usage: asm(ALTERNATIVE(oldinstr, newinstr, feature)); +* Usage: asm(ALTERNATIVE(oldinstr, newinstr, cpucap)); * -* Usage: asm(ALTERNATIVE(oldinstr, newinstr, feature, CONFIG_FOO)); +* Usage: asm(ALTERNATIVE(oldinstr, newinstr, cpucap, CONFIG_FOO)); * N.B. If CONFIG_FOO is specified, but not selected, the whole block * will be omitted, including oldinstr. */
@@ -224,15 +224,15 @@ alternative_endif#include <linux/types.h> static __always_inline bool -alternative_has_feature_likely (const unsigned long feature) +alternative_has_cap_likely (const unsigned long cpucap) { -compiletime_assert (feature <ARM64_NCAPS , -"feature must be < ARM64_NCAPS" ); +compiletime_assert (cpucap <ARM64_NCAPS , +"cpucap must be < ARM64_NCAPS" );asm_volatile_goto ( - ALTERNATIVE_CB("b %l[l_no]", %[feature], alt_cb_patch_nops) + ALTERNATIVE_CB("b %l[l_no]", %[cpucap], alt_cb_patch_nops) : - : [feature] "i" (feature) + : [cpucap] "i" (cpucap) : : l_no);
@@ -242,15 +242,15 @@ alternative_has_feature_likely(const unsigned long feature) } static __always_inline bool -alternative_has_feature_unlikely (const unsigned long feature) +alternative_has_cap_unlikely (const unsigned long cpucap) { -compiletime_assert (feature <ARM64_NCAPS , -"feature must be < ARM64_NCAPS" ); +compiletime_assert (cpucap <ARM64_NCAPS , +"cpucap must be < ARM64_NCAPS" );asm_volatile_goto ( - ALTERNATIVE("nop", "b %l[l_yes]", %[feature]) + ALTERNATIVE("nop", "b %l[l_yes]", %[cpucap]) : - : [feature] "i" (feature) + : [cpucap] "i" (cpucap) : : l_yes);
arch/arm64/include/asm/alternative.h +2 -2
@@ -13,7 +13,7 @@struct alt_instr {s32 orig_offset;/* offset to original instruction */ s32 alt_offset;/* offset to replacement instruction */ -u16 cpufeature;/* cpufeature bit set for replacement */ +u16 cpucap;/* cpucap bit set for replacement */ u8 orig_len;/* size of original instruction(s) */ u8 alt_len;/* size of new instruction(s), <= orig_len */ };
@@ -23,7 +23,7 @@ typedef void (*alternative_cb_t)(struct alt_instr *alt,void __init apply_boot_alternatives (void );void __init apply_alternatives_all (void ); -bool alternative_is_applied (u16 cpufeature); +bool alternative_is_applied (u16 cpucap);#ifdef CONFIG_MODULES void apply_alternatives_module (void *start,size_t length);
arch/arm64/include/asm/cpufeature.h +2 -2
@@ -437,7 +437,7 @@ unsigned long cpu_get_elf_hwcap2(void); static __always_inline bool system_capabilities_finalized(void) { -return alternative_has_feature_likely (ARM64_ALWAYS_SYSTEM ); +return alternative_has_cap_likely (ARM64_ALWAYS_SYSTEM ); }/*
@@ -464,7 +464,7 @@ static __always_inline bool __cpus_have_const_cap(int num) {if (num >=ARM64_NCAPS )return false; -return alternative_has_feature_unlikely (num); +return alternative_has_cap_unlikely (num); }/*
arch/arm64/include/asm/irqflags.h +1 -1
@@ -24,7 +24,7 @@ static __always_inline bool __irqflags_uses_pmr(void) {return IS_ENABLED (CONFIG_ARM64_PSEUDO_NMI ) && -alternative_has_feature_unlikely (ARM64_HAS_GIC_PRIO_MASKING ); +alternative_has_cap_unlikely (ARM64_HAS_GIC_PRIO_MASKING ); } static __always_inline void __daif_local_irq_enable(void)
arch/arm64/include/asm/lse.h +1 -1
@@ -18,7 +18,7 @@ static __always_inline bool system_uses_lse_atomics(void) { -return alternative_has_feature_likely (ARM64_HAS_LSE_ATOMICS ); +return alternative_has_cap_likely (ARM64_HAS_LSE_ATOMICS ); }#define __lse_ll_sc_body (op, ...) \
arch/arm64/kernel/alternative.c +8 -9
@@ -24,8 +24,8 @@#define ALT_ORIG_PTR (a) __ALT_PTR(a, orig_offset)#define ALT_REPL_PTR (a) __ALT_PTR(a, alt_offset) -#define ALT_CAP (a) ((a)->cpufeature & ~ARM64_CB_BIT) -#define ALT_HAS_CB (a) ((a)->cpufeature & ARM64_CB_BIT) +#define ALT_CAP (a) ((a)->cpucap & ~ARM64_CB_BIT) +#define ALT_HAS_CB (a) ((a)->cpucap & ARM64_CB_BIT)/* Volatile, as we may be patching the guts of READ_ONCE() */ static volatile int all_alternatives_applied;
@@ -37,12 +37,12 @@ struct alt_region {struct alt_instr *end; }; -bool alternative_is_applied (u16 cpufeature) +bool alternative_is_applied (u16 cpucap) { -if (WARN_ON (cpufeature >=ARM64_NCAPS )) +if (WARN_ON (cpucap >=ARM64_NCAPS ))return false; -return test_bit (cpufeature, applied_alternatives); +return test_bit (cpucap, applied_alternatives); }/*
@@ -141,7 +141,7 @@ static void clean_dcache_range_nopatch(u64 start, u64 end)static void __apply_alternatives (const struct alt_region *region,bool is_module, -unsigned long *feature_mask) +unsigned long *cpucap_mask) {struct alt_instr *alt;__le32 *origptr, *updptr;
@@ -151,7 +151,7 @@ static void __apply_alternatives(const struct alt_region *region,int nr_inst;int cap =ALT_CAP (alt); -if (!test_bit (cap, feature_mask)) +if (!test_bit (cap, cpucap_mask))continue ;if (!cpus_have_cap (cap))
@@ -188,9 +188,8 @@ static void __apply_alternatives(const struct alt_region *region,icache_inval_all_pou ();isb (); -/* Ignore ARM64_CB bit from feature mask */ bitmap_or (applied_alternatives, applied_alternatives, - feature_mask,ARM64_NCAPS ); + cpucap_mask,ARM64_NCAPS );bitmap_and (applied_alternatives, applied_alternatives, system_cpucaps,ARM64_NCAPS ); }
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mark Rutland
reviewerPATCH v2 3/4 arm64: cpufeature: use cpucap naming
In reply to Mark RutlandTo more clearly align the various users of the cpucap enumeration, this patch changes the cpufeature code to use the term cpucap in favour of cpu_hwcap. This more clearly aligns with other users of the cpucaps, and avoids confusion with the ELF hwcaps.
There should be no functional change as a result of this patch; this is purely a renaming exercise.
--- arch/arm64/kernel/cpufeature.c | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-)
arch/arm64/kernel/cpufeature.c +19 -19
@@ -107,7 +107,7 @@ unsigned int compat_elf_hwcap2 __read_mostly;DECLARE_BITMAP (system_cpucaps,ARM64_NCAPS );EXPORT_SYMBOL (system_cpucaps); -static struct arm64_cpu_capabilities const __ro_after_init *cpu_hwcaps_ptrs[ARM64_NCAPS ]; +static struct arm64_cpu_capabilities const __ro_after_init *cpucap_ptrs[ARM64_NCAPS ];DECLARE_BITMAP (boot_cpucaps,ARM64_NCAPS );
@@ -954,24 +954,24 @@ extern const struct arm64_cpu_capabilities arm64_errata[];static const struct arm64_cpu_capabilities arm64_features[];static void __init -init_cpu_hwcaps_indirect_list_from_array (const struct arm64_cpu_capabilities *caps) +init_cpucap_indirect_list_from_array (const struct arm64_cpu_capabilities *caps) {for (; caps->matches; caps++) {if (WARN (caps->capability >=ARM64_NCAPS ,"Invalid capability %d\n" , caps->capability))continue ; -if (WARN (cpu_hwcaps_ptrs[caps->capability], +if (WARN (cpucap_ptrs[caps->capability],"Duplicate entry for capability %d\n" , caps->capability))continue ; - cpu_hwcaps_ptrs[caps->capability] = caps; + cpucap_ptrs[caps->capability] = caps; } } -static void __init init_cpu_hwcaps_indirect_list (void ) +static void __init init_cpucap_indirect_list (void ) { -init_cpu_hwcaps_indirect_list_from_array (arm64_features); -init_cpu_hwcaps_indirect_list_from_array (arm64_errata); +init_cpucap_indirect_list_from_array (arm64_features); +init_cpucap_indirect_list_from_array (arm64_errata); }static void __init setup_boot_cpu_capabilities (void );
@@ -1049,10 +1049,10 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info)init_cpu_ftr_reg (SYS_GMID_EL1 , info->reg_gmid);/* -* Initialize the indirect array of CPU hwcaps capabilities pointers -* before we handle the boot CPU below. +* Initialize the indirect array of CPU capabilities pointers before we +* handle the boot CPU below. */ -init_cpu_hwcaps_indirect_list (); +init_cpucap_indirect_list ();/* * Detect and enable early CPU capabilities based on the boot CPU,
@@ -2048,9 +2048,9 @@ static bool has_address_auth_cpucap(const struct arm64_cpu_capabilities *entry,static bool has_address_auth_metacap (const struct arm64_cpu_capabilities *entry,int scope) { -bool api =has_address_auth_cpucap (cpu_hwcaps_ptrs[ARM64_HAS_ADDRESS_AUTH_IMP_DEF ], scope); -bool apa =has_address_auth_cpucap (cpu_hwcaps_ptrs[ARM64_HAS_ADDRESS_AUTH_ARCH_QARMA5 ], scope); -bool apa3 =has_address_auth_cpucap (cpu_hwcaps_ptrs[ARM64_HAS_ADDRESS_AUTH_ARCH_QARMA3 ], scope); +bool api =has_address_auth_cpucap (cpucap_ptrs[ARM64_HAS_ADDRESS_AUTH_IMP_DEF ], scope); +bool apa =has_address_auth_cpucap (cpucap_ptrs[ARM64_HAS_ADDRESS_AUTH_ARCH_QARMA5 ], scope); +bool apa3 =has_address_auth_cpucap (cpucap_ptrs[ARM64_HAS_ADDRESS_AUTH_ARCH_QARMA3 ], scope);return apa || apa3 || api; }
@@ -2895,7 +2895,7 @@ static void update_cpu_capabilities(u16 scope_mask) scope_mask &=ARM64_CPUCAP_SCOPE_MASK ;for (i =0 ; i <ARM64_NCAPS ; i++) { - caps = cpu_hwcaps_ptrs[i]; + caps = cpucap_ptrs[i];if (!caps || !(caps->type & scope_mask) ||cpus_have_cap (caps->capability) || !caps->matches (caps,cpucap_default_scope (caps)))
@@ -2920,7 +2920,7 @@ static int cpu_enable_non_boot_scope_capabilities(void *__unused)u16 non_boot_scope =SCOPE_ALL & ~SCOPE_BOOT_CPU ;for_each_available_cap (i) { -const struct arm64_cpu_capabilities *cap = cpu_hwcaps_ptrs[i]; +const struct arm64_cpu_capabilities *cap = cpucap_ptrs[i];if (WARN_ON (!cap))continue ;
@@ -2950,7 +2950,7 @@ static void __init enable_cpu_capabilities(u16 scope_mask)for (i =0 ; i <ARM64_NCAPS ; i++) {unsigned int num; - caps = cpu_hwcaps_ptrs[i]; + caps = cpucap_ptrs[i];if (!caps || !(caps->type & scope_mask))continue ; num = caps->capability;
@@ -2995,7 +2995,7 @@ static void verify_local_cpu_caps(u16 scope_mask) scope_mask &=ARM64_CPUCAP_SCOPE_MASK ;for (i =0 ; i <ARM64_NCAPS ; i++) { - caps = cpu_hwcaps_ptrs[i]; + caps = cpucap_ptrs[i];if (!caps || !(caps->type & scope_mask))continue ;
@@ -3194,7 +3194,7 @@ static void __init setup_boot_cpu_capabilities(void)bool this_cpu_has_cap (unsigned int n) {if (!WARN_ON (preemptible ()) && n <ARM64_NCAPS ) { -const struct arm64_cpu_capabilities *cap = cpu_hwcaps_ptrs[n]; +const struct arm64_cpu_capabilities *cap = cpucap_ptrs[n];if (cap)return cap->matches (cap,SCOPE_LOCAL_CPU );
@@ -3213,7 +3213,7 @@ EXPORT_SYMBOL_GPL(this_cpu_has_cap);static bool __maybe_unused __system_matches_cap (unsigned int n) {if (n <ARM64_NCAPS ) { -const struct arm64_cpu_capabilities *cap = cpu_hwcaps_ptrs[n]; +const struct arm64_cpu_capabilities *cap = cpucap_ptrs[n];if (cap)return cap->matches (cap,SCOPE_SYSTEM );
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mark Rutland
reviewerPATCH v2 4/4 arm64: cpufeature: fold cpus_set_cap() into update_cpu_capabilities()
In reply to Mark RutlandWe only use cpus_set_cap() in update_cpu_capabilities(), where we open-code an analgous update to boot_cpucaps.
Due to the way the cpucap_ptrs[] array is initialized, we know that the capability number cannot be greater than or equal to ARM64_NCAPS, so the warning is superfluous.
Fold cpus_set_cap() into update_cpu_capabilities(), matching what we do for the boot_cpucaps, and making the relationship between the two a bit clearer.
There should be no functional change as a result of this patch.
--- arch/arm64/include/asm/cpufeature.h | 10 ---------- arch/arm64/kernel/cpufeature.c | 3 ++- 2 files changed, 2 insertions(+), 11 deletions(-)
arch/arm64/include/asm/cpufeature.h +0 -10
@@ -504,16 +504,6 @@ static __always_inline bool cpus_have_const_cap(int num)return cpus_have_cap (num); } -static inline void cpus_set_cap (unsigned int num) -{ -if (num >=ARM64_NCAPS ) { -pr_warn ("Attempt to set an illegal CPU capability (%d >= %d)\n" , - num,ARM64_NCAPS ); - }else { -__set_bit (num, system_cpucaps); - } -} - static inline int __attribute_const__cpuid_feature_extract_signed_field_width (u64 features,int field,int width) {
arch/arm64/kernel/cpufeature.c +2 -1
@@ -2903,7 +2903,8 @@ static void update_cpu_capabilities(u16 scope_mask)if (caps->desc)pr_info ("detected: %s\n" , caps->desc); -cpus_set_cap (caps->capability); + +__set_bit (caps->capability, system_cpucaps);if ((scope_mask &SCOPE_BOOT_CPU ) && (caps->type &SCOPE_BOOT_CPU ))set_bit (caps->capability, boot_cpucaps);
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 9 lines · Mark Rutland
Currently arm64 uses inconsistent terminology when handling cpucaps, with different places in the code referring to these as "capabilities", "features", "cpufeatures", "hwcaps", and "
cpu_hwcaps" with the latter two easily being confused with the ELF hwcaps.Similarly, the bitmaps used to store the boot and system cpucaps are named "
boot_capabilities" and "cpu_hwcaps" respectively.[...]
Applied to arm64 (for-next/cpucap), thanks!
[1/4] arm64: standardise cpucap bitmap names
https://git.kernel.org/arm64/c/7f242982e408 [2/4] arm64: alternatives: use cpucap naming https://git.kernel.org/arm64/c/5235c7e2cfcc [3/4] arm64: cpufeature: use cpucap naming https://git.kernel.org/arm64/c/1c8ae42975bd [4/4] arm64: cpufeature: fold cpus_set_cap() into update_cpu_capabilities() https://git.kernel.org/arm64/c/7dae5f086fce
Signature · 7 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel