arch/x86/kernel/cpu/amd.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/amd.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/cpu/amd.c- Extension
.c- Size
- 38990 bytes
- Lines
- 1439
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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/export.hlinux/bitops.hlinux/dmi.hlinux/elf.hlinux/mm.hlinux/kvm_types.hlinux/io.hlinux/sched.hlinux/sched/clock.hlinux/random.hlinux/topology.hlinux/platform_data/x86/amd-fch.hasm/processor.hasm/apic.hasm/cacheinfo.hasm/cpu.hasm/cpu_device_id.hasm/cpuid/api.hasm/spec-ctrl.hasm/smp.hasm/numa.hasm/pci-direct.hasm/delay.hasm/debugreg.hasm/resctrl.hasm/msr.hasm/sev.hasm/mmconfig.hcpu.h
Detected Declarations
function rdmsrq_amd_safefunction wrmsrq_amd_safefunction init_amd_k5function init_amd_k6function init_amd_k7function srat_detect_nodefunction srat_detect_nodefunction bsp_determine_snpfunction tsa_initfunction bsp_init_amdfunction early_detect_mem_encryptfunction featurefunction early_init_amdfunction init_amd_k8function init_amd_ghfunction init_amd_lnfunction rdrand_cmdlinefunction clear_rdrand_cpuid_bitfunction init_amd_jgfunction init_amd_bdfunction fix_erratum_1386function init_spectral_chickenfunction init_amd_zen_commonfunction init_amd_zen1function zen2_zenbleed_checkfunction init_amd_zen2function init_amd_zen3function init_amd_zen4function init_amd_zen5function init_amdfunction amd_size_cachefunction cpu_detect_tlb_amdfunction amd_set_dr_addr_maskfunction amd_get_dr_addr_maskfunction zenbleed_check_cpufunction amd_check_microcodefunction print_s5_reset_status_mmiofunction dmi_scan_additionalfunction print_dmi_agesa
Annotated Snippet
if (c->x86_model == 0) {
clear_cpu_cap(c, X86_FEATURE_APIC);
set_cpu_cap(c, X86_FEATURE_PGE);
}
return;
}
if (c->x86_model == 6 && c->x86_stepping == 1) {
const int K6_BUG_LOOP = 1000000;
int n;
void (*f_vide)(void);
u64 d, d2;
pr_info("AMD K6 stepping B detected - ");
/*
* It looks like AMD fixed the 2.6.2 bug and improved indirect
* calls at the same time.
*/
n = K6_BUG_LOOP;
f_vide = vide;
OPTIMIZER_HIDE_VAR(f_vide);
d = rdtsc();
while (n--)
f_vide();
d2 = rdtsc();
d = d2-d;
if (d > 20*K6_BUG_LOOP)
pr_cont("system stability may be impaired when more than 32 MB are used.\n");
else
pr_cont("probably OK (after B9730xxxx).\n");
}
/* K6 with old style WHCR */
if (c->x86_model < 8 ||
(c->x86_model == 8 && c->x86_stepping < 8)) {
/* We can only write allocate on the low 508Mb */
if (mbytes > 508)
mbytes = 508;
rdmsr(MSR_K6_WHCR, l, h);
if ((l&0x0000FFFF) == 0) {
unsigned long flags;
l = (1<<0)|((mbytes/4)<<1);
local_irq_save(flags);
wbinvd();
wrmsr(MSR_K6_WHCR, l, h);
local_irq_restore(flags);
pr_info("Enabling old style K6 write allocation for %d Mb\n",
mbytes);
}
return;
}
if ((c->x86_model == 8 && c->x86_stepping > 7) ||
c->x86_model == 9 || c->x86_model == 13) {
/* The more serious chips .. */
if (mbytes > 4092)
mbytes = 4092;
rdmsr(MSR_K6_WHCR, l, h);
if ((l&0xFFFF0000) == 0) {
unsigned long flags;
l = ((mbytes>>2)<<22)|(1<<16);
local_irq_save(flags);
wbinvd();
wrmsr(MSR_K6_WHCR, l, h);
local_irq_restore(flags);
pr_info("Enabling new style K6 write allocation for %d Mb\n",
mbytes);
}
return;
}
if (c->x86_model == 10) {
/* AMD Geode LX is model 10 */
/* placeholder for any needed mods */
return;
}
#endif
}
static void init_amd_k7(struct cpuinfo_x86 *c)
{
#ifdef CONFIG_X86_32
u32 l, h;
Annotation
- Immediate include surface: `linux/export.h`, `linux/bitops.h`, `linux/dmi.h`, `linux/elf.h`, `linux/mm.h`, `linux/kvm_types.h`, `linux/io.h`, `linux/sched.h`.
- Detected declarations: `function rdmsrq_amd_safe`, `function wrmsrq_amd_safe`, `function init_amd_k5`, `function init_amd_k6`, `function init_amd_k7`, `function srat_detect_node`, `function srat_detect_node`, `function bsp_determine_snp`, `function tsa_init`, `function bsp_init_amd`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.