]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/asm: add KDSA instruction support
authorSrinivas Pokala <Pokala.Srinivas@ibm.com>
Wed, 14 Jun 2023 05:13:37 +0000 (07:13 +0200)
committerDavid Chase <drchase@google.com>
Fri, 11 Aug 2023 20:48:28 +0000 (20:48 +0000)
KDSA(Compute Digital Signature Authentication) instruction provides
support for the signing and verification of elliptic curves

Change-Id: I19996a307162dd4f476a1cfe4f8d1a74a609e6c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/503215
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/asm/internal/asm/testdata/s390x.s
src/cmd/internal/obj/s390x/a.out.go
src/cmd/internal/obj/s390x/anames.go
src/cmd/internal/obj/s390x/asmz.go
src/crypto/ecdsa/ecdsa_s390x.s
src/internal/cpu/cpu_s390x.s

index c73aecdaa60eb9a61995c30d148beed4d038cc9e..bb1573ae5bb1b266b5983bbee224e741b5789884 100644 (file)
@@ -419,6 +419,7 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
        KMC     R2, R6                 // b92f0026
        KLMD    R2, R8                 // b93f0028
        KIMD    R0, R4                 // b93e0004
+       KDSA    R0, R8                 // b93a0008
 
        // vector add and sub instructions
        VAB     V3, V4, V4              // e743400000f3
index 0b1aa5af1627948f8fd6f368552d04e7e3f8063a..ef02fed28323e599210360a5c1991a9444ac8006 100644 (file)
@@ -485,6 +485,7 @@ const (
        AKMC
        AKLMD
        AKIMD
+       AKDSA
 
        // vector
        AVA
index d5f5f343e30f17034f44d719479b74a7afd13344..40cc5e6b0d483fc19df8f4f7641e17a5a8f7f811 100644 (file)
@@ -211,6 +211,7 @@ var Anames = []string{
        "KMC",
        "KLMD",
        "KIMD",
+       "KDSA",
        "VA",
        "VAB",
        "VAH",
index 81e7a2d62efe41c58eca9361ba7bc43eb4650bda..a744d742cfa45480598fde0093f0180fa8b30d1f 100644 (file)
@@ -344,6 +344,9 @@ var optab = []Optab{
        // KM
        {i: 124, as: AKM, a1: C_REG, a6: C_REG},
 
+       // KDSA
+       {i: 125, as: AKDSA, a1: C_REG, a6: C_REG},
+
        // vector instructions
 
        // VRX store
@@ -2638,6 +2641,10 @@ const (
        op_VUPLL  uint32 = 0xE7D4 //    VRR-a   VECTOR UNPACK LOGICAL LOW
        op_VUPL   uint32 = 0xE7D6 //    VRR-a   VECTOR UNPACK LOW
        op_VMSL   uint32 = 0xE7B8 //    VRR-d   VECTOR MULTIPLY SUM LOGICAL
+
+       // added in z15
+       op_KDSA uint32 = 0xB93A // FORMAT_RRE        COMPUTE DIGITAL SIGNATURE AUTHENTICATION (KDSA)
+
 )
 
 func oclass(a *obj.Addr) int {
@@ -4411,6 +4418,16 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
                        opcode = op_KIMD
                }
                zRRE(opcode, uint32(p.From.Reg), uint32(p.To.Reg), asm)
+
+       case 125: // KDSA sign and verify
+               if p.To.Reg == REG_R0 {
+                       c.ctxt.Diag("second argument must not be R0 in %v", p)
+               }
+               if p.To.Reg&1 != 0 {
+                       c.ctxt.Diag("second argument must be an even register in %v", p)
+               }
+               zRRE(op_KDSA, uint32(p.From.Reg), uint32(p.To.Reg), asm)
+
        }
 }
 
index ba5b3bf9fa0ce29065c3a07460531375cefbbf08..ea1f4469e9918ca7d730344073caaa0ed2f2754b 100644 (file)
@@ -10,7 +10,7 @@ TEXT ·kdsa(SB), NOSPLIT|NOFRAME, $0-24
        MOVD params+8(FP), R1 // address parameter block
 
 loop:
-       WORD $0xB93A0008 // compute digital signature authentication
+       KDSA R0, R4      // compute digital signature authentication
        BVS  loop        // branch back if interrupted
        BGT  retry       // signing unsuccessful, but retry with new CSPRN
        BLT  error       // condition code of 1 indicates a failure
index 9f73113870c3379586f9cbb61f44d7ed4abe102b..46b3b5348121691f630a49fad60499393ebe362a 100644 (file)
@@ -58,6 +58,6 @@ TEXT ·klmdQuery(SB), NOSPLIT|NOFRAME, $0-16
 TEXT ·kdsaQuery(SB), NOSPLIT|NOFRAME, $0-16
        MOVD $0, R0         // set function code to 0 (KLMD-Query)
        MOVD $ret+0(FP), R1 // address of 16-byte return value
-       WORD $0xB93A0008    // compute digital signature authentication
+       KDSA R0, R4      // compute digital signature authentication
        RET