[PATCH v4 07/13] arm64: debug: split hardware breakpoint exception entry

Will Deacon will at kernel.org
Fri Jun 27 08:46:17 PDT 2025


On Fri, Jun 20, 2025 at 10:12:01PM +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 breakpoints exceptions are generated by the hardware after user
> configuration. As such, they can be exploited when training branch
> predictors outside of the userspace VA range: they still need to call
> `arm64_apply_bp_hardening()` if needed to mitigate against this attack.
> 
> However, they do not need to handle the Cortex-A76 erratum #1463225 as
> it only applies to single stepping exceptions.
> It does not set an address in FAR_EL1 either, only the hardware
> watchpoint does.
> 
> As the hardware breakpoint 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 breakpoint exception entry, adjust
> the function signature, and handling of the Cortex-A76 erratum to fit
> the behaviour of the exception.
> 
> Move the call to `arm64_apply_bp_hardening()` to `entry-common.c` so that
> we can do it as early as possible, and only for the exceptions coming
> from EL0, where it is needed.
> This is safe to do as it is `noinstr`, as are all the functions it
> may call. `el0_ia()` and `el0_pc()` already call it this way.
> 
> Signed-off-by: Ada Couprie Diaz <ada.coupriediaz at arm.com>
> Tested-by: Luis Claudio R. Goncalves <lgoncalv at redhat.com>
> ---
>  arch/arm64/include/asm/exception.h |  1 +
>  arch/arm64/kernel/entry-common.c   | 28 ++++++++++++++++++++++++++++
>  arch/arm64/kernel/hw_breakpoint.c  | 16 ++++++----------
>  3 files changed, 35 insertions(+), 10 deletions(-)

Reviewed-by: Will Deacon <will at kernel.org>

Will



More information about the linux-arm-kernel mailing list