arch/sparc/kernel/uprobes.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/uprobes.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/uprobes.c- Extension
.c- Size
- 8676 bytes
- Lines
- 321
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- 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/highmem.hlinux/uprobes.hlinux/uaccess.hlinux/sched.hlinux/kdebug.hasm/cacheflush.hkernel.h
Detected Declarations
function Copyrightfunction copy_to_pagefunction arch_uprobe_copy_ixolfunction arch_uprobe_analyze_insnfunction relbranch_fixupfunction retpc_fixupfunction arch_uprobe_skip_sstepfunction arch_uprobe_pre_xolfunction arch_uprobe_post_xolfunction uprobe_trapfunction arch_uprobe_exception_notifyfunction arch_uprobe_abort_xolfunction arch_uprobe_xol_was_trappedfunction arch_uretprobe_hijack_return_addr
Annotated Snippet
if (rd <= 15) {
slot = ®s->u_regs[rd];
} else {
unsigned long fp = regs->u_regs[UREG_FP];
/* Hard case, it goes onto the stack. */
flushw_all();
rd -= 16;
if (test_thread_64bit_stack(fp)) {
unsigned long __user *uslot =
(unsigned long __user *) (fp + STACK_BIAS) + rd;
rc = __put_user(real_pc, uslot);
} else {
unsigned int __user *uslot = (unsigned int
__user *) fp + rd;
rc = __put_user((u32) real_pc, uslot);
}
}
}
if (slot != NULL)
*slot = real_pc;
return rc;
}
/* Single-stepping can be avoided for certain instructions: NOPs and
* instructions that can be emulated. This function determines
* whether the instruction where the uprobe is installed falls in one
* of these cases and emulates it.
*
* This function returns true if the single-stepping can be skipped,
* false otherwise.
*/
bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
{
/* We currently only emulate NOP instructions.
*/
if (auprobe->ixol == (1 << 24)) {
regs->tnpc += 4;
regs->tpc += 4;
return true;
}
return false;
}
/* Prepare to execute out of line. At this point
* current->utask->xol_vaddr points to an allocated XOL slot properly
* initialized with the original instruction and the single-stepping
* trap instruction.
*
* This function returns 0 on success, any other number on error.
*/
int arch_uprobe_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
{
struct uprobe_task *utask = current->utask;
struct arch_uprobe_task *autask = ¤t->utask->autask;
/* Save the current program counters so they can be restored
* later.
*/
autask->saved_tpc = regs->tpc;
autask->saved_tnpc = regs->tnpc;
/* Adjust PC and NPC so the first instruction in the XOL slot
* will be executed by the user task.
*/
instruction_pointer_set(regs, utask->xol_vaddr);
return 0;
}
/* Prepare to resume execution after the single-step. Called after
* single-stepping. To avoid the SMP problems that can occur when we
* temporarily put back the original opcode to single-step, we
* single-stepped a copy of the instruction.
*
* This function returns 0 on success, any other number on error.
*/
int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
{
struct uprobe_task *utask = current->utask;
struct arch_uprobe_task *autask = &utask->autask;
u32 insn = auprobe->ixol;
int rc = 0;
if (utask->state == UTASK_SSTEP_ACK) {
regs->tnpc = relbranch_fixup(insn, utask, regs);
regs->tpc = autask->saved_tnpc;
rc = retpc_fixup(regs, insn, (unsigned long) utask->vaddr);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/highmem.h`, `linux/uprobes.h`, `linux/uaccess.h`, `linux/sched.h`, `linux/kdebug.h`, `asm/cacheflush.h`, `kernel.h`.
- Detected declarations: `function Copyright`, `function copy_to_page`, `function arch_uprobe_copy_ixol`, `function arch_uprobe_analyze_insn`, `function relbranch_fixup`, `function retpc_fixup`, `function arch_uprobe_skip_sstep`, `function arch_uprobe_pre_xol`, `function arch_uprobe_post_xol`, `function uprobe_trap`.
- Atlas domain: Architecture Layer / arch/sparc.
- 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.