Lines Matching +full:single +full:- +full:shot

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * HW_breakpoint: a unified kernel/user-space hardware breakpoint facility,
53 * Atomic: we hold the counter->ctx->lock and we only handle variables
71 return -EBUSY; in arch_install_hw_breakpoint()
74 * Do not install DABR values if the instruction must be single-stepped. in arch_install_hw_breakpoint()
77 if (!info->perf_single_step) in arch_install_hw_breakpoint()
89 * Atomic: we hold the counter->ctx->lock and we only handle variables
114 return bp->overflow_handler == ptrace_triggered; in is_ptrace_bp()
122 return is_kernel_addr(hw->address); in arch_check_bp_in_kernelspace()
133 return -EINVAL; in arch_bp_generic_fields()
145 * |------------v--|------v--------|
147 * |---------------|---------------|
148 * <---8 bytes--->
151 * start_addr = address & ~(HW_BREAKPOINT_SIZE - 1)
162 start_addr = ALIGN_DOWN(hw->address, HW_BREAKPOINT_SIZE); in hw_breakpoint_validate_len()
163 end_addr = ALIGN(hw->address + hw->len, HW_BREAKPOINT_SIZE); in hw_breakpoint_validate_len()
164 hw_len = end_addr - start_addr; in hw_breakpoint_validate_len()
170 (ALIGN_DOWN(start_addr, SZ_512) != ALIGN_DOWN(end_addr - 1, SZ_512))) in hw_breakpoint_validate_len()
171 return -EINVAL; in hw_breakpoint_validate_len()
178 return -EINVAL; in hw_breakpoint_validate_len()
180 hw->hw_len = hw_len; in hw_breakpoint_validate_len()
185 * Validate the arch-specific HW Breakpoint register settings
191 int ret = -EINVAL; in hw_breakpoint_arch_parse()
193 if (!bp || !attr->bp_len) in hw_breakpoint_arch_parse()
196 hw->type = HW_BRK_TYPE_TRANSLATE; in hw_breakpoint_arch_parse()
197 if (attr->bp_type & HW_BREAKPOINT_R) in hw_breakpoint_arch_parse()
198 hw->type |= HW_BRK_TYPE_READ; in hw_breakpoint_arch_parse()
199 if (attr->bp_type & HW_BREAKPOINT_W) in hw_breakpoint_arch_parse()
200 hw->type |= HW_BRK_TYPE_WRITE; in hw_breakpoint_arch_parse()
201 if (hw->type == HW_BRK_TYPE_TRANSLATE) in hw_breakpoint_arch_parse()
204 if (!attr->exclude_user) in hw_breakpoint_arch_parse()
205 hw->type |= HW_BRK_TYPE_USER; in hw_breakpoint_arch_parse()
206 if (!attr->exclude_kernel) in hw_breakpoint_arch_parse()
207 hw->type |= HW_BRK_TYPE_KERNEL; in hw_breakpoint_arch_parse()
208 if (!attr->exclude_hv) in hw_breakpoint_arch_parse()
209 hw->type |= HW_BRK_TYPE_HYP; in hw_breakpoint_arch_parse()
210 hw->address = attr->bp_addr; in hw_breakpoint_arch_parse()
211 hw->len = attr->bp_len; in hw_breakpoint_arch_parse()
214 return -ENODEV; in hw_breakpoint_arch_parse()
224 * The perf watchpoint will simply re-trigger once the thread is started again,
238 if (unlikely(bp && counter_arch_bp(bp)->perf_single_step)) in thread_change_pc()
244 regs_set_return_msr(regs, regs->msr & ~MSR_SE); in thread_change_pc()
248 info->perf_single_step = false; in thread_change_pc()
266 * We've failed in reliably handling the hw-breakpoint. Unregister
272 counter_arch_bp(bp)->address); in handler_error()
279 counter_arch_bp(bp)->address); in larx_stcx_err()
289 /* Do not emulate user-space instructions, instead single-step them */ in stepping_handler()
295 counter_arch_bp(bp[i])->perf_single_step = true; in stepping_handler()
298 regs_set_return_msr(regs, regs->msr | MSR_SE); in stepping_handler()
334 hw_end_addr = ALIGN(info->address + info->len, HW_BREAKPOINT_SIZE); in handle_p10dd1_spurious_exception()
340 if ((hw_end_addr - 1) >= ea) in handle_p10dd1_spurious_exception()
347 if (((hw_end_addr - 1) >> 10) != (ea >> 10)) in handle_p10dd1_spurious_exception()
366 counter_arch_bp(bp[i])->type |= HW_BRK_TYPE_EXTRANEOUS_IRQ; in handle_p10dd1_spurious_exception()
381 struct pt_regs *regs = args->regs; in hw_breakpoint_handler()
413 info->type &= ~HW_BRK_TYPE_EXTRANEOUS_IRQ; in hw_breakpoint_handler()
446 * Return early after invoking user-callback function without restoring in hw_breakpoint_handler()
448 * one-shot mode. The ptrace-ed process will receive the SIGTRAP signal in hw_breakpoint_handler()
478 * As a policy, the callback is invoked in a 'trigger-after-execute' in hw_breakpoint_handler()
484 if (!(counter_arch_bp(bp[i])->type & HW_BRK_TYPE_EXTRANEOUS_IRQ)) in hw_breakpoint_handler()
502 * Handle single-step exceptions following a DABR hit.
508 struct pt_regs *regs = args->regs; in single_step_dabr_instruction()
512 * Check if we are single-stepping as a result of a in single_step_dabr_instruction()
526 if (!info->perf_single_step) in single_step_dabr_instruction()
532 * We shall invoke the user-defined callback function in the in single_step_dabr_instruction()
533 * single stepping handler to confirm to 'trigger-after-execute' in single_step_dabr_instruction()
536 if (!(info->type & HW_BRK_TYPE_EXTRANEOUS_IRQ)) in single_step_dabr_instruction()
539 info->perf_single_step = false; in single_step_dabr_instruction()
544 * If the process was being single-stepped by ptrace, let the in single_step_dabr_instruction()
545 * other single-step actions occur (e.g. generate SIGTRAP). in single_step_dabr_instruction()
583 struct thread_struct *t = &tsk->thread; in flush_ptrace_hw_breakpoint()
586 unregister_hw_breakpoint(t->ptrace_bps[i]); in flush_ptrace_hw_breakpoint()
587 t->ptrace_bps[i] = NULL; in flush_ptrace_hw_breakpoint()
603 * one-shot behaviour for breakpoint exceptions in PPC64. in ptrace_triggered()
607 attr = bp->attr; in ptrace_triggered()