arch/x86/mm/init_32.c
Source file repositories/reference/linux-study-clean/arch/x86/mm/init_32.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/mm/init_32.c- Extension
.c- Size
- 20112 bytes
- Lines
- 760
- 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.
Dependency Surface
linux/signal.hlinux/sched.hlinux/kernel.hlinux/errno.hlinux/string.hlinux/types.hlinux/ptrace.hlinux/mman.hlinux/mm.hlinux/hugetlb.hlinux/swap.hlinux/smp.hlinux/init.hlinux/highmem.hlinux/pagemap.hlinux/pci.hlinux/pfn.hlinux/poison.hlinux/memblock.hlinux/proc_fs.hlinux/memory_hotplug.hlinux/initrd.hlinux/cpumask.hlinux/gfp.hasm/asm.hasm/bios_ebda.hasm/processor.hlinux/uaccess.hasm/dma.hasm/fixmap.hasm/e820/api.hasm/apic.h
Detected Declarations
function one_md_table_initfunction one_page_table_initfunction populate_extra_pmdfunction populate_extra_ptefunction page_table_range_init_countfunction page_table_kmap_checkfunction page_table_range_initfunction is_x86_32_kernel_textfunction kernel_physical_mapping_initfunction permanent_kmaps_initfunction permanent_kmaps_initfunction native_pagetable_initfunction early_ioremap_page_table_range_initfunction pagetable_initfunction parse_highmemfunction lowmem_pfn_initfunction highmem_pfn_initfunction find_low_pfn_rangefunction initmem_initfunction paging_initfunction test_wp_bitfunction arch_mm_preinitfunction mem_initfunction mark_nxdata_nxfunction mark_rodata_roexport __supported_pte_maskexport __default_kernel_pte_mask
Annotated Snippet
if (use_pse) {
unsigned int addr2;
pgprot_t prot = PAGE_KERNEL_LARGE;
/*
* first pass will use the same initial
* identity mapping attribute + _PAGE_PSE.
*/
pgprot_t init_prot =
__pgprot(PTE_IDENT_ATTR |
_PAGE_PSE);
pfn &= PMD_MASK >> PAGE_SHIFT;
addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
PAGE_OFFSET + PAGE_SIZE-1;
if (is_x86_32_kernel_text(addr) ||
is_x86_32_kernel_text(addr2))
prot = PAGE_KERNEL_LARGE_EXEC;
pages_2m++;
if (mapping_iter == 1)
set_pmd(pmd, pfn_pmd(pfn, init_prot));
else
set_pmd(pmd, pfn_pmd(pfn, prot));
pfn += PTRS_PER_PTE;
continue;
}
pte = one_page_table_init(pmd);
pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
pte += pte_ofs;
for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
pgprot_t prot = PAGE_KERNEL;
/*
* first pass will use the same initial
* identity mapping attribute.
*/
pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
if (is_x86_32_kernel_text(addr))
prot = PAGE_KERNEL_EXEC;
pages_4k++;
if (mapping_iter == 1) {
set_pte(pte, pfn_pte(pfn, init_prot));
last_map_addr = (pfn << PAGE_SHIFT) + PAGE_SIZE;
} else
set_pte(pte, pfn_pte(pfn, prot));
}
}
}
if (mapping_iter == 1) {
/*
* update direct mapping page count only in the first
* iteration.
*/
update_page_count(PG_LEVEL_2M, pages_2m);
update_page_count(PG_LEVEL_4K, pages_4k);
/*
* local global flush tlb, which will flush the previous
* mappings present in both small and large page TLB's.
*/
__flush_tlb_all();
/*
* Second iteration will set the actual desired PTE attributes.
*/
mapping_iter = 2;
goto repeat;
}
return last_map_addr;
}
#ifdef CONFIG_HIGHMEM
static void __init permanent_kmaps_init(pgd_t *pgd_base)
{
unsigned long vaddr = PKMAP_BASE;
page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
pkmap_page_table = virt_to_kpte(vaddr);
}
#else
static inline void permanent_kmaps_init(pgd_t *pgd_base)
{
}
#endif /* CONFIG_HIGHMEM */
Annotation
- Immediate include surface: `linux/signal.h`, `linux/sched.h`, `linux/kernel.h`, `linux/errno.h`, `linux/string.h`, `linux/types.h`, `linux/ptrace.h`, `linux/mman.h`.
- Detected declarations: `function one_md_table_init`, `function one_page_table_init`, `function populate_extra_pmd`, `function populate_extra_pte`, `function page_table_range_init_count`, `function page_table_kmap_check`, `function page_table_range_init`, `function is_x86_32_kernel_text`, `function kernel_physical_mapping_init`, `function permanent_kmaps_init`.
- 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.