arch/x86/kernel/cpu/common.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/common.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/cpu/common.c- Extension
.c- Size
- 76923 bytes
- Lines
- 2667
- 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/memblock.hlinux/linkage.hlinux/bitops.hlinux/kernel.hlinux/export.hlinux/kvm_types.hlinux/percpu.hlinux/string.hlinux/ctype.hlinux/delay.hlinux/sched/mm.hlinux/sched/clock.hlinux/sched/task.hlinux/sched/smt.hlinux/init.hlinux/kprobes.hlinux/kgdb.hlinux/mem_encrypt.hlinux/smp.hlinux/cpu.hlinux/io.hlinux/syscore_ops.hlinux/pgtable.hlinux/stackprotector.hlinux/utsname.hlinux/efi.hasm/alternative.hasm/cmdline.hasm/cpuid/api.hasm/perf_event.hasm/mmu_context.hasm/doublefault.h
Detected Declarations
struct cpuid_dependent_featurefunction ppin_initfunction default_initfunction x86_nopcid_setupfunction x86_noinvpcid_setupfunction flag_is_changeable_pfunction cachesize_setupfunction cpuid_featurefunction squash_the_stupid_serial_numberfunction x86_serial_nr_setupfunction squash_the_stupid_serial_numberfunction setup_smapfunction setup_umipfunction enable_lassfunction cpu_finalize_pre_userspacefunction native_write_cr0function native_write_cr4function cr4_update_irqsofffunction cr4_read_shadowfunction cr4_initfunction finishedfunction x86_nofsgsbase_setupfunction setup_pkufunction setup_disable_pkufunction ibt_savefunction ibt_restorefunction setup_cetfunction cet_disablefunction filter_cpuid_featuresfunction load_direct_gdtfunction load_fixmap_gdtfunction switch_gdt_and_percpu_basefunction get_model_namefunction cpu_detect_cache_sizesfunction cpu_detect_tlbfunction get_cpu_vendorfunction cpu_detectfunction apply_forced_capsfunction init_speculation_controlfunction get_cpu_capfunction get_cpu_address_sizesfunction identify_cpu_without_cpuidfunction cpu_matchesfunction x86_read_arch_cap_msrfunction arch_cap_mmio_immunefunction vulnerable_to_rfdsfunction vulnerable_to_itsfunction cpu_has_old_microcode
Annotated Snippet
struct cpuid_dependent_feature {
u32 feature;
u32 level;
};
static const struct cpuid_dependent_feature
cpuid_dependent_features[] = {
{ X86_FEATURE_MWAIT, CPUID_LEAF_MWAIT },
{ X86_FEATURE_DCA, CPUID_LEAF_DCA },
{ X86_FEATURE_XSAVE, CPUID_LEAF_XSTATE },
{ 0, 0 }
};
static void filter_cpuid_features(struct cpuinfo_x86 *c, bool warn)
{
const struct cpuid_dependent_feature *df;
for (df = cpuid_dependent_features; df->feature; df++) {
if (!cpu_has(c, df->feature))
continue;
/*
* Note: cpuid_level is set to -1 if unavailable, but
* extended_extended_level is set to 0 if unavailable
* and the legitimate extended levels are all negative
* when signed; hence the weird messing around with
* signs here...
*/
if (!((s32)df->level < 0 ?
(u32)df->level > (u32)c->extended_cpuid_level :
(s32)df->level > (s32)c->cpuid_level))
continue;
clear_cpu_cap(c, df->feature);
if (!warn)
continue;
pr_warn("CPU: CPU feature %s disabled, no CPUID level 0x%x\n",
x86_cap_flags[df->feature], df->level);
}
}
/*
* Naming convention should be: <Name> [(<Codename>)]
* This table only is used unless init_<vendor>() below doesn't set it;
* in particular, if CPUID levels 0x80000002..4 are supported, this
* isn't used
*/
/* Look up CPU names by table lookup. */
static const char *table_lookup_model(struct cpuinfo_x86 *c)
{
#ifdef CONFIG_X86_32
const struct legacy_cpu_model_info *info;
if (c->x86_model >= 16)
return NULL; /* Range check */
if (!this_cpu)
return NULL;
info = this_cpu->legacy_models;
while (info->family) {
if (info->family == c->x86)
return info->model_names[c->x86_model];
info++;
}
#endif
return NULL; /* Not found */
}
/* Aligned to unsigned long to avoid split lock in atomic bitmap ops */
__u32 cpu_caps_cleared[NCAPINTS + NBUGINTS] __aligned(sizeof(unsigned long));
__u32 cpu_caps_set[NCAPINTS + NBUGINTS] __aligned(sizeof(unsigned long));
#ifdef CONFIG_X86_32
/* The 32-bit entry code needs to find cpu_entry_area. */
DEFINE_PER_CPU(struct cpu_entry_area *, cpu_entry_area);
#endif
/* Load the original GDT from the per-cpu structure */
void load_direct_gdt(int cpu)
{
struct desc_ptr gdt_descr;
gdt_descr.address = (long)get_cpu_gdt_rw(cpu);
gdt_descr.size = GDT_SIZE - 1;
load_gdt(&gdt_descr);
}
Annotation
- Immediate include surface: `linux/memblock.h`, `linux/linkage.h`, `linux/bitops.h`, `linux/kernel.h`, `linux/export.h`, `linux/kvm_types.h`, `linux/percpu.h`, `linux/string.h`.
- Detected declarations: `struct cpuid_dependent_feature`, `function ppin_init`, `function default_init`, `function x86_nopcid_setup`, `function x86_noinvpcid_setup`, `function flag_is_changeable_p`, `function cachesize_setup`, `function cpuid_feature`, `function squash_the_stupid_serial_number`, `function x86_serial_nr_setup`.
- 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.