arch/openrisc/kernel/traps.c
Source file repositories/reference/linux-study-clean/arch/openrisc/kernel/traps.c
File Facts
- System
- Linux kernel
- Corpus path
arch/openrisc/kernel/traps.c- Extension
.c- Size
- 10709 bytes
- Lines
- 440
- Domain
- Architecture Layer
- Bucket
- arch/openrisc
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/sched.hlinux/sched/debug.hlinux/sched/task_stack.hlinux/kernel.hlinux/extable.hlinux/kmod.hlinux/string.hlinux/errno.hlinux/ptrace.hlinux/timer.hlinux/mm.hlinux/kallsyms.hlinux/uaccess.hasm/bug.hasm/fpu.hasm/io.hasm/processor.hasm/unwinder.hasm/sections.h
Detected Declarations
function print_tracefunction print_datafunction show_stackfunction show_registersfunction diefunction unhandled_exceptionfunction do_fpe_trapfunction do_trapfunction do_unaligned_accessfunction do_bus_faultfunction in_delay_slotfunction adjust_pcfunction simulate_lwafunction simulate_swafunction do_illegal_instruction
Annotated Snippet
if (__get_user(word, &((unsigned long *)esp)[i])) {
bad_stack:
pr_info(" Bad Stack value.");
break;
}
print_data(esp, word, i);
}
pr_info("\nCode: ");
if (regs->pc < PAGE_OFFSET)
goto bad;
for (i = -6; i < 6; i += 1) {
unsigned long word;
if (__get_user(word, &((unsigned long *)regs->pc)[i])) {
bad:
pr_info(" Bad PC value.");
break;
}
print_data(regs->pc, word, i);
}
}
pr_info("\n");
}
/* This is normally the 'Oops' routine */
void __noreturn die(const char *str, struct pt_regs *regs, long err)
{
console_verbose();
pr_emerg("\n%s#: %04lx\n", str, err & 0xffff);
show_registers(regs);
#ifdef CONFIG_JUMP_UPON_UNHANDLED_EXCEPTION
pr_emerg("\n\nUNHANDLED_EXCEPTION: entering infinite loop\n");
/* shut down interrupts */
local_irq_disable();
__asm__ __volatile__("l.nop 1");
do {} while (1);
#endif
make_task_dead(SIGSEGV);
}
asmlinkage void unhandled_exception(struct pt_regs *regs, int ea, int vector)
{
pr_emerg("Unable to handle exception at EA =0x%x, vector 0x%x",
ea, vector);
die("Oops", regs, 9);
}
asmlinkage void do_fpe_trap(struct pt_regs *regs, unsigned long address)
{
if (user_mode(regs)) {
int code = FPE_FLTUNK;
#ifdef CONFIG_FPU
unsigned long fpcsr;
save_fpu(current);
fpcsr = current->thread.fpcsr;
if (fpcsr & SPR_FPCSR_IVF)
code = FPE_FLTINV;
else if (fpcsr & SPR_FPCSR_OVF)
code = FPE_FLTOVF;
else if (fpcsr & SPR_FPCSR_UNF)
code = FPE_FLTUND;
else if (fpcsr & SPR_FPCSR_DZF)
code = FPE_FLTDIV;
else if (fpcsr & SPR_FPCSR_IXF)
code = FPE_FLTRES;
/* Clear all flags */
current->thread.fpcsr &= ~SPR_FPCSR_ALLF;
restore_fpu(current);
#endif
force_sig_fault(SIGFPE, code, (void __user *)regs->pc);
} else {
pr_emerg("KERNEL: Illegal fpe exception 0x%.8lx\n", regs->pc);
die("Die:", regs, SIGFPE);
}
}
asmlinkage void do_trap(struct pt_regs *regs, unsigned long address)
{
if (user_mode(regs)) {
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc);
Annotation
- Immediate include surface: `linux/init.h`, `linux/sched.h`, `linux/sched/debug.h`, `linux/sched/task_stack.h`, `linux/kernel.h`, `linux/extable.h`, `linux/kmod.h`, `linux/string.h`.
- Detected declarations: `function print_trace`, `function print_data`, `function show_stack`, `function show_registers`, `function die`, `function unhandled_exception`, `function do_fpe_trap`, `function do_trap`, `function do_unaligned_access`, `function do_bus_fault`.
- Atlas domain: Architecture Layer / arch/openrisc.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.