arch/arm/probes/kprobes/core.c
Source file repositories/reference/linux-study-clean/arch/arm/probes/kprobes/core.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/probes/kprobes/core.c- Extension
.c- Size
- 12929 bytes
- Lines
- 486
- Domain
- Architecture Layer
- Bucket
- arch/arm
- 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/kernel.hlinux/kprobes.hlinux/module.hlinux/slab.hlinux/stop_machine.hlinux/sched/debug.hlinux/stringify.hasm/traps.hasm/opcodes.hasm/cacheflush.hlinux/percpu.hlinux/bug.hasm/text-patching.hasm/sections.h../decode-arm.h../decode-thumb.hcore.h
Detected Declarations
struct patchfunction arch_prepare_kprobefunction arch_arm_kprobefunction __kprobes_remove_breakpointfunction kprobes_remove_breakpointfunction arch_disarm_kprobefunction arch_remove_kprobefunction save_previous_kprobefunction restore_previous_kprobefunction set_current_kprobefunction singlestep_skipfunction singlestepfunction kprobe_handlerfunction kprobe_trap_handlerfunction kprobe_fault_handlerfunction kprobe_exceptions_notifyfunction __kretprobe_trampolinefunction arch_prepare_kretprobefunction arch_trampoline_kprobefunction arch_init_kprobesfunction arch_within_kprobe_blacklist
Annotated Snippet
struct patch {
void *addr;
unsigned int insn;
};
static int __kprobes_remove_breakpoint(void *data)
{
struct patch *p = data;
__patch_text(p->addr, p->insn);
return 0;
}
void __kprobes kprobes_remove_breakpoint(void *addr, unsigned int insn)
{
struct patch p = {
.addr = addr,
.insn = insn,
};
stop_machine_cpuslocked(__kprobes_remove_breakpoint, &p,
cpu_online_mask);
}
void __kprobes arch_disarm_kprobe(struct kprobe *p)
{
kprobes_remove_breakpoint((void *)((uintptr_t)p->addr & ~1),
p->opcode);
}
void __kprobes arch_remove_kprobe(struct kprobe *p)
{
if (p->ainsn.insn) {
free_insn_slot(p->ainsn.insn, 0);
p->ainsn.insn = NULL;
}
}
static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb)
{
kcb->prev_kprobe.kp = kprobe_running();
kcb->prev_kprobe.status = kcb->kprobe_status;
}
static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb)
{
__this_cpu_write(current_kprobe, kcb->prev_kprobe.kp);
kcb->kprobe_status = kcb->prev_kprobe.status;
}
static void __kprobes set_current_kprobe(struct kprobe *p)
{
__this_cpu_write(current_kprobe, p);
}
static void __kprobes
singlestep_skip(struct kprobe *p, struct pt_regs *regs)
{
#ifdef CONFIG_THUMB2_KERNEL
regs->ARM_cpsr = it_advance(regs->ARM_cpsr);
if (is_wide_instruction(p->opcode))
regs->ARM_pc += 4;
else
regs->ARM_pc += 2;
#else
regs->ARM_pc += 4;
#endif
}
static inline void __kprobes
singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
{
p->ainsn.insn_singlestep(p->opcode, &p->ainsn, regs);
}
/*
* Called with IRQs disabled. IRQs must remain disabled from that point
* all the way until processing this kprobe is complete. The current
* kprobes implementation cannot process more than one nested level of
* kprobe, and that level is reserved for user kprobe handlers, so we can't
* risk encountering a new kprobe in an interrupt handler.
*/
static void __kprobes kprobe_handler(struct pt_regs *regs)
{
struct kprobe *p, *cur;
struct kprobe_ctlblk *kcb;
kcb = get_kprobe_ctlblk();
cur = kprobe_running();
#ifdef CONFIG_THUMB2_KERNEL
/*
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/kprobes.h`, `linux/module.h`, `linux/slab.h`, `linux/stop_machine.h`, `linux/sched/debug.h`, `linux/stringify.h`, `asm/traps.h`.
- Detected declarations: `struct patch`, `function arch_prepare_kprobe`, `function arch_arm_kprobe`, `function __kprobes_remove_breakpoint`, `function kprobes_remove_breakpoint`, `function arch_disarm_kprobe`, `function arch_remove_kprobe`, `function save_previous_kprobe`, `function restore_previous_kprobe`, `function set_current_kprobe`.
- Atlas domain: Architecture Layer / arch/arm.
- 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.