arch/powerpc/mm/mem.c
Source file repositories/reference/linux-study-clean/arch/powerpc/mm/mem.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/mm/mem.c- Extension
.c- Size
- 11283 bytes
- Lines
- 454
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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/memblock.hlinux/highmem.hlinux/suspend.hlinux/dma-direct.hlinux/execmem.hlinux/vmalloc.hasm/swiotlb.hasm/machdep.hasm/rtas.hasm/kasan.hasm/svm.hasm/mmzone.hasm/ftrace.hasm/text-patching.hasm/setup.hasm/fixmap.hasm/fadump.hasm/kexec.hasm/kvm_ppc.hmm/mmu_decl.h
Detected Declarations
function __phys_mem_access_protfunction memory_add_physaddr_to_nidfunction create_section_mappingfunction remove_section_mappingfunction arch_create_linear_mappingfunction arch_remove_linear_mappingfunction update_end_of_memory_varsfunction add_pagesfunction arch_add_memoryfunction arch_remove_memoryfunction mem_topology_setupfunction mark_nonram_nosavefunction for_each_mem_pfn_rangefunction mark_nonram_nosavefunction arch_zone_limits_initfunction paging_initfunction arch_mm_preinitfunction free_initmemfunction add_system_ram_resourcesfunction for_each_mem_rangefunction devmem_is_allowedfunction prealloc_execmem_pgtablefunction prealloc_execmem_pgtablemodule init add_system_ram_resourcesexport __phys_mem_access_protexport memory_add_physaddr_to_nidexport walk_system_ram_range
Annotated Snippet
subsys_initcall(add_system_ram_resources);
#ifdef CONFIG_STRICT_DEVMEM
/*
* devmem_is_allowed(): check to see if /dev/mem access to a certain address
* is valid. The argument is a physical page number.
*
* Access has to be given to non-kernel-ram areas as well, these contain the
* PCI mmio resources as well as potential bios/acpi data regions.
*/
int devmem_is_allowed(unsigned long pfn)
{
if (page_is_rtas_user_buf(pfn))
return 1;
if (iomem_is_exclusive(PFN_PHYS(pfn)))
return 0;
if (!page_is_ram(pfn))
return 1;
return 0;
}
#endif /* CONFIG_STRICT_DEVMEM */
/*
* This is defined in kernel/resource.c but only powerpc needs to export it, for
* the EHEA driver. Drop this when drivers/net/ethernet/ibm/ehea is removed.
*/
EXPORT_SYMBOL_GPL(walk_system_ram_range);
#ifdef CONFIG_EXECMEM
static struct execmem_info execmem_info __ro_after_init;
#if defined(CONFIG_PPC_8xx) || defined(CONFIG_PPC_BOOK3S_603)
static void prealloc_execmem_pgtable(void)
{
unsigned long va;
for (va = ALIGN_DOWN(MODULES_VADDR, PGDIR_SIZE); va < MODULES_END; va += PGDIR_SIZE)
pte_alloc_kernel(pmd_off_k(va), va);
}
#else
static void prealloc_execmem_pgtable(void) { }
#endif
struct execmem_info __init *execmem_arch_setup(void)
{
pgprot_t kprobes_prot = strict_module_rwx_enabled() ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;
pgprot_t prot = strict_module_rwx_enabled() ? PAGE_KERNEL : PAGE_KERNEL_EXEC;
unsigned long fallback_start = 0, fallback_end = 0;
unsigned long start, end;
/*
* BOOK3S_32 and 8xx define MODULES_VADDR for text allocations and
* allow allocating data in the entire vmalloc space
*/
#ifdef MODULES_VADDR
unsigned long limit = (unsigned long)_etext - SZ_32M;
/* First try within 32M limit from _etext to avoid branch trampolines */
if (MODULES_VADDR < PAGE_OFFSET && MODULES_END > limit) {
start = limit;
fallback_start = MODULES_VADDR;
fallback_end = MODULES_END;
} else {
start = MODULES_VADDR;
}
end = MODULES_END;
#else
start = VMALLOC_START;
end = VMALLOC_END;
#endif
prealloc_execmem_pgtable();
execmem_info = (struct execmem_info){
.ranges = {
[EXECMEM_DEFAULT] = {
.start = start,
.end = end,
.pgprot = prot,
.alignment = 1,
.fallback_start = fallback_start,
.fallback_end = fallback_end,
},
[EXECMEM_KPROBES] = {
.start = VMALLOC_START,
.end = VMALLOC_END,
.pgprot = kprobes_prot,
.alignment = 1,
},
Annotation
- Immediate include surface: `linux/memblock.h`, `linux/highmem.h`, `linux/suspend.h`, `linux/dma-direct.h`, `linux/execmem.h`, `linux/vmalloc.h`, `asm/swiotlb.h`, `asm/machdep.h`.
- Detected declarations: `function __phys_mem_access_prot`, `function memory_add_physaddr_to_nid`, `function create_section_mapping`, `function remove_section_mapping`, `function arch_create_linear_mapping`, `function arch_remove_linear_mapping`, `function update_end_of_memory_vars`, `function add_pages`, `function arch_add_memory`, `function arch_remove_memory`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.