summaryrefslogtreecommitdiffstats
path: root/crypto/perlasm
diff options
context:
space:
mode:
authorChristoph Müllner <christoph.muellner@vrull.eu>2023-01-18 20:58:12 +0100
committerHugo Landau <hlandau@openssl.org>2023-10-26 15:55:49 +0100
commit7543bb3a69c021edbe73bb38a8cc4d3708a68c5d (patch)
treef09f67bf7f9a50f45e294e61b600652d91ec2b4f /crypto/perlasm
parent9c22a240dab51dc9a5583d36726b81073f9c8d34 (diff)
riscv: SM4: Provide a Zvksed-based implementation
The upcoming RISC-V vector crypto extensions feature a Zvksed extension, that provides SM4-specific instructions. This patch provides an implementation that utilizes this extension if available. Tested on QEMU and no regressions observed. Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21923)
Diffstat (limited to 'crypto/perlasm')
-rw-r--r--crypto/perlasm/riscv.pm19
1 files changed, 19 insertions, 0 deletions
diff --git a/crypto/perlasm/riscv.pm b/crypto/perlasm/riscv.pm
index 215b563663..7db6305877 100644
--- a/crypto/perlasm/riscv.pm
+++ b/crypto/perlasm/riscv.pm
@@ -644,4 +644,23 @@ sub vsha2cl_vv {
return ".word ".($template | ($vs2 << 20)| ($vs1 << 15 )| ($vd << 7));
}
+## Zvksed instructions
+
+sub vsm4k_vi {
+ # vsm4k.vi vd, vs2, uimm
+ my $template = 0b1000011_00000_00000_010_00000_1110111;
+ my $vd = read_vreg shift;
+ my $vs2 = read_vreg shift;
+ my $uimm = shift;
+ return ".word ".($template | ($vs2 << 20) | ($uimm << 15) | ($vd << 7));
+}
+
+sub vsm4r_vs {
+ # vsm4r.vs vd, vs2
+ my $template = 0b1010011_00000_10000_010_00000_1110111;
+ my $vd = read_vreg shift;
+ my $vs2 = read_vreg shift;
+ return ".word ".($template | ($vs2 << 20) | ($vd << 7));
+}
+
1;