arch/arm/mm/init.c
Source file repositories/reference/linux-study-clean/arch/arm/mm/init.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/mm/init.c- Extension
.c- Size
- 11689 bytes
- Lines
- 478
- Domain
- Architecture Layer
- Bucket
- arch/arm
- 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/kernel.hlinux/errno.hlinux/swap.hlinux/init.hlinux/mman.hlinux/sched/signal.hlinux/sched/task.hlinux/export.hlinux/nodemask.hlinux/initrd.hlinux/of_fdt.hlinux/highmem.hlinux/gfp.hlinux/memblock.hlinux/dma-map-ops.hlinux/sizes.hlinux/stop_machine.hlinux/swiotlb.hlinux/execmem.hasm/cp15.hasm/mach-types.hasm/memblock.hasm/page.hasm/prom.hasm/sections.hasm/setup.hasm/set_memory.hasm/system_info.hasm/tlb.hasm/fixmap.hasm/ptdump.hasm/mach/arch.h
Detected Declarations
struct section_permfunction Copyrightfunction parse_tag_initrdfunction parse_tag_initrd2function find_limitsfunction setup_dma_zonefunction arch_zone_limits_initfunction pfn_validfunction arm_memblock_stealfunction check_cpu_icache_sizefunction arm_memblock_initfunction bootmem_initfunction instructionfunction arch_mm_preinitfunction mmfunction arch_has_strict_permsfunction set_section_permsfunction update_sections_earlyfunction for_each_processfunction __fix_kernmem_permsfunction fix_kernmem_permsfunction __mark_rodata_rofunction mark_rodata_rofunction fix_kernmem_permsfunction free_initrd_memexport arm_dma_zone_sizeexport pfn_valid
Annotated Snippet
struct section_perm {
const char *name;
unsigned long start;
unsigned long end;
pmdval_t mask;
pmdval_t prot;
pmdval_t clear;
};
/* First section-aligned location at or after __start_rodata. */
extern char __start_rodata_section_aligned[];
static struct section_perm nx_perms[] = {
/* Make pages tables, etc before _stext RW (set NX). */
{
.name = "pre-text NX",
.start = PAGE_OFFSET,
.end = (unsigned long)_stext,
.mask = ~PMD_SECT_XN,
.prot = PMD_SECT_XN,
},
/* Make init RW (set NX). */
{
.name = "init NX",
.start = (unsigned long)__init_begin,
.end = (unsigned long)_sdata,
.mask = ~PMD_SECT_XN,
.prot = PMD_SECT_XN,
},
/* Make rodata NX (set RO in ro_perms below). */
{
.name = "rodata NX",
.start = (unsigned long)__start_rodata_section_aligned,
.end = (unsigned long)__init_begin,
.mask = ~PMD_SECT_XN,
.prot = PMD_SECT_XN,
},
};
static struct section_perm ro_perms[] = {
/* Make kernel code and rodata RX (set RO). */
{
.name = "text/rodata RO",
.start = (unsigned long)_stext,
.end = (unsigned long)__init_begin,
#ifdef CONFIG_ARM_LPAE
.mask = ~(L_PMD_SECT_RDONLY | PMD_SECT_AP2),
.prot = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
#else
.mask = ~(PMD_SECT_APX | PMD_SECT_AP_WRITE),
.prot = PMD_SECT_APX | PMD_SECT_AP_WRITE,
.clear = PMD_SECT_AP_WRITE,
#endif
},
};
/*
* Updates section permissions only for the current mm (sections are
* copied into each mm). During startup, this is the init_mm. Is only
* safe to be called with preemption disabled, as under stop_machine().
*/
static inline void section_update(unsigned long addr, pmdval_t mask,
pmdval_t prot, struct mm_struct *mm)
{
pmd_t *pmd;
pmd = pmd_offset(pud_offset(p4d_offset(pgd_offset(mm, addr), addr), addr), addr);
#ifdef CONFIG_ARM_LPAE
pmd[0] = __pmd((pmd_val(pmd[0]) & mask) | prot);
#else
if (addr & SECTION_SIZE)
pmd[1] = __pmd((pmd_val(pmd[1]) & mask) | prot);
else
pmd[0] = __pmd((pmd_val(pmd[0]) & mask) | prot);
#endif
flush_pmd_entry(pmd);
local_flush_tlb_kernel_range(addr, addr + SECTION_SIZE);
}
/* Make sure extended page tables are in use. */
static inline bool arch_has_strict_perms(void)
{
if (cpu_architecture() < CPU_ARCH_ARMv6)
return false;
return !!(get_cr() & CR_XP);
}
static void set_section_perms(struct section_perm *perms, int n, bool set,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/swap.h`, `linux/init.h`, `linux/mman.h`, `linux/sched/signal.h`, `linux/sched/task.h`, `linux/export.h`.
- Detected declarations: `struct section_perm`, `function Copyright`, `function parse_tag_initrd`, `function parse_tag_initrd2`, `function find_limits`, `function setup_dma_zone`, `function arch_zone_limits_init`, `function pfn_valid`, `function arm_memblock_steal`, `function check_cpu_icache_size`.
- Atlas domain: Architecture Layer / arch/arm.
- 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.