From: Richard Henderson <richard.henderson@linaro.org>
To: Weiwei Li <liweiwei@iscas.ac.cn>,
palmer@dabbelt.com, alistair.francis@wdc.com,
bin.meng@windriver.com, qemu-riscv@nongnu.org,
qemu-devel@nongnu.org
Cc: wangjunqiang@iscas.ac.cn, lazyparser@gmail.com,
luruibo2000@163.com, lustrew@foxmail.com
Subject: Re: [PATCH v7 12/14] target/riscv: rvk: add CSR support for Zkr
Date: Tue, 1 Mar 2022 05:59:07 -1000 [thread overview]
Message-ID: <8b6ff05f-7246-940e-be90-44ede1a6a3ba@linaro.org> (raw)
In-Reply-To: <07c003f8-b34b-0da0-2298-ff3be5fd7655@iscas.ac.cn>
On 2/28/22 16:27, Weiwei Li wrote:
>
> 在 2022/3/1 上午9:44, Weiwei Li 写道:
>>
>> 在 2022/3/1 上午4:11, Richard Henderson 写道:
>>> On 2/28/22 04:48, Weiwei Li wrote:
>>>> +/* Crypto Extension */
>>>> +static RISCVException rmw_seed(CPURISCVState *env, int csrno,
>>>> + target_ulong *ret_value,
>>>> + target_ulong new_value, target_ulong write_mask)
>>>> +{
>>>> + if (!write_mask) {
>>>> + return RISCV_EXCP_ILLEGAL_INST;
>>>> + }
>>>
>>> This is incorrect. The error should only be with a write-mask of the actual x0
>>> register, not another register which happens to contain 0. There is in fact no way to
>>> diagnose exactly what you want here, which IIRC has an existing fixme comment somewhere.
>> Yeah. write_mask is also used in riscv_csrrw_check to check whether the read-only csr is
>> written. We cannot distinguish x0 and reg which contains 0 here without changing total
>> progress of csr read/write.
>>>
> I seems misunderstand the code for csr read/write: write_mask will be set zero only for
> read-only operation (CSRRS/CSRRC with rs1=x0 or CSRRSI/CSRRCI with uimm=0) via do_csrr -->
> helper_csrr -> riscv_csrrw call-chain.
>
> The write_mask for do_csrw and do_csrrw will not be zero.
>
> As said in the spec :
>
> "TheseedCSR must be accessed with a read-write instruction. A read-only instruction such
> asCSRRS/CSRRC
> withrs1=x0orCSRRSI/CSRRCIwithuimm=0will raise an illegal instruction exception. "
>
> So it's suitable to check write_mask here.
Consider CSRRS with rs1=x31. In that case mask will be the value in x31. Even if the
value is 0, this is still considered a read-write instruction.
r~
next prev parent reply other threads:[~2022-03-01 16:01 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 14:47 [PATCH v7 00/14] support subsets of scalar crypto extension Weiwei Li
2022-02-28 14:47 ` [PATCH v7 01/14] target/riscv: rvk: add cfg properties for zbk* and zk* Weiwei Li
2022-02-28 14:47 ` [PATCH v7 02/14] target/riscv: rvk: add support for zbkb extension Weiwei Li
2022-02-28 18:54 ` Richard Henderson
2022-02-28 14:47 ` [PATCH v7 03/14] target/riscv: rvk: add support for zbkc extension Weiwei Li
2022-02-28 18:55 ` Richard Henderson
2022-02-28 14:48 ` [PATCH v7 04/14] target/riscv: rvk: add support for zbkx extension Weiwei Li
2022-02-28 14:48 ` [PATCH v7 05/14] crypto: move sm4_sbox from target/arm Weiwei Li
2022-02-28 14:48 ` [PATCH v7 06/14] target/riscv: rvk: add support for zknd/zkne extension in RV32 Weiwei Li
2022-02-28 18:57 ` Richard Henderson
2022-02-28 14:48 ` [PATCH v7 07/14] target/riscv: rvk: add support for zkne/zknd extension in RV64 Weiwei Li
2022-02-28 19:01 ` Richard Henderson
2022-02-28 14:48 ` [PATCH v7 08/14] target/riscv: rvk: add support for sha256 related instructions in zknh extension Weiwei Li
2022-02-28 19:03 ` Richard Henderson
2022-02-28 14:48 ` [PATCH v7 09/14] target/riscv: rvk: add support for sha512 related instructions for RV32 " Weiwei Li
2022-02-28 19:38 ` Richard Henderson
2022-03-01 1:28 ` Weiwei Li
2022-02-28 14:48 ` [PATCH v7 10/14] target/riscv: rvk: add support for sha512 related instructions for RV64 " Weiwei Li
2022-02-28 19:40 ` Richard Henderson
2022-02-28 14:48 ` [PATCH v7 11/14] target/riscv: rvk: add support for zksed/zksh extension Weiwei Li
2022-02-28 19:44 ` Richard Henderson
2022-02-28 14:48 ` [PATCH v7 12/14] target/riscv: rvk: add CSR support for Zkr Weiwei Li
2022-02-28 20:11 ` Richard Henderson
2022-03-01 1:44 ` Weiwei Li
2022-03-01 2:27 ` Weiwei Li
2022-03-01 15:59 ` Richard Henderson [this message]
2022-03-02 0:57 ` Weiwei Li
2022-02-28 14:48 ` [PATCH v7 13/14] disas/riscv.c: rvk: add disas support for Zbk* and Zk* instructions Weiwei Li
2022-02-28 14:48 ` [PATCH v7 14/14] target/riscv: rvk: expose zbk* and zk* properties Weiwei Li
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=8b6ff05f-7246-940e-be90-44ede1a6a3ba@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=lazyparser@gmail.com \
--cc=liweiwei@iscas.ac.cn \
--cc=luruibo2000@163.com \
--cc=lustrew@foxmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=wangjunqiang@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;
as well as URLs for NNTP newsgroup(s).