[RFC PATCH 0/9] arm64: Make the kprobes debug exception path noinstr
From: Hongyan Xia
Date: Mon Jul 27 2026 - 08:26:04 EST
From: Hongyan Xia <hongyan.xia@xxxxxxxxxxxxx>
Commit 879a6754d3d1 ("arm64: kprobes: Only handle faults originating
from XOL slot") and 23f851ac0078 ("arm64: kprobes: Allow reentering
kprobes while single-stepping") band-aided two corner cases in the arm64
kprobe path: Unrelated page faults inside Kprobe and nested Kprobe SS
handling. Although the two patches were taken, Will asked whether we
should keep patching things like this each time we find a corner case,
and whether making Kprobe noinstr is the correct answer [1].
This series attempts to do exactly that: Making the Kprobe path noinstr.
The kprobe handlers become noinstr end to end, and everything that is
inherently instrumentable is confined to instrumentation_begin/end()
windows, similar to the x86 side. After this series, the two
corner-cases mentioned above are also gone, hence the revert in 7/9 and
8/9. Some of the instrumentation_begin/end() sections are suggested by
AI, so they may need careful review.
Note that arm64 has no objtool to validate noinstr, so I wrote a small
script finding bl/blr and validated that their calls are confined within
noinstr. This is exactly what found the Clang outline compile problem
that motivated patch 9/9.
One question is whether other BRK paths get the same treatment.
Currently they stay instrumentable inside a big window.
[1] https://lore.kernel.org/all/alpuL10h7-OK2hFb@willie-the-truck/
Hongyan Xia (9):
arm64/entry: Bound certain debug exception paths in instrumentation
windows
arm64/entry: Make debug_exception_enter/exit() noinstr
arm64/debug-monitors: Make do_el1_brk64()/do_el1_softstep() noinstr
arm64/kprobes: Make the single-step machinery noinstr
arm64/kprobes: Invoke pre/post handlers inside instrumentation
arm64/kprobes: Make kprobe_fault_handler() noinstr
arm64/kprobes: Drop the KPROBE_HIT_SS reentry special case
arm64/kprobes: Drop the XOL single-step fault PC check
arm64/debug: Mark debug exception helpers __always_inline
arch/arm64/include/asm/esr.h | 2 +-
arch/arm64/include/asm/kprobes.h | 15 +----
arch/arm64/include/asm/percpu.h | 2 +-
arch/arm64/include/asm/preempt.h | 4 +-
arch/arm64/include/asm/ptrace.h | 4 +-
arch/arm64/kernel/debug-monitors.c | 76 ++++++++++++-----------
arch/arm64/kernel/entry-common.c | 43 +++++++++----
arch/arm64/kernel/probes/kprobes.c | 96 ++++++++++++++----------------
include/linux/kprobes.h | 8 +--
9 files changed, 131 insertions(+), 119 deletions(-)
--
2.47.3