All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Chao Liu <chao.liu.zevorn@gmail.com>
Cc: qemu-riscv@nongnu.org, Laurent Vivier <laurent@vivier.eu>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	 Weiwei Li <liwei1518@gmail.com>,
	Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
	 Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
	qemu-devel@nongnu.org, Joel Stanley <joel@jms.id.au>
Subject: Re: [PATCH v3 3/3] tests/tcg: Add riscv test for interrupted vector ops
Date: Thu, 26 Mar 2026 16:32:52 +1000	[thread overview]
Message-ID: <acTSVA-Ln9wp-2fk@lima-default> (raw)
In-Reply-To: <acNSjHocMNviKQVZ@ZEVORN-PC.localdomain>

On Wed, Mar 25, 2026 at 11:19:26AM +0800, Chao Liu wrote:
> On Sun, Mar 22, 2026 at 12:45:54AM +1000, Nicholas Piggin wrote:
> > riscv vector instructions can be interrupted with a trap, and partial
> > completion is recorded in the vstart register. Some causes are
> > implementation dependent, for example an asynchronous interrupt (which I
> > don't think TCG allows). Others are architectural, typically memory
> > access faults on vector load/store instructions.
> > 
> > Add some TCG tests for interrupting vector load instructions and
> > resuming partially completed ones.
> > 
> > This would have caught a recent (now reverted) regression in vector
> > stride load implementation, commit 28c12c1f2f50d ("Generate strided
> > vector loads/stores with tcg nodes.")
> > 
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> >  tests/tcg/riscv64/Makefile.target      |  11 +
> >  tests/tcg/riscv64/test-interrupted-v.c | 329 +++++++++++++++++++++++++
> >  2 files changed, 340 insertions(+)
> >  create mode 100644 tests/tcg/riscv64/test-interrupted-v.c
> > 
> > diff --git a/tests/tcg/riscv64/Makefile.target b/tests/tcg/riscv64/Makefile.target
> > index 19a49b6467..b2b2325843 100644
> > --- a/tests/tcg/riscv64/Makefile.target
> > +++ b/tests/tcg/riscv64/Makefile.target
> > @@ -1,6 +1,10 @@
> >  # -*- Mode: makefile -*-
> >  # RISC-V specific tweaks
> >  
> > +# Not all environments have compilers with vector intrinsics yet.
> > +HAVE_RISCV_VECTOR_INTRINSICS := $(shell echo '#ifndef __riscv_v_intrinsic\n#error\n#endif' |  \
> > +                                  $(CC) -march=rv64gcv -E -x c - >/dev/null 2>&1 && echo y)
> The feature probe relies on echo interpreting '\n'
> as newlines, but this is not portable.
> 
> POSIX leaves echo's handling of backslash sequences
> implementation-defined.
> 
> On bash (the default /bin/sh on many systems including
> Fedora, Arch, and some CI images), echo outputs literal
> '\n', so the preprocessor sees a malformed single-line input
> and always fails. This silently disables test-interrupted-v
> even when the compiler supports vector intrinsics.
> 
> I suggest using printf for portability:
> 
>     HAVE_RISCV_VECTOR_INTRINSICS := $(shell printf \
>         '#ifndef __riscv_v_intrinsic\n#error\n#endif\n' | \
>         $(CC) -march=rv64gcv -E -x c - \
>         >/dev/null 2>&1 && echo y)

Wow nice catch. My shell skills amount to pressing random buttons
until it works, so I appreciate the help :P

[...]

> > +static volatile int nr_segv;
> > +static volatile unsigned long fault_start, fault_end;
> > +static volatile bool fault_write;
> checkpatch errors:
> 
>   ERROR: Use of volatile is usually wrong, please add a comment
>   #84: FILE: tests/tcg/riscv64/test-interrupted-v.c:26:
>   +static volatile int nr_segv;
> 
>   ERROR: Use of volatile is usually wrong, please add a comment
>   #85: FILE: tests/tcg/riscv64/test-interrupted-v.c:27:
>   +static volatile unsigned long fault_start, fault_end;
> 
>   ERROR: Use of volatile is usually wrong, please add a comment
>   #86: FILE: tests/tcg/riscv64/test-interrupted-v.c:28:
>   +static volatile bool fault_write;
> 
> Please fix it.

Yeah I guess they were missed in the rest of the checkpatch
errors, you're right the volatiles should be commented.

Thanks,
Nick


  reply	other threads:[~2026-03-26  6:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-21 14:45 [PATCH v3 0/3] target/riscv: corner case fixes Nicholas Piggin
2026-03-21 14:45 ` [PATCH v3 1/3] target/riscv: Fix IALIGN check in misa write Nicholas Piggin
2026-03-25  1:35   ` Alistair Francis
2026-03-25  3:08   ` Chao Liu
2026-03-25  3:26     ` Alistair Francis
2026-03-25  3:40       ` Chao Liu
2026-03-26  6:29         ` Nicholas Piggin
2026-03-21 14:45 ` [PATCH v3 2/3] target/riscv: Fix vector whole ldst vstart check Nicholas Piggin
2026-03-25  1:57   ` Alistair Francis
2026-03-25  2:10   ` Chao Liu
2026-03-21 14:45 ` [PATCH v3 3/3] tests/tcg: Add riscv test for interrupted vector ops Nicholas Piggin
2026-03-25  2:08   ` Alistair Francis
2026-03-25  3:19   ` Chao Liu
2026-03-26  6:32     ` Nicholas Piggin [this message]
2026-03-25  2:20 ` [PATCH v3 0/3] target/riscv: corner case fixes Alistair Francis

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=acTSVA-Ln9wp-2fk@lima-default \
    --to=npiggin@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=chao.liu.zevorn@gmail.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=joel@jms.id.au \
    --cc=laurent@vivier.eu \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=zhiwei_liu@linux.alibaba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.