arch/arm/mm/proc-v7-bugs.c
Source file repositories/reference/linux-study-clean/arch/arm/mm/proc-v7-bugs.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/mm/proc-v7-bugs.c- Extension
.c- Size
- 6793 bytes
- Lines
- 298
- Domain
- Architecture Layer
- Bucket
- arch/arm
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/arm-smccc.hlinux/kernel.hlinux/smp.hasm/cp15.hasm/cputype.hasm/proc-fns.hasm/spectre.hasm/system_misc.h
Detected Declarations
function spectre_v2_get_cpu_fw_mitigation_statefunction spectre_v2_get_cpu_fw_mitigation_statefunction harden_branch_predictor_bpiallfunction harden_branch_predictor_iciallufunction call_smc_arch_workaround_1function call_hvc_arch_workaround_1function spectre_v2_install_workaroundfunction spectre_v2_install_workaroundfunction cpu_v7_spectre_v2_initfunction spectre_bhb_install_workaroundfunction spectre_bhb_install_workaroundfunction cpu_v7_spectre_bhb_initfunction cpu_v7_check_auxcr_setfunction check_spectre_auxcrfunction cpu_v7_ca8_ibefunction cpu_v7_ca15_ibefunction cpu_v7_bugs_init
Annotated Snippet
if (read_cpuid_implementor() == ARM_CPU_IMP_ARM) {
state = SPECTRE_UNAFFECTED;
break;
}
fallthrough;
/* Cortex A57/A72 require firmware workaround */
case ARM_CPU_PART_CORTEX_A57:
case ARM_CPU_PART_CORTEX_A72:
state = spectre_v2_get_cpu_fw_mitigation_state();
if (state != SPECTRE_MITIGATED)
break;
switch (arm_smccc_1_1_get_conduit()) {
case SMCCC_CONDUIT_HVC:
method = SPECTRE_V2_METHOD_HVC;
break;
case SMCCC_CONDUIT_SMC:
method = SPECTRE_V2_METHOD_SMC;
break;
default:
state = SPECTRE_VULNERABLE;
break;
}
}
if (state == SPECTRE_MITIGATED)
state = spectre_v2_install_workaround(method);
spectre_v2_update_state(state, method);
}
#ifdef CONFIG_HARDEN_BRANCH_HISTORY
static int spectre_bhb_method;
static const char *spectre_bhb_method_name(int method)
{
switch (method) {
case SPECTRE_V2_METHOD_LOOP8:
return "loop";
case SPECTRE_V2_METHOD_BPIALL:
return "BPIALL";
default:
return "unknown";
}
}
static int spectre_bhb_install_workaround(int method)
{
if (spectre_bhb_method != method) {
if (spectre_bhb_method) {
pr_err("CPU%u: Spectre BHB: method disagreement, system vulnerable\n",
smp_processor_id());
return SPECTRE_VULNERABLE;
}
if (spectre_bhb_update_vectors(method) == SPECTRE_VULNERABLE)
return SPECTRE_VULNERABLE;
spectre_bhb_method = method;
pr_info("CPU%u: Spectre BHB: enabling %s workaround for all CPUs\n",
smp_processor_id(), spectre_bhb_method_name(method));
}
return SPECTRE_MITIGATED;
}
#else
static int spectre_bhb_install_workaround(int method)
{
return SPECTRE_VULNERABLE;
}
#endif
static void cpu_v7_spectre_bhb_init(void)
{
unsigned int state, method = 0;
switch (read_cpuid_part()) {
case ARM_CPU_PART_CORTEX_A15:
case ARM_CPU_PART_BRAHMA_B15:
case ARM_CPU_PART_CORTEX_A57:
case ARM_CPU_PART_CORTEX_A72:
state = SPECTRE_MITIGATED;
Annotation
- Immediate include surface: `linux/arm-smccc.h`, `linux/kernel.h`, `linux/smp.h`, `asm/cp15.h`, `asm/cputype.h`, `asm/proc-fns.h`, `asm/spectre.h`, `asm/system_misc.h`.
- Detected declarations: `function spectre_v2_get_cpu_fw_mitigation_state`, `function spectre_v2_get_cpu_fw_mitigation_state`, `function harden_branch_predictor_bpiall`, `function harden_branch_predictor_iciallu`, `function call_smc_arch_workaround_1`, `function call_hvc_arch_workaround_1`, `function spectre_v2_install_workaround`, `function spectre_v2_install_workaround`, `function cpu_v7_spectre_v2_init`, `function spectre_bhb_install_workaround`.
- Atlas domain: Architecture Layer / arch/arm.
- Implementation status: source 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.