arch/mips/kernel/uprobes.c
Source file repositories/reference/linux-study-clean/arch/mips/kernel/uprobes.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/kernel/uprobes.c- Extension
.c- Size
- 6173 bytes
- Lines
- 247
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/highmem.hlinux/kdebug.hlinux/types.hlinux/notifier.hlinux/sched.hlinux/uprobes.hasm/branch.hasm/cpu-features.hasm/ptrace.hprobes-common.h
Detected Declarations
function insn_has_delay_slotfunction arch_uprobe_analyze_insnfunction instructionsfunction arch_uprobe_pre_xolfunction arch_uprobe_post_xolfunction signalfunction arch_uprobe_exception_notifyfunction arch_uprobe_abort_xolfunction arch_uretprobe_hijack_return_addrfunction arch_uprobe_copy_ixolfunction uprobe_get_swbp_addrfunction arch_uprobe_skip_sstep
Annotated Snippet
switch (inst.r_format.func) {
case break_op:
case teq_op:
case tge_op:
case tgeu_op:
case tlt_op:
case tltu_op:
case tne_op:
return true;
}
break;
case bcond_op: /* Yes, really ... */
switch (inst.u_format.rt) {
case teqi_op:
case tgei_op:
case tgeiu_op:
case tlti_op:
case tltiu_op:
case tnei_op:
return true;
}
break;
}
return false;
}
#define UPROBE_TRAP_NR ULONG_MAX
/*
* arch_uprobe_pre_xol - prepare to execute out of line.
* @auprobe: the probepoint information.
* @regs: reflects the saved user state of current task.
*/
int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs)
{
struct uprobe_task *utask = current->utask;
/*
* Now find the EPC where to resume after the breakpoint has been
* dealt with. This may require emulation of a branch.
*/
aup->resume_epc = regs->cp0_epc + 4;
if (insn_has_delay_slot((union mips_instruction) aup->insn[0])) {
__compute_return_epc_for_insn(regs,
(union mips_instruction) aup->insn[0]);
aup->resume_epc = regs->cp0_epc;
}
utask->autask.saved_trap_nr = current->thread.trap_nr;
current->thread.trap_nr = UPROBE_TRAP_NR;
regs->cp0_epc = current->utask->xol_vaddr;
return 0;
}
int arch_uprobe_post_xol(struct arch_uprobe *aup, struct pt_regs *regs)
{
struct uprobe_task *utask = current->utask;
current->thread.trap_nr = utask->autask.saved_trap_nr;
regs->cp0_epc = aup->resume_epc;
return 0;
}
/*
* If xol insn itself traps and generates a signal(Say,
* SIGILL/SIGSEGV/etc), then detect the case where a singlestepped
* instruction jumps back to its own address. It is assumed that anything
* like do_page_fault/do_trap/etc sets thread.trap_nr != -1.
*
* arch_uprobe_pre_xol/arch_uprobe_post_xol save/restore thread.trap_nr,
* arch_uprobe_xol_was_trapped() simply checks that ->trap_nr is not equal to
* UPROBE_TRAP_NR == -1 set by arch_uprobe_pre_xol().
*/
bool arch_uprobe_xol_was_trapped(struct task_struct *tsk)
{
if (tsk->thread.trap_nr != UPROBE_TRAP_NR)
return true;
return false;
}
int arch_uprobe_exception_notify(struct notifier_block *self,
unsigned long val, void *data)
{
struct die_args *args = data;
struct pt_regs *regs = args->regs;
Annotation
- Immediate include surface: `linux/highmem.h`, `linux/kdebug.h`, `linux/types.h`, `linux/notifier.h`, `linux/sched.h`, `linux/uprobes.h`, `asm/branch.h`, `asm/cpu-features.h`.
- Detected declarations: `function insn_has_delay_slot`, `function arch_uprobe_analyze_insn`, `function instructions`, `function arch_uprobe_pre_xol`, `function arch_uprobe_post_xol`, `function signal`, `function arch_uprobe_exception_notify`, `function arch_uprobe_abort_xol`, `function arch_uretprobe_hijack_return_addr`, `function arch_uprobe_copy_ixol`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: source implementation candidate.
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.