Add RISC-V vector cryptographic instruction set support
Subsystems (3)
v7 cover Add RISC-V vector cryptographic instruction set support
This patchset provides an implementation for Zvbb, Zvbc, Zvkned, Zvknh, Zvksh, Zvkg, and Zvksed of the draft RISC-V vector cryptography extensions as per the v20230620 version of the specification(1)(168e7b4). This is an update to the patchset submitted to qemu-devel on Sun, 2 Jul 2023 23:27:00 +0800
Based-on: [email protected] ([PATCH v3 00/37] crypto: Provide aes-round.h and host accel)
v2:
Squashed commits into one commit per extension with separate commits for each refactoring.
Unified trans_rvzvk*.c.inc files into one trans_rvvk.c.inc. Style fixes in insn32.decode and other files.
Added macros for EGS values in translation functions. Updated from v20230303 to v20230407 of the spec:
Zvkb has been split into Zvbb and Zvbc.
vbrev, vclz, vctz, vcpop and vwsll have been added to Zvbb.
v3:
New patch 03/19 removes redundant “cpu_vl == 0” checks from trans_rvv.c.inc.
Introduction of new tcg ops has been factored out of patch 11/19 and into 09/19.
These ops are now added to non riscv-specific files.
v4:
New patch 08/17 fixes the tcg_gen_gvec_andcs temporary variable issue.
Patch 09/17 fixes imm mode for vror.vi.
Rebased to riscv-to-apply.next branch (de395bb):
Replace vstart constraint checking by TCG op.
Verified by code examples provided by vector crypto spec repository (riscv-crypto).
v5:
Imported aes-round.h for Zvkned extension.
Rebased to [email protected]
Exposed the properties of v4 patch 17/17 to the patches that the extension was added.
Removed v4 patch 08/17 that is queued to tcg-next.
v6:
Resent the same content becaue v5 was splitted by broken git-send-mail
v7:
Fixed endian issues
Replace the TCG ops of vstart & vl EGS checking by helper function Changed the SEW selection of vsha2c[hl].vv to TCG translation
As v20230620 is a frozen version, we are not expecting any significant changes to the specification or this patch series.
Please note that the Zvkt data-independent execution latency extension (and all extensions including it) has not been implemented, and we would recommend not using these patches in an environment where timing attacks are an issue.
Work performed by Dickon, Lawrence, Nazar, Kiran, and William from Codethink sponsored by SiFive, as well as Max Chou and Frank Chang from SiFive.
https://github.com/riscv/riscv-crypto/releases
Thanks to those who have already reviewed:
Daniel Henrique Barboza [email protected]
[PATCH v4 09/17] target/riscv: Add Zvbb ISA extension support
[PATCH v4 10/17] target/riscv: Add Zvkned ISA extension support [PATCH v4 11/17] target/riscv: Add Zvknh ISA extension support
[PATCH v4 12/17] target/riscv: Add Zvksh ISA extension support
[PATCH v4 13/17] target/riscv: Add Zvkg ISA extension support
Weiwei Li [email protected]
[PATCH v3 01/19] target/riscv: Refactor some of the generic vector functionality [PATCH v3 02/19] target/riscv: Refactor vector-vector translation macro [PATCH v3 03/19] target/riscv: Remove redundant "cpu_vl == 0" checks [PATCH v3 05/19] target/riscv: Move vector translation checks
[PATCH v3 06/19] target/riscv: Refactor translation of vector-widening instruction [PATCH v3 07/19] target/riscv: Refactor some of the generic vector functionality [PATCH v3 19/19] target/riscv: Expose Zvk* and Zvb[b, c] cpu properties
Richard Henderson [email protected]
[PATCH v2 02/17] target/riscv: Refactor vector-vector translation macro [PATCH v2 04/17] target/riscv: Move vector translation checks
[PATCH v2 05/17] target/riscv: Refactor translation of vector-widening instruction [PATCH v2 07/17] qemu/bitops.h: Limit rotate amounts
[PATCH v2 08/17] qemu/host-utils.h: Add clz and ctz functions for lower-bit integers [PATCH v2 14/17] crypto: Create sm4_subword
Alistair Francis [email protected]
[PATCH v2 02/17] target/riscv: Refactor vector-vector translation macro
Philipp Tomsich [email protected]
Various v1 reviews
Christoph Müllner [email protected]
Various v1 reviews
Dickon Hood (2):
target/riscv: Refactor translation of vector-widening instruction target/riscv: Add Zvbb ISA extension support
Kiran Ostrolenk (4):
target/riscv: Refactor some of the generic vector functionality target/riscv: Refactor vector-vector translation macro target/riscv: Refactor some of the generic vector functionality target/riscv: Add Zvknh ISA extension support
Lawrence Hunter (2):
target/riscv: Add Zvbc ISA extension support
target/riscv: Add Zvksh ISA extension support
Max Chou (3):
crypto: Create sm4_subword
crypto: Add SM4 constant parameter CK
target/riscv: Add Zvksed ISA extension support
Nazar Kazakov (4):
target/riscv: Remove redundant "cpu_vl == 0" checks target/riscv: Move vector translation checks target/riscv: Add Zvkned ISA extension support target/riscv: Add Zvkg ISA extension support
crypto/sm4.c | 10 + include/crypto/sm4.h | 9 + target/arm/tcg/crypto_helper.c | 10 +- target/riscv/cpu.c | 37 + target/riscv/cpu_cfg.h | 8 + target/riscv/helper.h | 98 +++ target/riscv/insn32.decode | 58 ++ target/riscv/insn_trans/trans_rvv.c.inc | 171 ++-- target/riscv/insn_trans/trans_rvvk.c.inc | 606 ++++++++++++++ target/riscv/meson.build | 4 +- target/riscv/translate.c | 1 + target/riscv/vcrypto_helper.c | 970 +++++++++++++++++++++++ target/riscv/vector_helper.c | 243 +----- target/riscv/vector_internals.c | 81 ++ target/riscv/vector_internals.h | 228 ++++++ 15 files changed, 2179 insertions(+), 355 deletions(-) create mode 100644 target/riscv/insn_trans/trans_rvvk.c.inc create mode 100644 target/riscv/vcrypto_helper.c create mode 100644 target/riscv/vector_internals.c create mode 100644 target/riscv/vector_internals.h
Signature · 1 line
2.34.1
PATCH v7 1/15 target/riscv: Refactor some of the generic vector functionality
From: Kiran Ostrolenk <[email protected]>
Take some functions/macros out of vector_helper and put them in a new module called vector_internals. This ensures they can be used by both vector and vector-crypto helpers (latter implemented in proceeding commits).
--- target/riscv/meson.build | 1 + target/riscv/vector_helper.c | 201 +------------------------------- target/riscv/vector_internals.c | 81 +++++++++++++ target/riscv/vector_internals.h | 182 +++++++++++++++++++++++++++++ 4 files changed, 265 insertions(+), 200 deletions(-) create mode 100644 target/riscv/vector_internals.c create mode 100644 target/riscv/vector_internals.h
target/riscv/meson.build +1 -0
@@ -16,6 +16,7 @@ riscv_ss.add(files( 'gdbstub.c', 'op_helper.c', 'vector_helper.c', + 'vector_internals.c', 'bitmanip_helper.c', 'translate.c', 'm128_helper.c',
target/riscv/vector_helper.c +1 -200
266 lines not on this page · raw message
target/riscv/vector_internals.c new file +81 -0
81 lines not on this page · raw message
target/riscv/vector_internals.h new file +182 -0
182 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 2/15 target/riscv: Refactor vector-vector translation macro
In reply to Max ChouFrom: Kiran Ostrolenk <[email protected]>
Refactor the non SEW-specific stuff out of GEN_OPIVV_TRANS into function opivv_trans (similar to opivi_trans). opivv_trans will be used in proceeding vector-crypto commits.
--- target/riscv/insn_trans/trans_rvv.c.inc | 62 +++++++++++++------------ 1 file changed, 32 insertions(+), 30 deletions(-)
target/riscv/insn_trans/trans_rvv.c.inc +32 -30
@@ -1643,38 +1643,40 @@ GEN_OPIWX_WIDEN_TRANS(vwadd_wx) GEN_OPIWX_WIDEN_TRANS(vwsubu_wx) GEN_OPIWX_WIDEN_TRANS(vwsub_wx) +static bool opivv_trans(uint32_t vd, uint32_t vs1, uint32_t vs2, uint32_t vm, + gen_helper_gvec_4_ptr *fn, DisasContext *s) +{ + uint32_t data = 0; + TCGLabel *over = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); + tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); + + data = FIELD_DP32(data, VDATA, VM, vm); + data = FIELD_DP32(data, VDATA, LMUL, s->lmul); + data = FIELD_DP32(data, VDATA, VTA, s->vta); + data = FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s); + data = FIELD_DP32(data, VDATA, VMA, s->vma); + tcg_gen_gvec_4_ptr(vreg_ofs(s, vd), vreg_ofs(s, 0), vreg_ofs(s, vs1), + vreg_ofs(s, vs2), cpu_env, s->cfg_ptr->vlen / 8, + s->cfg_ptr->vlen / 8, data, fn); + mark_vs_dirty(s); + gen_set_label(over); + return true; +} + /* Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions */ /* OPIVV without GVEC IR */ -#define GEN_OPIVV_TRANS(NAME, CHECK) \ -static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ -{ \ - if (CHECK(s, a)) { \ - uint32_t data = 0; \ - static gen_helper_gvec_4_ptr * const fns[4] = { \ - gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ - gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ - }; \ - TCGLabel *over = gen_new_label(); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ - tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ - \ - data = FIELD_DP32(data, VDATA, VM, a->vm); \ - data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \ - data = FIELD_DP32(data, VDATA, VTA, s->vta); \ - data = \ - FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s);\ - data = FIELD_DP32(data, VDATA, VMA, s->vma); \ - tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ - vreg_ofs(s, a->rs1), \ - vreg_ofs(s, a->rs2), cpu_env, \ - s->cfg_ptr->vlen / 8, \ - s->cfg_ptr->vlen / 8, data, \ - fns[s->sew]); \ - mark_vs_dirty(s); \ - gen_set_label(over); \ - return true; \ - } \ - return false; \ +#define GEN_OPIVV_TRANS(NAME, CHECK) \ +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ +{ \ + if (CHECK(s, a)) { \ + static gen_helper_gvec_4_ptr * const fns[4] = { \ + gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ + gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ + }; \ + return opivv_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s);\ + } \ + return false; \ } /*
Signature · 1 line
2.34.1
PATCH v7 3/15 target/riscv: Remove redundant "cpu_vl == 0" checks
In reply to Max ChouFrom: Nazar Kazakov <[email protected]>
Remove the redundant "vl == 0" check which is already included within the vstart >= vl check, when vl == 0.
--- target/riscv/insn_trans/trans_rvv.c.inc | 31 +------------------------ 1 file changed, 1 insertion(+), 30 deletions(-)
target/riscv/insn_trans/trans_rvv.c.inc +1 -30
@@ -617,7 +617,6 @@ static bool ldst_us_trans(uint32_t vd, uint32_t rs1, uint32_t data, TCGv_i32 desc; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); dest = tcg_temp_new_ptr();
@@ -786,7 +785,6 @@ static bool ldst_stride_trans(uint32_t vd, uint32_t rs1, uint32_t rs2, TCGv_i32 desc; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); dest = tcg_temp_new_ptr();
@@ -893,7 +891,6 @@ static bool ldst_index_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, TCGv_i32 desc; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); dest = tcg_temp_new_ptr();
@@ -1034,7 +1031,6 @@ static bool ldff_trans(uint32_t vd, uint32_t rs1, uint32_t data, TCGv_i32 desc; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); dest = tcg_temp_new_ptr();
@@ -1191,7 +1187,6 @@ do_opivv_gvec(DisasContext *s, arg_rmrr *a, GVecGen3Fn *gvec_fn, return false; } - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) {
@@ -1241,7 +1236,6 @@ static bool opivx_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, uint32_t vm, uint32_t data = 0; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); dest = tcg_temp_new_ptr();
@@ -1405,7 +1399,6 @@ static bool opivi_trans(uint32_t vd, uint32_t imm, uint32_t vs2, uint32_t vm, uint32_t data = 0; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); dest = tcg_temp_new_ptr();
@@ -1492,7 +1485,6 @@ static bool do_opivv_widen(DisasContext *s, arg_rmrr *a, if (checkfn(s, a)) { uint32_t data = 0; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); data = FIELD_DP32(data, VDATA, VM, a->vm);
@@ -1575,7 +1567,6 @@ static bool do_opiwv_widen(DisasContext *s, arg_rmrr *a, if (opiwv_widen_check(s, a)) { uint32_t data = 0; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); data = FIELD_DP32(data, VDATA, VM, a->vm);
@@ -1648,7 +1639,6 @@ static bool opivv_trans(uint32_t vd, uint32_t vs1, uint32_t vs2, uint32_t vm, { uint32_t data = 0; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); data = FIELD_DP32(data, VDATA, VM, vm);
@@ -1842,7 +1832,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##NAME##_w, \ }; \ TCGLabel *over = gen_new_label(); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2054,7 +2043,6 @@ static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_v *a) gen_helper_vmv_v_v_w, gen_helper_vmv_v_v_d, }; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); tcg_gen_gvec_2_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1),
@@ -2078,7 +2066,6 @@ static bool trans_vmv_v_x(DisasContext *s, arg_vmv_v_x *a) vext_check_ss(s, a->rd, 0, 1)) { TCGv s1; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); s1 = get_gpr(s, a->rs1, EXT_SIGN);
@@ -2140,7 +2127,6 @@ static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_i *a) gen_helper_vmv_v_x_w, gen_helper_vmv_v_x_d, }; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); s1 = tcg_constant_i64(simm);
@@ -2288,7 +2274,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ }; \ TCGLabel *over = gen_new_label(); \ gen_set_rm(s, RISCV_FRM_DYN); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2323,7 +2308,6 @@ static bool opfvf_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, TCGv_i64 t1; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); dest = tcg_temp_new_ptr();
@@ -2408,7 +2392,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ }; \ TCGLabel *over = gen_new_label(); \ gen_set_rm(s, RISCV_FRM_DYN); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);\ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2483,7 +2466,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ }; \ TCGLabel *over = gen_new_label(); \ gen_set_rm(s, RISCV_FRM_DYN); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2601,7 +2583,6 @@ static bool do_opfv(DisasContext *s, arg_rmr *a, uint32_t data = 0; TCGLabel *over = gen_new_label(); gen_set_rm_chkfrm(s, rm); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); data = FIELD_DP32(data, VDATA, VM, a->vm);
@@ -2713,7 +2694,6 @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_v_f *a) gen_helper_vmv_v_x_d, }; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); t1 = tcg_temp_new_i64();
@@ -2792,7 +2772,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ }; \ TCGLabel *over = gen_new_label(); \ gen_set_rm_chkfrm(s, FRM); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2844,7 +2823,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ }; \ TCGLabel *over = gen_new_label(); \ gen_set_rm(s, RISCV_FRM_DYN); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2912,7 +2890,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ }; \ TCGLabel *over = gen_new_label(); \ gen_set_rm_chkfrm(s, FRM); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -2962,7 +2939,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ }; \ TCGLabel *over = gen_new_label(); \ gen_set_rm_chkfrm(s, FRM); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data = FIELD_DP32(data, VDATA, VM, a->vm); \
@@ -3053,7 +3029,6 @@ static bool trans_##NAME(DisasContext *s, arg_r *a) \ uint32_t data = 0; \ gen_helper_gvec_4_ptr *fn = gen_helper_##NAME; \ TCGLabel *over = gen_new_label(); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data = FIELD_DP32(data, VDATA, LMUL, s->lmul); \
@@ -3224,7 +3199,6 @@ static bool trans_vid_v(DisasContext *s, arg_vid_v *a) require_vm(a->vm, a->rd)) { uint32_t data = 0; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); data = FIELD_DP32(data, VDATA, VM, a->vm);
@@ -3411,7 +3385,6 @@ static bool trans_vmv_s_x(DisasContext *s, arg_vmv_s_x *a) TCGv s1; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); t1 = tcg_temp_new_i64();
@@ -3468,8 +3441,7 @@ static bool trans_vfmv_s_f(DisasContext *s, arg_vfmv_s_f *a) TCGv_i64 t1; TCGLabel *over = gen_new_label(); - /* if vl == 0 or vstart >= vl, skip vector register write back */ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); + /* if vstart >= vl, skip vector register write back */ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); /* NaN-box f[rs1] */
@@ -3720,7 +3692,6 @@ static bool int_ext_op(DisasContext *s, arg_rmr *a, uint8_t seq) uint32_t data = 0; gen_helper_gvec_3_ptr *fn; TCGLabel *over = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); static gen_helper_gvec_3_ptr * const fns[6][4] = {
Signature · 1 line
2.34.1
PATCH v7 4/15 target/riscv: Add Zvbc ISA extension support
In reply to Max ChouFrom: Lawrence Hunter <[email protected]>
This commit adds support for the Zvbc vector-crypto extension, which consists of the following instructions:
* vclmulh.[vx,vv]
* vclmul.[vx,vv]
Translation functions are defined in target/riscv/insn_trans/trans_rvvk.c.inc and helpers are defined in target/riscv/vcrypto_helper.c.
--- target/riscv/cpu.c | 9 ++++ target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 6 +++ target/riscv/insn32.decode | 6 +++ target/riscv/insn_trans/trans_rvvk.c.inc | 62 ++++++++++++++++++++++++ target/riscv/meson.build | 3 +- target/riscv/translate.c | 1 + target/riscv/vcrypto_helper.c | 59 ++++++++++++++++++++++ 8 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 target/riscv/insn_trans/trans_rvvk.c.inc create mode 100644 target/riscv/vcrypto_helper.c
target/riscv/cpu.c +9 -0
@@ -111,6 +111,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zksed,PRIV_VERSION_1_12_0 , ext_zksed),ISA_EXT_DATA_ENTRY (zksh,PRIV_VERSION_1_12_0 , ext_zksh),ISA_EXT_DATA_ENTRY (zkt,PRIV_VERSION_1_12_0 , ext_zkt), +ISA_EXT_DATA_ENTRY (zvbc,PRIV_VERSION_1_12_0 , ext_zvbc),ISA_EXT_DATA_ENTRY (zve32f,PRIV_VERSION_1_10_0 , ext_zve32f),ISA_EXT_DATA_ENTRY (zve64f,PRIV_VERSION_1_10_0 , ext_zve64f), ISA_EXT_DATA_ENTRY(zve64d, PRIV_VERSION_1_10_0, ext_zve64d),
@@ -1184,6 +1185,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)return ; } +if (cpu->cfg.ext_zvbc && !cpu->cfg.ext_zve64f) { +error_setg (errp,"Zvbc extension requires V or Zve64{f,d} extensions" ); +return ; + } +if (cpu->cfg.ext_zk) { cpu->cfg.ext_zkn = true; cpu->cfg.ext_zkr = true;
@@ -1683,6 +1689,9 @@ static Property riscv_cpu_extensions[] = {DEFINE_PROP_BOOL ("x-zvfh" ,RISCVCPU , cfg.ext_zvfh, false),DEFINE_PROP_BOOL ("x-zvfhmin" ,RISCVCPU , cfg.ext_zvfhmin, false), +/* Vector cryptography extensions */ +DEFINE_PROP_BOOL ("x-zvbc" ,RISCVCPU , cfg.ext_zvbc, false), + DEFINE_PROP_END_OF_LIST(), };
target/riscv/cpu_cfg.h +1 -0
@@ -83,6 +83,7 @@ struct RISCVCPUConfig {bool ext_zve32f;bool ext_zve64f;bool ext_zve64d; +bool ext_zvbc;bool ext_zmmul;bool ext_zvfh;bool ext_zvfhmin;
target/riscv/helper.h +6 -0
@@ -1153,3 +1153,9 @@ DEF_HELPER_FLAGS_3(sm4ks, TCG_CALL_NO_RWG_SE, tl, tl, tl, tl)/* Zce helper */ DEF_HELPER_FLAGS_2 (cm_jalt,TCG_CALL_NO_WG , tl, env, i32) + +/* Vector crypto functions */ +DEF_HELPER_6(vclmul_vv, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vclmul_vx, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vclmulh_vv, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6 (vclmulh_vx, void, ptr, ptr, tl, ptr, env, i32)
target/riscv/insn32.decode +6 -0
@@ -908,3 +908,9 @@ sm4ks .. 11010 ..... ..... 000 ..... 0110011 @k_aes # *** RV32 Zicond Standard Extension *** czero_eqz 0000111 ..... ..... 101 ..... 0110011 @r czero_nez 0000111 ..... ..... 111 ..... 0110011 @r + +# *** Zvbc vector crypto extension *** +vclmul_vv 001100 . ..... ..... 010 ..... 1010111 @r_vm +vclmul_vx 001100 . ..... ..... 110 ..... 1010111 @r_vm +vclmulh_vv 001101 . ..... ..... 010 ..... 1010111 @r_vm +vclmulh_vx 001101 . ..... ..... 110 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvvk.c.inc new file +62 -0
62 lines not on this page · raw message
target/riscv/meson.build +2 -1
@@ -21,7 +21,8 @@ riscv_ss.add(files( 'translate.c', 'm128_helper.c', 'crypto_helper.c', - 'zce_helper.c' + 'zce_helper.c', + 'vcrypto_helper.c' )) riscv_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c'))
target/riscv/translate.c +1 -0
@@ -1106,6 +1106,7 @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)#include "insn_trans/trans_rvzicbo.c.inc" #include "insn_trans/trans_rvzfh.c.inc" #include "insn_trans/trans_rvk.c.inc" +#include "insn_trans/trans_rvvk.c.inc" #include "insn_trans/trans_privileged.c.inc" #include "insn_trans/trans_svinval.c.inc" #include "decode-xthead.c.inc"
target/riscv/vcrypto_helper.c new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 5/15 target/riscv: Move vector translation checks
In reply to Max ChouFrom: Nazar Kazakov <[email protected]>
Move the checks out of do_opiv{v,x,i}_gvec{,_shift} functions and into the corresponding macros. This enables the functions to be reused in proceeding commits without check duplication.
--- target/riscv/insn_trans/trans_rvv.c.inc | 28 +++++++++++-------------- 1 file changed, 12 insertions(+), 16 deletions(-)
target/riscv/insn_trans/trans_rvv.c.inc +12 -16
@@ -1183,9 +1183,6 @@ do_opivv_gvec(DisasContext *s, arg_rmrr *a, GVecGen3Fn *gvec_fn, gen_helper_gvec_4_ptr *fn) { TCGLabel *over = gen_new_label(); - if (!opivv_check(s, a)) { - return false; - } tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);
@@ -1218,6 +1215,9 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ }; \ + if (!opivv_check(s, a)) { \ + return false; \ + } \ return do_opivv_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ }
@@ -1276,10 +1276,6 @@ static inline bool do_opivx_gvec(DisasContext *s, arg_rmrr *a, GVecGen2sFn *gvec_fn, gen_helper_opivx *fn) { - if (!opivx_check(s, a)) { - return false; - } - if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) { TCGv_i64 src1 = tcg_temp_new_i64();
@@ -1301,6 +1297,9 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ }; \ + if (!opivx_check(s, a)) { \ + return false; \ + } \ return do_opivx_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ }
@@ -1432,10 +1431,6 @@ static inline bool do_opivi_gvec(DisasContext *s, arg_rmrr *a, GVecGen2iFn *gvec_fn, gen_helper_opivx *fn, imm_mode_t imm_mode) { - if (!opivx_check(s, a)) { - return false; - } - if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) { gvec_fn(s->sew, vreg_ofs(s, a->rd), vreg_ofs(s, a->rs2), extract_imm(s, a->rs1, imm_mode), MAXSZ(s), MAXSZ(s));
@@ -1453,6 +1448,9 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##OPIVX##_b, gen_helper_##OPIVX##_h, \ gen_helper_##OPIVX##_w, gen_helper_##OPIVX##_d, \ }; \ + if (!opivx_check(s, a)) { \ + return false; \ + } \ return do_opivi_gvec(s, a, tcg_gen_gvec_##SUF, \ fns[s->sew], IMM_MODE); \ }
@@ -1775,10 +1773,6 @@ static inline bool do_opivx_gvec_shift(DisasContext *s, arg_rmrr *a, GVecGen2sFn32 *gvec_fn, gen_helper_opivx *fn) { - if (!opivx_check(s, a)) { - return false; - } - if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) { TCGv_i32 src1 = tcg_temp_new_i32();
@@ -1800,7 +1794,9 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ }; \ - \ + if (!opivx_check(s, a)) { \ + return false; \ + } \ return do_opivx_gvec_shift(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ }
Signature · 1 line
2.34.1
PATCH v7 6/15 target/riscv: Refactor translation of vector-widening instruction
In reply to Max ChouFrom: Dickon Hood <[email protected]>
Zvbb (implemented in later commit) has a widening instruction, which requires an extra check on the enabled extensions. Refactor GEN_OPIVX_WIDEN_TRANS() to take a check function to avoid reimplementing it.
--- target/riscv/insn_trans/trans_rvv.c.inc | 52 +++++++++++-------------- 1 file changed, 23 insertions(+), 29 deletions(-)
target/riscv/insn_trans/trans_rvv.c.inc +23 -29
@@ -1526,30 +1526,24 @@ static bool opivx_widen_check(DisasContext *s, arg_rmrr *a) vext_check_ds(s, a->rd, a->rs2, a->vm); } -static bool do_opivx_widen(DisasContext *s, arg_rmrr *a, - gen_helper_opivx *fn) -{ - if (opivx_widen_check(s, a)) { - return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fn, s); - } - return false; -} - -#define GEN_OPIVX_WIDEN_TRANS(NAME) \ -static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ -{ \ - static gen_helper_opivx * const fns[3] = { \ - gen_helper_##NAME##_b, \ - gen_helper_##NAME##_h, \ - gen_helper_##NAME##_w \ - }; \ - return do_opivx_widen(s, a, fns[s->sew]); \ +#define GEN_OPIVX_WIDEN_TRANS(NAME, CHECK) \ +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ +{ \ + if (CHECK(s, a)) { \ + static gen_helper_opivx * const fns[3] = { \ + gen_helper_##NAME##_b, \ + gen_helper_##NAME##_h, \ + gen_helper_##NAME##_w \ + }; \ + return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s); \ + } \ + return false; \ } -GEN_OPIVX_WIDEN_TRANS(vwaddu_vx) -GEN_OPIVX_WIDEN_TRANS(vwadd_vx) -GEN_OPIVX_WIDEN_TRANS(vwsubu_vx) -GEN_OPIVX_WIDEN_TRANS(vwsub_vx) +GEN_OPIVX_WIDEN_TRANS(vwaddu_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwadd_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwsubu_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwsub_vx, opivx_widen_check) /* WIDEN OPIVV with WIDEN */ static bool opiwv_widen_check(DisasContext *s, arg_rmrr *a)
@@ -1997,9 +1991,9 @@ GEN_OPIVX_TRANS(vrem_vx, opivx_check) GEN_OPIVV_WIDEN_TRANS(vwmul_vv, opivv_widen_check) GEN_OPIVV_WIDEN_TRANS(vwmulu_vv, opivv_widen_check) GEN_OPIVV_WIDEN_TRANS(vwmulsu_vv, opivv_widen_check) -GEN_OPIVX_WIDEN_TRANS(vwmul_vx) -GEN_OPIVX_WIDEN_TRANS(vwmulu_vx) -GEN_OPIVX_WIDEN_TRANS(vwmulsu_vx) +GEN_OPIVX_WIDEN_TRANS(vwmul_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwmulu_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwmulsu_vx, opivx_widen_check) /* Vector Single-Width Integer Multiply-Add Instructions */ GEN_OPIVV_TRANS(vmacc_vv, opivv_check)
@@ -2015,10 +2009,10 @@ GEN_OPIVX_TRANS(vnmsub_vx, opivx_check) GEN_OPIVV_WIDEN_TRANS(vwmaccu_vv, opivv_widen_check) GEN_OPIVV_WIDEN_TRANS(vwmacc_vv, opivv_widen_check) GEN_OPIVV_WIDEN_TRANS(vwmaccsu_vv, opivv_widen_check) -GEN_OPIVX_WIDEN_TRANS(vwmaccu_vx) -GEN_OPIVX_WIDEN_TRANS(vwmacc_vx) -GEN_OPIVX_WIDEN_TRANS(vwmaccsu_vx) -GEN_OPIVX_WIDEN_TRANS(vwmaccus_vx) +GEN_OPIVX_WIDEN_TRANS(vwmaccu_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwmacc_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwmaccsu_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwmaccus_vx, opivx_widen_check) /* Vector Integer Merge and Move Instructions */ static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_v *a)
Signature · 1 line
2.34.1
PATCH v7 7/15 target/riscv: Refactor some of the generic vector functionality
In reply to Max ChouFrom: Kiran Ostrolenk <[email protected]>
Move some macros out of vector_helper and into vector_internals. This ensures they can be used by both vector and vector-crypto helpers (latter implemented in proceeding commits).
--- target/riscv/vector_helper.c | 42 ------------------------------ target/riscv/vector_internals.h | 46 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 42 deletions(-)
target/riscv/vector_helper.c +0 -42
@@ -635,9 +635,6 @@ GEN_VEXT_ST_WHOLE(vs8r_v, int8_t, ste_b)#define OP_SUS_H int16_t, uint16_t, int16_t, uint16_t, int16_t#define OP_SUS_W int32_t, uint32_t, int32_t, uint32_t, int32_t#define OP_SUS_D int64_t, uint64_t, int64_t, uint64_t, int64_t -#define WOP_UUU_B uint16_t, uint8_t, uint8_t, uint16_t, uint16_t -#define WOP_UUU_H uint32_t, uint16_t, uint16_t, uint32_t, uint32_t -#define WOP_UUU_W uint64_t, uint32_t, uint32_t, uint64_t, uint64_t#define WOP_SSS_B int16_t, int8_t, int8_t, int16_t, int16_t#define WOP_SSS_H int32_t, int16_t, int16_t, int32_t, int32_t#define WOP_SSS_W int64_t, int32_t, int32_t, int64_t, int64_t
@@ -3426,11 +3423,6 @@ GEN_VEXT_VF(vfwnmsac_vf_h, 4)GEN_VEXT_VF (vfwnmsac_vf_w,8 ) /* Vector Floating-Point Square-Root Instruction */ -/* (TD, T2, TX2) */ -#define OP_UU_H uint16_t, uint16_t, uint16_t -#define OP_UU_W uint32_t, uint32_t, uint32_t -#define OP_UU_D uint64_t, uint64_t, uint64_t -#define OPFVV1 (NAME ,TD ,T2 ,TX2 ,HD ,HS2 ,OP ) \ static void do_##NAME(void *vd, void *vs2, int i, \ CPURISCVState *env) \
@@ -4127,40 +4119,6 @@ GEN_VEXT_CMP_VF(vmfge_vf_w, uint32_t, H4, vmfge32)GEN_VEXT_CMP_VF (vmfge_vf_d, uint64_t,H8 , vmfge64) /* Vector Floating-Point Classify Instruction */ -#define OPIVV1 (NAME ,TD ,T2 ,TX2 ,HD ,HS2 ,OP ) \ -static void do_##NAME(void *vd, void *vs2, int i) \ -{ \ - TX2 s2 = *((T2 *)vs2 + HS2(i)); \ - *((TD *)vd + HD(i)) = OP(s2); \ -} - -#define GEN_VEXT_V (NAME ,ESZ ) \ -void HELPER(NAME)(void *vd, void *v0, void *vs2, \ - CPURISCVState *env, uint32_t desc) \ -{ \ - uint32_t vm = vext_vm(desc); \ - uint32_t vl = env->vl; \ - uint32_t total_elems = \ - vext_get_total_elems(env, desc, ESZ); \ - uint32_t vta = vext_vta(desc); \ - uint32_t vma = vext_vma(desc); \ - uint32_t i; \ - \ - for (i = env->vstart; i < vl; i++) { \ - if (!vm && !vext_elem_mask(v0, i)) { \ -/* set masked-off elements to 1s */ \ -vext_set_elems_1s (vd, vma, i *ESZ , \ - (i +1 ) *ESZ ); \ -continue ; \ - } \ - do_##NAME(vd, vs2, i); \ - } \ - env->vstart = 0; \ -/* set tail elements to 1s */ \ -vext_set_elems_1s (vd, vta, vl *ESZ , \ - total_elems *ESZ ); \ -} -target_ulong fclass_h (uint64_t frs1) {float16 f = frs1;
target/riscv/vector_internals.h +46 -0
62 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 8/15 target/riscv: Add Zvbb ISA extension support
In reply to Max ChouFrom: Dickon Hood <[email protected]>
This commit adds support for the Zvbb vector-crypto extension, which consists of the following instructions:
* vrol.[vv,vx]
* vror.[vv,vx,vi]
* vbrev8.v
* vrev8.v
* vandn.[vv,vx]
* vbrev.v
* vclz.v
* vctz.v
* vcpop.v
* vwsll.[vv,vx,vi]
Translation functions are defined in target/riscv/insn_trans/trans_rvvk.c.inc and helpers are defined in target/riscv/vcrypto_helper.c.
--- target/riscv/cpu.c | 12 ++ target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 62 +++++++++ target/riscv/insn32.decode | 20 +++ target/riscv/insn_trans/trans_rvvk.c.inc | 164 +++++++++++++++++++++++ target/riscv/vcrypto_helper.c | 138 +++++++++++++++++++ 6 files changed, 397 insertions(+)
target/riscv/cpu.c +12 -0
@@ -111,6 +111,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zksed,PRIV_VERSION_1_12_0 , ext_zksed),ISA_EXT_DATA_ENTRY (zksh,PRIV_VERSION_1_12_0 , ext_zksh),ISA_EXT_DATA_ENTRY (zkt,PRIV_VERSION_1_12_0 , ext_zkt), +ISA_EXT_DATA_ENTRY (zvbb,PRIV_VERSION_1_12_0 , ext_zvbb),ISA_EXT_DATA_ENTRY (zvbc,PRIV_VERSION_1_12_0 , ext_zvbc),ISA_EXT_DATA_ENTRY (zve32f,PRIV_VERSION_1_10_0 , ext_zve32f), ISA_EXT_DATA_ENTRY(zve64f, PRIV_VERSION_1_10_0, ext_zve64f),
@@ -1185,6 +1186,16 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)return ; } +/* +* In principle Zve*x would also suffice here, were they supported +* in qemu +*/ +if (cpu->cfg.ext_zvbb && !cpu->cfg.ext_zve32f) { +error_setg (errp, +"Vector crypto extensions require V or Zve* extensions" ); +return ; + } +if (cpu->cfg.ext_zvbc && !cpu->cfg.ext_zve64f) {error_setg (errp,"Zvbc extension requires V or Zve64{f,d} extensions" );return ;
@@ -1690,6 +1701,7 @@ static Property riscv_cpu_extensions[] = {DEFINE_PROP_BOOL ("x-zvfhmin" ,RISCVCPU , cfg.ext_zvfhmin, false),/* Vector cryptography extensions */ +DEFINE_PROP_BOOL ("x-zvbb" ,RISCVCPU , cfg.ext_zvbb, false),DEFINE_PROP_BOOL ("x-zvbc" ,RISCVCPU , cfg.ext_zvbc, false), DEFINE_PROP_END_OF_LIST(),
target/riscv/cpu_cfg.h +1 -0
@@ -83,6 +83,7 @@ struct RISCVCPUConfig {bool ext_zve32f;bool ext_zve64f;bool ext_zve64d; +bool ext_zvbb;bool ext_zvbc;bool ext_zmmul;bool ext_zvfh;
target/riscv/helper.h +62 -0
65 lines not on this page · raw message
target/riscv/insn32.decode +20 -0
@@ -37,6 +37,7 @@ %imm_u 12:s20 !function=ex_shift_12 %imm_bs 30:2 !function=ex_shift_3 %imm_rnum 20:4 +%imm_z6 26:1 15:5 # Argument sets: &empty
@@ -82,6 +83,7 @@ @r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd @r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=1 %rs2 %rs1 %rd @r_vm_0 ...... . ..... ..... ... ..... ....... &rmrr vm=0 %rs2 %rs1 %rd +@r2_zimm6 ..... . vm:1 ..... ..... ... ..... ....... &rmrr %rs2 rs1=%imm_z6 %rd @r2_zimm11 . zimm:11 ..... ... ..... ....... %rs1 %rd @r2_zimm10 .. zimm:10 ..... ... ..... ....... %rs1 %rd @r2_s ....... ..... ..... ... ..... ....... %rs2 %rs1
@@ -914,3 +916,21 @@ vclmul_vv 001100 . ..... ..... 010 ..... 1010111 @r_vm vclmul_vx 001100 . ..... ..... 110 ..... 1010111 @r_vm vclmulh_vv 001101 . ..... ..... 010 ..... 1010111 @r_vm vclmulh_vx 001101 . ..... ..... 110 ..... 1010111 @r_vm + +# *** Zvbb vector crypto extension *** +vrol_vv 010101 . ..... ..... 000 ..... 1010111 @r_vm +vrol_vx 010101 . ..... ..... 100 ..... 1010111 @r_vm +vror_vv 010100 . ..... ..... 000 ..... 1010111 @r_vm +vror_vx 010100 . ..... ..... 100 ..... 1010111 @r_vm +vror_vi 01010. . ..... ..... 011 ..... 1010111 @r2_zimm6 +vbrev8_v 010010 . ..... 01000 010 ..... 1010111 @r2_vm +vrev8_v 010010 . ..... 01001 010 ..... 1010111 @r2_vm +vandn_vv 000001 . ..... ..... 000 ..... 1010111 @r_vm +vandn_vx 000001 . ..... ..... 100 ..... 1010111 @r_vm +vbrev_v 010010 . ..... 01010 010 ..... 1010111 @r2_vm +vclz_v 010010 . ..... 01100 010 ..... 1010111 @r2_vm +vctz_v 010010 . ..... 01101 010 ..... 1010111 @r2_vm +vcpop_v 010010 . ..... 01110 010 ..... 1010111 @r2_vm +vwsll_vv 110101 . ..... ..... 000 ..... 1010111 @r_vm +vwsll_vx 110101 . ..... ..... 100 ..... 1010111 @r_vm +vwsll_vi 110101 . ..... ..... 011 ..... 1010111 @r_vm
target/riscv/insn_trans/trans_rvvk.c.inc +164 -0
167 lines not on this page · raw message
target/riscv/vcrypto_helper.c +138 -0
147 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 9/15 target/riscv: Add Zvkned ISA extension support
In reply to Max ChouFrom: Nazar Kazakov <[email protected]>
This commit adds support for the Zvkned vector-crypto extension, which consists of the following instructions:
* vaesef.[vv,vs]
* vaesdf.[vv,vs]
* vaesdm.[vv,vs]
* vaesz.vs
* vaesem.[vv,vs]
* vaeskf1.vi
* vaeskf2.vi
Translation functions are defined in target/riscv/insn_trans/trans_rvvk.c.inc and helpers are defined in target/riscv/vcrypto_helper.c.
[[email protected]: Imported aes-round.h and exposed x-zvkned property]
[[email protected]: Fixed endian issues and replaced the vstart & vl egs checking by helper function]
--- target/riscv/cpu.c | 4 +- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 14 ++ target/riscv/insn32.decode | 14 ++ target/riscv/insn_trans/trans_rvvk.c.inc | 147 +++++++++++++++++ target/riscv/vcrypto_helper.c | 202 +++++++++++++++++++++++ 6 files changed, 381 insertions(+), 1 deletion(-)
target/riscv/cpu.c +3 -1
@@ -118,6 +118,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zve64d,PRIV_VERSION_1_10_0 , ext_zve64d),ISA_EXT_DATA_ENTRY (zvfh,PRIV_VERSION_1_12_0 , ext_zvfh),ISA_EXT_DATA_ENTRY (zvfhmin,PRIV_VERSION_1_12_0 , ext_zvfhmin), +ISA_EXT_DATA_ENTRY (zvkned,PRIV_VERSION_1_12_0 , ext_zvkned),ISA_EXT_DATA_ENTRY (zhinx,PRIV_VERSION_1_12_0 , ext_zhinx),ISA_EXT_DATA_ENTRY (zhinxmin,PRIV_VERSION_1_12_0 , ext_zhinxmin), ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia),
@@ -1190,7 +1191,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)* In principle Zve*x would also suffice here, were they supported * in qemu */ -if (cpu->cfg.ext_zvbb && !cpu->cfg.ext_zve32f) { +if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned) && !cpu->cfg.ext_zve32f) {error_setg (errp,"Vector crypto extensions require V or Zve* extensions" );return ;
@@ -1703,6 +1704,7 @@ static Property riscv_cpu_extensions[] = {/* Vector cryptography extensions */ DEFINE_PROP_BOOL ("x-zvbb" ,RISCVCPU , cfg.ext_zvbb, false),DEFINE_PROP_BOOL ("x-zvbc" ,RISCVCPU , cfg.ext_zvbc, false), +DEFINE_PROP_BOOL ("x-zvkned" ,RISCVCPU , cfg.ext_zvkned, false), DEFINE_PROP_END_OF_LIST(), };
target/riscv/cpu_cfg.h +1 -0
@@ -85,6 +85,7 @@ struct RISCVCPUConfig {bool ext_zve64d;bool ext_zvbb;bool ext_zvbc; +bool ext_zvkned;bool ext_zmmul;bool ext_zvfh;bool ext_zvfhmin;
target/riscv/helper.h +14 -0
@@ -1221,3 +1221,17 @@ DEF_HELPER_6(vandn_vx_b, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vandn_vx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vandn_vx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vandn_vx_d, void, ptr, ptr, tl, ptr, env, i32) + +DEF_HELPER_2(egs_check, void, i32, env) + +DEF_HELPER_4(vaesef_vv, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesef_vs, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesdf_vv, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesdf_vs, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesem_vv, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesem_vs, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesdm_vv, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesdm_vs, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesz_vs, void, ptr, ptr, env, i32) +DEF_HELPER_5(vaeskf1_vi, void, ptr, ptr, i32, env, i32) +DEF_HELPER_5 (vaeskf2_vi, void, ptr, ptr, i32, env, i32)
target/riscv/insn32.decode +14 -0
@@ -75,6 +75,7 @@ @r_rm ....... ..... ..... ... ..... ....... %rs2 %rs1 %rm %rd @r2_rm ....... ..... ..... ... ..... ....... %rs1 %rm %rd @r2 ....... ..... ..... ... ..... ....... &r2 %rs1 %rd +@r2_vm_1 ...... . ..... ..... ... ..... ....... &rmr vm=1 %rs2 %rd @r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd @r2_vm ...... vm:1 ..... ..... ... ..... ....... &rmr %rs2 %rd @r1_vm ...... vm:1 ..... ..... ... ..... ....... %rd
@@ -934,3 +935,16 @@ vcpop_v 010010 . ..... 01110 010 ..... 1010111 @r2_vm vwsll_vv 110101 . ..... ..... 000 ..... 1010111 @r_vm vwsll_vx 110101 . ..... ..... 100 ..... 1010111 @r_vm vwsll_vi 110101 . ..... ..... 011 ..... 1010111 @r_vm + +# *** Zvkned vector crypto extension *** +vaesef_vv 101000 1 ..... 00011 010 ..... 1110111 @r2_vm_1 +vaesef_vs 101001 1 ..... 00011 010 ..... 1110111 @r2_vm_1 +vaesdf_vv 101000 1 ..... 00001 010 ..... 1110111 @r2_vm_1 +vaesdf_vs 101001 1 ..... 00001 010 ..... 1110111 @r2_vm_1 +vaesem_vv 101000 1 ..... 00010 010 ..... 1110111 @r2_vm_1 +vaesem_vs 101001 1 ..... 00010 010 ..... 1110111 @r2_vm_1 +vaesdm_vv 101000 1 ..... 00000 010 ..... 1110111 @r2_vm_1 +vaesdm_vs 101001 1 ..... 00000 010 ..... 1110111 @r2_vm_1 +vaesz_vs 101001 1 ..... 00111 010 ..... 1110111 @r2_vm_1 +vaeskf1_vi 100010 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vaeskf2_vi 101010 1 ..... ..... 010 ..... 1110111 @r_vm_1
target/riscv/insn_trans/trans_rvvk.c.inc +147 -0
150 lines not on this page · raw message
target/riscv/vcrypto_helper.c +202 -0
211 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 10/15 target/riscv: Add Zvknh ISA extension support
In reply to Max ChouFrom: Kiran Ostrolenk <[email protected]>
This commit adds support for the Zvknh vector-crypto extension, which consists of the following instructions:
* vsha2ms.vv
* vsha2c[hl].vv
Translation functions are defined in target/riscv/insn_trans/trans_rvvk.c.inc and helpers are defined in target/riscv/vcrypto_helper.c.
[[email protected]: Replaced SEW selection to happened during translation]
--- target/riscv/cpu.c | 13 +- target/riscv/cpu_cfg.h | 2 + target/riscv/helper.h | 6 + target/riscv/insn32.decode | 5 + target/riscv/insn_trans/trans_rvvk.c.inc | 129 ++++++++++++ target/riscv/vcrypto_helper.c | 238 +++++++++++++++++++++++ 6 files changed, 390 insertions(+), 3 deletions(-)
target/riscv/cpu.c +10 -3
@@ -119,6 +119,8 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zvfh,PRIV_VERSION_1_12_0 , ext_zvfh),ISA_EXT_DATA_ENTRY (zvfhmin,PRIV_VERSION_1_12_0 , ext_zvfhmin),ISA_EXT_DATA_ENTRY (zvkned,PRIV_VERSION_1_12_0 , ext_zvkned), +ISA_EXT_DATA_ENTRY (zvknha,PRIV_VERSION_1_12_0 , ext_zvknha), +ISA_EXT_DATA_ENTRY (zvknhb,PRIV_VERSION_1_12_0 , ext_zvknhb),ISA_EXT_DATA_ENTRY (zhinx,PRIV_VERSION_1_12_0 , ext_zhinx),ISA_EXT_DATA_ENTRY (zhinxmin,PRIV_VERSION_1_12_0 , ext_zhinxmin), ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia),
@@ -1191,14 +1193,17 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)* In principle Zve*x would also suffice here, were they supported * in qemu */ -if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned) && !cpu->cfg.ext_zve32f) { +if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha) && + !cpu->cfg.ext_zve32f) {error_setg (errp,"Vector crypto extensions require V or Zve* extensions" );return ; } -if (cpu->cfg.ext_zvbc && !cpu->cfg.ext_zve64f) { -error_setg (errp,"Zvbc extension requires V or Zve64{f,d} extensions" ); +if ((cpu->cfg.ext_zvbc || cpu->cfg.ext_zvknhb) && !cpu->cfg.ext_zve64f) { +error_setg ( + errp, +"Zvbc and Zvknhb extensions require V or Zve64{f,d} extensions" );return ; }
@@ -1705,6 +1710,8 @@ static Property riscv_cpu_extensions[] = {DEFINE_PROP_BOOL ("x-zvbb" ,RISCVCPU , cfg.ext_zvbb, false),DEFINE_PROP_BOOL ("x-zvbc" ,RISCVCPU , cfg.ext_zvbc, false),DEFINE_PROP_BOOL ("x-zvkned" ,RISCVCPU , cfg.ext_zvkned, false), +DEFINE_PROP_BOOL ("x-zvknha" ,RISCVCPU , cfg.ext_zvknha, false), +DEFINE_PROP_BOOL ("x-zvknhb" ,RISCVCPU , cfg.ext_zvknhb, false), DEFINE_PROP_END_OF_LIST(), };
target/riscv/cpu_cfg.h +2 -0
@@ -86,6 +86,8 @@ struct RISCVCPUConfig {bool ext_zvbb;bool ext_zvbc;bool ext_zvkned; +bool ext_zvknha; +bool ext_zvknhb;bool ext_zmmul;bool ext_zvfh;bool ext_zvfhmin;
target/riscv/helper.h +6 -0
@@ -1235,3 +1235,9 @@ DEF_HELPER_4(vaesdm_vs, void, ptr, ptr, env, i32) DEF_HELPER_4(vaesz_vs, void, ptr, ptr, env, i32) DEF_HELPER_5(vaeskf1_vi, void, ptr, ptr, i32, env, i32) DEF_HELPER_5(vaeskf2_vi, void, ptr, ptr, i32, env, i32) + +DEF_HELPER_5(vsha2ms_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsha2ch32_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsha2ch64_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsha2cl32_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5 (vsha2cl64_vv, void, ptr, ptr, ptr, env, i32)
target/riscv/insn32.decode +5 -0
@@ -948,3 +948,8 @@ vaesdm_vs 101001 1 ..... 00000 010 ..... 1110111 @r2_vm_1 vaesz_vs 101001 1 ..... 00111 010 ..... 1110111 @r2_vm_1 vaeskf1_vi 100010 1 ..... ..... 010 ..... 1110111 @r_vm_1 vaeskf2_vi 101010 1 ..... ..... 010 ..... 1110111 @r_vm_1 + +# *** Zvknh vector crypto extension *** +vsha2ms_vv 101101 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vsha2ch_vv 101110 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vsha2cl_vv 101111 1 ..... ..... 010 ..... 1110111 @r_vm_1
target/riscv/insn_trans/trans_rvvk.c.inc +129 -0
132 lines not on this page · raw message
target/riscv/vcrypto_helper.c +238 -0
241 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 11/15 target/riscv: Add Zvksh ISA extension support
In reply to Max ChouFrom: Lawrence Hunter <[email protected]>
This commit adds support for the Zvksh vector-crypto extension, which consists of the following instructions:
* vsm3me.vv
* vsm3c.vi
Translation functions are defined in target/riscv/insn_trans/trans_rvvk.c.inc and helpers are defined in target/riscv/vcrypto_helper.c.
--- target/riscv/cpu.c | 6 +- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 3 + target/riscv/insn32.decode | 4 + target/riscv/insn_trans/trans_rvvk.c.inc | 31 ++++++ target/riscv/vcrypto_helper.c | 134 +++++++++++++++++++++++ 6 files changed, 177 insertions(+), 2 deletions(-)
target/riscv/cpu.c +4 -2
@@ -121,6 +121,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zvkned,PRIV_VERSION_1_12_0 , ext_zvkned),ISA_EXT_DATA_ENTRY (zvknha,PRIV_VERSION_1_12_0 , ext_zvknha),ISA_EXT_DATA_ENTRY (zvknhb,PRIV_VERSION_1_12_0 , ext_zvknhb), +ISA_EXT_DATA_ENTRY (zvksh,PRIV_VERSION_1_12_0 , ext_zvksh),ISA_EXT_DATA_ENTRY (zhinx,PRIV_VERSION_1_12_0 , ext_zhinx),ISA_EXT_DATA_ENTRY (zhinxmin,PRIV_VERSION_1_12_0 , ext_zhinxmin), ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia),
@@ -1193,8 +1194,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)* In principle Zve*x would also suffice here, were they supported * in qemu */ -if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha) && - !cpu->cfg.ext_zve32f) { +if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha || + cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) {error_setg (errp,"Vector crypto extensions require V or Zve* extensions" );return ;
@@ -1712,6 +1713,7 @@ static Property riscv_cpu_extensions[] = {DEFINE_PROP_BOOL ("x-zvkned" ,RISCVCPU , cfg.ext_zvkned, false),DEFINE_PROP_BOOL ("x-zvknha" ,RISCVCPU , cfg.ext_zvknha, false),DEFINE_PROP_BOOL ("x-zvknhb" ,RISCVCPU , cfg.ext_zvknhb, false), +DEFINE_PROP_BOOL ("x-zvksh" ,RISCVCPU , cfg.ext_zvksh, false), DEFINE_PROP_END_OF_LIST(), };
target/riscv/cpu_cfg.h +1 -0
@@ -88,6 +88,7 @@ struct RISCVCPUConfig {bool ext_zvkned;bool ext_zvknha;bool ext_zvknhb; +bool ext_zvksh;bool ext_zmmul;bool ext_zvfh;bool ext_zvfhmin;
target/riscv/helper.h +3 -0
@@ -1241,3 +1241,6 @@ DEF_HELPER_5(vsha2ch32_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsha2ch64_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsha2cl32_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32) + +DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5 (vsm3c_vi, void, ptr, ptr, i32, env, i32)
target/riscv/insn32.decode +4 -0
@@ -953,3 +953,7 @@ vaeskf2_vi 101010 1 ..... ..... 010 ..... 1110111 @r_vm_1 vsha2ms_vv 101101 1 ..... ..... 010 ..... 1110111 @r_vm_1 vsha2ch_vv 101110 1 ..... ..... 010 ..... 1110111 @r_vm_1 vsha2cl_vv 101111 1 ..... ..... 010 ..... 1110111 @r_vm_1 + +# *** Zvksh vector crypto extension *** +vsm3me_vv 100000 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_vm_1
target/riscv/insn_trans/trans_rvvk.c.inc +31 -0
@@ -500,3 +500,34 @@ static bool trans_vsha2ch_vv(DisasContext *s, arg_rmrr *a) } return false; } + +/* + * Zvksh + */ + +#define ZVKSH_EGS 8 + +static inline bool vsm3_check(DisasContext *s, arg_rmrr *a) +{ + int egw_bytes = ZVKSH_EGS << s->sew; + int mult = 1 << MAX(s->lmul, 0); + return s->cfg_ptr->ext_zvksh == true && + require_rvv(s) && + vext_check_isa_ill(s) && + !is_overlapped(a->rd, mult, a->rs2, mult) && + MAXSZ(s) >= egw_bytes && + s->sew == MO_32; +} + +static inline bool vsm3me_check(DisasContext *s, arg_rmrr *a) +{ + return vsm3_check(s, a) && vext_check_sss(s, a->rd, a->rs1, a->rs2, a->vm); +} + +static inline bool vsm3c_check(DisasContext *s, arg_rmrr *a) +{ + return vsm3_check(s, a) && vext_check_ss(s, a->rd, a->rs2, a->vm); +} + +GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS) +GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS)
target/riscv/vcrypto_helper.c +134 -0
137 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 12/15 target/riscv: Add Zvkg ISA extension support
In reply to Max ChouFrom: Nazar Kazakov <[email protected]>
This commit adds support for the Zvkg vector-crypto extension, which consists of the following instructions:
* vgmul.vv
* vghsh.vv
Translation functions are defined in target/riscv/insn_trans/trans_rvvk.c.inc and helpers are defined in target/riscv/vcrypto_helper.c.
--- target/riscv/cpu.c | 6 +- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 3 + target/riscv/insn32.decode | 4 ++ target/riscv/insn_trans/trans_rvvk.c.inc | 30 ++++++++++ target/riscv/vcrypto_helper.c | 72 ++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 2 deletions(-)
target/riscv/cpu.c +4 -2
@@ -118,6 +118,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zve64d,PRIV_VERSION_1_10_0 , ext_zve64d),ISA_EXT_DATA_ENTRY (zvfh,PRIV_VERSION_1_12_0 , ext_zvfh),ISA_EXT_DATA_ENTRY (zvfhmin,PRIV_VERSION_1_12_0 , ext_zvfhmin), +ISA_EXT_DATA_ENTRY (zvkg,PRIV_VERSION_1_12_0 , ext_zvkg),ISA_EXT_DATA_ENTRY (zvkned,PRIV_VERSION_1_12_0 , ext_zvkned),ISA_EXT_DATA_ENTRY (zvknha,PRIV_VERSION_1_12_0 , ext_zvknha), ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb),
@@ -1194,8 +1195,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)* In principle Zve*x would also suffice here, were they supported * in qemu */ -if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha || - cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) { +if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkg || cpu->cfg.ext_zvkned || + cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) {error_setg (errp,"Vector crypto extensions require V or Zve* extensions" );return ;
@@ -1710,6 +1711,7 @@ static Property riscv_cpu_extensions[] = {/* Vector cryptography extensions */ DEFINE_PROP_BOOL ("x-zvbb" ,RISCVCPU , cfg.ext_zvbb, false),DEFINE_PROP_BOOL ("x-zvbc" ,RISCVCPU , cfg.ext_zvbc, false), +DEFINE_PROP_BOOL ("x-zvkg" ,RISCVCPU , cfg.ext_zvkg, false),DEFINE_PROP_BOOL ("x-zvkned" ,RISCVCPU , cfg.ext_zvkned, false),DEFINE_PROP_BOOL ("x-zvknha" ,RISCVCPU , cfg.ext_zvknha, false), DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false),
target/riscv/cpu_cfg.h +1 -0
@@ -85,6 +85,7 @@ struct RISCVCPUConfig {bool ext_zve64d;bool ext_zvbb;bool ext_zvbc; +bool ext_zvkg;bool ext_zvkned;bool ext_zvknha;bool ext_zvknhb;
target/riscv/helper.h +3 -0
@@ -1244,3 +1244,6 @@ DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32) + +DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_4 (vgmul_vv, void, ptr, ptr, env, i32)
target/riscv/insn32.decode +4 -0
@@ -957,3 +957,7 @@ vsha2cl_vv 101111 1 ..... ..... 010 ..... 1110111 @r_vm_1 # *** Zvksh vector crypto extension *** vsm3me_vv 100000 1 ..... ..... 010 ..... 1110111 @r_vm_1 vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_vm_1 + +# *** Zvkg vector crypto extension *** +vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1
target/riscv/insn_trans/trans_rvvk.c.inc +30 -0
@@ -531,3 +531,33 @@ static inline bool vsm3c_check(DisasContext *s, arg_rmrr *a) GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS) GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS) + +/* + * Zvkg + */ + +#define ZVKG_EGS 4 + +static bool vgmul_check(DisasContext *s, arg_rmr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + vext_check_isa_ill(s) && + require_rvv(s) && + MAXSZ(s) >= egw_bytes && + vext_check_ss(s, a->rd, a->rs2, a->vm) && + s->sew == MO_32; +} + +GEN_V_UNMASKED_TRANS(vgmul_vv, vgmul_check, ZVKG_EGS) + +static bool vghsh_check(DisasContext *s, arg_rmrr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + opivv_check(s, a) && + MAXSZ(s) >= egw_bytes && + s->sew == MO_32; +} + +GEN_VV_UNMASKED_TRANS(vghsh_vv, vghsh_check, ZVKG_EGS)
target/riscv/vcrypto_helper.c +72 -0
75 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v7 12/15] target/riscv: Add Zvkg ISA extension support
Hi,
This patch breaks some gitlab runners because of this:
Quoted 149 lines · Max Chou
From: Nazar Kazakov <[email protected]>
This commit adds support for the Zvkg vector-crypto extension, which consists of the following instructions:
* vgmul.vv
* vghsh.vvTranslation functions are defined in
target/riscv/insn_trans/trans_rvvk.c.incand helpers are defined intarget/riscv/vcrypto_helper.c.Co-authored-by Lawrence Hunter <[email protected]>[[email protected]: Replaced vstart checking by TCG op]Signed-off-by Lawrence Hunter <[email protected]>Signed-off-by Nazar Kazakov <[email protected]>Signed-off-by Max Chou <[email protected]>Reviewed-by Daniel Henrique Barboza <[email protected]>[[email protected]: Exposed x-zvkg property]--- target/riscv/cpu.c | 6 +- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 3 + target/riscv/insn32.decode | 4 ++ target/riscv/insn_trans/trans_rvvk.c.inc | 30 ++++++++++ target/riscv/vcrypto_helper.c | 72 ++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 2 deletions(-)target/riscv/cpu.c +4
-2@@ -118,6 +118,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zve64d,PRIV_VERSION_1_10_0 , ext_zve64d),ISA_EXT_DATA_ENTRY (zvfh,PRIV_VERSION_1_12_0 , ext_zvfh),ISA_EXT_DATA_ENTRY (zvfhmin,PRIV_VERSION_1_12_0 , ext_zvfhmin), +ISA_EXT_DATA_ENTRY (zvkg,PRIV_VERSION_1_12_0 , ext_zvkg),ISA_EXT_DATA_ENTRY (zvkned,PRIV_VERSION_1_12_0 , ext_zvkned),ISA_EXT_DATA_ENTRY (zvknha,PRIV_VERSION_1_12_0 , ext_zvknha), ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb),@@ -1194,8 +1195,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)* In principle Zve*x would also suffice here, were they supported * in qemu */ -if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha || - cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) { +if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkg || cpu->cfg.ext_zvkned || + cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) {error_setg (errp,"Vector crypto extensions require V or Zve* extensions" );return ;@@ -1710,6 +1711,7 @@ static Property riscv_cpu_extensions[] = {/* Vector cryptography extensions */ DEFINE_PROP_BOOL ("x-zvbb" ,RISCVCPU , cfg.ext_zvbb, false),DEFINE_PROP_BOOL ("x-zvbc" ,RISCVCPU , cfg.ext_zvbc, false), +DEFINE_PROP_BOOL ("x-zvkg" ,RISCVCPU , cfg.ext_zvkg, false),DEFINE_PROP_BOOL ("x-zvkned" ,RISCVCPU , cfg.ext_zvkned, false),DEFINE_PROP_BOOL ("x-zvknha" ,RISCVCPU , cfg.ext_zvknha, false), DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false),target/riscv/cpu_cfg.h +1
-0@@ -85,6 +85,7 @@ struct RISCVCPUConfig {bool ext_zve64d;bool ext_zvbb;bool ext_zvbc; +bool ext_zvkg;bool ext_zvkned;bool ext_zvknha;bool ext_zvknhb;target/riscv/helper.h +3
-0@@ -1244,3 +1244,6 @@ DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32) + +DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_4 (vgmul_vv, void, ptr, ptr, env, i32)target/riscv/insn32.decode +4
-0@@ -957,3 +957,7 @@ vsha2cl_vv 101111 1 ..... ..... 010 ..... 1110111 @r_vm_1 # *** Zvksh vector crypto extension *** vsm3me_vv 100000 1 ..... ..... 010 ..... 1110111 @r_vm_1 vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_vm_1 + +# *** Zvkg vector crypto extension *** +vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1target/riscv/insn_trans/trans_rvvk.c.inc +30
-0@@ -531,3 +531,33 @@ static inline bool vsm3c_check(DisasContext *s, arg_rmrr *a) GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS) GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS) + +/* + * Zvkg + */ + +#define ZVKG_EGS 4 + +static bool vgmul_check(DisasContext *s, arg_rmr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + vext_check_isa_ill(s) && + require_rvv(s) && + MAXSZ(s) >= egw_bytes && + vext_check_ss(s, a->rd, a->rs2, a->vm) && + s->sew == MO_32; +} + +GEN_V_UNMASKED_TRANS(vgmul_vv, vgmul_check, ZVKG_EGS) + +static bool vghsh_check(DisasContext *s, arg_rmrr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + opivv_check(s, a) && + MAXSZ(s) >= egw_bytes && + s->sew == MO_32; +} + +GEN_VV_UNMASKED_TRANS(vghsh_vv, vghsh_check, ZVKG_EGS)target/riscv/vcrypto_helper.c +9
-0@@ -769,3 +769,75 @@ void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,vext_set_elems_1s (vd_vptr, vta, env->vl * esz, total_elems * esz); env->vstart =0 ; } + +void HELPER (vghsh_vv )(void *vd_vptr,void *vs1_vptr,void *vs2_vptr, +CPURISCVState *env,uint32_t desc) +{ +uint64_t *vd = vd_vptr; +uint64_t *vs1 = vs1_vptr; +uint64_t *vs2 = vs2_vptr; +uint32_t vta =vext_vta (desc); +uint32_t total_elems =vext_get_total_elems (env, desc,4 );
target/riscv/vcrypto_helper.c void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, · line 790
Quoted 10 lines
target/riscv/vcrypto_helper.c +10
-0+ +for (uint32_t i = env->vstart /4 ; i < env->vl /4 ; i++) { +uint64_t Y [2 ] = {vd[i *2 +0 ], vd[i *2 +1 ]}; +uint64_t H [2 ] = {brev8 (vs2[i *2 +0 ]),brev8 (vs2[i *2 +1 ])}; +uint64_t X [2 ] = {vs1[i *2 +0 ], vs1[i *2 +1 ]}; +uint64_t Z [2 ] = {0 ,0 }; + +uint64_t S [2 ] = {brev8 (Y [0 ] ^X [0 ]),brev8 (Y [1 ] ^X [1 ])}; + +for (uint j =0 ; j <128 ; j++) {
^
and this
FAILED:
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj i686-w64-mingw32-gcc -m32 -Ilibqemu-riscv64-softmmu.fa.p -I. -I.. -Itarget/riscv -I../target/riscv -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/i686-w64-mingw32/sys-root/mingw/include/pixman-1 -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -iquote . -iquote /builds/danielhb/qemu -iquote /builds/danielhb/qemu/include -iquote /builds/danielhb/qemu/host/include/i386 -iquote /builds/danielhb/qemu/host/include/generic -iquote /builds/danielhb/qemu/tcg/i386 -mms-bitfields -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -no-pie -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -MF libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj.d -o libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -c ../target/riscv/vcrypto_helper.c ../target/riscv/vcrypto_helper.c: In function 'helper_vghsh_vv':
../target/riscv/vcrypto_helper.c:791:14: error: unknown type name 'uint'; did you mean 'u_int'?
791 | for (uint j = 0; j < 128; j++) {
| ^~~~
| u_int
../target/riscv/vcrypto_helper.c: In function 'helper_vgmul_vv':
../target/riscv/vcrypto_helper.c:825:14: error: unknown type name 'uint'; did you mean 'u_int'?
825 | for (uint j = 0; j < 128; j++) {
| ^~~~
| u_int
[2503/3700] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_vector_helper.c.obj
If you want to take a look yourself:
https://gitlab.com/danielhb/qemu/-/jobs/4615946161
The fix is to use 'int' instead of 'uint' in both cases.
I apologize for noticing the error this late. I haven't had the chance to run Gitlab runners in these patches until now.
Alistair, in case you decide to take this series you'll have to amend this in-tree I'm afraid. It's too late to ask for another review.
Thanks,
Daniel
Quoted 24 lines
target/riscv/vcrypto_helper.c +24
-0+if ((S [j /64 ] >> (j %64 )) &1 ) { +Z [0 ] ^=H [0 ]; +Z [1 ] ^=H [1 ]; + } +bool reduce = ((H [1 ] >>63 ) &1 ); +H [1 ] =H [1 ] <<1 |H [0 ] >>63 ; +H [0 ] =H [0 ] <<1 ; +if (reduce) { +H [0 ] ^=0x87 ; + } + } + + vd[i *2 +0 ] =brev8 (Z [0 ]); + vd[i *2 +1 ] =brev8 (Z [1 ]); + } +/* set tail elements to 1s */ +vext_set_elems_1s (vd, vta, env->vl *4 , total_elems *4 ); + env->vstart =0 ; +} + +void HELPER (vgmul_vv )(void *vd_vptr,void *vs2_vptr,CPURISCVState *env, +uint32_t desc) +{ +uint64_t *vd = vd_vptr;
target/riscv/vcrypto_helper.c void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, · line 824
Quoted 10 lines
target/riscv/vcrypto_helper.c +10
-0+uint64_t *vs2 = vs2_vptr; +uint32_t vta =vext_vta (desc); +uint32_t total_elems =vext_get_total_elems (env, desc,4 ); + +for (uint32_t i = env->vstart /4 ; i < env->vl /4 ; i++) { +uint64_t Y [2 ] = {brev8 (vd[i *2 +0 ]),brev8 (vd[i *2 +1 ])}; +uint64_t H [2 ] = {brev8 (vs2[i *2 +0 ]),brev8 (vs2[i *2 +1 ])}; +uint64_t Z [2 ] = {0 ,0 }; + +for (uint j =0 ; j <128 ; j++) {
^
The error being thrown:
FAILED:
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj i686-w64-mingw32-gcc -m32 -Ilibqemu-riscv64-softmmu.fa.p -I. -I.. -Itarget/riscv -I../target/riscv -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/i686-w64-mingw32/sys-root/mingw/include/pixman-1 -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -iquote . -iquote /builds/danielhb/qemu -iquote /builds/danielhb/qemu/include -iquote /builds/danielhb/qemu/host/include/i386 -iquote /builds/danielhb/qemu/host/include/generic -iquote /builds/danielhb/qemu/tcg/i386 -mms-bitfields -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -no-pie -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -MF libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj.d -o libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -c ../target/riscv/vcrypto_helper.c ../target/riscv/vcrypto_helper.c: In function 'helper_vghsh_vv':
../target/riscv/vcrypto_helper.c:791:14: error: unknown type name 'uint'; did you mean 'u_int'?
791 | for (uint j = 0; j < 128; j++) {
| ^~~~
| u_int
../target/riscv/vcrypto_helper.c: In function 'helper_vgmul_vv':
../target/riscv/vcrypto_helper.c:825:14: error: unknown type name 'uint'; did you mean 'u_int'?
825 | for (uint j = 0; j < 128; j++) {
| ^~~~
| u_int
[2503/3700] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_vector_helper.c.obj
Quoted 19 lines
target/riscv/vcrypto_helper.c +19
-0+if ((Y [j /64 ] >> (j %64 )) &1 ) { +Z [0 ] ^=H [0 ]; +Z [1 ] ^=H [1 ]; + } +bool reduce = ((H [1 ] >>63 ) &1 ); +H [1 ] =H [1 ] <<1 |H [0 ] >>63 ; +H [0 ] =H [0 ] <<1 ; +if (reduce) { +H [0 ] ^=0x87 ; + } + } + + vd[i *2 +0 ] =brev8 (Z [0 ]); + vd[i *2 +1 ] =brev8 (Z [1 ]); + } +/* set tail elements to 1s */ +vext_set_elems_1s (vd, vta, env->vl *4 , total_elems *4 ); + env->vstart =0 ; +}
Re: [PATCH v7 12/15] target/riscv: Add Zvkg ISA extension support
Quoted 229 lines · Daniel Henrique Barboza
Hi,
This patch breaks some gitlab runners because of this:
Quoted 155 lines · Max Chou
From: Nazar Kazakov <[email protected]>
This commit adds support for the Zvkg vector-crypto extension, which consists of the following instructions:
* vgmul.vv
* vghsh.vvTranslation functions are defined in
target/riscv/insn_trans/trans_rvvk.c.incand helpers are defined intarget/riscv/vcrypto_helper.c.Co-authored-by Lawrence Hunter <[email protected]>[[email protected]: Replaced vstart checking by TCG op]Signed-off-by Lawrence Hunter <[email protected]>Signed-off-by Nazar Kazakov <[email protected]>Signed-off-by Max Chou <[email protected]>Reviewed-by Daniel Henrique Barboza <[email protected]>[[email protected]: Exposed x-zvkg property]---
target/riscv/cpu.c | 6 +- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 3 + target/riscv/insn32.decode | 4 ++ target/riscv/insn_trans/trans_rvvk.c.inc | 30 ++++++++++ target/riscv/vcrypto_helper.c | 72 ++++++++++++++++++++++++6 files changed, 114 insertions(+), 2 deletions(-)target/riscv/cpu.c +1
-1@@ -118,6 +118,7 @@ static const struct isa_ext_data isa_edata_arr[] = { ISA_EXT_DATA_ENTRY(zve64d, PRIV_VERSION_1_10_0, ext_zve64d), ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh), ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin), + ISA_EXT_DATA_ENTRY(zvkg, PRIV_VERSION_1_12_0, ext_zvkg), ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned), ISA_EXT_DATA_ENTRY(zvknha, PRIV_VERSION_1_12_0, ext_zvknha), ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb),@@ -1194,8 +1195,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU*cpu, Error **errp) * In principle Zve*x would also suffice here, were they supported * in qemu */ - if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned ||
cpu->cfg.ext_zvknha||
-cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) {
+ if ((cpu->cfg.ext_zvbb||cpu->cfg.ext_zvkg||cpu->cfg.ext_zvkned||
+cpu->cfg.ext_zvknha||cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) {
error_setg(errp,
"Vector crypto extensions require V or Zve* extensions"); return;target/riscv/cpu.c +1
-0@@ -1710,6 +1711,7 @@ static Property riscv_cpu_extensions[] = { /* Vector cryptography extensions */ DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false), DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false), + DEFINE_PROP_BOOL("x-zvkg", RISCVCPU, cfg.ext_zvkg, false), DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false), DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false), DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false),target/riscv/cpu_cfg.h +1
-0@@ -85,6 +85,7 @@ struct RISCVCPUConfig { bool ext_zve64d; bool ext_zvbb; bool ext_zvbc; + bool ext_zvkg; bool ext_zvkned; bool ext_zvknha; bool ext_zvknhb;target/riscv/helper.h +3
-0@@ -1244,3 +1244,6 @@ DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32) + +DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_4 (vgmul_vv, void, ptr, ptr, env, i32)target/riscv/insn32.decode +0
-0@@ -957,3 +957,7 @@ vsha2cl_vv 101111 1 ..... ..... 010 .....1110111 @r_vm_1
# *** Zvksh vector crypto extension *** vsm3me_vv 100000 1 ..... ..... 010 ..... 1110111 @r_vm_1 vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_vm_1target/riscv/insn32.decode +4
-0+ +# *** Zvkg vector crypto extension *** +vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1target/riscv/insn_trans/trans_rvvk.c.inc +30
-0@@ -531,3 +531,33 @@ static inline bool vsm3c_check(DisasContext *s, arg_rmrr *a) GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS) GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS) + +/* + * Zvkg + */ + +#define ZVKG_EGS 4 + +static bool vgmul_check(DisasContext *s, arg_rmr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + vext_check_isa_ill(s) && + require_rvv(s) && + MAXSZ(s) >= egw_bytes && + vext_check_ss(s, a->rd, a->rs2, a->vm) && + s->sew == MO_32; +} + +GEN_V_UNMASKED_TRANS(vgmul_vv, vgmul_check, ZVKG_EGS) + +static bool vghsh_check(DisasContext *s, arg_rmrr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + opivv_check(s, a) && + MAXSZ(s) >= egw_bytes && + s->sew == MO_32; +} + +GEN_VV_UNMASKED_TRANS(vghsh_vv, vghsh_check, ZVKG_EGS)target/riscv/vcrypto_helper.c +0
-0@@ -769,3 +769,75 @@ void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, vext_set_elems_1s(vd_vptr, vta, env->vl * esz, total_elems * esz); env->vstart = 0;}
target/riscv/vcrypto_helper.c +9
-0+ +void HELPER (vghsh_vv )(void *vd_vptr,void *vs1_vptr,void *vs2_vptr, + CPURISCVState *env, uint32_t desc) +{ + uint64_t *vd = vd_vptr; + uint64_t *vs1 = vs1_vptr; + uint64_t *vs2 = vs2_vptr; + uint32_t vta = vext_vta(desc); + uint32_t total_elems = vext_get_total_elems(env, desc, 4);target/riscv/vcrypto_helper.c void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, · line 790
Quoted 10 lines
target/riscv/vcrypto_helper.c +10
-0+ + for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) { + uint64_t Y[2] = {vd[i * 2 + 0], vd[i * 2 + 1]}; + uint64_t H[2] = {brev8(vs2[i * 2 + 0]), brev8(vs2[i * 2 + 1])}; + uint64_t X[2] = {vs1[i * 2 + 0], vs1[i * 2 + 1]}; + uint64_t Z[2] = {0, 0}; + + uint64_t S[2] = {brev8(Y[0] ^ X[0]), brev8(Y[1] ^ X[1])}; + + for (uint j = 0; j < 128; j++) {^
and this
FAILED:
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj i686-w64-mingw32-gcc -m32 -Ilibqemu-riscv64-softmmu.fa.p -I. -I.. -Itarget/riscv -I../target/riscv -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/i686-w64-mingw32/sys-root/mingw/include/pixman-1 -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g
-fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -iquote . -iquote /builds/danielhb/qemu -iquote /builds/danielhb/qemu/include -iquote /builds/danielhb/qemu/host/include/i386 -iquote /builds/danielhb/qemu/host/include/generic -iquote /builds/danielhb/qemu/tcg/i386 -mms-bitfields -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -no-pie -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -MF libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj.d -o libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -c../target/riscv/vcrypto_helper.c../target/riscv/vcrypto_helper.c: In function 'helper_vghsh_vv':
../target/riscv/vcrypto_helper.c:791:14: error: unknown type name 'uint'; did you mean 'u_int'?
791 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int../target/riscv/vcrypto_helper.c: In function 'helper_vgmul_vv':
../target/riscv/vcrypto_helper.c:825:14: error: unknown type name 'uint'; did you mean 'u_int'?
825 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
[2503/3700] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_vector_helper.c.objIf you want to take a look yourself:
https://gitlab.com/danielhb/qemu/-/jobs/4615946161
The fix is to use 'int' instead of 'uint' in both cases.
I apologize for noticing the error this late. I haven't had the chance to run Gitlab runners in these patches until now.
Quoted 8 lines
Alistair, in case you decide to take this series you'll have to amend this in-tree I'm afraid. It's too late to ask for another review.
Thanks,
Daniel
Hi Daniel,
Thanks you for the testing and notification.
If this series are not be taken at the 8.1 feature freeze (July 11th), I'll provide the next version with the fix.
Thanks,
Max
Quoted 105 lines
Quoted 26 lines
+ if ((S[j / 64] >> (j % 64)) & 1) {
+ Z[0] ^= H[0];
+ Z[1] ^= H[1];
+ }
+ bool reduce = ((H[1] >> 63) & 1);
+ H[1] = H[1] << 1 | H[0] >> 63;
+ H[0] = H[0] << 1;
+ if (reduce) {
+ H[0] ^=0x87;
+ }
+ }target/riscv/vcrypto_helper.c +10
-0+ + vd[i * 2 + 0] = brev8(Z[0]); + vd[i * 2 + 1] = brev8(Z[1]); + } + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vta, env->vl * 4, total_elems * 4); + env->vstart = 0; +} + +void HELPER(vgmul_vv)(void *vd_vptr, void *vs2_vptr, CPURISCVState*env,
+uint32_tdesc)target/riscv/vcrypto_helper.c +2
-0+{ + uint64_t *vd = vd_vptr;target/riscv/vcrypto_helper.c void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, · line 824
Quoted 10 lines
target/riscv/vcrypto_helper.c +10
-0+ uint64_t *vs2 = vs2_vptr; + uint32_t vta = vext_vta(desc); + uint32_t total_elems = vext_get_total_elems(env, desc, 4); + + for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) { + uint64_t Y[2] = {brev8(vd[i * 2 + 0]), brev8(vd[i * 2 + 1])}; + uint64_t H[2] = {brev8(vs2[i * 2 + 0]), brev8(vs2[i * 2 + 1])}; + uint64_t Z[2] = {0, 0}; + + for (uint j = 0; j < 128; j++) {^
The error being thrown:
FAILED:
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj i686-w64-mingw32-gcc -m32 -Ilibqemu-riscv64-softmmu.fa.p -I. -I.. -Itarget/riscv -I../target/riscv -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/i686-w64-mingw32/sys-root/mingw/include/pixman-1 -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g
-fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -iquote . -iquote /builds/danielhb/qemu -iquote /builds/danielhb/qemu/include -iquote /builds/danielhb/qemu/host/include/i386 -iquote /builds/danielhb/qemu/host/include/generic -iquote /builds/danielhb/qemu/tcg/i386 -mms-bitfields -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -no-pie -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -MF libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj.d -o libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -c../target/riscv/vcrypto_helper.c../target/riscv/vcrypto_helper.c: In function 'helper_vghsh_vv':
../target/riscv/vcrypto_helper.c:791:14: error: unknown type name 'uint'; did you mean 'u_int'?
791 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int../target/riscv/vcrypto_helper.c: In function 'helper_vgmul_vv':
../target/riscv/vcrypto_helper.c:825:14: error: unknown type name 'uint'; did you mean 'u_int'?
825 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
[2503/3700] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_vector_helper.c.objQuoted 19 lines
+ if ((Y[j / 64] >> (j % 64)) & 1) {
+ Z[0] ^= H[0];
+ Z[1] ^= H[1];
+ }
+ bool reduce = ((H[1] >> 63) & 1);
+ H[1] = H[1] << 1 | H[0] >> 63;
+ H[0] = H[0] << 1;
+ if (reduce) {
+ H[0] ^=0x87;
+ }
+ }target/riscv/vcrypto_helper.c +8
-0+ + vd[i * 2 + 0] = brev8(Z[0]); + vd[i * 2 + 1] = brev8(Z[1]); + } + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vta, env->vl * 4, total_elems * 4); + env->vstart = 0; +}
Re: [PATCH v7 12/15] target/riscv: Add Zvkg ISA extension support
Quoted 244 lines · Max Chou
Quoted 241 lines · Daniel Henrique Barboza
Hi,
This patch breaks some gitlab runners because of this:
Quoted 158 lines · Max Chou
From: Nazar Kazakov <[email protected]>
This commit adds support for the Zvkg vector-crypto extension, which consists of the following instructions:
* vgmul.vv
* vghsh.vvTranslation functions are defined in
target/riscv/insn_trans/trans_rvvk.c.incand helpers are defined intarget/riscv/vcrypto_helper.c.Co-authored-by Lawrence Hunter <[email protected]>[[email protected]: Replaced vstart checking by TCG op]Signed-off-by Lawrence Hunter <[email protected]>Signed-off-by Nazar Kazakov <[email protected]>Signed-off-by Max Chou <[email protected]>Reviewed-by Daniel Henrique Barboza <[email protected]>[[email protected]: Exposed x-zvkg property]--- target/riscv/cpu.c | 6 +- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 3 + target/riscv/insn32.decode | 4 ++ target/riscv/insn_trans/trans_rvvk.c.inc | 30 ++++++++++ target/riscv/vcrypto_helper.c | 72 ++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 2 deletions(-)target/riscv/cpu.c +1
-1@@ -118,6 +118,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zve64d,PRIV_VERSION_1_10_0 , ext_zve64d),ISA_EXT_DATA_ENTRY (zvfh,PRIV_VERSION_1_12_0 , ext_zvfh),ISA_EXT_DATA_ENTRY (zvfhmin,PRIV_VERSION_1_12_0 , ext_zvfhmin), +ISA_EXT_DATA_ENTRY (zvkg,PRIV_VERSION_1_12_0 , ext_zvkg),ISA_EXT_DATA_ENTRY (zvkned,PRIV_VERSION_1_12_0 , ext_zvkned),ISA_EXT_DATA_ENTRY (zvknha,PRIV_VERSION_1_12_0 , ext_zvknha), ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb),@@ -1194,8 +1195,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU*cpu, Error **errp) * In principle Zve*x would also suffice here, were they supported * in qemu */ - if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned ||
cpu->cfg.ext_zvknha||target/riscv/cpu.c +1
-1- cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) { + if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkg ||
cpu->cfg.ext_zvkned||
+cpu->cfg.ext_zvknha||cpu->cfg.ext_zvksh) &&
!cpu->cfg.ext_zve32f) {
error_setg(errp,
"Vector crypto extensions require V or Zve*extensions"); return;target/riscv/cpu.c +1
-0@@ -1710,6 +1711,7 @@ static Property riscv_cpu_extensions[] = {/* Vector cryptography extensions */ DEFINE_PROP_BOOL ("x-zvbb" ,RISCVCPU , cfg.ext_zvbb, false),DEFINE_PROP_BOOL ("x-zvbc" ,RISCVCPU , cfg.ext_zvbc, false), +DEFINE_PROP_BOOL ("x-zvkg" ,RISCVCPU , cfg.ext_zvkg, false),DEFINE_PROP_BOOL ("x-zvkned" ,RISCVCPU , cfg.ext_zvkned, false),DEFINE_PROP_BOOL ("x-zvknha" ,RISCVCPU , cfg.ext_zvknha, false), DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false),target/riscv/cpu_cfg.h +1
-0@@ -85,6 +85,7 @@ struct RISCVCPUConfig {bool ext_zve64d;bool ext_zvbb;bool ext_zvbc; +bool ext_zvkg;bool ext_zvkned;bool ext_zvknha;bool ext_zvknhb;target/riscv/helper.h +3
-0@@ -1244,3 +1244,6 @@ DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32) + +DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_4 (vgmul_vv, void, ptr, ptr, env, i32)target/riscv/insn32.decode +0
-0@@ -957,3 +957,7 @@ vsha2cl_vv 101111 1 ..... ..... 010 .....1110111 @r_vm_1
# *** Zvksh vector crypto extension ***
vsm3me_vv100000 1 ..... ..... 010 ..... 1110111 @r_vm_1
vsm3c_vi101011 1 ..... ..... 010 ..... 1110111 @r_vm_1target/riscv/insn32.decode +4
-0+ +# *** Zvkg vector crypto extension *** +vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1target/riscv/insn_trans/trans_rvvk.c.inc +30
-0@@ -531,3 +531,33 @@ static inline bool vsm3c_check(DisasContext *s, arg_rmrr *a) GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS) GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS) + +/* + * Zvkg + */ + +#define ZVKG_EGS 4 + +static bool vgmul_check(DisasContext *s, arg_rmr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + vext_check_isa_ill(s) && + require_rvv(s) && + MAXSZ(s) >= egw_bytes && + vext_check_ss(s, a->rd, a->rs2, a->vm) && + s->sew == MO_32; +} + +GEN_V_UNMASKED_TRANS(vgmul_vv, vgmul_check, ZVKG_EGS) + +static bool vghsh_check(DisasContext *s, arg_rmrr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + opivv_check(s, a) && + MAXSZ(s) >= egw_bytes && + s->sew == MO_32; +} + +GEN_VV_UNMASKED_TRANS(vghsh_vv, vghsh_check, ZVKG_EGS)target/riscv/vcrypto_helper.c +9
-0@@ -769,3 +769,75 @@ void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,vext_set_elems_1s (vd_vptr, vta, env->vl * esz, total_elems * esz); env->vstart =0 ; } + +void HELPER (vghsh_vv )(void *vd_vptr,void *vs1_vptr,void *vs2_vptr, +CPURISCVState *env,uint32_t desc) +{ +uint64_t *vd = vd_vptr; +uint64_t *vs1 = vs1_vptr; +uint64_t *vs2 = vs2_vptr; +uint32_t vta =vext_vta (desc); +uint32_t total_elems =vext_get_total_elems (env, desc,4 );target/riscv/vcrypto_helper.c void HELPER(vsm3c_vi)(void *vd_vptr, void · line 790
Quoted 10 lines
target/riscv/vcrypto_helper.c +10
-0+ +for (uint32_t i = env->vstart /4 ; i < env->vl /4 ; i++) { +uint64_t Y [2 ] = {vd[i *2 +0 ], vd[i *2 +1 ]}; +uint64_t H [2 ] = {brev8 (vs2[i *2 +0 ]),brev8 (vs2[i *2 +1 ])}; +uint64_t X [2 ] = {vs1[i *2 +0 ], vs1[i *2 +1 ]}; +uint64_t Z [2 ] = {0 ,0 }; + +uint64_t S [2 ] = {brev8 (Y [0 ] ^X [0 ]),brev8 (Y [1 ] ^X [1 ])}; + +for (uint j =0 ; j <128 ; j++) {^
and this
FAILED: libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj i686-w64-mingw32-gcc -m32 -Ilibqemu-riscv64-softmmu.fa.p -I. -I.. -Itarget/riscv -I../target/riscv -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/i686-w64-mingw32/sys-root/mingw/include/pixman-1 -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11-O2 -g
-fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -iquote . -iquote /builds/danielhb/qemu -iquote /builds/danielhb/qemu/include -iquote /builds/danielhb/qemu/host/include/i386 -iquote /builds/danielhb/qemu/host/include/generic -iquote /builds/danielhb/qemu/tcg/i386 -mms-bitfields -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -no-pie -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -MF
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj.d -o
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -c../target/riscv/vcrypto_helper.c../target/riscv/vcrypto_helper.c: In function 'helper_vghsh_vv':
../target/riscv/vcrypto_helper.c:791:14: error: unknown type name 'uint'; did you mean 'u_int'?
791 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
../target/riscv/vcrypto_helper.c: In function 'helper_vgmul_vv':
../target/riscv/vcrypto_helper.c:825:14: error: unknown type name 'uint'; did you mean 'u_int'?
825 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
[2503/3700] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_vector_helper.c.objIf you want to take a look yourself:
https://gitlab.com/danielhb/qemu/-/jobs/4615946161
The fix is to use 'int' instead of 'uint' in both cases.
I apologize for noticing the error this late. I haven't had the chance to run
Gitlab runners in these patches until now.Alistair, in case you decide to take this series you'll have to amend this
in-tree I'm afraid. It's too late to ask for another review.Thanks,
Quoted 7 lines
Quoted 1 line
Daniel
Hi Daniel,
Thanks you for the testing and notification.
If this series are not be taken at the 8.1 feature freeze (July 11th), I'll provide the next version with the fix.
Hey Max,
Thanks for the patches. Unfortunately they won't make the feature freeze. They depend on other patches and I haven't gotten a chance to look at them yet. If you can send a new version I can start reviewing and apply them to my tree in preparation of the next release
Alistair
Quoted 111 lines
Thanks,
Max
Quoted 105 lines
Quoted 26 lines
target/riscv/vcrypto_helper.c +21
-0+if ((S [j /64 ] >> (j %64 )) &1 ) { +Z [0 ] ^=H [0 ]; +Z [1 ] ^=H [1 ]; + } +bool reduce = ((H [1 ] >>63 ) &1 ); +H [1 ] =H [1 ] <<1 |H [0 ] >>63 ; +H [0 ] =H [0 ] <<1 ; +if (reduce) { +H [0 ] ^=0x87 ; + } + } + + vd[i *2 +0 ] =brev8 (Z [0 ]); + vd[i *2 +1 ] =brev8 (Z [1 ]); + } +/* set tail elements to 1s */ +vext_set_elems_1s (vd, vta, env->vl *4 , total_elems *4 ); + env->vstart =0 ; +} + +void HELPER(vgmul_vv)(void *vd_vptr, void *vs2_vptr, CPURISCVState*env,
target/riscv/vcrypto_helper.c +3
-0+ uint32_t desc) +{ +uint64_t *vd = vd_vptr;target/riscv/vcrypto_helper.c void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, · line 824
Quoted 10 lines
target/riscv/vcrypto_helper.c +10
-0+uint64_t *vs2 = vs2_vptr; +uint32_t vta =vext_vta (desc); +uint32_t total_elems =vext_get_total_elems (env, desc,4 ); + +for (uint32_t i = env->vstart /4 ; i < env->vl /4 ; i++) { +uint64_t Y [2 ] = {brev8 (vd[i *2 +0 ]),brev8 (vd[i *2 +1 ])}; +uint64_t H [2 ] = {brev8 (vs2[i *2 +0 ]),brev8 (vs2[i *2 +1 ])}; +uint64_t Z [2 ] = {0 ,0 }; + +for (uint j =0 ; j <128 ; j++) {^
The error being thrown:
FAILED: libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj i686-w64-mingw32-gcc -m32 -Ilibqemu-riscv64-softmmu.fa.p -I. -I.. -Itarget/riscv -I../target/riscv -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/i686-w64-mingw32/sys-root/mingw/include/pixman-1 -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11-O2 -g
-fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -iquote . -iquote /builds/danielhb/qemu -iquote /builds/danielhb/qemu/include -iquote /builds/danielhb/qemu/host/include/i386 -iquote /builds/danielhb/qemu/host/include/generic -iquote /builds/danielhb/qemu/tcg/i386 -mms-bitfields -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -no-pie -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -MF
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj.d -o
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -c../target/riscv/vcrypto_helper.c../target/riscv/vcrypto_helper.c: In function 'helper_vghsh_vv':
../target/riscv/vcrypto_helper.c:791:14: error: unknown type name 'uint'; did you mean 'u_int'?
791 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
../target/riscv/vcrypto_helper.c: In function 'helper_vgmul_vv':
../target/riscv/vcrypto_helper.c:825:14: error: unknown type name 'uint'; did you mean 'u_int'?
825 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
[2503/3700] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_vector_helper.c.objQuoted 19 lines
target/riscv/vcrypto_helper.c +19
-0+if ((Y [j /64 ] >> (j %64 )) &1 ) { +Z [0 ] ^=H [0 ]; +Z [1 ] ^=H [1 ]; + } +bool reduce = ((H [1 ] >>63 ) &1 ); +H [1 ] =H [1 ] <<1 |H [0 ] >>63 ; +H [0 ] =H [0 ] <<1 ; +if (reduce) { +H [0 ] ^=0x87 ; + } + } + + vd[i *2 +0 ] =brev8 (Z [0 ]); + vd[i *2 +1 ] =brev8 (Z [1 ]); + } +/* set tail elements to 1s */ +vext_set_elems_1s (vd, vta, env->vl *4 , total_elems *4 ); + env->vstart =0 ; +}
Re: [PATCH v7 12/15] target/riscv: Add Zvkg ISA extension support
Quoted 249 lines · Alistair Francis
Quoted 242 lines · Max Chou
Quoted 240 lines · Daniel Henrique Barboza
Hi,
This patch breaks some gitlab runners because of this:
Quoted 158 lines · Max Chou
From: Nazar Kazakov<[email protected]>
This commit adds support for the Zvkg vector-crypto extension, which consists of the following instructions:
* vgmul.vv
* vghsh.vvTranslation functions are defined in
target/riscv/insn_trans/trans_rvvk.c.incand helpers are defined intarget/riscv/vcrypto_helper.c.Co-authored-by Lawrence Hunter<[email protected]>[[email protected]: Replaced vstart checking by TCG op]Signed-off-by Lawrence Hunter<[email protected]>Signed-off-by Nazar Kazakov<[email protected]>Signed-off-by Max Chou<[email protected]>Reviewed-by Daniel Henrique Barboza<[email protected]>[[email protected]: Exposed x-zvkg property]--- target/riscv/cpu.c | 6 +- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 3 + target/riscv/insn32.decode | 4 ++ target/riscv/insn_trans/trans_rvvk.c.inc | 30 ++++++++++ target/riscv/vcrypto_helper.c | 72 ++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 2 deletions(-)target/riscv/cpu.c +1
-1@@ -118,6 +118,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zve64d,PRIV_VERSION_1_10_0 , ext_zve64d),ISA_EXT_DATA_ENTRY (zvfh,PRIV_VERSION_1_12_0 , ext_zvfh),ISA_EXT_DATA_ENTRY (zvfhmin,PRIV_VERSION_1_12_0 , ext_zvfhmin), +ISA_EXT_DATA_ENTRY (zvkg,PRIV_VERSION_1_12_0 , ext_zvkg),ISA_EXT_DATA_ENTRY (zvkned,PRIV_VERSION_1_12_0 , ext_zvkned),ISA_EXT_DATA_ENTRY (zvknha,PRIV_VERSION_1_12_0 , ext_zvknha), ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb),@@ -1194,8 +1195,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU*cpu, Error **errp) * In principle Zve*x would also suffice here, were they supported * in qemu */ - if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned ||
cpu->cfg.ext_zvknha||target/riscv/cpu.c +1
-1- cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) { + if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkg ||
cpu->cfg.ext_zvkned||
+cpu->cfg.ext_zvknha||cpu->cfg.ext_zvksh) &&
!cpu->cfg.ext_zve32f) {
error_setg(errp,
"Vector crypto extensions require V or Zve*extensions"); return;target/riscv/cpu.c +1
-0@@ -1710,6 +1711,7 @@ static Property riscv_cpu_extensions[] = {/* Vector cryptography extensions */ DEFINE_PROP_BOOL ("x-zvbb" ,RISCVCPU , cfg.ext_zvbb, false),DEFINE_PROP_BOOL ("x-zvbc" ,RISCVCPU , cfg.ext_zvbc, false), +DEFINE_PROP_BOOL ("x-zvkg" ,RISCVCPU , cfg.ext_zvkg, false),DEFINE_PROP_BOOL ("x-zvkned" ,RISCVCPU , cfg.ext_zvkned, false),DEFINE_PROP_BOOL ("x-zvknha" ,RISCVCPU , cfg.ext_zvknha, false), DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false),target/riscv/cpu_cfg.h +1
-0@@ -85,6 +85,7 @@ struct RISCVCPUConfig {bool ext_zve64d;bool ext_zvbb;bool ext_zvbc; +bool ext_zvkg;bool ext_zvkned;bool ext_zvknha;bool ext_zvknhb;target/riscv/helper.h +3
-0@@ -1244,3 +1244,6 @@ DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32) + +DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_4 (vgmul_vv, void, ptr, ptr, env, i32)target/riscv/insn32.decode +0
-0@@ -957,3 +957,7 @@ vsha2cl_vv 101111 1 ..... ..... 010 .....1110111 @r_vm_1
# *** Zvksh vector crypto extension ***
vsm3me_vv100000 1 ..... ..... 010 ..... 1110111 @r_vm_1
vsm3c_vi101011 1 ..... ..... 010 ..... 1110111 @r_vm_1target/riscv/insn32.decode +4
-0+ +# *** Zvkg vector crypto extension *** +vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1target/riscv/insn_trans/trans_rvvk.c.inc +30
-0@@ -531,3 +531,33 @@ static inline bool vsm3c_check(DisasContext *s, arg_rmrr *a) GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS) GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS) + +/* + * Zvkg + */ + +#define ZVKG_EGS 4 + +static bool vgmul_check(DisasContext *s, arg_rmr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + vext_check_isa_ill(s) && + require_rvv(s) && + MAXSZ(s) >= egw_bytes && + vext_check_ss(s, a->rd, a->rs2, a->vm) && + s->sew == MO_32; +} + +GEN_V_UNMASKED_TRANS(vgmul_vv, vgmul_check, ZVKG_EGS) + +static bool vghsh_check(DisasContext *s, arg_rmrr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + opivv_check(s, a) && + MAXSZ(s) >= egw_bytes && + s->sew == MO_32; +} + +GEN_VV_UNMASKED_TRANS(vghsh_vv, vghsh_check, ZVKG_EGS)target/riscv/vcrypto_helper.c +9
-0@@ -769,3 +769,75 @@ void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,vext_set_elems_1s (vd_vptr, vta, env->vl * esz, total_elems * esz); env->vstart =0 ; } + +void HELPER (vghsh_vv )(void *vd_vptr,void *vs1_vptr,void *vs2_vptr, +CPURISCVState *env,uint32_t desc) +{ +uint64_t *vd = vd_vptr; +uint64_t *vs1 = vs1_vptr; +uint64_t *vs2 = vs2_vptr; +uint32_t vta =vext_vta (desc); +uint32_t total_elems =vext_get_total_elems (env, desc,4 );target/riscv/vcrypto_helper.c void HELPER(vsm3c_vi)(void *vd_vptr, void · line 790
Quoted 10 lines
target/riscv/vcrypto_helper.c +10
-0+ +for (uint32_t i = env->vstart /4 ; i < env->vl /4 ; i++) { +uint64_t Y [2 ] = {vd[i *2 +0 ], vd[i *2 +1 ]}; +uint64_t H [2 ] = {brev8 (vs2[i *2 +0 ]),brev8 (vs2[i *2 +1 ])}; +uint64_t X [2 ] = {vs1[i *2 +0 ], vs1[i *2 +1 ]}; +uint64_t Z [2 ] = {0 ,0 }; + +uint64_t S [2 ] = {brev8 (Y [0 ] ^X [0 ]),brev8 (Y [1 ] ^X [1 ])}; + +for (uint j =0 ; j <128 ; j++) {^
and this
FAILED: libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj i686-w64-mingw32-gcc -m32 -Ilibqemu-riscv64-softmmu.fa.p -I. -I.. -Itarget/riscv -I../target/riscv -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/i686-w64-mingw32/sys-root/mingw/include/pixman-1 -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11-O2 -g
-fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -iquote . -iquote /builds/danielhb/qemu -iquote /builds/danielhb/qemu/include -iquote /builds/danielhb/qemu/host/include/i386 -iquote /builds/danielhb/qemu/host/include/generic -iquote /builds/danielhb/qemu/tcg/i386 -mms-bitfields -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -no-pie -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -MF
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj.d -o
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -c../target/riscv/vcrypto_helper.c../target/riscv/vcrypto_helper.c: In function 'helper_vghsh_vv':
../target/riscv/vcrypto_helper.c:791:14: error: unknown type name 'uint'; did you mean 'u_int'?
791 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
../target/riscv/vcrypto_helper.c: In function 'helper_vgmul_vv':
../target/riscv/vcrypto_helper.c:825:14: error: unknown type name 'uint'; did you mean 'u_int'?
825 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
[2503/3700] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_vector_helper.c.objIf you want to take a look yourself:
https://gitlab.com/danielhb/qemu/-/jobs/4615946161
The fix is to use 'int' instead of 'uint' in both cases.
I apologize for noticing the error this late. I haven't had the chance to run
Gitlab runners in these patches until now.Alistair, in case you decide to take this series you'll have to amend this
in-tree I'm afraid. It's too late to ask for another review.Thanks,
Quoted 6 lines
Quoted 1 line
Daniel
Hi Daniel,
Thanks you for the testing and notification.
If this series are not be taken at the 8.1 feature freeze (July 11th), I'll provide the next version with the fix.
Quoted 8 lines
Hey Max,
Thanks for the patches. Unfortunately they won't make the feature freeze. They depend on other patches and I haven't gotten a chance to look at them yet. If you can send a new version I can start reviewing and apply them to my tree in preparation of the next release
Alistair
Hi Alistair,
No problem, I'll send a new version based on the riscv-to-apply.next branch.
Thanks,
Max
Quoted 108 lines
Quoted 108 lines
Thanks,
Max
Quoted 103 lines
Quoted 25 lines
target/riscv/vcrypto_helper.c +21
-0+if ((S [j /64 ] >> (j %64 )) &1 ) { +Z [0 ] ^=H [0 ]; +Z [1 ] ^=H [1 ]; + } +bool reduce = ((H [1 ] >>63 ) &1 ); +H [1 ] =H [1 ] <<1 |H [0 ] >>63 ; +H [0 ] =H [0 ] <<1 ; +if (reduce) { +H [0 ] ^=0x87 ; + } + } + + vd[i *2 +0 ] =brev8 (Z [0 ]); + vd[i *2 +1 ] =brev8 (Z [1 ]); + } +/* set tail elements to 1s */ +vext_set_elems_1s (vd, vta, env->vl *4 , total_elems *4 ); + env->vstart =0 ; +} + +void HELPER(vgmul_vv)(void *vd_vptr, void *vs2_vptr, CPURISCVState*env,
target/riscv/vcrypto_helper.c +3
-0+ uint32_t desc) +{ +uint64_t *vd = vd_vptr;target/riscv/vcrypto_helper.c void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, · line 824
Quoted 10 lines
target/riscv/vcrypto_helper.c +10
-0+uint64_t *vs2 = vs2_vptr; +uint32_t vta =vext_vta (desc); +uint32_t total_elems =vext_get_total_elems (env, desc,4 ); + +for (uint32_t i = env->vstart /4 ; i < env->vl /4 ; i++) { +uint64_t Y [2 ] = {brev8 (vd[i *2 +0 ]),brev8 (vd[i *2 +1 ])}; +uint64_t H [2 ] = {brev8 (vs2[i *2 +0 ]),brev8 (vs2[i *2 +1 ])}; +uint64_t Z [2 ] = {0 ,0 }; + +for (uint j =0 ; j <128 ; j++) {^
The error being thrown:
FAILED: libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj i686-w64-mingw32-gcc -m32 -Ilibqemu-riscv64-softmmu.fa.p -I. -I.. -Itarget/riscv -I../target/riscv -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/i686-w64-mingw32/sys-root/mingw/include/pixman-1 -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11-O2 -g
-fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -iquote . -iquote /builds/danielhb/qemu -iquote /builds/danielhb/qemu/include -iquote /builds/danielhb/qemu/host/include/i386 -iquote /builds/danielhb/qemu/host/include/generic -iquote /builds/danielhb/qemu/tcg/i386 -mms-bitfields -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -no-pie -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -MF
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj.d -o
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -c../target/riscv/vcrypto_helper.c../target/riscv/vcrypto_helper.c: In function 'helper_vghsh_vv':
../target/riscv/vcrypto_helper.c:791:14: error: unknown type name 'uint'; did you mean 'u_int'?
791 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
../target/riscv/vcrypto_helper.c: In function 'helper_vgmul_vv':
../target/riscv/vcrypto_helper.c:825:14: error: unknown type name 'uint'; did you mean 'u_int'?
825 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
[2503/3700] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_vector_helper.c.objQuoted 19 lines
target/riscv/vcrypto_helper.c +19
-0+if ((Y [j /64 ] >> (j %64 )) &1 ) { +Z [0 ] ^=H [0 ]; +Z [1 ] ^=H [1 ]; + } +bool reduce = ((H [1 ] >>63 ) &1 ); +H [1 ] =H [1 ] <<1 |H [0 ] >>63 ; +H [0 ] =H [0 ] <<1 ; +if (reduce) { +H [0 ] ^=0x87 ; + } + } + + vd[i *2 +0 ] =brev8 (Z [0 ]); + vd[i *2 +1 ] =brev8 (Z [1 ]); + } +/* set tail elements to 1s */ +vext_set_elems_1s (vd, vta, env->vl *4 , total_elems *4 ); + env->vstart =0 ; +}
Re: [PATCH v7 12/15] target/riscv: Add Zvkg ISA extension support
Quoted 258 lines · Max Chou
Quoted 256 lines · Alistair Francis
Quoted 242 lines · Max Chou
Quoted 240 lines · Daniel Henrique Barboza
Hi,
This patch breaks some gitlab runners because of this:
Quoted 158 lines · Max Chou
From: Nazar Kazakov<[email protected]>
This commit adds support for the Zvkg vector-crypto extension, which consists of the following instructions:
* vgmul.vv
* vghsh.vvTranslation functions are defined in
target/riscv/insn_trans/trans_rvvk.c.incand helpers are defined intarget/riscv/vcrypto_helper.c.Co-authored-by Lawrence Hunter<[email protected]>[[email protected]: Replaced vstart checking by TCG op]Signed-off-by Lawrence Hunter<[email protected]>Signed-off-by Nazar Kazakov<[email protected]>Signed-off-by Max Chou<[email protected]>Reviewed-by Daniel Henrique Barboza<[email protected]>[[email protected]: Exposed x-zvkg property]--- target/riscv/cpu.c | 6 +- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 3 + target/riscv/insn32.decode | 4 ++ target/riscv/insn_trans/trans_rvvk.c.inc | 30 ++++++++++ target/riscv/vcrypto_helper.c | 72 ++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 2 deletions(-)target/riscv/cpu.c +1
-1@@ -118,6 +118,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zve64d,PRIV_VERSION_1_10_0 , ext_zve64d),ISA_EXT_DATA_ENTRY (zvfh,PRIV_VERSION_1_12_0 , ext_zvfh),ISA_EXT_DATA_ENTRY (zvfhmin,PRIV_VERSION_1_12_0 , ext_zvfhmin), +ISA_EXT_DATA_ENTRY (zvkg,PRIV_VERSION_1_12_0 , ext_zvkg),ISA_EXT_DATA_ENTRY (zvkned,PRIV_VERSION_1_12_0 , ext_zvkned),ISA_EXT_DATA_ENTRY (zvknha,PRIV_VERSION_1_12_0 , ext_zvknha), ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb),@@ -1194,8 +1195,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU*cpu, Error **errp) * In principle Zve*x would also suffice here, were they supported * in qemu */ - if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned ||
cpu->cfg.ext_zvknha||target/riscv/cpu.c +1
-1- cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) { + if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkg ||
cpu->cfg.ext_zvkned||
+cpu->cfg.ext_zvknha||cpu->cfg.ext_zvksh) &&
!cpu->cfg.ext_zve32f) {
error_setg(errp,
"Vector crypto extensions require V or Zve*extensions"); return;target/riscv/cpu.c +1
-0@@ -1710,6 +1711,7 @@ static Property riscv_cpu_extensions[] = {/* Vector cryptography extensions */ DEFINE_PROP_BOOL ("x-zvbb" ,RISCVCPU , cfg.ext_zvbb, false),DEFINE_PROP_BOOL ("x-zvbc" ,RISCVCPU , cfg.ext_zvbc, false), +DEFINE_PROP_BOOL ("x-zvkg" ,RISCVCPU , cfg.ext_zvkg, false),DEFINE_PROP_BOOL ("x-zvkned" ,RISCVCPU , cfg.ext_zvkned, false),DEFINE_PROP_BOOL ("x-zvknha" ,RISCVCPU , cfg.ext_zvknha, false), DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false),target/riscv/cpu_cfg.h +1
-0@@ -85,6 +85,7 @@ struct RISCVCPUConfig {bool ext_zve64d;bool ext_zvbb;bool ext_zvbc; +bool ext_zvkg;bool ext_zvkned;bool ext_zvknha;bool ext_zvknhb;target/riscv/helper.h +3
-0@@ -1244,3 +1244,6 @@ DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32) + +DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_4 (vgmul_vv, void, ptr, ptr, env, i32)target/riscv/insn32.decode +0
-0@@ -957,3 +957,7 @@ vsha2cl_vv 101111 1 ..... ..... 010 .....1110111 @r_vm_1
# *** Zvksh vector crypto extension ***
vsm3me_vv100000 1 ..... ..... 010 ..... 1110111 @r_vm_1
vsm3c_vi101011 1 ..... ..... 010 ..... 1110111 @r_vm_1target/riscv/insn32.decode +4
-0+ +# *** Zvkg vector crypto extension *** +vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1target/riscv/insn_trans/trans_rvvk.c.inc +30
-0@@ -531,3 +531,33 @@ static inline bool vsm3c_check(DisasContext *s, arg_rmrr *a) GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS) GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS) + +/* + * Zvkg + */ + +#define ZVKG_EGS 4 + +static bool vgmul_check(DisasContext *s, arg_rmr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + vext_check_isa_ill(s) && + require_rvv(s) && + MAXSZ(s) >= egw_bytes && + vext_check_ss(s, a->rd, a->rs2, a->vm) && + s->sew == MO_32; +} + +GEN_V_UNMASKED_TRANS(vgmul_vv, vgmul_check, ZVKG_EGS) + +static bool vghsh_check(DisasContext *s, arg_rmrr *a) +{ + int egw_bytes = ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg == true && + opivv_check(s, a) && + MAXSZ(s) >= egw_bytes && + s->sew == MO_32; +} + +GEN_VV_UNMASKED_TRANS(vghsh_vv, vghsh_check, ZVKG_EGS)target/riscv/vcrypto_helper.c +9
-0@@ -769,3 +769,75 @@ void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,vext_set_elems_1s (vd_vptr, vta, env->vl * esz, total_elems * esz); env->vstart =0 ; } + +void HELPER (vghsh_vv )(void *vd_vptr,void *vs1_vptr,void *vs2_vptr, +CPURISCVState *env,uint32_t desc) +{ +uint64_t *vd = vd_vptr; +uint64_t *vs1 = vs1_vptr; +uint64_t *vs2 = vs2_vptr; +uint32_t vta =vext_vta (desc); +uint32_t total_elems =vext_get_total_elems (env, desc,4 );target/riscv/vcrypto_helper.c void HELPER(vsm3c_vi)(void *vd_vptr, void · line 790
Quoted 10 lines
target/riscv/vcrypto_helper.c +10
-0+ +for (uint32_t i = env->vstart /4 ; i < env->vl /4 ; i++) { +uint64_t Y [2 ] = {vd[i *2 +0 ], vd[i *2 +1 ]}; +uint64_t H [2 ] = {brev8 (vs2[i *2 +0 ]),brev8 (vs2[i *2 +1 ])}; +uint64_t X [2 ] = {vs1[i *2 +0 ], vs1[i *2 +1 ]}; +uint64_t Z [2 ] = {0 ,0 }; + +uint64_t S [2 ] = {brev8 (Y [0 ] ^X [0 ]),brev8 (Y [1 ] ^X [1 ])}; + +for (uint j =0 ; j <128 ; j++) {^
and this
FAILED: libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj i686-w64-mingw32-gcc -m32 -Ilibqemu-riscv64-softmmu.fa.p -I. -I.. -Itarget/riscv -I../target/riscv -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/i686-w64-mingw32/sys-root/mingw/include/pixman-1 -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11-O2 -g
-fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -iquote . -iquote /builds/danielhb/qemu -iquote /builds/danielhb/qemu/include -iquote /builds/danielhb/qemu/host/include/i386 -iquote /builds/danielhb/qemu/host/include/generic -iquote /builds/danielhb/qemu/tcg/i386 -mms-bitfields -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -no-pie -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -MF
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj.d -o
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -c../target/riscv/vcrypto_helper.c../target/riscv/vcrypto_helper.c: In function 'helper_vghsh_vv':
../target/riscv/vcrypto_helper.c:791:14: error: unknown type name 'uint'; did you mean 'u_int'?
791 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
../target/riscv/vcrypto_helper.c: In function 'helper_vgmul_vv':
../target/riscv/vcrypto_helper.c:825:14: error: unknown type name 'uint'; did you mean 'u_int'?
825 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
[2503/3700] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_vector_helper.c.objIf you want to take a look yourself:
https://gitlab.com/danielhb/qemu/-/jobs/4615946161
The fix is to use 'int' instead of 'uint' in both cases.
I apologize for noticing the error this late. I haven't had the chance to run
Gitlab runners in these patches until now.Alistair, in case you decide to take this series you'll have to amend this
in-tree I'm afraid. It's too late to ask for another review.Thanks,
Quoted 6 lines
Quoted 1 line
Daniel
Hi Daniel,
Thanks you for the testing and notification.
If this series are not be taken at the 8.1 feature freeze (July 11th), I'll provide the next version with the fix.Hey Max,
Thanks for the patches. Unfortunately they won't make the feature freeze. They depend on other patches and I haven't gotten a chance to look at them yet. If you can send a new version I can start reviewing and apply them to my tree in preparation of the next release
Quoted 7 lines
Quoted 1 line
Alistair
Hi Alistair,
No problem, I'll send a new version based on the riscv-to-apply.next branch.
Thanks,
Max
Hi Alistair,
The v8 patches rebase to the riscv-to-apply.next branch and include the fix of the cross win32 build issue.
https://patchew.org/QEMU/[email protected]/
Thanks,
Max
Quoted 107 lines
Quoted 107 lines
Quoted 107 lines
Thanks,
Max
Quoted 103 lines
Quoted 25 lines
target/riscv/vcrypto_helper.c +21
-0+if ((S [j /64 ] >> (j %64 )) &1 ) { +Z [0 ] ^=H [0 ]; +Z [1 ] ^=H [1 ]; + } +bool reduce = ((H [1 ] >>63 ) &1 ); +H [1 ] =H [1 ] <<1 |H [0 ] >>63 ; +H [0 ] =H [0 ] <<1 ; +if (reduce) { +H [0 ] ^=0x87 ; + } + } + + vd[i *2 +0 ] =brev8 (Z [0 ]); + vd[i *2 +1 ] =brev8 (Z [1 ]); + } +/* set tail elements to 1s */ +vext_set_elems_1s (vd, vta, env->vl *4 , total_elems *4 ); + env->vstart =0 ; +} + +void HELPER(vgmul_vv)(void *vd_vptr, void *vs2_vptr, CPURISCVState*env,
target/riscv/vcrypto_helper.c +3
-0+ uint32_t desc) +{ +uint64_t *vd = vd_vptr;target/riscv/vcrypto_helper.c void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, · line 824
Quoted 10 lines
target/riscv/vcrypto_helper.c +10
-0+uint64_t *vs2 = vs2_vptr; +uint32_t vta =vext_vta (desc); +uint32_t total_elems =vext_get_total_elems (env, desc,4 ); + +for (uint32_t i = env->vstart /4 ; i < env->vl /4 ; i++) { +uint64_t Y [2 ] = {brev8 (vd[i *2 +0 ]),brev8 (vd[i *2 +1 ])}; +uint64_t H [2 ] = {brev8 (vs2[i *2 +0 ]),brev8 (vs2[i *2 +1 ])}; +uint64_t Z [2 ] = {0 ,0 }; + +for (uint j =0 ; j <128 ; j++) {^
The error being thrown:
FAILED: libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj i686-w64-mingw32-gcc -m32 -Ilibqemu-riscv64-softmmu.fa.p -I. -I.. -Itarget/riscv -I../target/riscv -Isubprojects/dtc/libfdt -I../subprojects/dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/usr/i686-w64-mingw32/sys-root/mingw/include/pixman-1 -I/usr/i686-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/i686-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11-O2 -g
-fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -iquote . -iquote /builds/danielhb/qemu -iquote /builds/danielhb/qemu/include -iquote /builds/danielhb/qemu/host/include/i386 -iquote /builds/danielhb/qemu/host/include/generic -iquote /builds/danielhb/qemu/tcg/i386 -mms-bitfields -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -no-pie -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -MF
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj.d -o
libqemu-riscv64-softmmu.fa.p/target_riscv_vcrypto_helper.c.obj -c../target/riscv/vcrypto_helper.c../target/riscv/vcrypto_helper.c: In function 'helper_vghsh_vv':
../target/riscv/vcrypto_helper.c:791:14: error: unknown type name 'uint'; did you mean 'u_int'?
791 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
../target/riscv/vcrypto_helper.c: In function 'helper_vgmul_vv':
../target/riscv/vcrypto_helper.c:825:14: error: unknown type name 'uint'; did you mean 'u_int'?
825 | for (uint j = 0; j < 128; j++) {
| ^~~~
|u_int
[2503/3700] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_vector_helper.c.objQuoted 19 lines
target/riscv/vcrypto_helper.c +19
-0+if ((Y [j /64 ] >> (j %64 )) &1 ) { +Z [0 ] ^=H [0 ]; +Z [1 ] ^=H [1 ]; + } +bool reduce = ((H [1 ] >>63 ) &1 ); +H [1 ] =H [1 ] <<1 |H [0 ] >>63 ; +H [0 ] =H [0 ] <<1 ; +if (reduce) { +H [0 ] ^=0x87 ; + } + } + + vd[i *2 +0 ] =brev8 (Z [0 ]); + vd[i *2 +1 ] =brev8 (Z [1 ]); + } +/* set tail elements to 1s */ +vext_set_elems_1s (vd, vta, env->vl *4 , total_elems *4 ); + env->vstart =0 ; +}
PATCH v7 13/15 crypto: Create sm4_subword
In reply to Max ChouAllows sharing of sm4_subword between different targets.
--- include/crypto/sm4.h | 8 ++++++++ target/arm/tcg/crypto_helper.c | 10 ++-------- 2 files changed, 10 insertions(+), 8 deletions(-)
include/crypto/sm4.h +8 -0
@@ -3,4 +3,12 @@extern const uint8_t sm4_sbox[256 ]; +static inline uint32_t sm4_subword (uint32_t word) +{ +return sm4_sbox[word &0xff ] | + sm4_sbox[(word >>8 ) &0xff ] <<8 | + sm4_sbox[(word >>16 ) &0xff ] <<16 | + sm4_sbox[(word >>24 ) &0xff ] <<24 ; +} +#endif
target/arm/tcg/crypto_helper.c +2 -8
@@ -614,10 +614,7 @@ static void do_crypto_sm4e(uint64_t *rd, uint64_t *rn, uint64_t *rm)CR_ST_WORD (d, (i +3 ) %4 ) ^CR_ST_WORD (n, i); - t = sm4_sbox[t &0xff ] | - sm4_sbox[(t >>8 ) &0xff ] <<8 | - sm4_sbox[(t >>16 ) &0xff ] <<16 | - sm4_sbox[(t >>24 ) &0xff ] <<24 ; + t =sm4_subword (t);CR_ST_WORD (d, i) ^= t ^rol32 (t,2 ) ^rol32 (t,10 ) ^rol32 (t,18 ) ^rol32 (t,24 );
@@ -651,10 +648,7 @@ static void do_crypto_sm4ekey(uint64_t *rd, uint64_t *rn, uint64_t *rm)CR_ST_WORD (d, (i +3 ) %4 ) ^CR_ST_WORD (m, i); - t = sm4_sbox[t &0xff ] | - sm4_sbox[(t >>8 ) &0xff ] <<8 | - sm4_sbox[(t >>16 ) &0xff ] <<16 | - sm4_sbox[(t >>24 ) &0xff ] <<24 ; + t =sm4_subword (t);CR_ST_WORD (d, i) ^= t ^rol32 (t,13 ) ^rol32 (t,23 ); }
Signature · 1 line
2.34.1
PATCH v7 14/15 crypto: Add SM4 constant parameter CK
In reply to Max ChouAdds sm4_ck constant for use in sm4 cryptography across different targets.
--- crypto/sm4.c | 10 ++++++++++ include/crypto/sm4.h | 1 + 2 files changed, 11 insertions(+)
crypto/sm4.c +10 -0
@@ -47,3 +47,13 @@ uint8_t const sm4_sbox[] = { 0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48, }; +uint32_t const sm4_ck[] = { +0x00070e15 ,0x1c232a31 ,0x383f464d ,0x545b6269 , +0x70777e85 ,0x8c939aa1 ,0xa8afb6bd ,0xc4cbd2d9 , +0xe0e7eef5 ,0xfc030a11 ,0x181f262d ,0x343b4249 , +0x50575e65 ,0x6c737a81 ,0x888f969d ,0xa4abb2b9 , +0xc0c7ced5 ,0xdce3eaf1 ,0xf8ff060d ,0x141b2229 , +0x30373e45 ,0x4c535a61 ,0x686f767d ,0x848b9299 , +0xa0a7aeb5 ,0xbcc3cad1 ,0xd8dfe6ed ,0xf4fb0209 , +0x10171e25 ,0x2c333a41 ,0x484f565d ,0x646b7279 +};
include/crypto/sm4.h +1 -0
@@ -2,6 +2,7 @@#define QEMU_SM4_H extern const uint8_t sm4_sbox[256 ]; +extern const uint32_t sm4_ck[32 ];static inline uint32_t sm4_subword (uint32_t word) {
Signature · 1 line
2.34.1
PATCH v7 15/15 target/riscv: Add Zvksed ISA extension support
In reply to Max ChouThis commit adds support for the Zvksed vector-crypto extension, which consists of the following instructions:
* vsm4k.vi
* vsm4r.[vv,vs]
Translation functions are defined in target/riscv/insn_trans/trans_rvvk.c.inc and helpers are defined in target/riscv/vcrypto_helper.c.
[[email protected]: Moved SM4 functions from crypto_helper.c to vcrypto_helper.c] [[email protected]: Added alignment checks, refactored code to use macros, and minor style changes]
--- target/riscv/cpu.c | 5 +- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 4 + target/riscv/insn32.decode | 5 + target/riscv/insn_trans/trans_rvvk.c.inc | 43 ++++++++ target/riscv/vcrypto_helper.c | 127 +++++++++++++++++++++++ 6 files changed, 184 insertions(+), 1 deletion(-)
target/riscv/cpu.c +4 -1
@@ -122,6 +122,7 @@ static const struct isa_ext_data isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zvkned,PRIV_VERSION_1_12_0 , ext_zvkned),ISA_EXT_DATA_ENTRY (zvknha,PRIV_VERSION_1_12_0 , ext_zvknha),ISA_EXT_DATA_ENTRY (zvknhb,PRIV_VERSION_1_12_0 , ext_zvknhb), +ISA_EXT_DATA_ENTRY (zvksed,PRIV_VERSION_1_12_0 , ext_zvksed),ISA_EXT_DATA_ENTRY (zvksh,PRIV_VERSION_1_12_0 , ext_zvksh),ISA_EXT_DATA_ENTRY (zhinx,PRIV_VERSION_1_12_0 , ext_zhinx), ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin),
@@ -1196,7 +1197,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)* in qemu */ if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkg || cpu->cfg.ext_zvkned || - cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) { + cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksed || cpu->cfg.ext_zvksh) && + !cpu->cfg.ext_zve32f) {error_setg (errp,"Vector crypto extensions require V or Zve* extensions" );return ;
@@ -1715,6 +1717,7 @@ static Property riscv_cpu_extensions[] = {DEFINE_PROP_BOOL ("x-zvkned" ,RISCVCPU , cfg.ext_zvkned, false),DEFINE_PROP_BOOL ("x-zvknha" ,RISCVCPU , cfg.ext_zvknha, false),DEFINE_PROP_BOOL ("x-zvknhb" ,RISCVCPU , cfg.ext_zvknhb, false), +DEFINE_PROP_BOOL ("x-zvksed" ,RISCVCPU , cfg.ext_zvksed, false),DEFINE_PROP_BOOL ("x-zvksh" ,RISCVCPU , cfg.ext_zvksh, false), DEFINE_PROP_END_OF_LIST(),
target/riscv/cpu_cfg.h +1 -0
@@ -89,6 +89,7 @@ struct RISCVCPUConfig {bool ext_zvkned;bool ext_zvknha;bool ext_zvknhb; +bool ext_zvksed;bool ext_zvksh;bool ext_zmmul;bool ext_zvfh;
target/riscv/helper.h +4 -0
@@ -1247,3 +1247,7 @@ DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32) DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_4(vgmul_vv, void, ptr, ptr, env, i32) + +DEF_HELPER_5(vsm4k_vi, void, ptr, ptr, i32, env, i32) +DEF_HELPER_4(vsm4r_vv, void, ptr, ptr, env, i32) +DEF_HELPER_4 (vsm4r_vs, void, ptr, ptr, env, i32)
target/riscv/insn32.decode +5 -0
@@ -961,3 +961,8 @@ vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_vm_1 # *** Zvkg vector crypto extension *** vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1 vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1 + +# *** Zvksed vector crypto extension *** +vsm4k_vi 100001 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vsm4r_vv 101000 1 ..... 10000 010 ..... 1110111 @r2_vm_1 +vsm4r_vs 101001 1 ..... 10000 010 ..... 1110111 @r2_vm_1
target/riscv/insn_trans/trans_rvvk.c.inc +43 -0
46 lines not on this page · raw message
target/riscv/vcrypto_helper.c +127 -0
136 lines not on this page · raw message
Signature · 1 line
2.34.1