[PATCH v2 06/11] arm64: debug: split hardware breakpoint exeception entry

Ada Couprie Diaz ada.coupriediaz at arm.com
Wed May 28 09:10:52 PDT 2025


On 28/05/2025 16:17, Mark Rutland wrote:

> On Tue, May 20, 2025 at 04:36:39PM +0100, Will Deacon wrote:
>> On Mon, May 12, 2025 at 06:43:21PM +0100, Ada Couprie Diaz wrote:
>>> +static void noinstr el0_breakpt(struct pt_regs *regs, unsigned long esr)
>>> +{
>>> +	if (!is_ttbr0_addr(regs->pc))
>>> +		arm64_apply_bp_hardening();
>> I think this is a change in behaviour, as arm64_apply_bp_hardening() is
>> now called before enter_from_user_mode() and debug_exception_enter().
>> Is that safe and intentional?
> Yes on both counts:
>
> * It's safe. The arm64_apply_bp_hardening() helper, and the callbacks
>    that it may call are all noinstr, and are written to be safe to call
>    in this environment.
>
> * It's intentional. The goal was to do this as soon as reasonably
>    possible, at least before unmasking exceptions, without incurring the
>    cost for exceptions where this didn't matter.
>
>    We've already executed a bunch of code to get here, and moving this
>    after enter_from_user_mode() should be fine.
>
> This is inteneded to look the same as el0_ia() and el0_pc(), which both
> call arm64_apply_bp_hardening() before enter_from_user_mode().
>
> Mark.
A you mention in the other patch Will, I can definitely highlight
those points in the commit message for v3, especially that it is safe
and already done by `el0_ia()` and `el0_pc()`.

Thanks both,
Ada




More information about the linux-arm-kernel mailing list