arch/arm64/mm/mmu.c
Source file repositories/reference/linux-study-clean/arch/arm64/mm/mmu.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/mm/mmu.c- Extension
.c- Size
- 63535 bytes
- Lines
- 2373
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/cache.hlinux/export.hlinux/kernel.hlinux/errno.hlinux/init.hlinux/ioport.hlinux/kexec.hlinux/libfdt.hlinux/mman.hlinux/nodemask.hlinux/memblock.hlinux/memremap.hlinux/memory.hlinux/fs.hlinux/io.hlinux/mm.hlinux/vmalloc.hlinux/set_memory.hlinux/kfence.hlinux/pkeys.hlinux/mm_inline.hlinux/pagewalk.hlinux/stop_machine.hasm/barrier.hasm/cputype.hasm/fixmap.hasm/kasan.hasm/kernel-pgtable.hasm/sections.hasm/setup.hlinux/sizes.hasm/tlb.h
Detected Declarations
function set_swapper_pgdfunction phys_mem_access_protfunction early_pgtable_allocfunction pgattr_change_is_safefunction init_clear_pgtablefunction init_ptefunction pte_range_has_valid_noncontfunction alloc_init_cont_ptefunction init_pmdfunction pmd_range_has_valid_noncontfunction alloc_init_cont_pmdfunction alloc_init_pudfunction alloc_init_p4dfunction __create_pgd_mapping_lockedfunction __create_pgd_mappingfunction early_create_pgd_mappingfunction __pgd_pgtable_allocfunction pgd_pgtable_alloc_init_mm_gfpfunction pgd_pgtable_alloc_init_mmfunction pgd_pgtable_alloc_special_mmfunction split_contptefunction split_pmdfunction split_contpmdfunction split_pudfunction split_kernel_leaf_mapping_lockedfunction force_pte_mappingfunction split_kernel_leaf_mappingfunction split_kernel_leaf_mapping_lockedfunction split_to_ptes_pud_entryfunction split_to_ptes_pmd_entryfunction split_to_ptes_pte_entryfunction range_split_to_ptesfunction init_idmap_kpti_bbml2_flagfunction linear_map_split_to_ptesfunction linear_map_maybe_split_to_ptesfunction create_mapping_noallocfunction create_pgd_mappingfunction update_mapping_protfunction __map_memblockfunction mark_linear_text_alias_rofunction parse_kfence_early_initfunction arm64_kfence_map_poolfunction arch_kfence_init_poolfunction arm64_kfence_map_poolfunction mark_rodata_rofunction declare_vmafunction kpti_ng_pgd_allocfunction __kpti_install_ng_mappings
Annotated Snippet
core_initcall(map_entry_trampoline);
#endif
/*
* Declare the VMA areas for the kernel
*/
static void __init declare_kernel_vmas(void)
{
static struct vm_struct vmlinux_seg[KERNEL_SEGMENT_COUNT];
declare_vma(&vmlinux_seg[0], _text, _etext, VM_NO_GUARD);
declare_vma(&vmlinux_seg[1], __start_rodata, __inittext_begin, VM_NO_GUARD);
declare_vma(&vmlinux_seg[2], __inittext_begin, __inittext_end, VM_NO_GUARD);
declare_vma(&vmlinux_seg[3], __initdata_begin, __initdata_end, VM_NO_GUARD);
declare_vma(&vmlinux_seg[4], _data, _end, 0);
}
void __pi_map_range(phys_addr_t *pte, u64 start, u64 end, phys_addr_t pa,
pgprot_t prot, int level, pte_t *tbl, bool may_use_cont,
u64 va_offset);
static u8 idmap_ptes[IDMAP_LEVELS - 1][PAGE_SIZE] __aligned(PAGE_SIZE) __ro_after_init,
kpti_bbml2_ptes[IDMAP_LEVELS - 1][PAGE_SIZE] __aligned(PAGE_SIZE) __ro_after_init;
static void __init create_idmap(void)
{
phys_addr_t start = __pa_symbol(__idmap_text_start);
phys_addr_t end = __pa_symbol(__idmap_text_end);
phys_addr_t ptep = __pa_symbol(idmap_ptes);
__pi_map_range(&ptep, start, end, start, PAGE_KERNEL_ROX,
IDMAP_ROOT_LEVEL, (pte_t *)idmap_pg_dir, false,
__phys_to_virt(ptep) - ptep);
if (linear_map_requires_bbml2 ||
(IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0) && !arm64_use_ng_mappings)) {
phys_addr_t pa = __pa_symbol(&idmap_kpti_bbml2_flag);
/*
* The KPTI G-to-nG conversion code needs a read-write mapping
* of its synchronization flag in the ID map. This is also used
* when splitting the linear map to ptes if a secondary CPU
* doesn't support bbml2.
*/
ptep = __pa_symbol(kpti_bbml2_ptes);
__pi_map_range(&ptep, pa, pa + sizeof(u32), pa, PAGE_KERNEL,
IDMAP_ROOT_LEVEL, (pte_t *)idmap_pg_dir, false,
__phys_to_virt(ptep) - ptep);
}
}
void __init paging_init(void)
{
map_mem();
memblock_allow_resize();
create_idmap();
declare_kernel_vmas();
}
#ifdef CONFIG_MEMORY_HOTPLUG
static void free_hotplug_page_range(struct page *page, size_t size,
struct vmem_altmap *altmap)
{
if (altmap) {
vmem_altmap_free(altmap, size >> PAGE_SHIFT);
} else {
WARN_ON(PageReserved(page));
__free_pages(page, get_order(size));
}
}
static void free_hotplug_pgtable_page(struct page *page)
{
pagetable_dtor(page_ptdesc(page));
free_hotplug_page_range(page, PAGE_SIZE, NULL);
}
static bool pgtable_range_aligned(unsigned long start, unsigned long end,
unsigned long floor, unsigned long ceiling,
unsigned long mask)
{
start &= mask;
if (start < floor)
return false;
if (ceiling) {
ceiling &= mask;
if (!ceiling)
Annotation
- Immediate include surface: `linux/cache.h`, `linux/export.h`, `linux/kernel.h`, `linux/errno.h`, `linux/init.h`, `linux/ioport.h`, `linux/kexec.h`, `linux/libfdt.h`.
- Detected declarations: `function set_swapper_pgd`, `function phys_mem_access_prot`, `function early_pgtable_alloc`, `function pgattr_change_is_safe`, `function init_clear_pgtable`, `function init_pte`, `function pte_range_has_valid_noncont`, `function alloc_init_cont_pte`, `function init_pmd`, `function pmd_range_has_valid_noncont`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.