From: sashiko-bot@kernel.org
To: "Jinchao Wang" <wangjinchao600@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/3] x86/hw_breakpoints: Add arch_modify_local_hw_breakpoint_addr() API
Date: Sun, 26 Jul 2026 12:34:45 +0000 [thread overview]
Message-ID: <20260726123445.D07391F000E9@smtp.kernel.org> (raw)
In-Reply-To: <59637b96946653393a7ad3c7de094094796b39c2.1785067572.git.wangjinchao600@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] arch_modify_local_hw_breakpoint_addr() fails to increment cpu_dr7_seq, causing a race condition that can desynchronize hardware debug registers from their shadow state if interrupted by an NMI.
- [High] arch_modify_local_hw_breakpoint_addr() fails to update the primary breakpoint shadow address (info->address), causing future updates to silently revert the address.
--
--- Patch [2]: [PATCH 2/3] x86/hw_breakpoints: Add arch_modify_local_hw_breakpoint_addr() API ---
commit 91337a1d81005389f6b66cba9728d9f95a16cec3
Author: Jinchao Wang <wangjinchao600@gmail.com>
x86/hw_breakpoints: Add arch_modify_local_hw_breakpoint_addr() API
Wprobe needs to move an active per-CPU watchpoint without releasing and
reserving its hardware slot. This adds a new API to find the installed
local slot and update only its address shadow and hardware debug address
register.
> diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
> index 9ef24b55737f8..ff1b9b78f78c1 100644
> --- a/arch/x86/kernel/hw_breakpoint.c
> +++ b/arch/x86/kernel/hw_breakpoint.c
[ ... ]
> @@ -128,6 +128,26 @@ int arch_install_hw_breakpoint(struct perf_event *bp)
>
> void arch_modify_local_hw_breakpoint_addr(struct perf_event *bp,
> unsigned long addr)
> {
> int i;
>
> lockdep_assert_irqs_disabled();
>
> for (i = 0; i < HBP_NUM; i++) {
> if (this_cpu_read(bp_per_reg[i]) == bp)
> break;
> }
>
> if (WARN_ONCE(i == HBP_NUM, "Can't find any breakpoint slot"))
> return;
>
[Severity: High]
Does this missing cpu_dr7_seq increment leave a race condition if interrupted
by an NMI?
If hw_breakpoint_restore() is running, reads the old shadow value, and is
interrupted by an NMI that calls this function to update the address, the
lack of a sequence bump means hw_breakpoint_restore() will not detect the
interruption. It would exit its retry loop and overwrite the hardware
register with the stale value.
[Severity: High]
Could this also cause the watchpoint to silently revert to its previous
value when rescheduled?
Since the perf_event's internal info->address (retrieved via
counter_arch_bp(bp)) is not updated here, any future call to
arch_install_hw_breakpoint() during PMU multiplexing or CPU hotplug
would reinstall the breakpoint using that stale address.
> this_cpu_write(cpu_debugreg[i], addr);
> barrier();
> set_debugreg(addr, i);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1785067572.git.wangjinchao600@gmail.com?part=2
next prev parent reply other threads:[~2026-07-26 12:34 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 23:02 [PATCH v10 00/11] tracing: wprobe: x86: Add wprobe for watchpoint Masami Hiramatsu (Google)
2026-07-22 23:02 ` [PATCH v10 01/11] tracing: wprobe: Add watchpoint probe event based on hardware breakpoint Masami Hiramatsu (Google)
2026-07-22 23:32 ` sashiko-bot
2026-07-22 23:02 ` [PATCH v10 02/11] x86: hw_breakpoint: Add a kconfig to clarify when a breakpoint fires Masami Hiramatsu (Google)
2026-07-22 23:11 ` sashiko-bot
2026-07-23 18:34 ` Steven Rostedt
2026-07-22 23:03 ` [PATCH v10 03/11] selftests: tracing: Add a basic testcase for wprobe Masami Hiramatsu (Google)
2026-07-22 23:03 ` [PATCH v10 04/11] selftests: tracing: Add syntax " Masami Hiramatsu (Google)
2026-07-22 23:03 ` [PATCH v10 05/11] x86/hw_breakpoint: Unify breakpoint install/uninstall Masami Hiramatsu (Google)
2026-07-22 23:26 ` sashiko-bot
2026-07-22 23:03 ` [PATCH v10 06/11] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint Masami Hiramatsu (Google)
2026-07-22 23:25 ` sashiko-bot
2026-07-22 23:03 ` [PATCH v10 07/11] HWBP: Add modify_wide_hw_breakpoint_local() API Masami Hiramatsu (Google)
2026-07-26 12:22 ` [PATCH 0/3] hw_breakpoint: Fix and simplify local address updates for wprobe Jinchao Wang
2026-07-26 12:22 ` [PATCH 1/3] x86/hw_breakpoints: Make DR7 updates NMI safe Jinchao Wang
2026-07-26 12:22 ` [PATCH 2/3] x86/hw_breakpoints: Add arch_modify_local_hw_breakpoint_addr() API Jinchao Wang
2026-07-26 12:34 ` sashiko-bot [this message]
2026-07-26 12:22 ` [PATCH 3/3] HWBP: Add modify_local_hw_breakpoint_addr() API Jinchao Wang
2026-07-26 12:27 ` Jinchao Wang
2026-07-26 12:35 ` sashiko-bot
2026-07-22 23:04 ` [PATCH v10 08/11] tracing: wprobe: Add wprobe event trigger Masami Hiramatsu (Google)
2026-07-22 23:29 ` sashiko-bot
2026-07-22 23:04 ` [PATCH v10 09/11] selftests: ftrace: Add wprobe trigger testcase Masami Hiramatsu (Google)
2026-07-22 23:24 ` sashiko-bot
2026-07-22 23:04 ` [PATCH v10 10/11] tracing/wprobe: Support BTF typecast in fetchargs Masami Hiramatsu (Google)
2026-07-22 23:04 ` [PATCH v10 11/11] tracing/wprobe: Support BTF typecast in wprobe trigger command Masami Hiramatsu (Google)
2026-07-22 23:31 ` 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=20260726123445.D07391F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wangjinchao600@gmail.com \
/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