From: Hongyan Xia <hongyan.xia@transsion.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Jiazi Li <jiazi.li@transsion.com>, Pu Hu <hupu@transsion.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC PATCH 6/9] arm64/kprobes: Make kprobe_fault_handler() noinstr
Date: Mon, 3 Aug 2026 06:40:38 +0000 [thread overview]
Message-ID: <500f0d1e-7aa7-4f58-92fa-8abb0ed8876e@transsion.com> (raw)
In-Reply-To: <amzF2Rfan44rYxI6@J2N7QTR9R3>
On 7/31/2026 11:57 PM, Mark Rutland wrote:
> On Mon, Jul 27, 2026 at 12:25:43PM +0000, Hongyan Xia wrote:
>> From: Hongyan Xia <hongyan.xia@transsion.com>
>>
>> kprobe_fault_handler() is reached from do_page_fault() when a fault
>> happens while a kprobe single-step is armed. Everything it calls (the
>> save/restore helpers, kprobes_restore_local_irqflag(),
>> reset_current_kprobe(), register access) is noinstr after the previous
>> patch, and being called from an instrumentable caller into a noinstr
>> callee is fine.
>
> I think it's fine to mark this as noinstr.
>
> I don't think we need kprobe_fault_handler() in the first place given we
> don't permit kprobes to be placed on instructions with an extable entry.
> Any instruction which can be probled cannot legitimately cause a fault.
I think so, too. If we cannot attach to ex_table entry instructions,
then there is no point in handling a page fault. The only thing worth
being in kprobe_fault_handler() is probably just a BUG(). Or, we could
remove it entirely.
> That and kprobes_restore_local_irqflag() can't do the right thing w.r.t
> DAIF, since it only fiddles with the value in the pt_regs, and doesn't
> touch the live inherited DAIF value. If we need to fiddle with the live
> DAIF value, we must do that much earlier in the entry-common code.
This should be fine. It manipulates DAIF in the previous fault, not the
live one, and the value will be picked up correctly on ERET.
kprobes_{save/restore}_local_irqflag() doesn't change anything in the
current exception, unlike local_irq_save().
Unless you mean something else?
> Mark.
>
>> Signed-off-by: Hongyan Xia <hongyan.xia@transsion.com>
>> ---
>> arch/arm64/kernel/probes/kprobes.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
>> index e9fa66fa4217..4172998d48d9 100644
>> --- a/arch/arm64/kernel/probes/kprobes.c
>> +++ b/arch/arm64/kernel/probes/kprobes.c
>> @@ -310,7 +310,7 @@ post_kprobe_handler(struct kprobe *cur, struct kprobe_ctlblk *kcb, struct pt_reg
>> reset_current_kprobe();
>> }
>>
>> -int __kprobes kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr)
>> +int noinstr kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr)
>> {
>> struct kprobe *cur = kprobe_running();
>> struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
>> --
>> 2.47.3
>>
next prev parent reply other threads:[~2026-08-03 6:41 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1785153469.git.hongyan.xia@transsion.com>
2026-07-27 12:25 ` [RFC PATCH 1/9] arm64/entry: Bound certain debug exception paths in instrumentation windows Hongyan Xia
2026-07-31 14:41 ` Mark Rutland
2026-08-03 3:42 ` Hongyan Xia
2026-07-27 12:25 ` [RFC PATCH 2/9] arm64/entry: Make debug_exception_enter/exit() noinstr Hongyan Xia
2026-07-31 14:43 ` Mark Rutland
2026-07-27 12:25 ` [RFC PATCH 3/9] arm64/debug-monitors: Make do_el1_brk64()/do_el1_softstep() noinstr Hongyan Xia
2026-07-31 15:25 ` Mark Rutland
2026-08-03 3:54 ` Hongyan Xia
2026-07-27 12:25 ` [RFC PATCH 4/9] arm64/kprobes: Make the single-step machinery noinstr Hongyan Xia
2026-07-31 15:38 ` Mark Rutland
2026-08-03 4:31 ` Hongyan Xia
2026-07-27 12:25 ` [RFC PATCH 5/9] arm64/kprobes: Invoke pre/post handlers inside instrumentation Hongyan Xia
2026-07-31 15:44 ` Mark Rutland
2026-08-03 6:11 ` Hongyan Xia
2026-07-27 12:25 ` [RFC PATCH 6/9] arm64/kprobes: Make kprobe_fault_handler() noinstr Hongyan Xia
2026-07-31 15:57 ` Mark Rutland
2026-08-03 6:40 ` Hongyan Xia [this message]
2026-07-27 12:25 ` [RFC PATCH 7/9] arm64/kprobes: Drop the KPROBE_HIT_SS reentry special case Hongyan Xia
2026-07-27 12:25 ` [RFC PATCH 8/9] arm64/kprobes: Drop the XOL single-step fault PC check Hongyan Xia
2026-07-31 16:12 ` Mark Rutland
2026-07-27 12:25 ` [RFC PATCH 9/9] arm64/debug: Mark debug exception helpers __always_inline Hongyan Xia
2026-07-27 19:22 ` Nick Desaulniers
2026-07-27 21:49 ` Will Deacon
2026-07-28 2:03 ` Hongyan Xia
2026-07-29 18:08 ` Steven Rostedt
2026-07-30 0:03 ` Masami Hiramatsu
2026-07-30 11:50 ` Hongyan Xia
2026-07-31 16:15 ` Mark Rutland
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=500f0d1e-7aa7-4f58-92fa-8abb0ed8876e@transsion.com \
--to=hongyan.xia@transsion.com \
--cc=catalin.marinas@arm.com \
--cc=hupu@transsion.com \
--cc=jiazi.li@transsion.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@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