arch/sh/kernel/traps_32.c
Source file repositories/reference/linux-study-clean/arch/sh/kernel/traps_32.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sh/kernel/traps_32.c- Extension
.c- Size
- 18998 bytes
- Lines
- 797
- Domain
- Architecture Layer
- Bucket
- arch/sh
- 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/kernel.hlinux/ptrace.hlinux/hardirq.hlinux/init.hlinux/spinlock.hlinux/kallsyms.hlinux/io.hlinux/bug.hlinux/debug_locks.hlinux/kdebug.hlinux/limits.hlinux/sysfs.hlinux/uaccess.hlinux/perf_event.hlinux/sched/task_stack.hasm/alignment.hasm/fpu.hasm/kprobes.hasm/setup.hasm/traps.hasm/bl_bit.h
Detected Declarations
function Copyrightfunction copy_from_kernel_wrapperfunction copy_to_kernel_wrapperfunction handle_unaligned_insfunction handle_delayslotfunction handle_unaligned_accessfunction do_address_errorfunction is_dsp_instfunction is_dsp_instfunction do_divide_errorfunction do_reserved_instfunction emulate_branchfunction do_illegal_slot_instfunction do_exception_errorfunction per_cpu_trap_initfunction trap_init
Annotated Snippet
if (instruction & 8) {
/* from memory */
srcu = (unsigned char __user *)*rm;
srcu += regs->regs[0];
dst = (unsigned char *)rn;
*(unsigned long *)dst = 0;
#if !defined(__LITTLE_ENDIAN__)
dst += 4-count;
#endif
if (ma->from(dst, srcu, count))
goto fetch_fault;
sign_extend(count, dst);
} else {
/* to memory */
src = (unsigned char *)rm;
#if !defined(__LITTLE_ENDIAN__)
src += 4-count;
#endif
dstu = (unsigned char __user *)*rn;
dstu += regs->regs[0];
if (ma->to(dstu, src, count))
goto fetch_fault;
}
ret = 0;
break;
case 1: /* mov.l Rm,@(disp,Rn) */
src = (unsigned char*) rm;
dstu = (unsigned char __user *)*rn;
dstu += (instruction&0x000F)<<2;
if (ma->to(dstu, src, 4))
goto fetch_fault;
ret = 0;
break;
case 2: /* mov.[bwl] to memory, possibly with pre-decrement */
if (instruction & 4)
*rn -= count;
src = (unsigned char*) rm;
dstu = (unsigned char __user *)*rn;
#if !defined(__LITTLE_ENDIAN__)
src += 4-count;
#endif
if (ma->to(dstu, src, count))
goto fetch_fault;
ret = 0;
break;
case 5: /* mov.l @(disp,Rm),Rn */
srcu = (unsigned char __user *)*rm;
srcu += (instruction & 0x000F) << 2;
dst = (unsigned char *)rn;
*(unsigned long *)dst = 0;
if (ma->from(dst, srcu, 4))
goto fetch_fault;
ret = 0;
break;
case 6: /* mov.[bwl] from memory, possibly with post-increment */
srcu = (unsigned char __user *)*rm;
if (instruction & 4)
*rm += count;
dst = (unsigned char*) rn;
*(unsigned long*)dst = 0;
#if !defined(__LITTLE_ENDIAN__)
dst += 4-count;
#endif
if (ma->from(dst, srcu, count))
goto fetch_fault;
sign_extend(count, dst);
ret = 0;
break;
case 8:
switch ((instruction&0xFF00)>>8) {
case 0x81: /* mov.w R0,@(disp,Rn) */
src = (unsigned char *) ®s->regs[0];
#if !defined(__LITTLE_ENDIAN__)
src += 2;
#endif
dstu = (unsigned char __user *)*rm; /* called Rn in the spec */
dstu += (instruction & 0x000F) << 1;
if (ma->to(dstu, src, 2))
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/ptrace.h`, `linux/hardirq.h`, `linux/init.h`, `linux/spinlock.h`, `linux/kallsyms.h`, `linux/io.h`, `linux/bug.h`.
- Detected declarations: `function Copyright`, `function copy_from_kernel_wrapper`, `function copy_to_kernel_wrapper`, `function handle_unaligned_ins`, `function handle_delayslot`, `function handle_unaligned_access`, `function do_address_error`, `function is_dsp_inst`, `function is_dsp_inst`, `function do_divide_error`.
- Atlas domain: Architecture Layer / arch/sh.
- 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.