arch/mips/kernel/traps.c
Source file repositories/reference/linux-study-clean/arch/mips/kernel/traps.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/kernel/traps.c- Extension
.c- Size
- 63046 bytes
- Lines
- 2534
- Domain
- Architecture Layer
- Bucket
- arch/mips
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/bug.hlinux/compiler.hlinux/context_tracking.hlinux/cpu_pm.hlinux/kexec.hlinux/init.hlinux/kernel.hlinux/module.hlinux/extable.hlinux/mm.hlinux/sched/mm.hlinux/sched/debug.hlinux/smp.hlinux/spinlock.hlinux/kallsyms.hlinux/memblock.hlinux/interrupt.hlinux/ptrace.hlinux/kgdb.hlinux/kdebug.hlinux/kprobes.hlinux/notifier.hlinux/kdb.hlinux/irq.hlinux/perf_event.hlinux/string_choices.hasm/addrspace.hasm/bootinfo.hasm/branch.hasm/break.hasm/cop2.h
Detected Declarations
function mips_set_be_handlerfunction show_raw_backtracefunction set_raw_show_tracefunction show_backtracefunction get_userfunction show_stackfunction show_codefunction __show_regsfunction show_regsfunction show_registersfunction diefunction do_befunction simulate_llfunction simulate_scfunction simulate_llscfunction simulate_rdhwrfunction simulate_rdhwr_normalfunction simulate_rdhwr_mmfunction simulate_syncfunction simulate_loongson3_cpucfgfunction do_ovfunction force_fcr31_sigfunction process_fpemu_returnfunction simulate_fpfunction do_fpefunction mt_ase_fp_affinityfunction simulate_fpfunction do_trap_or_bpfunction do_bpfunction do_trfunction do_rifunction likelyfunction register_cu2_notifierfunction cu2_notifier_call_chainfunction default_cu2_callfunction enable_restore_fp_contextfunction enable_restore_fp_contextfunction do_cpufunction do_msa_fpefunction do_msafunction do_mdmxfunction do_watchfunction do_mcheckfunction do_mtfunction do_dspfunction do_reservedfunction nol1parityfunction nol2parity
Annotated Snippet
if (__get_addr(&addr, sp++, user)) {
printk("%s (Bad stack address)", loglvl);
break;
}
if (__kernel_text_address(addr))
print_ip_sym(loglvl, addr);
}
printk("%s\n", loglvl);
}
#ifdef CONFIG_KALLSYMS
int raw_show_trace;
static int __init set_raw_show_trace(char *str)
{
raw_show_trace = 1;
return 1;
}
__setup("raw_show_trace", set_raw_show_trace);
#endif
static void show_backtrace(struct task_struct *task, const struct pt_regs *regs,
const char *loglvl, bool user)
{
unsigned long sp = regs->regs[29];
unsigned long ra = regs->regs[31];
unsigned long pc = regs->cp0_epc;
if (!task)
task = current;
if (raw_show_trace || user_mode(regs) || !__kernel_text_address(pc)) {
show_raw_backtrace(sp, loglvl, user);
return;
}
printk("%sCall Trace:\n", loglvl);
do {
print_ip_sym(loglvl, pc);
pc = unwind_stack(task, &sp, pc, &ra);
} while (pc);
pr_cont("\n");
}
/*
* This routine abuses get_user()/put_user() to reference pointers
* with at least a bit of error checking ...
*/
static void show_stacktrace(struct task_struct *task,
const struct pt_regs *regs, const char *loglvl, bool user)
{
const int field = 2 * sizeof(unsigned long);
unsigned long stackdata;
int i;
unsigned long *sp = (unsigned long *)regs->regs[29];
printk("%sStack :", loglvl);
i = 0;
while ((unsigned long) sp & (PAGE_SIZE - 1)) {
if (i && ((i % (64 / field)) == 0)) {
pr_cont("\n");
printk("%s ", loglvl);
}
if (i > 39) {
pr_cont(" ...");
break;
}
if (__get_addr(&stackdata, sp++, user)) {
pr_cont(" (Bad stack address)");
break;
}
pr_cont(" %0*lx", field, stackdata);
i++;
}
pr_cont("\n");
show_backtrace(task, regs, loglvl, user);
}
void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
{
struct pt_regs regs;
regs.cp0_status = KSU_KERNEL;
if (sp) {
regs.regs[29] = (unsigned long)sp;
regs.regs[31] = 0;
regs.cp0_epc = 0;
} else {
if (task && task != current) {
regs.regs[29] = task->thread.reg29;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/bug.h`, `linux/compiler.h`, `linux/context_tracking.h`, `linux/cpu_pm.h`, `linux/kexec.h`, `linux/init.h`, `linux/kernel.h`.
- Detected declarations: `function mips_set_be_handler`, `function show_raw_backtrace`, `function set_raw_show_trace`, `function show_backtrace`, `function get_user`, `function show_stack`, `function show_code`, `function __show_regs`, `function show_regs`, `function show_registers`.
- Atlas domain: Architecture Layer / arch/mips.
- 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.