arch/arm/mm/fault.c
Source file repositories/reference/linux-study-clean/arch/arm/mm/fault.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/mm/fault.c- Extension
.c- Size
- 17449 bytes
- Lines
- 720
- Domain
- Architecture Layer
- Bucket
- arch/arm
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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.
- 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/extable.hlinux/signal.hlinux/mm.hlinux/hardirq.hlinux/init.hlinux/kprobes.hlinux/uaccess.hlinux/page-flags.hlinux/sched/signal.hlinux/sched/debug.hlinux/highmem.hlinux/perf_event.hlinux/kfence.hasm/system_misc.hasm/system_info.hasm/tlbflush.hfault.hfsr-3level.cfsr-2level.c
Detected Declarations
struct fsr_infofunction Copyrightfunction show_ptefunction show_ptefunction die_kernel_faultfunction __do_kernel_faultfunction __do_user_faultfunction do_bad_areafunction ttbr0_usermode_access_allowedfunction ttbr0_usermode_access_allowedfunction vmalloc_faultfunction do_kernel_address_page_faultfunction do_page_faultfunction do_page_faultfunction addressfunction do_translation_faultfunction do_sect_faultfunction do_badfunction hook_fault_codefunction do_DataAbortfunction hook_ifault_codefunction do_PrefetchAbortfunction early_abort_handlerfunction early_abt_enablefunction exceptions_init
Annotated Snippet
fault = handle_mm_fault(vma, addr, flags | FAULT_FLAG_VMA_LOCK, regs);
if (!(fault & (VM_FAULT_RETRY | VM_FAULT_COMPLETED)))
vma_end_read(vma);
if (!(fault & VM_FAULT_RETRY)) {
count_vm_vma_lock_event(VMA_LOCK_SUCCESS);
goto done;
}
count_vm_vma_lock_event(VMA_LOCK_RETRY);
if (fault & VM_FAULT_MAJOR)
flags |= FAULT_FLAG_TRIED;
/* Quick path to respond to signals */
if (fault_signal_pending(fault, regs)) {
if (!user_mode(regs))
goto no_context;
return 0;
}
lock_mmap:
retry:
vma = lock_mm_and_find_vma(mm, addr, regs);
if (unlikely(!vma)) {
fault = 0;
code = SEGV_MAPERR;
goto bad_area;
}
/*
* ok, we have a good vm_area for this memory access, check the
* permissions on the VMA allow for the fault which occurred.
*/
if (!(vma->vm_flags & vm_flags)) {
mmap_read_unlock(mm);
fault = 0;
code = SEGV_ACCERR;
goto bad_area;
}
fault = handle_mm_fault(vma, addr & PAGE_MASK, flags, regs);
/* If we need to retry but a fatal signal is pending, handle the
* signal first. We do not need to release the mmap_lock because
* it would already be released in __lock_page_or_retry in
* mm/filemap.c. */
if (fault_signal_pending(fault, regs)) {
if (!user_mode(regs))
goto no_context;
return 0;
}
/* The fault is fully completed (including releasing mmap lock) */
if (fault & VM_FAULT_COMPLETED)
return 0;
if (!(fault & VM_FAULT_ERROR)) {
if (fault & VM_FAULT_RETRY) {
flags |= FAULT_FLAG_TRIED;
goto retry;
}
}
mmap_read_unlock(mm);
done:
/* Handle the "normal" case first */
if (likely(!(fault & VM_FAULT_ERROR)))
return 0;
code = SEGV_MAPERR;
bad_area:
/*
* If we are in kernel mode at this point, we
* have no context to handle this fault with.
*/
if (!user_mode(regs))
goto no_context;
if (fault & VM_FAULT_OOM) {
/*
* We ran out of memory, call the OOM killer, and return to
* userspace (which will retry the fault, or kill us if we
* got oom-killed)
*/
pagefault_out_of_memory();
return 0;
}
if (fault & VM_FAULT_SIGBUS) {
/*
Annotation
- Immediate include surface: `linux/extable.h`, `linux/signal.h`, `linux/mm.h`, `linux/hardirq.h`, `linux/init.h`, `linux/kprobes.h`, `linux/uaccess.h`, `linux/page-flags.h`.
- Detected declarations: `struct fsr_info`, `function Copyright`, `function show_pte`, `function show_pte`, `function die_kernel_fault`, `function __do_kernel_fault`, `function __do_user_fault`, `function do_bad_area`, `function ttbr0_usermode_access_allowed`, `function ttbr0_usermode_access_allowed`.
- Atlas domain: Architecture Layer / arch/arm.
- Implementation status: source 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.