From: Nam Cao <namcao@linutronix.de>
To: Xiaofeng Yuan <yuanxiaofeng@eswincomputing.com>,
Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>, Naveen N Rao <naveen@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
Masami Hiramatsu <mhiramat@kernel.org>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
Xiaofeng Yuan <yuanxiaofeng@eswincomputing.com>
Subject: Re: [PATCH v6 2/2] riscv: kprobes: add KUnit test for LR/SC sequence rejection
Date: Fri, 16 Oct 2026 12:42:04 +0200 [thread overview]
Message-ID: <87pkxa3p1f.fsf@yellow.woof> (raw)
In-Reply-To: <20261016081706.1085-3-yuanxiaofeng@eswincomputing.com>
Xiaofeng Yuan <yuanxiaofeng@eswincomputing.com> writes:
> +.section .rodata
> +SYM_DATA_START(test_kprobes_lrsc_offsets)
> + RISCV_PTR .Llrsc_before
> + RISCV_PTR .Llrsc_lr
> + RISCV_PTR .Llrsc_inside
> + RISCV_PTR .Llrsc_sc
> + RISCV_PTR .Llrsc_after
> +SYM_DATA_END(test_kprobes_lrsc_offsets)
"_offsets" is not precise, as this array has absolute addresses. Maybe
rename to "_addresses"?
> diff --git a/arch/riscv/kernel/tests/kprobes/test-kprobes.c b/arch/riscv/kernel/tests/kprobes/test-kprobes.c
> index 027424a3f..c2d9c87f2 100644
> --- a/arch/riscv/kernel/tests/kprobes/test-kprobes.c
> +++ b/arch/riscv/kernel/tests/kprobes/test-kprobes.c
> @@ -43,8 +43,39 @@ static void test_kprobe_riscv(struct kunit *test)
> kfree(kp);
> }
>
> +static void test_kprobe_lrsc(struct kunit *test)
> +{
> + /*
> + * test_kprobes_lrsc_offsets[] points, in order, at an instruction
> + * right before an LR/SC sequence, the LR itself, an instruction
> + * inside the sequence, the SC, and an instruction right after it.
> + * reject[] must have the same number of entries.
> + */
> + bool reject[] = { false, true, true, true, false };
I am not a fan of coupled code. A change at test_kprobes_lrsc_offsets
mandates a change here.
Instead of this, how about we split test_kprobes_lrsc_offsets into
test_kprobes_lrsc_allowed_addresses and test_kprobes_lrsc_rejected_addresses?
Nam
prev parent reply other threads:[~2026-10-16 10:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 8:17 [PATCH v6 0/2] riscv: kprobes: reject probes inside LR/SC sequences Xiaofeng Yuan
2026-10-16 8:17 ` [PATCH v6 1/2] " Xiaofeng Yuan
2026-10-16 8:29 ` sashiko-bot
2026-10-16 10:13 ` Nam Cao
2026-10-16 8:17 ` [PATCH v6 2/2] riscv: kprobes: add KUnit test for LR/SC sequence rejection Xiaofeng Yuan
2026-10-16 10:42 ` Nam Cao [this message]
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=87pkxa3p1f.fsf@yellow.woof \
--to=namcao@linutronix.de \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=naveen@kernel.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=yuanxiaofeng@eswincomputing.com \
/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