arch/arm64/kernel/debug-monitors.c
Source file repositories/reference/linux-study-clean/arch/arm64/kernel/debug-monitors.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kernel/debug-monitors.c- Extension
.c- Size
- 9631 bytes
- Lines
- 396
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- 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/cpu.hlinux/debugfs.hlinux/hardirq.hlinux/init.hlinux/ptrace.hlinux/kprobes.hlinux/stat.hlinux/uaccess.hlinux/sched/task_stack.hasm/cpufeature.hasm/cputype.hasm/daifflags.hasm/debug-monitors.hasm/exception.hasm/kgdb.hasm/kprobes.hasm/system_misc.hasm/traps.hasm/uprobes.h
Detected Declarations
function Copyrightfunction mdscr_writefunction mdscr_readfunction create_debug_debugfs_entryfunction early_debug_disablefunction enable_debug_monitorsfunction disable_debug_monitorsfunction clear_os_lockfunction debug_monitors_initfunction set_user_regs_spsr_ssfunction clear_user_regs_spsr_ssfunction send_user_sigtrapfunction do_el0_softstepfunction do_el1_softstepfunction call_el1_break_hookfunction do_el0_brk64function do_el1_brk64function do_bkpt32function try_handle_aarch32_breakfunction user_rewind_single_stepfunction user_fastforward_single_stepfunction user_regs_reset_single_stepfunction kernel_enable_single_stepfunction kernel_disable_single_stepfunction kernel_active_single_stepfunction kernel_rewind_single_stepfunction kernel_fastforward_single_stepfunction user_enable_single_stepfunction user_disable_single_stepmodule init create_debug_debugfs_entry
Annotated Snippet
if (thumb_instr == AARCH32_BREAK_THUMB2_LO) {
/* get second half of 32-bit Thumb-2 instruction */
get_user(instr, (__le16 __user *)(pc + 2));
thumb_instr = le16_to_cpu(instr);
bp = thumb_instr == AARCH32_BREAK_THUMB2_HI;
} else {
bp = thumb_instr == AARCH32_BREAK_THUMB;
}
} else {
/* 32-bit ARM instruction */
__le32 instr;
get_user(instr, (__le32 __user *)pc);
arm_instr = le32_to_cpu(instr);
bp = (arm_instr & ~0xf0000000) == AARCH32_BREAK_ARM;
}
if (!bp)
return false;
send_user_sigtrap(TRAP_BRKPT);
return true;
}
NOKPROBE_SYMBOL(try_handle_aarch32_break);
/* Re-enable single step for syscall restarting. */
void user_rewind_single_step(struct task_struct *task)
{
/*
* If single step is active for this thread, then set SPSR.SS
* to 1 to avoid returning to the active-pending state.
*/
if (test_tsk_thread_flag(task, TIF_SINGLESTEP))
set_regs_spsr_ss(task_pt_regs(task));
}
NOKPROBE_SYMBOL(user_rewind_single_step);
void user_fastforward_single_step(struct task_struct *task)
{
if (test_tsk_thread_flag(task, TIF_SINGLESTEP))
clear_regs_spsr_ss(task_pt_regs(task));
}
void user_regs_reset_single_step(struct user_pt_regs *regs,
struct task_struct *task)
{
if (test_tsk_thread_flag(task, TIF_SINGLESTEP))
set_user_regs_spsr_ss(regs);
else
clear_user_regs_spsr_ss(regs);
}
/* Kernel API */
void kernel_enable_single_step(struct pt_regs *regs)
{
WARN_ON(!irqs_disabled());
set_regs_spsr_ss(regs);
mdscr_write(mdscr_read() | MDSCR_EL1_SS);
enable_debug_monitors(DBG_ACTIVE_EL1);
}
NOKPROBE_SYMBOL(kernel_enable_single_step);
void kernel_disable_single_step(void)
{
WARN_ON(!irqs_disabled());
mdscr_write(mdscr_read() & ~MDSCR_EL1_SS);
disable_debug_monitors(DBG_ACTIVE_EL1);
}
NOKPROBE_SYMBOL(kernel_disable_single_step);
int kernel_active_single_step(void)
{
WARN_ON(!irqs_disabled());
return mdscr_read() & MDSCR_EL1_SS;
}
NOKPROBE_SYMBOL(kernel_active_single_step);
void kernel_rewind_single_step(struct pt_regs *regs)
{
set_regs_spsr_ss(regs);
}
void kernel_fastforward_single_step(struct pt_regs *regs)
{
clear_regs_spsr_ss(regs);
}
/* ptrace API */
void user_enable_single_step(struct task_struct *task)
{
struct thread_info *ti = task_thread_info(task);
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/debugfs.h`, `linux/hardirq.h`, `linux/init.h`, `linux/ptrace.h`, `linux/kprobes.h`, `linux/stat.h`, `linux/uaccess.h`.
- Detected declarations: `function Copyright`, `function mdscr_write`, `function mdscr_read`, `function create_debug_debugfs_entry`, `function early_debug_disable`, `function enable_debug_monitors`, `function disable_debug_monitors`, `function clear_os_lock`, `function debug_monitors_init`, `function set_user_regs_spsr_ss`.
- Atlas domain: Architecture Layer / arch/arm64.
- 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.