arch/mips/kernel/unaligned.c
Source file repositories/reference/linux-study-clean/arch/mips/kernel/unaligned.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/kernel/unaligned.c- Extension
.c- Size
- 35251 bytes
- Lines
- 1615
- Domain
- Architecture Layer
- Bucket
- arch/mips
- 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/context_tracking.hlinux/mm.hlinux/signal.hlinux/smp.hlinux/sched.hlinux/debugfs.hlinux/perf_event.hasm/asm.hasm/branch.hasm/byteorder.hasm/cop2.hasm/debug.hasm/fpu.hasm/fpu_emulator.hasm/inst.hasm/unaligned-emul.hasm/mmu_context.hasm/traps.hlinux/uaccess.haccess-helper.h
Detected Declarations
function emulate_load_store_insnfunction emulate_load_store_microMIPSfunction emulate_load_store_MIPS16efunction do_adefunction debugfs_unaligned
Annotated Snippet
switch (insn.mxu_lx_format.op) {
case mxu_lxw_op:
if (user && !access_ok(addr, 4))
goto sigbus;
LoadW(addr, value, res);
if (res)
goto fault;
compute_return_epc(regs);
regs->regs[insn.mxu_lx_format.rd] = value;
break;
case mxu_lxh_op:
if (user && !access_ok(addr, 2))
goto sigbus;
LoadHW(addr, value, res);
if (res)
goto fault;
compute_return_epc(regs);
regs->regs[insn.dsp_format.rd] = value;
break;
case mxu_lxhu_op:
if (user && !access_ok(addr, 2))
goto sigbus;
LoadHWU(addr, value, res);
if (res)
goto fault;
compute_return_epc(regs);
regs->regs[insn.dsp_format.rd] = value;
break;
case mxu_lxb_op:
case mxu_lxbu_op:
goto sigbus;
default:
goto sigill;
}
break;
#endif
case spec3_op:
if (insn.dsp_format.func == lx_op) {
switch (insn.dsp_format.op) {
case lwx_op:
if (user && !access_ok(addr, 4))
goto sigbus;
LoadW(addr, value, res);
if (res)
goto fault;
compute_return_epc(regs);
regs->regs[insn.dsp_format.rd] = value;
break;
case lhx_op:
if (user && !access_ok(addr, 2))
goto sigbus;
LoadHW(addr, value, res);
if (res)
goto fault;
compute_return_epc(regs);
regs->regs[insn.dsp_format.rd] = value;
break;
default:
goto sigill;
}
}
#ifdef CONFIG_EVA
else {
/*
* we can land here only from kernel accessing user
* memory, so we need to "switch" the address limit to
* user space, so that address check can work properly.
*/
switch (insn.spec3_format.func) {
case lhe_op:
if (!access_ok(addr, 2))
goto sigbus;
LoadHWE(addr, value, res);
if (res)
goto fault;
compute_return_epc(regs);
regs->regs[insn.spec3_format.rt] = value;
break;
case lwe_op:
if (!access_ok(addr, 4))
goto sigbus;
LoadWE(addr, value, res);
if (res)
goto fault;
compute_return_epc(regs);
regs->regs[insn.spec3_format.rt] = value;
break;
case lhue_op:
if (!access_ok(addr, 2))
goto sigbus;
Annotation
- Immediate include surface: `linux/context_tracking.h`, `linux/mm.h`, `linux/signal.h`, `linux/smp.h`, `linux/sched.h`, `linux/debugfs.h`, `linux/perf_event.h`, `asm/asm.h`.
- Detected declarations: `function emulate_load_store_insn`, `function emulate_load_store_microMIPS`, `function emulate_load_store_MIPS16e`, `function do_ade`, `function debugfs_unaligned`.
- Atlas domain: Architecture Layer / arch/mips.
- 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.