arch/x86/kernel/cpu/microcode/amd.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/microcode/amd.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/cpu/microcode/amd.c- Extension
.c- Size
- 29766 bytes
- Lines
- 1310
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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.
- 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/bsearch.hlinux/uaccess.hlinux/vmalloc.hlinux/initrd.hlinux/kernel.hlinux/pci.hcrypto/sha2.hasm/microcode.hasm/processor.hasm/cpuid/api.hasm/cmdline.hasm/setup.hasm/cpu.hasm/msr.hasm/tlb.hinternal.hamd_shas.c
Detected Declarations
struct ucode_patchstruct equiv_cpu_entrystruct microcode_header_amdstruct microcode_amdstruct cont_descstruct patch_digestfunction cmp_idfunction cpuid_to_ucode_revfunction get_cutoff_revisionfunction need_sha_checkfunction cpu_has_entrysignfunction verify_sha256_digestfunction ucode_rev_to_cpuidfunction get_patch_levelfunction find_equiv_idfunction verify_containerfunction verify_equivalence_tablefunction __verify_patch_sectionfunction __verify_patch_sizefunction verify_patchfunction mc_patch_matchesfunction parse_containerfunction patchfunction scan_containersfunction __apply_microcode_amdfunction get_builtin_microcodefunction find_blobs_in_containersfunction vmallocfunction patch_cpus_equivalentfunction patch_newerfunction update_cachefunction list_for_each_entryfunction free_cachefunction list_for_each_entry_safefunction reload_ucode_amdfunction collect_cpu_info_amdfunction apply_microcode_amdfunction load_ucode_amd_apfunction install_equiv_cpu_tablefunction free_equiv_cpu_tablefunction cleanupfunction verify_and_add_patchfunction __load_microcode_amdfunction _load_microcode_amdfunction load_microcode_amdfunction for_each_node_with_cpusfunction save_microcode_in_initrdfunction request_microcode_amd
Annotated Snippet
struct ucode_patch {
struct list_head plist;
void *data;
unsigned int size;
u32 patch_id;
u16 equiv_cpu;
};
static LIST_HEAD(microcode_cache);
#define UCODE_MAGIC 0x00414d44
#define UCODE_EQUIV_CPU_TABLE_TYPE 0x00000000
#define UCODE_UCODE_TYPE 0x00000001
#define SECTION_HDR_SIZE 8
#define CONTAINER_HDR_SZ 12
struct equiv_cpu_entry {
u32 installed_cpu;
u32 fixed_errata_mask;
u32 fixed_errata_compare;
u16 equiv_cpu;
u16 res;
} __packed;
struct microcode_header_amd {
u32 data_code;
u32 patch_id;
u16 mc_patch_data_id;
u8 mc_patch_data_len;
u8 init_flag;
u32 mc_patch_data_checksum;
u32 nb_dev_id;
u32 sb_dev_id;
u16 processor_rev_id;
u8 nb_rev_id;
u8 sb_rev_id;
u8 bios_api_rev;
u8 reserved1[3];
u32 match_reg[8];
} __packed;
struct microcode_amd {
struct microcode_header_amd hdr;
unsigned int mpb[];
};
static struct equiv_cpu_table {
unsigned int num_entries;
struct equiv_cpu_entry *entry;
} equiv_table;
union zen_patch_rev {
struct {
__u32 rev : 8,
stepping : 4,
model : 4,
__reserved : 4,
ext_model : 4,
ext_fam : 8;
};
__u32 ucode_rev;
};
union cpuid_1_eax {
struct {
__u32 stepping : 4,
model : 4,
family : 4,
__reserved0 : 4,
ext_model : 4,
ext_fam : 8,
__reserved1 : 4;
};
__u32 full;
};
/*
* This points to the current valid container of microcode patches which we will
* save from the initrd/builtin before jettisoning its contents. @mc is the
* microcode patch we found to match.
*/
struct cont_desc {
struct microcode_amd *mc;
u32 psize;
u8 *data;
size_t size;
};
/*
Annotation
- Immediate include surface: `linux/earlycpio.h`, `linux/firmware.h`, `linux/bsearch.h`, `linux/uaccess.h`, `linux/vmalloc.h`, `linux/initrd.h`, `linux/kernel.h`, `linux/pci.h`.
- Detected declarations: `struct ucode_patch`, `struct equiv_cpu_entry`, `struct microcode_header_amd`, `struct microcode_amd`, `struct cont_desc`, `struct patch_digest`, `function cmp_id`, `function cpuid_to_ucode_rev`, `function get_cutoff_revision`, `function need_sha_check`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.