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 07/14] target/riscv: rvk: add support for zkne/zknd extension in RV64
Date: Sun, 27 Feb 2022 09:13:51 -1000 [thread overview]
Message-ID: <7dcdb5fc-b440-e3f8-36d0-774865b7bf01@linaro.org> (raw)
In-Reply-To: <20220227142553.25815-8-liweiwei@iscas.ac.cn>
On 2/27/22 04:25, Weiwei Li wrote:
> - add aes64dsm, aes64ds, aes64im, aes64es, aes64esm, aes64ks2, aes64ks1i instructions
>
> Co-authored-by: Ruibo Lu <luruibo2000@163.com>
> 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 | 136 ++++++++++++++++++++++++
> target/riscv/helper.h | 8 ++
> target/riscv/insn32.decode | 11 ++
> target/riscv/insn_trans/trans_rvk.c.inc | 102 ++++++++++++++++++
> 4 files changed, 257 insertions(+)
>
> diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c
> index f5a5909538..9e56668627 100644
> --- a/target/riscv/crypto_helper.c
> +++ b/target/riscv/crypto_helper.c
> @@ -136,4 +136,140 @@ target_ulong HELPER(aes32dsi)(target_ulong rs1, target_ulong rs2,
> {
> return aes32_operation(bs, rs1, rs2, false, false);
> }
> +
> +static inline target_ulong aes64_operation(target_ulong rs1, target_ulong rs2,
> + bool enc, bool mix)
> +{
> + uint64_t RS1 = rs1;
> + uint64_t RS2 = rs2;
> + uint64_t result;
> + uint64_t temp;
> + uint32_t col_0;
> + uint32_t col_1;
> +
> + if (enc) {
> + temp = AES_SHIFROWS_LO(RS1, RS2);
Ah, those unused macros get used, and with the right type.
> +target_ulong HELPER(aes64ks1i)(target_ulong rs1, target_ulong rnum)
> +{
> + uint64_t RS1 = rs1;
> + uint8_t round_consts[10] = {
> + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36
> + };
static const.
> + temp = (temp >> 8) | (temp << 24); /* Rotate right by 8 */
rol32
> +DEF_HELPER_2(aes64esm, tl, tl, tl)
> +DEF_HELPER_2(aes64es, tl, tl, tl)
> +DEF_HELPER_2(aes64ds, tl, tl, tl)
> +DEF_HELPER_2(aes64dsm, tl, tl, tl)
> +DEF_HELPER_2(aes64ks2, tl, tl, tl)
> +DEF_HELPER_2(aes64ks1i, tl, tl, tl)
> +DEF_HELPER_1(aes64im, tl, tl)
DEF_HELPER_FLAGS.
> +%rnum 20:4
...
> +aes64ks1i 00 11000 1.... ..... 001 ..... 0010011 %rnum %rs1 %rd
It is much better to put the field where it belongs,
especially for a one-off like this.
aes64ks1i 00 11000 1 rnum:4 rs1:5 001 rd:5 0010011
The whole of riscv needs a cleanup on this point.
> +static bool trans_aes64esm(DisasContext *ctx, arg_aes64esm *a)
> +{
> + REQUIRE_ZKNE(ctx);
> +
> + TCGv dest = dest_gpr(ctx, a->rd);
> + TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE);
> + TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE);
> +
> + gen_helper_aes64esm(dest, src1, src2);
> + gen_set_gpr(ctx, a->rd, dest);
> +
> + return true;
> +}
...
> +static bool trans_aes64es(DisasContext *ctx, arg_aes64es *a)
> +{
> + REQUIRE_ZKNE(ctx);
> +
> + TCGv dest = dest_gpr(ctx, a->rd);
> + TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE);
> + TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE);
> +
> + gen_helper_aes64es(dest, src1, src2);
> + gen_set_gpr(ctx, a->rd, dest);
> +
> + return true;
> +}
gen_arith.
> +static bool trans_aes64dsm(DisasContext *ctx, arg_aes64dsm *a)
> +static bool trans_aes64ks2(DisasContext *ctx, arg_aes64ks2 *a)
> +static bool trans_aes64ds(DisasContext *ctx, arg_aes64ds *a)
Likewise.
> +static bool trans_aes64ks1i(DisasContext *ctx, arg_aes64ks1i *a)
> +{
> + REQUIRE_EITHER_EXT(ctx, zknd, zkne);
> +
> + if (a->rnum > 0xA) {
> + return false;
> + }
> +
> + TCGv rnum = tcg_const_tl(a->rnum);
> + TCGv dest = dest_gpr(ctx, a->rd);
> + TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE);
> +
> + gen_helper_aes64ks1i(dest, src1, rnum);
> + gen_set_gpr(ctx, a->rd, dest);
> +
> + tcg_temp_free(rnum);
> + return true;
> +}
tcg_constant_tl.
> +
> +static bool trans_aes64im(DisasContext *ctx, arg_aes64im *a)
> +{
> + REQUIRE_ZKND(ctx);
> +
> + TCGv dest = dest_gpr(ctx, a->rd);
> + TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE);
> +
> + gen_helper_aes64im(dest, src1);
> + gen_set_gpr(ctx, a->rd, dest);
> +
> + return true;
> +}
gen_unary.
r~
next prev parent reply other threads:[~2022-02-27 19:15 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 [this message]
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
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=7dcdb5fc-b440-e3f8-36d0-774865b7bf01@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).