Linux Trace Kernel
 help / color / mirror / Atom feed
From: Stafford Horne <shorne@gmail.com>
To: Sahil <sahilcdq0@gmail.com>
Cc: jonas@southpole.se, stefan.kristiansson@saunalahti.fi,
	naveen@kernel.org, davem@davemloft.net, mhiramat@kernel.org,
	pjw@kernel.org, wangruikang@iscas.ac.cn, namcao@linutronix.de,
	kees@kernel.org, linux-openrisc@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/4] openrisc: Add unit tests for KProbes on branch instructions
Date: Sun, 15 Nov 2026 01:52:50 +0000	[thread overview]
Message-ID: <avkQctt0CKt3YcsH@antec> (raw)
In-Reply-To: <dbfe2a41-c99d-4f00-ac0d-2b2b31a72986@gmail.com>

On Fri, Nov 13, 2026 at 10:45:03PM +0530, Sahil wrote:
> On 11/8/26 1:33 PM, Stafford Horne wrote:
> > On Tue, Oct 27, 2026 at 01:42:39AM +0530, Sahil Siddiq wrote:
> > > Tests already exist lib/tests to verify the generic functionality of
> > > KProbes. Add unit tests to verify that KProbes work on instructions
> > > that require simulation in the OpenRISC ISA, and that the corresponding
> > > delay slots are handled correctly.
> > > 
> > > Signed-off-by: Sahil Siddiq <sahilcdq0@gmail.com>
> > > ---
> > > Changes v2 -> v3:
> > > - arch/openrisc/kernel/tests/test_kprobes_asm.S:
> > >    - (test_kprobes_*): Set value in r11 register to 0 prior to running tests
> > >    - (test_kprobes_adrp):
> > >      Place function at page-aligned address
> > >      Use PAGE_SIZE macro instead of magic number
> > >      Move value in r13 to r11 before exiting
> > > 
> > > Changes v1 -> v2: New commit
> > > 
> > >   arch/openrisc/Kconfig.debug                   |  30 +++-
> > >   arch/openrisc/kernel/Makefile                 |   1 +
> > >   arch/openrisc/kernel/tests/Makefile           |   3 +
> > >   arch/openrisc/kernel/tests/test_kprobes.c     |  59 +++++++
> > >   arch/openrisc/kernel/tests/test_kprobes.h     |  24 +++
> > >   arch/openrisc/kernel/tests/test_kprobes_asm.S | 157 ++++++++++++++++++
> > >   6 files changed, 273 insertions(+), 1 deletion(-)
> > >   create mode 100644 arch/openrisc/kernel/tests/Makefile
> > >   create mode 100644 arch/openrisc/kernel/tests/test_kprobes.c
> > >   create mode 100644 arch/openrisc/kernel/tests/test_kprobes.h
> > >   create mode 100644 arch/openrisc/kernel/tests/test_kprobes_asm.S
> > > 
> > > [...]
> > > diff --git a/arch/openrisc/kernel/tests/test_kprobes_asm.S b/arch/openrisc/kernel/tests/test_kprobes_asm.S
> > > new file mode 100644
> > > index 000000000000..bc87a5fb00d5
> > > --- /dev/null
> > > +++ b/arch/openrisc/kernel/tests/test_kprobes_asm.S
> > > @@ -0,0 +1,157 @@
> > > +/* SPDX-License-Identifier: GPL-2.0-or-later */
> > > +/*
> > > + * KProbes unit tests for OpenRISC
> > > + *
> > > + * Unit tests borrowed liberally from similar work of RISC-V. All
> > > + * original copyrights apply as per the original source declaration.
> > > + */
> > > +
> > > +#include <linux/linkage.h>
> > > +#include <asm/asm.h>
> > > +#include <asm/page.h>
> > > +
> > > +#include "test_kprobes.h"
> > > +
> > > +SYM_FUNC_START(test_kprobes_j)
> > > +test_kprobes_j_addr1:
> > > +	l.addi	r11,r0,0
> > > +	l.j	2f
> > > +	l.nop
> > 
> > Just a tiny comment here about indenting the delay slots.
> 
> Got it, I'll indent this.
> 
> > You could also use the delayslots here, for example:
> > 
> > 	l.j	2f
> > 	 l.addi	r11,r0,0
> 
> I initially thought of that too. But then I thought by keeping l.addi
> before l.j, I would also be able to test this for the case when
> there are no delay slots. I can reshuffle the instructions if that
> test isn't required. Please let me know what your thoughts are.

I don't think it matters either way since these are tests.  But, it would be good
to note that in a comment at the top of the files where you want to maintain
that convention.

However, thinking a bit further that may be hard to enforce down the line just
for a handful of files.  We should assume the kernel code uses delayslots.

-Stafford

> > > +1:	l.ori	r13,r13,KPROBE_TEST_MAGIC_LOWER
> > > +	l.addi	r11,r13,0
> > > +	l.jr	r9
> > > +	l.nop
> > > +2:	l.movhi	r13,KPROBE_TEST_MAGIC_UPPER
> > > +test_kprobes_j_addr2:
> > > +	l.j	1b
> > > +	l.nop
> > > +SYM_FUNC_END(test_kprobes_j)
> > > [...]
> > > -- 
> > > 2.55.0
> > > 
> 
> Regards,
> Sahil

  reply	other threads:[~2026-11-15  1:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260930202744.50489-1-sahilcdq0@gmail.com>
2026-10-26 20:12 ` [PATCH v3 0/4] openrisc: Add support for KProbes and Kretprobes Sahil Siddiq
2026-11-13  9:04   ` Masami Hiramatsu (Google)
2026-11-13 17:22     ` Sahil
2026-10-26 20:12 ` [PATCH v3 1/4] openrisc: Add utilities and clean up simulation of instructions Sahil Siddiq
2026-11-07  6:45   ` Stafford Horne
2026-11-13 17:11     ` Sahil
2026-11-15  1:13       ` Stafford Horne
2026-10-26 20:12 ` [PATCH v3 2/4] openrisc: Add KProbes Sahil Siddiq
2026-10-26 20:26   ` Sahil
2026-10-26 20:35   ` sashiko-bot
2026-11-08  7:46   ` Stafford Horne
2026-11-13 17:13     ` Sahil
2026-11-15  1:44       ` Stafford Horne
2026-10-26 20:12 ` [PATCH v3 3/4] openrisc: Add unit tests for KProbes on branch instructions Sahil Siddiq
2026-10-26 20:26   ` sashiko-bot
2026-11-08  8:03   ` Stafford Horne
2026-11-13 17:15     ` Sahil
2026-11-15  1:52       ` Stafford Horne [this message]
2026-10-26 20:12 ` [PATCH v3 4/4] openrisc: Add Kretprobes Sahil Siddiq
2026-10-26 20:28   ` sashiko-bot
2026-11-08  7:58   ` Stafford Horne
2026-11-13 17:16     ` Sahil

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=avkQctt0CKt3YcsH@antec \
    --to=shorne@gmail.com \
    --cc=davem@davemloft.net \
    --cc=jonas@southpole.se \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-openrisc@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=namcao@linutronix.de \
    --cc=naveen@kernel.org \
    --cc=pjw@kernel.org \
    --cc=sahilcdq0@gmail.com \
    --cc=stefan.kristiansson@saunalahti.fi \
    --cc=wangruikang@iscas.ac.cn \
    /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