mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
target/riscv: Add Zvbc ISA extension support
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`. Co-authored-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk> Co-authored-by: Max Chou <max.chou@sifive.com> Signed-off-by: Nazar Kazakov <nazar.kazakov@codethink.co.uk> Signed-off-by: Lawrence Hunter <lawrence.hunter@codethink.co.uk> Signed-off-by: Max Chou <max.chou@sifive.com> [max.chou@sifive.com: Exposed x-zvbc property] Message-ID: <20230711165917.2629866-5-max.chou@sifive.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
922f873511
commit
e13c7d3b5b
8 changed files with 146 additions and 1 deletions
59
target/riscv/vcrypto_helper.c
Normal file
59
target/riscv/vcrypto_helper.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* RISC-V Vector Crypto Extension Helpers for QEMU.
|
||||
*
|
||||
* Copyright (C) 2023 SiFive, Inc.
|
||||
* Written by Codethink Ltd and SiFive.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2 or later, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/host-utils.h"
|
||||
#include "qemu/bitops.h"
|
||||
#include "cpu.h"
|
||||
#include "exec/memop.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "exec/helper-proto.h"
|
||||
#include "internals.h"
|
||||
#include "vector_internals.h"
|
||||
|
||||
static uint64_t clmul64(uint64_t y, uint64_t x)
|
||||
{
|
||||
uint64_t result = 0;
|
||||
for (int j = 63; j >= 0; j--) {
|
||||
if ((y >> j) & 1) {
|
||||
result ^= (x << j);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint64_t clmulh64(uint64_t y, uint64_t x)
|
||||
{
|
||||
uint64_t result = 0;
|
||||
for (int j = 63; j >= 1; j--) {
|
||||
if ((y >> j) & 1) {
|
||||
result ^= (x >> (64 - j));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
RVVCALL(OPIVV2, vclmul_vv, OP_UUU_D, H8, H8, H8, clmul64)
|
||||
GEN_VEXT_VV(vclmul_vv, 8)
|
||||
RVVCALL(OPIVX2, vclmul_vx, OP_UUU_D, H8, H8, clmul64)
|
||||
GEN_VEXT_VX(vclmul_vx, 8)
|
||||
RVVCALL(OPIVV2, vclmulh_vv, OP_UUU_D, H8, H8, H8, clmulh64)
|
||||
GEN_VEXT_VV(vclmulh_vv, 8)
|
||||
RVVCALL(OPIVX2, vclmulh_vx, OP_UUU_D, H8, H8, clmulh64)
|
||||
GEN_VEXT_VX(vclmulh_vx, 8)
|
Loading…
Add table
Add a link
Reference in a new issue