From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: sashiko-bot@kernel.org, linux-perf-users@vger.kernel.org,
linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v15 02/12] x86/hw_breakpoints: Make DR7 updates NMI safe
Date: Mon, 14 Sep 2026 11:49:12 +0900 [thread overview]
Message-ID: <20260914114912.51a8c4649d5a9e812ede1349@kernel.org> (raw)
In-Reply-To: <20260907040017.1983E1F00ACA@smtp.kernel.org>
On Mon, 07 Sep 2026 04:00:16 +0000
sashiko-bot@kernel.org wrote:
> > diff --git a/arch/x86/include/asm/debugreg.h b/arch/x86/include/asm/debugreg.h
> > index 854d82b88ff4e..3399e166d3044 100644
> > --- a/arch/x86/include/asm/debugreg.h
> > +++ b/arch/x86/include/asm/debugreg.h
> [ ... ]
> > @@ -125,40 +126,66 @@ static __always_inline bool hw_breakpoint_active(void)
> >
> > extern void hw_breakpoint_restore(void);
> >
> > -static __always_inline unsigned long local_db_save(void)
> > +static __always_inline void local_db_save(unsigned long *dr7,
> > + unsigned int *dr7_seq)
> > {
> > - unsigned long dr7;
> > + do {
> > + *dr7_seq = this_cpu_read(cpu_dr7_seq);
> > + *dr7 = 0;
> >
> > - if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR) && !hw_breakpoint_active())
> > - return 0;
> > -
> > - get_debugreg(dr7, 7);
> > + if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR) &&
> > + !hw_breakpoint_active())
> > + return;
>
> [Severity: High]
> This isn't a bug introduced by this patch, but could this early return
> in local_db_save() bypass the sequence retry loop?
>
> If an NMI hits exactly before the return instruction and installs a
> breakpoint, the function exits immediately. This leaves the newly installed
> hardware breakpoint active during exception handlers like MCE, which could
> trigger a recursive #DB exception and lead to a kernel panic.
Wait... but fixing this may leak the DR7 setting to the guest. We need another
patch to solve this, which introduce a per-cpu flag to prohibit updating the
DR7 during switching to the guest.
Thanks,
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2026-09-14 2:49 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 3:46 [PATCH v15 00/12] tracing: wprobe: x86: Add wprobe for watchpoint Masami Hiramatsu (Google)
2026-09-07 3:46 ` [PATCH v15 01/12] x86/mce: Fix hardware debug register corruption on task migration Masami Hiramatsu (Google)
2026-09-07 3:57 ` sashiko-bot
2026-09-07 3:46 ` [PATCH v15 02/12] x86/hw_breakpoints: Make DR7 updates NMI safe Masami Hiramatsu (Google)
2026-09-07 4:00 ` sashiko-bot
2026-09-14 1:02 ` Masami Hiramatsu
2026-09-14 2:49 ` Masami Hiramatsu [this message]
2026-09-07 3:46 ` [PATCH v15 03/12] x86/hw_breakpoints: Add arch_modify_local_hw_breakpoint_addr() API Masami Hiramatsu (Google)
2026-09-07 4:02 ` sashiko-bot
2026-09-14 5:13 ` Masami Hiramatsu
2026-09-07 3:47 ` [PATCH v15 04/12] HWBP: Add modify_local_hw_breakpoint_addr() API Masami Hiramatsu (Google)
2026-09-07 4:04 ` sashiko-bot
2026-09-07 3:47 ` [PATCH v15 05/12] tracing/wprobe: Add wprobe (watchpoint probe) trace event support Masami Hiramatsu (Google)
2026-09-07 4:15 ` sashiko-bot
2026-09-14 5:25 ` Masami Hiramatsu
2026-09-07 3:47 ` [PATCH v15 06/12] x86: hw_breakpoint: Add a kconfig to clarify when a breakpoint fires Masami Hiramatsu (Google)
2026-09-07 3:52 ` sashiko-bot
2026-09-07 3:47 ` [PATCH v15 07/12] selftests: tracing: Add a basic testcase for wprobe Masami Hiramatsu (Google)
2026-09-07 3:53 ` sashiko-bot
2026-09-07 3:47 ` [PATCH v15 08/12] selftests: tracing: Add syntax " Masami Hiramatsu (Google)
2026-09-07 3:58 ` sashiko-bot
2026-09-07 3:47 ` [PATCH v15 09/12] tracing/wprobe: Add set_wprobe and clear_wprobe event triggers Masami Hiramatsu (Google)
2026-09-07 4:10 ` sashiko-bot
2026-09-14 6:46 ` Masami Hiramatsu
2026-09-07 3:48 ` [PATCH v15 10/12] selftests: tracing: Add wprobe trigger testcase Masami Hiramatsu (Google)
2026-09-07 3:58 ` sashiko-bot
2026-09-07 3:48 ` [PATCH v15 11/12] tracing/wprobe: Support BTF typecast in fetchargs Masami Hiramatsu (Google)
2026-09-07 4:03 ` sashiko-bot
2026-09-07 3:48 ` [PATCH v15 12/12] tracing/wprobe: Support BTF struct offset resolution in set_wprobe trigger Masami Hiramatsu (Google)
2026-09-07 4:06 ` sashiko-bot
2026-09-11 7:27 ` [PATCH v15 00/12] tracing: wprobe: x86: Add wprobe for watchpoint Jinchao Wang
2026-09-12 13:36 ` Masami Hiramatsu
2026-09-14 6:16 ` Jinchao Wang
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=20260914114912.51a8c4649d5a9e812ede1349@kernel.org \
--to=mhiramat@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-bot@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;
as well as URLs for NNTP newsgroup(s).