arch/alpha/kernel/traps.c
Source file repositories/reference/linux-study-clean/arch/alpha/kernel/traps.c
File Facts
- System
- Linux kernel
- Corpus path
arch/alpha/kernel/traps.c- Extension
.c- Size
- 23833 bytes
- Lines
- 930
- Domain
- Architecture Layer
- Bucket
- arch/alpha
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cpu.hlinux/jiffies.hlinux/mm.hlinux/sched/signal.hlinux/sched/debug.hlinux/tty.hlinux/delay.hlinux/extable.hlinux/kallsyms.hlinux/ratelimit.hasm/gentrap.hlinux/uaccess.hlinux/unaligned.hasm/sysinfo.hasm/hwrpb.hasm/mmu_context.hasm/special_insns.hproto.h
Detected Declarations
struct allregsstruct unaligned_statfunction dik_show_regsfunction dik_show_codefunction dik_show_tracefunction show_stackfunction die_if_kernelfunction dummy_emulfunction do_entArithfunction do_entIFfunction do_entDbgfunction do_entUnafunction s_mem_to_regfunction s_reg_to_memfunction do_entUnaUserfunction trap_initexport alpha_fp_emul_impreciseexport alpha_fp_emul
Annotated Snippet
struct allregs {
unsigned long regs[32];
unsigned long ps, pc, gp, a0, a1, a2;
};
struct unaligned_stat {
unsigned long count, va, pc;
} unaligned[2];
/* Macro for exception fixup code to access integer registers. */
#define una_reg(r) (_regs[(r) >= 16 && (r) <= 18 ? (r)+19 : (r)])
asmlinkage void
do_entUna(void * va, unsigned long opcode, unsigned long reg,
struct allregs *regs)
{
long error, tmp1, tmp2, tmp3, tmp4;
unsigned long pc = regs->pc - 4;
unsigned long *_regs = regs->regs;
const struct exception_table_entry *fixup;
unaligned[0].count++;
unaligned[0].va = (unsigned long) va;
unaligned[0].pc = pc;
/* We don't want to use the generic get/put unaligned macros as
we want to trap exceptions. Only if we actually get an
exception will we decide whether we should have caught it. */
switch (opcode) {
case 0x0c: /* ldwu */
__asm__ __volatile__(
"1: ldq_u %1,0(%3)\n"
"2: ldq_u %2,1(%3)\n"
" extwl %1,%3,%1\n"
" extwh %2,%3,%2\n"
"3:\n"
EXC(1b,3b,%1,%0)
EXC(2b,3b,%2,%0)
: "=r"(error), "=&r"(tmp1), "=&r"(tmp2)
: "r"(va), "0"(0));
if (error)
goto got_exception;
una_reg(reg) = tmp1|tmp2;
return;
case 0x28: /* ldl */
__asm__ __volatile__(
"1: ldq_u %1,0(%3)\n"
"2: ldq_u %2,3(%3)\n"
" extll %1,%3,%1\n"
" extlh %2,%3,%2\n"
"3:\n"
EXC(1b,3b,%1,%0)
EXC(2b,3b,%2,%0)
: "=r"(error), "=&r"(tmp1), "=&r"(tmp2)
: "r"(va), "0"(0));
if (error)
goto got_exception;
una_reg(reg) = (int)(tmp1|tmp2);
return;
case 0x29: /* ldq */
__asm__ __volatile__(
"1: ldq_u %1,0(%3)\n"
"2: ldq_u %2,7(%3)\n"
" extql %1,%3,%1\n"
" extqh %2,%3,%2\n"
"3:\n"
EXC(1b,3b,%1,%0)
EXC(2b,3b,%2,%0)
: "=r"(error), "=&r"(tmp1), "=&r"(tmp2)
: "r"(va), "0"(0));
if (error)
goto got_exception;
una_reg(reg) = tmp1|tmp2;
return;
/* Note that the store sequences do not indicate that they change
memory because it _should_ be affecting nothing in this context.
(Otherwise we have other, much larger, problems.) */
case 0x0d: /* stw */
__asm__ __volatile__(
"1: ldq_u %2,1(%5)\n"
"2: ldq_u %1,0(%5)\n"
" inswh %6,%5,%4\n"
" inswl %6,%5,%3\n"
" mskwh %2,%5,%2\n"
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/jiffies.h`, `linux/mm.h`, `linux/sched/signal.h`, `linux/sched/debug.h`, `linux/tty.h`, `linux/delay.h`, `linux/extable.h`.
- Detected declarations: `struct allregs`, `struct unaligned_stat`, `function dik_show_regs`, `function dik_show_code`, `function dik_show_trace`, `function show_stack`, `function die_if_kernel`, `function dummy_emul`, `function do_entArith`, `function do_entIF`.
- Atlas domain: Architecture Layer / arch/alpha.
- Implementation status: integration 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.