[PATCH v5 10/13] arm64: debug: split hardware watchpoint exception entry
Will Deacon
will at kernel.org
Fri Jul 4 10:32:19 PDT 2025
On Fri, Jun 27, 2025 at 06:20:35PM +0100, Ada Couprie Diaz wrote:
> Currently all debug exceptions share common entry code and are routed
> to `do_debug_exception()`, which calls dynamically-registered
> handlers for each specific debug exception. This is unfortunate as
> different debug exceptions have different entry handling requirements,
> and it would be better to handle these distinct requirements earlier.
>
> Hardware watchpoints are the only debug exceptions that will write
> FAR_EL1, so we need to preserve it and pass it down.
> However, they cannot be used to maliciously train branch predictors, so
> we can omit calling `arm64_bp_hardening()`, nor do they need to handle
> the Cortex-A76 erratum #1463225, as it only applies to single stepping
> exceptions.
>
> As the hardware watchpoint handler only returns 0 and never triggers
> the call to `arm64_notify_die()`, we can call it directly from
> `entry-common.c`.
> Split the hardware watchpoint exception entry and adjust the behaviour
> to match the lack of needed mitigations.
>
> Signed-off-by: Ada Couprie Diaz <ada.coupriediaz at arm.com>
> Tested-by: Luis Claudio R. Goncalves <lgoncalv at redhat.com>
> Reviewed-by: Will Deacon <will at kernel.org>
> ---
> arch/arm64/include/asm/exception.h | 4 ++++
> arch/arm64/kernel/entry-common.c | 31 +++++++++++++++++++++++++++++-
> arch/arm64/kernel/hw_breakpoint.c | 17 +++++-----------
> 3 files changed, 39 insertions(+), 13 deletions(-)
Not a huge deal, but I just noticed that this patch doesn't build on its
own and so this series isn't bisectable.
> diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
> index 7265bef96672..c2ea1653dbb8 100644
> --- a/arch/arm64/kernel/entry-common.c
> +++ b/arch/arm64/kernel/entry-common.c
> @@ -553,10 +553,20 @@ static void noinstr el1_softstp(struct pt_regs *regs, unsigned long esr)
> arm64_exit_el1_dbg(regs);
> }
>
> -static void noinstr el1_dbg(struct pt_regs *regs, unsigned long esr)
> +static void noinstr el1_watchpt(struct pt_regs *regs, unsigned long esr)
> {
> + /* Watchpoints are the only debug exception to write FAR_EL1 */
> unsigned long far = read_sysreg(far_el1);
>
> + arm64_enter_el1_dbg(regs);
> + debug_exception_enter(regs);
> + do_watchpoint(far, esr, regs);
> + debug_exception_exit(regs);
> + arm64_exit_el1_dbg(regs);
> +}
> +
> +static void noinstr el1_dbg(struct pt_regs *regs, unsigned long esr)
> +{
> arm64_enter_el1_dbg(regs);
> if (!cortex_a76_erratum_1463225_debug_handler(regs))
> do_debug_exception(far, esr, regs);
This leads to:
Failed to build patch #10: 0d0a8f024a19 arm64: debug: split hardware watchpoint exception entry
arch/arm64/kernel/entry-common.c: In function ‘el1_dbg’:
arch/arm64/kernel/entry-common.c:572:36: error: ‘far’ undeclared (first use in this function)
572 | do_debug_exception(far, esr, regs);
| ^~~
Catalin -- do you reckon we should fix this? It's only this series
sitting on for-next/debug-entry, nobody has pulled it afaik and we still
have plenty of time before the merge window so a rebase probably won't
hurt anybody.
Will
More information about the linux-arm-kernel
mailing list