From: Richard Henderson <richard.henderson@linaro.org>
To: "Frédéric Pétrot" <frederic.petrot@univ-grenoble-alpes.fr>,
qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: philmd@redhat.com, bin.meng@windriver.com,
alistair.francis@wdc.com, palmer@dabbelt.com,
fabien.portas@grenoble-inp.org
Subject: Re: [PATCH v4 17/17] target/riscv: actual functions to realize crs 128-bit insns
Date: Tue, 2 Nov 2021 09:22:14 -0400 [thread overview]
Message-ID: <3089f9fd-a108-1a32-db0d-4a5ec633ca4e@linaro.org> (raw)
In-Reply-To: <20211025122818.168890-18-frederic.petrot@univ-grenoble-alpes.fr>
On 10/25/21 8:28 AM, Frédéric Pétrot wrote:
> +typedef RISCVException (*riscv_csr_op128_fn)(CPURISCVState *env, int csrno,
> + Int128 *ret_value,
> + Int128 new_value,
> + Int128 write_mask);
> +
> typedef struct {
> const char *name;
> riscv_csr_predicate_fn predicate;
> riscv_csr_read_fn read;
> riscv_csr_write_fn write;
> riscv_csr_op_fn op;
> + riscv_csr_read128_fn read128;
> + riscv_csr_write128_fn write128;
> + riscv_csr_op128_fn op128;
I think you should drop op128 until there is a need for it.
> +static RISCVException read_mstatus_i128(CPURISCVState *env, int csrno,
> + Int128 *val)
> +{
> + *val = int128_make128(env->mstatus, add_status_sd(riscv_cpu_mxl(env), 0));
> + return RISCV_EXCP_NONE;
> +}
Well, you don't need to read mxl here, as you cannot arrive to this function without it
being MXL_RV128.
I think you need a similar read_sstatus_i128 function.
> - /* check privileges and return RISCV_EXCP_ILLEGAL_INST if check fails */
> + /* check privileges and return -1 if check fails */
Bad rebase change; the return type is RISCVException.
> + /* write value if writable and write mask set, otherwise drop writes */
> + if (int128_nz(write_mask)) {
> + new_value = int128_or(int128_and(old_value, int128_not(write_mask)),
> + int128_and(new_value, write_mask));
> + if (csr_ops[csrno].write128) {
> + ret = csr_ops[csrno].write128(env, csrno, new_value);
> + if (ret != RISCV_EXCP_NONE) {
> + return ret;
> + }
> + }
> + }
This is wrong; you certainly don't want to drop writes; you want to forward writes to the
64-bit version. At least...
> + [CSR_MSTATUS] = { "mstatus", any, read_mstatus, write_mstatus, NULL,
> + read_mstatus_i128 },
> + [CSR_MISA] = { "misa", any, read_misa, write_misa, NULL,
> + read_misa_i128 },
... that is certainly the case for these CSRs. Alternately, you've got to implement these
write functions.
r~
prev parent reply other threads:[~2021-11-02 13:24 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 12:28 [PATCH v4 00/17] Adding partial support for 128-bit riscv target Frédéric Pétrot
2021-10-25 12:28 ` [PATCH v4 01/17] exec/memop: Rename MO_Q definition as MO_UQ and add MO_UO Frédéric Pétrot
2021-10-25 20:09 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 02/17] qemu/int128: addition of a few 128-bit operations Frédéric Pétrot
2021-10-25 15:47 ` Philippe Mathieu-Daudé
2021-10-25 20:16 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 03/17] target/riscv: additional macros to check instruction support Frédéric Pétrot
2021-10-30 23:49 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 04/17] target/riscv: separation of bitwise logic and aritmetic helpers Frédéric Pétrot
2021-10-25 15:51 ` Philippe Mathieu-Daudé
2021-10-25 19:08 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 05/17] target/riscv: array for the 64 upper bits of 128-bit registers Frédéric Pétrot
2021-10-25 15:55 ` Philippe Mathieu-Daudé
2021-10-25 19:10 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 06/17] target/riscv: setup everything so that riscv128-softmmu compiles Frédéric Pétrot
2021-10-30 23:52 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 07/17] target/riscv: moving some insns close to similar insns Frédéric Pétrot
2021-10-25 15:56 ` Philippe Mathieu-Daudé
2021-10-25 12:28 ` [PATCH v4 08/17] target/riscv: accessors to registers upper part and 128-bit load/store Frédéric Pétrot
2021-10-31 3:41 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 09/17] target/riscv: support for 128-bit bitwise instructions Frédéric Pétrot
2021-10-31 3:44 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 10/17] target/riscv: support for 128-bit U-type instructions Frédéric Pétrot
2021-10-31 3:49 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 11/17] target/riscv: support for 128-bit shift instructions Frédéric Pétrot
2021-10-31 4:03 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 12/17] target/riscv: support for 128-bit arithmetic instructions Frédéric Pétrot
2021-11-02 12:43 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 13/17] target/riscv: support for 128-bit M extension Frédéric Pétrot
2021-11-02 13:05 ` Richard Henderson
2021-10-25 12:28 ` [PATCH v4 14/17] target/riscv: adding high part of some csrs Frédéric Pétrot
2021-10-25 12:28 ` [PATCH v4 15/17] target/riscv: helper functions to wrap calls to 128-bit csr insns Frédéric Pétrot
2021-10-25 12:28 ` [PATCH v4 16/17] target/riscv: modification of the trans_csrxx for 128-bit support Frédéric Pétrot
2021-10-25 12:28 ` [PATCH v4 17/17] target/riscv: actual functions to realize crs 128-bit insns Frédéric Pétrot
2021-11-02 13:22 ` Richard Henderson [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=3089f9fd-a108-1a32-db0d-4a5ec633ca4e@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=fabien.portas@grenoble-inp.org \
--cc=frederic.petrot@univ-grenoble-alpes.fr \
--cc=palmer@dabbelt.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.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;
as well as URLs for NNTP newsgroup(s).