[PATCH v3 01/13] arm64: debug: clean up single_step_handler logic
Mark Rutland
mark.rutland at arm.com
Tue Jun 10 10:26:47 PDT 2025
On Mon, Jun 09, 2025 at 06:34:01PM +0100, Ada Couprie Diaz wrote:
> Remove the unnecessary boolean which always checks if the handler was found
> and return early instead.
>
> Signed-off-by: Ada Couprie Diaz <ada.coupriediaz at arm.com>
Nice cleanup!
Acked-by: Mark Rutland <mark.rutland at arm.com>
Mark.
> ---
> arch/arm64/kernel/debug-monitors.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
> index 58f047de3e1c..676fa0231935 100644
> --- a/arch/arm64/kernel/debug-monitors.c
> +++ b/arch/arm64/kernel/debug-monitors.c
> @@ -241,8 +241,6 @@ static void send_user_sigtrap(int si_code)
> static int single_step_handler(unsigned long unused, unsigned long esr,
> struct pt_regs *regs)
> {
> - bool handler_found = false;
> -
> /*
> * If we are stepping a pending breakpoint, call the hw_breakpoint
> * handler first.
> @@ -250,10 +248,10 @@ static int single_step_handler(unsigned long unused, unsigned long esr,
> if (!reinstall_suspended_bps(regs))
> return 0;
>
> - if (!handler_found && call_step_hook(regs, esr) == DBG_HOOK_HANDLED)
> - handler_found = true;
> + if (call_step_hook(regs, esr) == DBG_HOOK_HANDLED)
> + return 0;
>
> - if (!handler_found && user_mode(regs)) {
> + if (user_mode(regs)) {
> send_user_sigtrap(TRAP_TRACE);
>
> /*
> @@ -263,7 +261,7 @@ static int single_step_handler(unsigned long unused, unsigned long esr,
> * to the active-not-pending state).
> */
> user_rewind_single_step(current);
> - } else if (!handler_found) {
> + } else {
> pr_warn("Unexpected kernel single-step exception at EL1\n");
> /*
> * Re-enable stepping since we know that we will be
>
> base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
> --
> 2.43.0
>
More information about the linux-arm-kernel
mailing list