arch/s390/kernel/kprobes.c
Source file repositories/reference/linux-study-clean/arch/s390/kernel/kprobes.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/kernel/kprobes.c- Extension
.c- Size
- 13098 bytes
- Lines
- 504
- Domain
- Architecture Layer
- Bucket
- arch/s390
- 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/kprobes.hlinux/ptrace.hlinux/preempt.hlinux/stop_machine.hlinux/cpufeature.hlinux/kdebug.hlinux/uaccess.hlinux/extable.hlinux/module.hlinux/slab.hlinux/hardirq.hlinux/ftrace.hlinux/execmem.hasm/text-patching.hasm/set_memory.hasm/sections.hasm/dis.hentry.h
Detected Declarations
struct swap_insn_argsfunction copy_instructionfunction can_probefunction arch_prepare_kprobefunction swap_instructionfunction arch_arm_kprobefunction arch_disarm_kprobefunction arch_remove_kprobefunction enable_singlestepfunction disable_singlestepfunction push_kprobefunction pop_kprobefunction kprobe_reenter_checkfunction kprobe_handlerfunction resume_executionfunction post_kprobe_handlerfunction kprobe_trap_handlerfunction kprobe_fault_handlerfunction kprobe_exceptions_notifyfunction arch_init_kprobesfunction arch_populate_kprobe_blacklistfunction arch_trampoline_kprobe
Annotated Snippet
struct swap_insn_args {
struct kprobe *p;
unsigned int arm_kprobe : 1;
};
static int swap_instruction(void *data)
{
struct swap_insn_args *args = data;
struct kprobe *p = args->p;
u16 opc;
opc = args->arm_kprobe ? BREAKPOINT_INSTRUCTION : p->opcode;
s390_kernel_write(p->addr, &opc, sizeof(opc));
return 0;
}
NOKPROBE_SYMBOL(swap_instruction);
void arch_arm_kprobe(struct kprobe *p)
{
struct swap_insn_args args = {.p = p, .arm_kprobe = 1};
if (cpu_has_seq_insn()) {
swap_instruction(&args);
text_poke_sync();
} else {
stop_machine_cpuslocked(swap_instruction, &args, NULL);
}
}
NOKPROBE_SYMBOL(arch_arm_kprobe);
void arch_disarm_kprobe(struct kprobe *p)
{
struct swap_insn_args args = {.p = p, .arm_kprobe = 0};
if (cpu_has_seq_insn()) {
swap_instruction(&args);
text_poke_sync();
} else {
stop_machine_cpuslocked(swap_instruction, &args, NULL);
}
}
NOKPROBE_SYMBOL(arch_disarm_kprobe);
void arch_remove_kprobe(struct kprobe *p)
{
if (!p->ainsn.insn)
return;
free_insn_slot(p->ainsn.insn, 0);
p->ainsn.insn = NULL;
}
NOKPROBE_SYMBOL(arch_remove_kprobe);
static void enable_singlestep(struct kprobe_ctlblk *kcb,
struct pt_regs *regs,
unsigned long ip)
{
union {
struct ctlreg regs[3];
struct {
struct ctlreg control;
struct ctlreg start;
struct ctlreg end;
};
} per_kprobe;
/* Set up the PER control registers %cr9-%cr11 */
per_kprobe.control.val = PER_EVENT_IFETCH;
per_kprobe.start.val = ip;
per_kprobe.end.val = ip;
/* Save control regs and psw mask */
__local_ctl_store(9, 11, kcb->kprobe_saved_ctl);
kcb->kprobe_saved_imask = regs->psw.mask &
(PSW_MASK_PER | PSW_MASK_IO | PSW_MASK_EXT);
/* Set PER control regs, turns on single step for the given address */
__local_ctl_load(9, 11, per_kprobe.regs);
regs->psw.mask |= PSW_MASK_PER;
regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT);
regs->psw.addr = ip;
}
NOKPROBE_SYMBOL(enable_singlestep);
static void disable_singlestep(struct kprobe_ctlblk *kcb,
struct pt_regs *regs,
unsigned long ip)
{
/* Restore control regs and psw mask, set new psw address */
__local_ctl_load(9, 11, kcb->kprobe_saved_ctl);
regs->psw.mask &= ~PSW_MASK_PER;
Annotation
- Immediate include surface: `linux/kprobes.h`, `linux/ptrace.h`, `linux/preempt.h`, `linux/stop_machine.h`, `linux/cpufeature.h`, `linux/kdebug.h`, `linux/uaccess.h`, `linux/extable.h`.
- Detected declarations: `struct swap_insn_args`, `function copy_instruction`, `function can_probe`, `function arch_prepare_kprobe`, `function swap_instruction`, `function arch_arm_kprobe`, `function arch_disarm_kprobe`, `function arch_remove_kprobe`, `function enable_singlestep`, `function disable_singlestep`.
- Atlas domain: Architecture Layer / arch/s390.
- 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.