arch/sh/kernel/hw_breakpoint.c
Source file repositories/reference/linux-study-clean/arch/sh/kernel/hw_breakpoint.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sh/kernel/hw_breakpoint.c- Extension
.c- Size
- 8426 bytes
- Lines
- 409
- Domain
- Architecture Layer
- Bucket
- arch/sh
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/perf_event.hlinux/sched/signal.hlinux/hw_breakpoint.hlinux/percpu.hlinux/kallsyms.hlinux/notifier.hlinux/kprobes.hlinux/kdebug.hlinux/io.hlinux/clk.hasm/hw_breakpoint.hasm/mmu_context.hasm/ptrace.hasm/traps.h
Detected Declarations
function arch_install_hw_breakpointfunction arch_uninstall_hw_breakpointfunction get_hbp_lenfunction arch_check_bp_in_kernelspacefunction arch_bp_generic_fieldsfunction arch_build_bp_infofunction hw_breakpoint_arch_parsefunction flush_ptrace_hw_breakpointfunction hw_breakpoint_handlerfunction hw_breakpoint_exceptions_notifyfunction hw_breakpoint_pmu_read
Annotated Snippet
if (!*slot) {
*slot = bp;
break;
}
}
if (WARN_ONCE(i == sh_ubc->num_events, "Can't find any breakpoint slot"))
return -EBUSY;
clk_enable(sh_ubc->clk);
sh_ubc->enable(info, i);
return 0;
}
/*
* Uninstall the breakpoint contained in the given counter.
*
* First we search the debug address register it uses and then we disable
* it.
*
* Atomic: we hold the counter->ctx->lock and we only handle variables
* and registers local to this cpu.
*/
void arch_uninstall_hw_breakpoint(struct perf_event *bp)
{
struct arch_hw_breakpoint *info = counter_arch_bp(bp);
int i;
for (i = 0; i < sh_ubc->num_events; i++) {
struct perf_event **slot = this_cpu_ptr(&bp_per_reg[i]);
if (*slot == bp) {
*slot = NULL;
break;
}
}
if (WARN_ONCE(i == sh_ubc->num_events, "Can't find any breakpoint slot"))
return;
sh_ubc->disable(info, i);
clk_disable(sh_ubc->clk);
}
static int get_hbp_len(u16 hbp_len)
{
unsigned int len_in_bytes = 0;
switch (hbp_len) {
case SH_BREAKPOINT_LEN_1:
len_in_bytes = 1;
break;
case SH_BREAKPOINT_LEN_2:
len_in_bytes = 2;
break;
case SH_BREAKPOINT_LEN_4:
len_in_bytes = 4;
break;
case SH_BREAKPOINT_LEN_8:
len_in_bytes = 8;
break;
}
return len_in_bytes;
}
/*
* Check for virtual address in kernel space.
*/
int arch_check_bp_in_kernelspace(struct arch_hw_breakpoint *hw)
{
unsigned int len;
unsigned long va;
va = hw->address;
len = get_hbp_len(hw->len);
return (va >= TASK_SIZE) && ((va + len - 1) >= TASK_SIZE);
}
int arch_bp_generic_fields(int sh_len, int sh_type,
int *gen_len, int *gen_type)
{
/* Len */
switch (sh_len) {
case SH_BREAKPOINT_LEN_1:
*gen_len = HW_BREAKPOINT_LEN_1;
break;
case SH_BREAKPOINT_LEN_2:
*gen_len = HW_BREAKPOINT_LEN_2;
Annotation
- Immediate include surface: `linux/init.h`, `linux/perf_event.h`, `linux/sched/signal.h`, `linux/hw_breakpoint.h`, `linux/percpu.h`, `linux/kallsyms.h`, `linux/notifier.h`, `linux/kprobes.h`.
- Detected declarations: `function arch_install_hw_breakpoint`, `function arch_uninstall_hw_breakpoint`, `function get_hbp_len`, `function arch_check_bp_in_kernelspace`, `function arch_bp_generic_fields`, `function arch_build_bp_info`, `function hw_breakpoint_arch_parse`, `function flush_ptrace_hw_breakpoint`, `function hw_breakpoint_handler`, `function hw_breakpoint_exceptions_notify`.
- Atlas domain: Architecture Layer / arch/sh.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.