arch/x86/mm/init.c
Source file repositories/reference/linux-study-clean/arch/x86/mm/init.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/mm/init.c- Extension
.c- Size
- 32954 bytes
- Lines
- 1129
- 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/gfp.hlinux/initrd.hlinux/ioport.hlinux/swap.hlinux/memblock.hlinux/swapfile.hlinux/swapops.hlinux/kmemleak.hlinux/sched/task.hlinux/execmem.hasm/set_memory.hasm/cpu_device_id.hasm/e820/api.hasm/init.hasm/page.hasm/page_types.hasm/sections.hasm/setup.hasm/tlbflush.hasm/tlb.hasm/proto.hasm/dma.hasm/kaslr.hasm/hypervisor.hasm/cpufeature.hasm/pti.hasm/text-patching.hasm/memtype.hasm/mmu_context.htrace/events/tlb.hmm_internal.h
Detected Declarations
struct map_rangefunction cachemode2protvalfunction upfunction pgprot2cachemodefunction early_alloc_pgt_buffunction cr4_set_bits_and_update_bootfunction probe_page_size_maskfunction setup_pcidfunction save_mrfunction adjust_range_page_size_maskfunction split_mem_rangefunction add_pfn_range_mappedfunction pfn_range_is_mappedfunction init_memory_mappingfunction sizefunction for_each_mem_pfn_rangefunction get_new_step_sizefunction memory_map_top_downfunction topfunction memory_map_bottom_upfunction bottomfunction init_trampolinefunction init_mem_mappingfunction poking_initfunction devmem_is_allowedfunction free_init_pagesfunction free_kernel_image_pagesfunction free_initmemfunction free_initrd_memfunction arch_zone_limits_initfunction update_cache_mode_entryfunction arch_max_swapfile_sizefunction execmem_fill_trapping_insnsexport cachemode2protval
Annotated Snippet
struct map_range {
unsigned long start;
unsigned long end;
unsigned page_size_mask;
};
static int page_size_mask;
/*
* Save some of cr4 feature set we're using (e.g. Pentium 4MB
* enable and PPro Global page enable), so that any CPU's that boot
* up after us can get the correct flags. Invoked on the boot CPU.
*/
static inline void cr4_set_bits_and_update_boot(unsigned long mask)
{
mmu_cr4_features |= mask;
if (trampoline_cr4_features)
*trampoline_cr4_features = mmu_cr4_features;
cr4_set_bits(mask);
}
static void __init probe_page_size_mask(void)
{
/*
* For pagealloc debugging, identity mapping will use small pages.
* This will simplify cpa(), which otherwise needs to support splitting
* large pages into small in interrupt context, etc.
*/
if (boot_cpu_has(X86_FEATURE_PSE) && !debug_pagealloc_enabled())
page_size_mask |= 1 << PG_LEVEL_2M;
else
direct_gbpages = 0;
/* Enable PSE if available */
if (boot_cpu_has(X86_FEATURE_PSE))
cr4_set_bits_and_update_boot(X86_CR4_PSE);
/* Enable PGE if available */
__supported_pte_mask &= ~_PAGE_GLOBAL;
if (boot_cpu_has(X86_FEATURE_PGE)) {
cr4_set_bits_and_update_boot(X86_CR4_PGE);
__supported_pte_mask |= _PAGE_GLOBAL;
}
/* By the default is everything supported: */
__default_kernel_pte_mask = __supported_pte_mask;
/* Except when with PTI where the kernel is mostly non-Global: */
if (cpu_feature_enabled(X86_FEATURE_PTI))
__default_kernel_pte_mask &= ~_PAGE_GLOBAL;
/* Enable 1 GB linear kernel mappings if available: */
if (direct_gbpages && boot_cpu_has(X86_FEATURE_GBPAGES)) {
printk(KERN_INFO "Using GB pages for direct mapping\n");
page_size_mask |= 1 << PG_LEVEL_1G;
} else {
direct_gbpages = 0;
}
}
/*
* INVLPG may not properly flush Global entries on
* these CPUs. New microcode fixes the issue.
*/
static const struct x86_cpu_id invlpg_miss_ids[] = {
X86_MATCH_VFM(INTEL_ALDERLAKE, 0x2e),
X86_MATCH_VFM(INTEL_ALDERLAKE_L, 0x42c),
X86_MATCH_VFM(INTEL_ATOM_GRACEMONT, 0x11),
X86_MATCH_VFM(INTEL_RAPTORLAKE, 0x118),
X86_MATCH_VFM(INTEL_RAPTORLAKE_P, 0x4117),
X86_MATCH_VFM(INTEL_RAPTORLAKE_S, 0x2e),
{}
};
static void setup_pcid(void)
{
const struct x86_cpu_id *invlpg_miss_match;
if (!IS_ENABLED(CONFIG_X86_64))
return;
if (!boot_cpu_has(X86_FEATURE_PCID))
return;
invlpg_miss_match = x86_match_cpu(invlpg_miss_ids);
if (invlpg_miss_match &&
boot_cpu_data.microcode < invlpg_miss_match->driver_data) {
pr_info("Incomplete global flushes, disabling PCID");
setup_clear_cpu_cap(X86_FEATURE_PCID);
return;
Annotation
- Immediate include surface: `linux/gfp.h`, `linux/initrd.h`, `linux/ioport.h`, `linux/swap.h`, `linux/memblock.h`, `linux/swapfile.h`, `linux/swapops.h`, `linux/kmemleak.h`.
- Detected declarations: `struct map_range`, `function cachemode2protval`, `function up`, `function pgprot2cachemode`, `function early_alloc_pgt_buf`, `function cr4_set_bits_and_update_boot`, `function probe_page_size_mask`, `function setup_pcid`, `function save_mr`, `function adjust_range_page_size_mask`.
- 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.