qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: frank.chang@sifive.com, qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
	Alistair Francis <Alistair.Francis@wdc.com>,
	Sagar Karandikar <sagark@eecs.berkeley.edu>,
	Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Subject: Re: [PATCH] target/riscv: fix vs() to return proper error code
Date: Tue, 23 Feb 2021 10:46:26 -0800	[thread overview]
Message-ID: <86510657-883a-f49e-c9da-d7a3d31d3de2@linaro.org> (raw)
In-Reply-To: <20210223065935.20208-1-frank.chang@sifive.com>

On 2/22/21 10:59 PM, frank.chang@sifive.com wrote:
> From: Frank Chang <frank.chang@sifive.com>
> 
> vs() should return -RISCV_EXCP_ILLEGAL_INST instead of -1 if rvv feature
> is not enabled.
> 
> If -1 is returned, exception will be raised and cs->exception_index will
> be set to the negative return value. The exception will then be treated
> as an instruction access fault instead of illegal instruction fault.

It does seem an unfortunate interface; -1 seems so tempting, but does not by
itself mean anything.

I wonder if we should dispense with the whole "negative number" thing and
simply return an exception value.  Then for bonus points put all of the
RISCV_EXCP_* values in an enumeration, and return that type from these
functions so that it's perfectly clear what the interface really is.

That said,

> @@ -54,7 +54,7 @@ static int vs(CPURISCVState *env, int csrno)
>      if (env->misa & RVV) {
>          return 0;
>      }
> -    return -1;
> +    return -RISCV_EXCP_ILLEGAL_INST;

this fixes the immediate bug, so
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


  reply	other threads:[~2021-02-23 18:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23  6:59 [PATCH] target/riscv: fix vs() to return proper error code frank.chang
2021-02-23 18:46 ` Richard Henderson [this message]
2021-03-08 13:38   ` 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=86510657-883a-f49e-c9da-d7a3d31d3de2@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=Alistair.Francis@wdc.com \
    --cc=frank.chang@sifive.com \
    --cc=kbastian@mail.uni-paderborn.de \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=sagark@eecs.berkeley.edu \
    /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;
as well as URLs for NNTP newsgroup(s).