arch/nios2/kernel/traps.c
Source file repositories/reference/linux-study-clean/arch/nios2/kernel/traps.c
File Facts
- System
- Linux kernel
- Corpus path
arch/nios2/kernel/traps.c- Extension
.c- Size
- 4750 bytes
- Lines
- 197
- Domain
- Architecture Layer
- Bucket
- arch/nios2
- 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.
- 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/sched.hlinux/sched/debug.hlinux/kernel.hlinux/signal.hlinux/export.hlinux/mm.hlinux/ptrace.hasm/traps.hasm/sections.hlinux/uaccess.h
Detected Declarations
function _send_sigfunction diefunction _exceptionfunction show_stackfunction breakpoint_cfunction handle_unaligned_cfunction handle_illegal_cfunction handle_supervisor_instrfunction handle_diverror_cfunction unhandled_exceptionfunction handle_trap_1_cfunction handle_trap_2_cfunction handle_trap_3_c
Annotated Snippet
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/kernel.h>
#include <linux/signal.h>
#include <linux/export.h>
#include <linux/mm.h>
#include <linux/ptrace.h>
#include <asm/traps.h>
#include <asm/sections.h>
#include <linux/uaccess.h>
static DEFINE_SPINLOCK(die_lock);
static void _send_sig(int signo, int code, unsigned long addr)
{
force_sig_fault(signo, code, (void __user *) addr);
}
void die(const char *str, struct pt_regs *regs, long err)
{
console_verbose();
spin_lock_irq(&die_lock);
pr_warn("Oops: %s, sig: %ld\n", str, err);
show_regs(regs);
spin_unlock_irq(&die_lock);
/*
* make_task_dead() should take care of panic'ing from an interrupt
* context so we don't handle it here
*/
make_task_dead(err);
}
void _exception(int signo, struct pt_regs *regs, int code, unsigned long addr)
{
if (!user_mode(regs))
die("Exception in kernel mode", regs, signo);
_send_sig(signo, code, addr);
}
/*
* The show_stack() is external API which we do not use ourselves.
*/
int kstack_depth_to_print = 48;
void show_stack(struct task_struct *task, unsigned long *stack,
const char *loglvl)
{
unsigned long *endstack, addr;
int i;
if (!stack) {
if (task)
stack = (unsigned long *)task->thread.ksp;
else
stack = (unsigned long *)&stack;
}
addr = (unsigned long) stack;
endstack = (unsigned long *) PAGE_ALIGN(addr);
printk("%sStack from %08lx:", loglvl, (unsigned long)stack);
for (i = 0; i < kstack_depth_to_print; i++) {
if (stack + 1 > endstack)
break;
if (i % 8 == 0)
printk("%s\n ", loglvl);
printk("%s %08lx", loglvl, *stack++);
}
printk("%s\nCall Trace:", loglvl);
i = 0;
while (stack + 1 <= endstack) {
addr = *stack++;
/*
* If the address is either in the text segment of the
* kernel, or in the region which contains vmalloc'ed
* memory, it *may* be the address of a calling
* routine; if so, print it so that someone tracing
* down the cause of the crash will be able to figure
* out the call path that was taken.
*/
if (((addr >= (unsigned long) _stext) &&
(addr <= (unsigned long) _etext))) {
if (i % 4 == 0)
pr_emerg("\n ");
printk("%s [<%08lx>]", loglvl, addr);
i++;
Annotation
- Immediate include surface: `linux/sched.h`, `linux/sched/debug.h`, `linux/kernel.h`, `linux/signal.h`, `linux/export.h`, `linux/mm.h`, `linux/ptrace.h`, `asm/traps.h`.
- Detected declarations: `function _send_sig`, `function die`, `function _exception`, `function show_stack`, `function breakpoint_c`, `function handle_unaligned_c`, `function handle_illegal_c`, `function handle_supervisor_instr`, `function handle_diverror_c`, `function unhandled_exception`.
- Atlas domain: Architecture Layer / arch/nios2.
- Implementation status: source implementation candidate.
- 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.