Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v8 6/9] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint
Date: Thu, 16 Jul 2026 03:08:40 +0000	[thread overview]
Message-ID: <20260716030841.5C8A51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <178417040126.209165.5176961124203156666.stgit@devnote2>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Modifying an active breakpoint via `arch_reinstall_hw_breakpoint()` updates the debug address register before disabling it in the control register, violating architectural requirements and creating a race condition that can trigger spurious `#DB` exceptions.
- [Low] The newly added function `arch_reinstall_hw_breakpoint()` has no callers in the kernel tree.
--

--- Patch [6]: [PATCH v8 6/9] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint ---
commit 26fd09a1abe10d2182564575b6e349d84a888d45
Author: Jinchao Wang <wangjinchao600@gmail.com>

x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint

The new arch_reinstall_hw_breakpoint() function can be used in an
atomic context to efficiently re-establish an existing breakpoint
without going through the more expensive free and re-allocation path.

> diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
> index c323c2aab2af9..5821bb4650cec 100644
> --- a/arch/x86/kernel/hw_breakpoint.c
> +++ b/arch/x86/kernel/hw_breakpoint.c

[ ... ]

> @@ -189,6 +193,11 @@ int arch_install_hw_breakpoint(struct perf_event *bp)
>  	return arch_manage_bp(bp, BP_SLOT_ACTION_INSTALL);
>  }
>  
> +int arch_reinstall_hw_breakpoint(struct perf_event *bp)
> +{
> +	return arch_manage_bp(bp, BP_SLOT_ACTION_REINSTALL);
> +}

[Severity: High]
Does this sequence risk triggering spurious hardware debug exceptions?

When arch_reinstall_hw_breakpoint() modifies an active breakpoint, it calls
arch_manage_bp() which then invokes setup_hwbp(). In setup_hwbp(), the debug
address register is updated before the control register (dr7) is safely
cleared:

arch/x86/kernel/hw_breakpoint.c:setup_hwbp() {
    ...
    set_debugreg(info->address, slot);
    ...
    dr7 &= ~(__encode_dr7(slot, 0xc, 0x3) |
             (DR_LOCAL_ENABLE << (slot * DR_ENABLE_SIZE)));
    ...
}

Because BP_SLOT_ACTION_REINSTALL operates on a breakpoint that might already
be active, dr7 is currently enabled in hardware during this window. Can
writing to the address register while the slot is still enabled in dr7
trigger a spurious debug exception if a concurrent execution accesses the new
address?

[Severity: Low]
This isn't a bug, but are there any planned callers for this function?

A search of the tree indicates that arch_reinstall_hw_breakpoint() is not
currently invoked by any subsystem or exported to modules.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/178417033089.209165.16717079876036408877.stgit@devnote2?part=6

  reply	other threads:[~2026-07-16  3:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16  2:52 [PATCH v8 0/9] tracing: wprobe: x86: Add wprobe for watchpoint Masami Hiramatsu (Google)
2026-07-16  2:52 ` [PATCH v8 1/9] tracing: wprobe: Add watchpoint probe event based on hardware breakpoint Masami Hiramatsu (Google)
2026-07-16  3:13   ` sashiko-bot
2026-07-16  2:52 ` [PATCH v8 2/9] x86: hw_breakpoint: Add a kconfig to clarify when a breakpoint fires Masami Hiramatsu (Google)
2026-07-16  2:52 ` [PATCH v8 3/9] selftests: tracing: Add a basic testcase for wprobe Masami Hiramatsu (Google)
2026-07-16  3:05   ` sashiko-bot
2026-07-16  2:52 ` [PATCH v8 4/9] selftests: tracing: Add syntax " Masami Hiramatsu (Google)
2026-07-16  2:53 ` [PATCH v8 5/9] x86/hw_breakpoint: Unify breakpoint install/uninstall Masami Hiramatsu (Google)
2026-07-16  2:53 ` [PATCH v8 6/9] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint Masami Hiramatsu (Google)
2026-07-16  3:08   ` sashiko-bot [this message]
2026-07-16  2:53 ` [PATCH v8 7/9] HWBP: Add modify_wide_hw_breakpoint_local() API Masami Hiramatsu (Google)
2026-07-16  3:08   ` sashiko-bot
2026-07-16  2:53 ` [PATCH v8 8/9] tracing: wprobe: Add wprobe event trigger Masami Hiramatsu (Google)
2026-07-16  3:12   ` sashiko-bot
2026-07-16  2:53 ` [PATCH v8 9/9] selftests: ftrace: Add wprobe trigger testcase Masami Hiramatsu (Google)
2026-07-16  3:12   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260716030841.5C8A51F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox