arch/x86/kernel/cpu/microcode/intel.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/microcode/intel.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/cpu/microcode/intel.c- Extension
.c- Size
- 27479 bytes
- Lines
- 1053
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/earlycpio.hlinux/firmware.hlinux/pci_ids.hlinux/uaccess.hlinux/initrd.hlinux/kernel.hlinux/delay.hlinux/slab.hlinux/cpu.hlinux/uio.hlinux/io.hlinux/mm.hasm/cpu_device_id.hasm/cpuid/api.hasm/processor.hasm/tlbflush.hasm/setup.hasm/msr.hinternal.h
Detected Declarations
struct extended_signaturestruct extended_sigtablestruct staging_statefunction get_totalsizefunction exttable_sizefunction intel_cpuid_vfmfunction intel_get_platform_idfunction intel_collect_cpu_infofunction cpu_signatures_matchfunction intel_find_matching_signaturefunction intel_microcode_sanity_checkfunction update_ucode_pointerfunction save_microcode_patchfunction read_mbox_dwordfunction write_mbox_dwordfunction read_mbox_headerfunction write_mbox_headerfunction write_mbox_datafunction init_stagefunction can_send_next_chunkfunction transactionsfunction is_end_offsetfunction staging_is_completefunction wait_for_transactionfunction send_data_chunkfunction fetch_next_offsetfunction do_stagefunction stage_microcodefunction __apply_microcodefunction apply_microcode_earlyfunction load_builtin_intel_microcodefunction save_builtin_microcodefunction load_ucode_intel_bspfunction load_ucode_intel_apfunction reload_ucode_intelfunction collect_cpu_infofunction apply_microcode_latefunction ucode_validate_minrevfunction parse_microcode_blobsfunction is_blacklistedfunction request_microcode_fwfunction finalize_late_loadfunction calc_llc_size_per_corefunction staging_availablefunction init_intel_microcodeexport intel_collect_cpu_infoexport intel_find_matching_signatureexport intel_microcode_sanity_check
Annotated Snippet
struct extended_signature {
unsigned int sig;
unsigned int pf;
unsigned int cksum;
};
struct extended_sigtable {
unsigned int count;
unsigned int cksum;
unsigned int reserved[3];
struct extended_signature sigs[];
};
/**
* struct staging_state - Track the current staging process state
*
* @mmio_base: MMIO base address for staging
* @ucode_len: Total size of the microcode image
* @chunk_size: Size of each data piece
* @bytes_sent: Total bytes transmitted so far
* @offset: Current offset in the microcode image
*/
struct staging_state {
void __iomem *mmio_base;
unsigned int ucode_len;
unsigned int chunk_size;
unsigned int bytes_sent;
unsigned int offset;
};
#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE)
#define EXT_HEADER_SIZE (sizeof(struct extended_sigtable))
#define EXT_SIGNATURE_SIZE (sizeof(struct extended_signature))
static inline unsigned int get_totalsize(struct microcode_header_intel *hdr)
{
return hdr->datasize ? hdr->totalsize : DEFAULT_UCODE_TOTALSIZE;
}
static inline unsigned int exttable_size(struct extended_sigtable *et)
{
return et->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE;
}
/*
* Use CPUID to generate a "vfm" value. Useful before cpuinfo_x86
* structures are populated.
*/
static u32 intel_cpuid_vfm(void)
{
u32 eax = cpuid_eax(1);
u32 fam = x86_family(eax);
u32 model = x86_model(eax);
return IFM(fam, model);
}
u32 intel_get_platform_id(void)
{
unsigned int val[2];
if (x86_hypervisor_present)
return 0;
/*
* This can be called early. Use CPUID directly instead of
* relying on cpuinfo_x86 which may not be fully initialized.
* The PII does not have MSR_IA32_PLATFORM_ID. Everything
* before _it_ has no microcode (for Linux at least).
*/
if (intel_cpuid_vfm() <= INTEL_PENTIUM_II_KLAMATH)
return 0;
/* get processor flags from MSR 0x17 */
native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
return (val[1] >> 18) & 7;
}
void intel_collect_cpu_info(struct cpu_signature *sig)
{
sig->sig = cpuid_eax(1);
sig->rev = intel_get_microcode_revision();
sig->pf = 1 << intel_get_platform_id();
}
EXPORT_SYMBOL_GPL(intel_collect_cpu_info);
static inline bool cpu_signatures_match(struct cpu_signature *s1, unsigned int sig2,
unsigned int pf2)
Annotation
- Immediate include surface: `linux/earlycpio.h`, `linux/firmware.h`, `linux/pci_ids.h`, `linux/uaccess.h`, `linux/initrd.h`, `linux/kernel.h`, `linux/delay.h`, `linux/slab.h`.
- Detected declarations: `struct extended_signature`, `struct extended_sigtable`, `struct staging_state`, `function get_totalsize`, `function exttable_size`, `function intel_cpuid_vfm`, `function intel_get_platform_id`, `function intel_collect_cpu_info`, `function cpu_signatures_match`, `function intel_find_matching_signature`.
- 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.