arch/arm64/mm/fault.c
Source file repositories/reference/linux-study-clean/arch/arm64/mm/fault.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/mm/fault.c- Extension
.c- Size
- 30168 bytes
- Lines
- 1046
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/bitfield.hlinux/bpf_defs.hlinux/extable.hlinux/kfence.hlinux/signal.hlinux/mm.hlinux/hardirq.hlinux/init.hlinux/kasan.hlinux/kprobes.hlinux/uaccess.hlinux/page-flags.hlinux/sched/signal.hlinux/sched/debug.hlinux/highmem.hlinux/perf_event.hlinux/pkeys.hlinux/preempt.hlinux/hugetlb.hasm/acpi.hasm/bug.hasm/cmpxchg.hasm/cpufeature.hasm/efi.hasm/exception.hasm/daifflags.hasm/debug-monitors.hasm/esr.hasm/kprobes.hasm/mte.hasm/processor.h
Detected Declarations
struct fault_infofunction data_abort_decodefunction mem_abort_decodefunction mm_to_pgd_physfunction show_ptefunction flagsfunction flush_tlb_fix_spurious_faultfunction is_el1_instruction_abortfunction is_el1_data_abortfunction is_el1_permission_faultfunction is_pkvm_stage2_abortfunction is_spurious_el1_translation_faultfunction die_kernel_faultfunction report_tag_faultfunction report_tag_faultfunction is_el1_mte_sync_tag_check_faultfunction __do_kernel_faultfunction set_thread_esrfunction do_bad_areafunction fault_from_pkeyfunction is_gcs_faultfunction is_el0_instruction_abortfunction is_write_abortfunction is_invalid_gcs_accessfunction do_page_faultfunction do_translation_faultfunction do_alignment_faultfunction do_badfunction do_seafunction do_tag_check_faultfunction do_mem_abortfunction do_sp_pc_abortfunction tag_clear_highpages
Annotated Snippet
fault = handle_mm_fault(vma, addr, mm_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)
mm_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;
si_code = SEGV_MAPERR;
goto bad_area;
}
if (!(vma->vm_flags & vm_flags)) {
mmap_read_unlock(mm);
fault = 0;
si_code = SEGV_ACCERR;
goto bad_area;
}
if (fault_from_pkey(vma, mm_flags)) {
pkey = vma_pkey(vma);
mmap_read_unlock(mm);
fault = 0;
si_code = SEGV_PKUERR;
goto bad_area;
}
fault = handle_mm_fault(vma, addr, mm_flags, regs);
/* Quick path to respond to signals */
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_RETRY) {
mm_flags |= FAULT_FLAG_TRIED;
goto retry;
}
mmap_read_unlock(mm);
done:
/* Handle the "normal" (no error) case first. */
if (likely(!(fault & VM_FAULT_ERROR)))
return 0;
si_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;
}
inf = esr_to_fault_info(esr);
set_thread_esr(addr, esr);
if (fault & VM_FAULT_SIGBUS) {
/*
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bitfield.h`, `linux/bpf_defs.h`, `linux/extable.h`, `linux/kfence.h`, `linux/signal.h`, `linux/mm.h`, `linux/hardirq.h`.
- Detected declarations: `struct fault_info`, `function data_abort_decode`, `function mem_abort_decode`, `function mm_to_pgd_phys`, `function show_pte`, `function flags`, `function flush_tlb_fix_spurious_fault`, `function is_el1_instruction_abort`, `function is_el1_data_abort`, `function is_el1_permission_fault`.
- Atlas domain: Architecture Layer / arch/arm64.
- 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.