arch/arm64/kernel/cpufeature.c
Source file repositories/reference/linux-study-clean/arch/arm64/kernel/cpufeature.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kernel/cpufeature.c- Extension
.c- Size
- 146752 bytes
- Lines
- 4216
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bsearch.hlinux/cpumask.hlinux/crash_dump.hlinux/kstrtox.hlinux/sort.hlinux/stop_machine.hlinux/sysfs.hlinux/types.hlinux/minmax.hlinux/mm.hlinux/cpu.hlinux/kasan.hlinux/percpu.hlinux/sched/isolation.hasm/arm_pmuv3.hasm/cpu.hasm/cpufeature.hasm/cpu_ops.hasm/fpsimd.hasm/hwcap.hasm/insn.hasm/kvm_host.hasm/mmu.hasm/mmu_context.hasm/mpam.hasm/mte.hasm/hypervisor.hasm/processor.hasm/smp.hasm/sysreg.hasm/traps.hasm/vectors.h
Detected Declarations
function dump_cpu_featuresfunction search_cmp_ftr_regfunction sys_regfunction sys_regfunction arm64_ftr_set_valuefunction arm64_ftr_safe_valuefunction sort_ftr_regsfunction init_cpu_ftr_regfunction init_cpucap_indirect_list_from_arrayfunction init_cpucap_indirect_listfunction init_32bit_cpu_featuresfunction early_enable_pseudo_nmifunction detect_system_supports_pseudo_nmifunction detect_system_supports_pseudo_nmifunction init_cpu_featuresfunction update_cpu_ftr_regfunction check_update_ftr_regfunction relax_cpu_ftr_regfunction lazy_init_32bit_cpu_featuresfunction update_32bit_cpu_featuresfunction update_cpu_featuresfunction id_aa64pfr0_svefunction id_aa64pfr1_mtefunction read_sanitised_ftr_regfunction __read_sysreg_by_encodingfunction has_alwaysfunction feature_matchesfunction read_scoped_sysregfunction has_user_cpuid_featurefunction has_cpuid_featurefunction parse_32bit_el0_paramfunction aarch32_el0_showfunction aarch32_el0_sysfs_initfunction has_32bit_el0function has_useable_gicv3_cpuiffunction has_cache_idcfunction cpu_emulate_effective_ctrfunction has_cache_dicfunction has_useable_cnpfunction unmap_kernel_at_el0function this_cpu_has_capfunction has_nv1function has_lpa2_at_stage1function has_lpa2_at_stage2function has_lpa2function has_lpa2function has_pmuv3function cpu_enable_kpti
Annotated Snippet
device_initcall(aarch32_el0_sysfs_init);
static bool has_32bit_el0(const struct arm64_cpu_capabilities *entry, int scope)
{
if (!has_cpuid_feature(entry, scope))
return allow_mismatched_32bit_el0;
if (scope == SCOPE_SYSTEM)
pr_info("detected: 32-bit EL0 Support\n");
return true;
}
static bool has_useable_gicv3_cpuif(const struct arm64_cpu_capabilities *entry, int scope)
{
bool has_sre;
if (!has_cpuid_feature(entry, scope))
return false;
has_sre = gic_enable_sre();
if (!has_sre)
pr_warn_once("%s present but disabled by higher exception level\n",
entry->desc);
return has_sre;
}
static bool has_cache_idc(const struct arm64_cpu_capabilities *entry,
int scope)
{
u64 ctr;
if (scope == SCOPE_SYSTEM)
ctr = arm64_ftr_reg_ctrel0.sys_val;
else
ctr = read_cpuid_effective_cachetype();
return ctr & BIT(CTR_EL0_IDC_SHIFT);
}
static void cpu_emulate_effective_ctr(const struct arm64_cpu_capabilities *__unused)
{
/*
* If the CPU exposes raw CTR_EL0.IDC = 0, while effectively
* CTR_EL0.IDC = 1 (from CLIDR values), we need to trap accesses
* to the CTR_EL0 on this CPU and emulate it with the real/safe
* value.
*/
if (!(read_cpuid_cachetype() & BIT(CTR_EL0_IDC_SHIFT)))
sysreg_clear_set(sctlr_el1, SCTLR_EL1_UCT, 0);
}
static bool has_cache_dic(const struct arm64_cpu_capabilities *entry,
int scope)
{
u64 ctr;
if (scope == SCOPE_SYSTEM)
ctr = arm64_ftr_reg_ctrel0.sys_val;
else
ctr = read_cpuid_cachetype();
return ctr & BIT(CTR_EL0_DIC_SHIFT);
}
static bool __maybe_unused
has_useable_cnp(const struct arm64_cpu_capabilities *entry, int scope)
{
/*
* Kdump isn't guaranteed to power-off all secondary CPUs, CNP
* may share TLB entries with a CPU stuck in the crashed
* kernel.
*/
if (is_kdump_kernel())
return false;
if (cpus_have_cap(ARM64_WORKAROUND_DISABLE_CNP))
return false;
return has_cpuid_feature(entry, scope);
}
static bool __meltdown_safe = true;
static int __kpti_forced; /* 0: not forced, >0: forced on, <0: forced off */
static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
int scope)
{
/* List of CPUs that are not vulnerable and don't need KPTI */
Annotation
- Immediate include surface: `linux/bsearch.h`, `linux/cpumask.h`, `linux/crash_dump.h`, `linux/kstrtox.h`, `linux/sort.h`, `linux/stop_machine.h`, `linux/sysfs.h`, `linux/types.h`.
- Detected declarations: `function dump_cpu_features`, `function search_cmp_ftr_reg`, `function sys_reg`, `function sys_reg`, `function arm64_ftr_set_value`, `function arm64_ftr_safe_value`, `function sort_ftr_regs`, `function init_cpu_ftr_reg`, `function init_cpucap_indirect_list_from_array`, `function init_cpucap_indirect_list`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.