arch/mips/kernel/ptrace.c
Source file repositories/reference/linux-study-clean/arch/mips/kernel/ptrace.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/kernel/ptrace.c- Extension
.c- Size
- 33502 bytes
- Lines
- 1373
- Domain
- Architecture Layer
- Bucket
- arch/mips
- 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/compiler.hlinux/context_tracking.hlinux/elf.hlinux/kernel.hlinux/sched.hlinux/sched/task_stack.hlinux/mm.hlinux/errno.hlinux/ptrace.hlinux/regset.hlinux/smp.hlinux/security.hlinux/stddef.hlinux/audit.hlinux/seccomp.hlinux/ftrace.hasm/branch.hasm/byteorder.hasm/cpu.hasm/cpu-info.hasm/dsp.hasm/fpu.hasm/mipsregs.hasm/mipsmtregs.hasm/page.hasm/processor.hasm/syscall.hlinux/uaccess.hasm/bootinfo.hasm/reg.htrace/events/syscalls.h
Detected Declarations
struct msa_control_regsstruct pt_regs_offsetenum mips_regsetfunction Copyrightfunction ptrace_disablefunction ptrace_getregsfunction ptrace_setregsfunction ptrace_get_watch_regsfunction ptrace_set_watch_regsfunction gpr32_getfunction gpr32_setfunction gpr64_getfunction gpr64_setfunction ptrace_setfcr31function ptrace_getfpregsfunction ptrace_setfpregsfunction fpr_get_fpafunction fpr_get_msafunction fpr_getfunction fpr_set_fpafunction fpr_set_msafunction fpr_setfunction fp_mode_getfunction fp_mode_setfunction copy_pad_fprsfunction msa_getfunction msa_setfunction dsp32_getfunction dsp32_setfunction dsp64_getfunction dsp64_setfunction dsp_activefunction regs_query_register_offsetfunction arch_ptracefunction syscall_trace_enterfunction syscall_trace_leaveexport exception_ip
Annotated Snippet
struct msa_control_regs {
unsigned int fir;
unsigned int fcsr;
unsigned int msair;
unsigned int msacsr;
};
static void copy_pad_fprs(struct task_struct *target,
const struct user_regset *regset,
struct membuf *to,
unsigned int live_sz)
{
int i, j;
unsigned long long fill = ~0ull;
unsigned int cp_sz, pad_sz;
cp_sz = min(regset->size, live_sz);
pad_sz = regset->size - cp_sz;
WARN_ON(pad_sz % sizeof(fill));
for (i = 0; i < NUM_FPU_REGS; i++) {
membuf_write(to, &target->thread.fpu.fpr[i], cp_sz);
for (j = 0; j < (pad_sz / sizeof(fill)); j++)
membuf_store(to, fill);
}
}
static int msa_get(struct task_struct *target,
const struct user_regset *regset,
struct membuf to)
{
const unsigned int wr_size = NUM_FPU_REGS * regset->size;
const struct msa_control_regs ctrl_regs = {
.fir = boot_cpu_data.fpu_id,
.fcsr = target->thread.fpu.fcr31,
.msair = boot_cpu_data.msa_id,
.msacsr = target->thread.fpu.msacsr,
};
if (!tsk_used_math(target)) {
/* The task hasn't used FP or MSA, fill with 0xff */
copy_pad_fprs(target, regset, &to, 0);
} else if (!test_tsk_thread_flag(target, TIF_MSA_CTX_LIVE)) {
/* Copy scalar FP context, fill the rest with 0xff */
copy_pad_fprs(target, regset, &to, 8);
} else if (sizeof(target->thread.fpu.fpr[0]) == regset->size) {
/* Trivially copy the vector registers */
membuf_write(&to, &target->thread.fpu.fpr, wr_size);
} else {
/* Copy as much context as possible, fill the rest with 0xff */
copy_pad_fprs(target, regset, &to,
sizeof(target->thread.fpu.fpr[0]));
}
return membuf_write(&to, &ctrl_regs, sizeof(ctrl_regs));
}
static int msa_set(struct task_struct *target,
const struct user_regset *regset,
unsigned int pos, unsigned int count,
const void *kbuf, const void __user *ubuf)
{
const unsigned int wr_size = NUM_FPU_REGS * regset->size;
struct msa_control_regs ctrl_regs;
unsigned int cp_sz;
int i, err, start;
init_fp_ctx(target);
if (sizeof(target->thread.fpu.fpr[0]) == regset->size) {
/* Trivially copy the vector registers */
err = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
&target->thread.fpu.fpr,
0, wr_size);
} else {
/* Copy as much context as possible */
cp_sz = min_t(unsigned int, regset->size,
sizeof(target->thread.fpu.fpr[0]));
i = start = err = 0;
for (; i < NUM_FPU_REGS; i++, start += regset->size) {
err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf,
&target->thread.fpu.fpr[i],
start, start + cp_sz);
}
}
if (!err)
err = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl_regs,
wr_size, wr_size + sizeof(ctrl_regs));
Annotation
- Immediate include surface: `linux/compiler.h`, `linux/context_tracking.h`, `linux/elf.h`, `linux/kernel.h`, `linux/sched.h`, `linux/sched/task_stack.h`, `linux/mm.h`, `linux/errno.h`.
- Detected declarations: `struct msa_control_regs`, `struct pt_regs_offset`, `enum mips_regset`, `function Copyright`, `function ptrace_disable`, `function ptrace_getregs`, `function ptrace_setregs`, `function ptrace_get_watch_regs`, `function ptrace_set_watch_regs`, `function gpr32_get`.
- Atlas domain: Architecture Layer / arch/mips.
- 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.