Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ada Couprie Diaz <ada.coupriediaz@arm.com>
To: Will Deacon <will@kernel.org>, Mark Rutland <mark.rutland@arm.com>
Cc: Rob Herring <robh@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	Anshuman Khandual <anshuman.khandual@arm.com>
Subject: Re: [PATCH 0/2] arm64/debug: clean up some HW BP edge cases
Date: Mon, 24 Aug 2026 17:57:48 +0100	[thread overview]
Message-ID: <b7e811a1-3d34-48d7-99a6-ad035aad0814@arm.com> (raw)
In-Reply-To: <amE5XZIag1vh6GqE@willie-the-truck>

Hi Will,

Sorry for the delay, I did not manage to respond before going on leave
as I got lost in the weeds of understanding what ptrace is doing when
using hardware debug registers.

On 22/07/2026 22:42, Will Deacon wrote:
> On Wed, Jul 22, 2026 at 01:56:44PM +0100, Mark Rutland wrote:
>> On Wed, Jul 22, 2026 at 12:30:34PM +0100, Will Deacon wrote:
>>> On Wed, May 27, 2026 at 05:15:51PM +0100, Ada Couprie Diaz wrote:
>>>> This is a small series focused on fixing some unsoundess and edge case
>>>> related to hardware breakpoints and watchpoints.
>>>>
>>>> It is motivated in part by the recent discussion on the
>>>> FEAT_Debugv8p6 series[0][1] regarding unclear guarantees on interruptions.
>>>>
>>>> It doesn't address the issue of instrumentation, as NO_KPROBE is not
>>>> sufficient to prevent it (specifically ftrace) and would require a pass
>>>> over the whole debug handling code.
>>>>
>>>> The bugs themselves are very much of the self-inflicted
>>>> "you should not be doing this" kind and not urgent, but it does solve
>>>> some of the questions on the FEAT_Dbugv8p6 series.
>>>>
>>>> Most of the raw additions are comments trying to give more context to
>>>> understand `hw_breakpoint_thread_switch()`.
>>> Hmm. From what I can tell, these patches are trying to handle various
>>> cases where we take a debug exception while executing the hw_breakpoint
>>> code itself. Even with these two fixes, is perf expecting to handle that
>>> sort of thing? I think it would be a lot more robust if we just prevented
>>> this from happening in the first place, similarly to the discussion from
>>> the other day around kprobes [2].
I am indeed handling weird edge-cases !
As Perf only uses local_irq masks, it is not sufficient to prevent us 
from taking
debug exceptions while it manipulates the debug registers, so even if 
all the
debug exceptions themselves are safe, perf/ptrace callbacks and syscalls 
are not.
>> Since [2] mentions noinstr, it's worth noting that noinstr alone isn't
>> sufficient. Watchpoints also use this path, and we can't practically
>> filter watchpoint addresses to avoid hitting a watchpoint here.
>>
>> I assume you'd be happy with masking debug exceptions entirely?
> Yes, I think that's the only option, really, and I think we might even
> have done that at some point in the past. [...]
>
If you both think that makes sense to save/restore DAIF here, I am
happy to send a patch doing so. That would indeed make sure we
don't hit this kind of issues !
Making the debug code safe from instrumentation is a different story...
> [...] The problem, however, is if we
> end up getting preempted in that state. We currently have preemption
> disabled, but there's a thread trying to change that based on one of
> Ada's tests (not blaming the test, it's pointing out a real issue here):
>
> https://lore.kernel.org/r/20260519222524.886454-1-longman@redhat.com
I did not have the time to take a proper look, but it seems that Sebastian
has sent another patch for this issue which keeps premption disabled :

https://lore.kernel.org/r/20260814085118.OPEA_Ssn@linutronix.de

So I think we should be OK masking DAIF here then.

Thanks both,
Ada


  reply	other threads:[~2026-08-24 16:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27 16:15 [PATCH 0/2] arm64/debug: clean up some HW BP edge cases Ada Couprie Diaz
2026-05-27 16:15 ` [PATCH 1/2] arm64/debug: update perf slots in sync with BP registers Ada Couprie Diaz
2026-05-27 16:15 ` [PATCH 2/2] arm64/debug: mask exceptions when switching cpu-bound watchpoints Ada Couprie Diaz
2026-07-22 11:30 ` [PATCH 0/2] arm64/debug: clean up some HW BP edge cases Will Deacon
2026-07-22 12:56   ` Mark Rutland
2026-07-22 21:42     ` Will Deacon
2026-08-24 16:57       ` Ada Couprie Diaz [this message]
2026-08-25 14:22         ` Will Deacon

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=b7e811a1-3d34-48d7-99a6-ad035aad0814@arm.com \
    --to=ada.coupriediaz@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=robh@kernel.org \
    --cc=will@kernel.org \
    /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