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 v6 08/14] target/riscv: rvk: add support for sha256 related instructions in zknh extension
Date: Sun, 27 Feb 2022 09:21:26 -1000 [thread overview]
Message-ID: <91b397ee-7b68-653c-8b73-4b0a91b057e0@linaro.org> (raw)
In-Reply-To: <20220227142553.25815-9-liweiwei@iscas.ac.cn>
On 2/27/22 04:25, Weiwei Li wrote:
> - add sha256sig0, sha256sig1, sha256sum0 and sha256sum1 instructions
>
> Co-authored-by: Zewen Ye <lustrew@foxmail.com>
> Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
> Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
> ---
> target/riscv/crypto_helper.c | 31 +++++++++++++
> target/riscv/helper.h | 5 +++
> target/riscv/insn32.decode | 5 +++
> target/riscv/insn_trans/trans_rvk.c.inc | 58 +++++++++++++++++++++++++
> 4 files changed, 99 insertions(+)
>
> diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c
> index 9e56668627..f5ffc262f2 100644
> --- a/target/riscv/crypto_helper.c
> +++ b/target/riscv/crypto_helper.c
> @@ -272,4 +272,35 @@ target_ulong HELPER(aes64im)(target_ulong rs1)
>
> return result;
> }
> +
> +#define ROR32(a, amt) ((a << (-amt & 31)) | (a >> (amt & 31)))
We already have a ror32 function. However...
> +target_ulong HELPER(sha256sig0)(target_ulong rs1)
> +{
> + uint32_t a = rs1;
> +
> + return sext_xlen(ROR32(a, 7) ^ ROR32(a, 18) ^ (a >> 3));
> +}
> +
> +target_ulong HELPER(sha256sig1)(target_ulong rs1)
> +{
> + uint32_t a = rs1;
> +
> + return sext_xlen(ROR32(a, 17) ^ ROR32(a, 19) ^ (a >> 10));
> +}
> +
> +target_ulong HELPER(sha256sum0)(target_ulong rs1)
> +{
> + uint32_t a = rs1;
> +
> + return sext_xlen(ROR32(a, 2) ^ ROR32(a, 13) ^ ROR32(a, 22));
> +}
> +
> +target_ulong HELPER(sha256sum1)(target_ulong rs1)
> +{
> + uint32_t a = rs1;
> +
> + return sext_xlen(ROR32(a, 6) ^ ROR32(a, 11) ^ ROR32(a, 25));
> +}
All of these functions are quite small, and could easily be generated inline.
tcg_gen_trunc_tl_i32(a, reg);
tcg_gen_rotri_i32(t1, a, 7);
tcg_gen_rotri_i32(t2, a, 18);
tcg_gen_xor_i32(t1, t1, t2);
tcg_gen_shri_i32(t2, a, 3);
tcg_gen_xor_i32(t1, t1, t2);
tcg_gen_ext_i32_tl(reg, t1);
> +static bool trans_sha256sig0(DisasContext *ctx, arg_sha256sig0 *a)
> +{
> + REQUIRE_ZKNH(ctx);
> +
> + TCGv dest = dest_gpr(ctx, a->rd);
> + TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE);
> +
> + gen_helper_sha256sig0(dest, src1);
> + gen_set_gpr(ctx, a->rd, dest);
> +
> + return true;
> +}
gen_unary, etc.
r~
next prev parent reply other threads:[~2022-02-27 19:22 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-27 14:25 [PATCH v6 00/14] support subsets of scalar crypto extension Weiwei Li
2022-02-27 14:25 ` [PATCH v6 01/14] target/riscv: rvk: add cfg properties for zbk* and zk* Weiwei Li
2022-02-27 14:25 ` [PATCH v6 02/14] target/riscv: rvk: add support for zbkb extension Weiwei Li
2022-02-27 18:47 ` Richard Henderson
2022-02-28 3:02 ` Weiwei Li
2022-02-28 18:16 ` Richard Henderson
2022-02-27 14:25 ` [PATCH v6 03/14] target/riscv: rvk: add support for zbkc extension Weiwei Li
2022-02-27 14:25 ` [PATCH v6 04/14] target/riscv: rvk: add support for zbkx extension Weiwei Li
2022-02-27 18:50 ` Richard Henderson
2022-02-27 14:25 ` [PATCH v6 05/14] crypto: move sm4_sbox from target/arm Weiwei Li
2022-02-27 18:51 ` Richard Henderson
2022-02-27 14:25 ` [PATCH v6 06/14] target/riscv: rvk: add support for zknd/zkne extension in RV32 Weiwei Li
2022-02-27 19:05 ` Richard Henderson
2022-02-28 3:08 ` Weiwei Li
2022-02-27 14:25 ` [PATCH v6 07/14] target/riscv: rvk: add support for zkne/zknd extension in RV64 Weiwei Li
2022-02-27 19:13 ` Richard Henderson
2022-02-28 3:10 ` Weiwei Li
2022-02-27 14:25 ` [PATCH v6 08/14] target/riscv: rvk: add support for sha256 related instructions in zknh extension Weiwei Li
2022-02-27 19:21 ` Richard Henderson [this message]
2022-02-28 3:11 ` Weiwei Li
2022-02-27 14:25 ` [PATCH v6 09/14] target/riscv: rvk: add support for sha512 related instructions for RV32 " Weiwei Li
2022-02-27 19:36 ` Richard Henderson
2022-02-28 3:17 ` Weiwei Li
2022-02-27 14:25 ` [PATCH v6 10/14] target/riscv: rvk: add support for sha512 related instructions for RV64 " Weiwei Li
2022-02-27 19:36 ` Richard Henderson
2022-02-27 14:25 ` [PATCH v6 11/14] target/riscv: rvk: add support for zksed/zksh extension Weiwei Li
2022-02-27 19:41 ` Richard Henderson
2022-02-28 3:19 ` Weiwei Li
2022-02-27 14:25 ` [PATCH v6 12/14] target/riscv: rvk: add CSR support for Zkr Weiwei Li
2022-02-27 14:25 ` [PATCH v6 13/14] disas/riscv.c: rvk: add disas support for Zbk* and Zk* instructions Weiwei Li
2022-02-27 14:25 ` [PATCH v6 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=91b397ee-7b68-653c-8b73-4b0a91b057e0@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).