arch/arm/kernel/traps.c
Source file repositories/reference/linux-study-clean/arch/arm/kernel/traps.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/kernel/traps.c- Extension
.c- Size
- 24273 bytes
- Lines
- 966
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/signal.hlinux/personality.hlinux/kallsyms.hlinux/spinlock.hlinux/uaccess.hlinux/hardirq.hlinux/kdebug.hlinux/kprobes.hlinux/module.hlinux/kexec.hlinux/bug.hlinux/delay.hlinux/init.hlinux/sched/signal.hlinux/sched/debug.hlinux/sched/task_stack.hlinux/irq.hlinux/vmalloc.hlinux/atomic.hasm/cacheflush.hasm/exception.hasm/spectre.hasm/unistd.hasm/traps.hasm/ptrace.hasm/unwind.hasm/tls.hasm/stacktrace.hasm/system_misc.hasm/opcodes.h
Detected Declarations
function user_debug_setupfunction dump_backtrace_entryfunction dump_backtrace_stmfunction verify_stackfunction dump_memfunction dump_instrfunction dump_backtracefunction dump_backtracefunction show_stackfunction __diefunction oops_beginfunction oops_endfunction diefunction arm_notify_diefunction is_valid_bugaddrfunction register_undef_hookfunction unregister_undef_hookfunction call_undef_hookfunction do_undefinstrfunction handle_fiq_as_nmifunction bad_modefunction bad_syscallfunction __do_cache_opfunction do_cache_opfunction arm_syscallfunction get_tp_trapfunction arm_mrc_hook_initfunction baddataabortfunction __readwrite_bugfunction __pte_errorfunction __pmd_errorfunction __pgd_errorfunction __div0function abortfunction kuser_initfunction kuser_initfunction flush_vectorsfunction spectre_bhb_update_vectorsfunction early_trap_initfunction early_trap_initfunction allocate_overflow_stacksfunction for_each_possible_cpufunction handle_bad_stackfunction arch_sync_kernel_mappingsexport __readwrite_bugexport __div0
Annotated Snippet
if (instruction & BIT(reg)) {
p += sprintf(p, " r%d:%08x", reg, *stack--);
if (++x == 6) {
x = 0;
p = str;
printk("%s%s\n", loglvl, str);
}
}
}
if (p != str)
printk("%s%s\n", loglvl, str);
}
#ifndef CONFIG_ARM_UNWIND
/*
* Stack pointers should always be within the kernels view of
* physical memory. If it is not there, then we can't dump
* out any information relating to the stack.
*/
static int verify_stack(unsigned long sp)
{
if (sp < PAGE_OFFSET ||
(!IS_ENABLED(CONFIG_VMAP_STACK) &&
sp > (unsigned long)high_memory && high_memory != NULL))
return -EFAULT;
return 0;
}
#endif
/*
* Dump out the contents of some memory nicely...
*/
void dump_mem(const char *lvl, const char *str, unsigned long bottom,
unsigned long top)
{
unsigned long first;
int i;
printk("%s%s(0x%08lx to 0x%08lx)\n", lvl, str, bottom, top);
for (first = bottom & ~31; first < top; first += 32) {
unsigned long p;
char str[sizeof(" 12345678") * 8 + 1];
memset(str, ' ', sizeof(str));
str[sizeof(str) - 1] = '\0';
for (p = first, i = 0; i < 8 && p < top; i++, p += 4) {
if (p >= bottom && p < top) {
unsigned long val;
if (!get_kernel_nofault(val, (unsigned long *)p))
sprintf(str + i * 9, " %08lx", val);
else
sprintf(str + i * 9, " ????????");
}
}
printk("%s%04lx:%s\n", lvl, first & 0xffff, str);
}
}
static void dump_instr(const char *lvl, struct pt_regs *regs)
{
unsigned long addr = instruction_pointer(regs);
const int thumb = thumb_mode(regs);
const int width = thumb ? 4 : 8;
char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str;
int i;
/*
* Note that we now dump the code first, just in case the backtrace
* kills us.
*/
for (i = -4; i < 1 + !!thumb; i++) {
unsigned int val, bad;
if (thumb) {
u16 tmp;
if (user_mode(regs))
bad = get_user(tmp, &((u16 __user *)addr)[i]);
else
bad = get_kernel_nofault(tmp, &((u16 *)addr)[i]);
val = __mem_to_opcode_thumb16(tmp);
} else {
if (user_mode(regs))
bad = get_user(val, &((u32 __user *)addr)[i]);
else
Annotation
- Immediate include surface: `linux/signal.h`, `linux/personality.h`, `linux/kallsyms.h`, `linux/spinlock.h`, `linux/uaccess.h`, `linux/hardirq.h`, `linux/kdebug.h`, `linux/kprobes.h`.
- Detected declarations: `function user_debug_setup`, `function dump_backtrace_entry`, `function dump_backtrace_stm`, `function verify_stack`, `function dump_mem`, `function dump_instr`, `function dump_backtrace`, `function dump_backtrace`, `function show_stack`, `function __die`.
- Atlas domain: Architecture Layer / arch/arm.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.