Skip to content

Commit 7f24298

Browse files
mrutland-armctmarinas
authored andcommitted
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. Signed-off-by: Mark Rutland <[email protected]> Reviewed-by: Mark Brown <[email protected]> Reviewed-by: Suzuki K Poulose <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 44c026a commit 7f24298

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

arch/arm64/include/asm/cpufeature.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ extern struct arm64_ftr_reg arm64_ftr_reg_ctrel0;
107107
* CPU capabilities:
108108
*
109109
* We use arm64_cpu_capabilities to represent system features, errata work
110-
* arounds (both used internally by kernel and tracked in cpu_hwcaps) and
110+
* arounds (both used internally by kernel and tracked in system_cpucaps) and
111111
* ELF HWCAPs (which are exposed to user).
112112
*
113113
* 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)
419419
return is_vhe_hyp_code() || is_nvhe_hyp_code();
420420
}
421421

422-
extern DECLARE_BITMAP(cpu_hwcaps, ARM64_NCAPS);
422+
extern DECLARE_BITMAP(system_cpucaps, ARM64_NCAPS);
423423

424-
extern DECLARE_BITMAP(boot_capabilities, ARM64_NCAPS);
424+
extern DECLARE_BITMAP(boot_cpucaps, ARM64_NCAPS);
425425

426426
#define for_each_available_cap(cap) \
427-
for_each_set_bit(cap, cpu_hwcaps, ARM64_NCAPS)
427+
for_each_set_bit(cap, system_cpucaps, ARM64_NCAPS)
428428

429429
bool this_cpu_has_cap(unsigned int cap);
430430
void cpu_set_feature(unsigned int num);
@@ -449,7 +449,7 @@ static __always_inline bool cpus_have_cap(unsigned int num)
449449
{
450450
if (num >= ARM64_NCAPS)
451451
return false;
452-
return arch_test_bit(num, cpu_hwcaps);
452+
return arch_test_bit(num, system_cpucaps);
453453
}
454454

455455
/*
@@ -510,7 +510,7 @@ static inline void cpus_set_cap(unsigned int num)
510510
pr_warn("Attempt to set an illegal CPU capability (%d >= %d)\n",
511511
num, ARM64_NCAPS);
512512
} else {
513-
__set_bit(num, cpu_hwcaps);
513+
__set_bit(num, system_cpucaps);
514514
}
515515
}
516516

arch/arm64/include/asm/mmu_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static inline void cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap)
164164
* up (i.e. cpufeature framework is not up yet) and
165165
* latter only when we enable CNP via cpufeature's
166166
* enable() callback.
167-
* Also we rely on the cpu_hwcap bit being set before
167+
* Also we rely on the system_cpucaps bit being set before
168168
* calling the enable() function.
169169
*/
170170
ttbr1 |= TTBR_CNP_BIT;

arch/arm64/kernel/alternative.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static void __apply_alternatives(const struct alt_region *region,
192192
bitmap_or(applied_alternatives, applied_alternatives,
193193
feature_mask, ARM64_NCAPS);
194194
bitmap_and(applied_alternatives, applied_alternatives,
195-
cpu_hwcaps, ARM64_NCAPS);
195+
system_cpucaps, ARM64_NCAPS);
196196
}
197197
}
198198

@@ -239,7 +239,7 @@ static int __init __apply_alternatives_multi_stop(void *unused)
239239
} else {
240240
DECLARE_BITMAP(remaining_capabilities, ARM64_NCAPS);
241241

242-
bitmap_complement(remaining_capabilities, boot_capabilities,
242+
bitmap_complement(remaining_capabilities, boot_cpucaps,
243243
ARM64_NCAPS);
244244

245245
BUG_ON(all_alternatives_applied);
@@ -274,7 +274,7 @@ void __init apply_boot_alternatives(void)
274274
pr_info("applying boot alternatives\n");
275275

276276
__apply_alternatives(&kernel_alternatives, false,
277-
&boot_capabilities[0]);
277+
&boot_cpucaps[0]);
278278
}
279279

280280
#ifdef CONFIG_MODULES

arch/arm64/kernel/cpufeature.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ unsigned int compat_elf_hwcap __read_mostly = COMPAT_ELF_HWCAP_DEFAULT;
105105
unsigned int compat_elf_hwcap2 __read_mostly;
106106
#endif
107107

108-
DECLARE_BITMAP(cpu_hwcaps, ARM64_NCAPS);
109-
EXPORT_SYMBOL(cpu_hwcaps);
108+
DECLARE_BITMAP(system_cpucaps, ARM64_NCAPS);
109+
EXPORT_SYMBOL(system_cpucaps);
110110
static struct arm64_cpu_capabilities const __ro_after_init *cpu_hwcaps_ptrs[ARM64_NCAPS];
111111

112-
DECLARE_BITMAP(boot_capabilities, ARM64_NCAPS);
112+
DECLARE_BITMAP(boot_cpucaps, ARM64_NCAPS);
113113

114114
bool arm64_use_ng_mappings = false;
115115
EXPORT_SYMBOL(arm64_use_ng_mappings);
@@ -137,7 +137,7 @@ static cpumask_var_t cpu_32bit_el0_mask __cpumask_var_read_mostly;
137137
void dump_cpu_features(void)
138138
{
139139
/* file-wide pr_fmt adds "CPU features: " prefix */
140-
pr_emerg("0x%*pb\n", ARM64_NCAPS, &cpu_hwcaps);
140+
pr_emerg("0x%*pb\n", ARM64_NCAPS, &system_cpucaps);
141141
}
142142

143143
#define ARM64_CPUID_FIELDS(reg, field, min_value) \
@@ -2906,7 +2906,7 @@ static void update_cpu_capabilities(u16 scope_mask)
29062906
cpus_set_cap(caps->capability);
29072907

29082908
if ((scope_mask & SCOPE_BOOT_CPU) && (caps->type & SCOPE_BOOT_CPU))
2909-
set_bit(caps->capability, boot_capabilities);
2909+
set_bit(caps->capability, boot_cpucaps);
29102910
}
29112911
}
29122912

@@ -3207,7 +3207,7 @@ EXPORT_SYMBOL_GPL(this_cpu_has_cap);
32073207
/*
32083208
* This helper function is used in a narrow window when,
32093209
* - The system wide safe registers are set with all the SMP CPUs and,
3210-
* - The SYSTEM_FEATURE cpu_hwcaps may not have been set.
3210+
* - The SYSTEM_FEATURE system_cpucaps may not have been set.
32113211
* In all other cases cpus_have_{const_}cap() should be used.
32123212
*/
32133213
static bool __maybe_unused __system_matches_cap(unsigned int n)

0 commit comments

Comments
 (0)