mirror of
https://github.com/golang/go
synced 2024-11-18 19:14:40 -07:00
cmd/asm: add KMA and KMCTR instructions on s390x.
This CL is to add assembly instruction mnemonics for the following instructions, mainly used in crypto packages. * KMA - cipher message with authentication * KMCTR - cipher message with counter Fixes #61163 Change-Id: Iff9a69911aeb4fab4bca8755b23a106eaebb2332 Reviewed-on: https://go-review.googlesource.com/c/go/+/515195 Reviewed-by: Carlos Amedee <carlos@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
a2647f08f0
commit
a40404da74
2
src/cmd/asm/internal/asm/testdata/s390x.s
vendored
2
src/cmd/asm/internal/asm/testdata/s390x.s
vendored
@ -420,6 +420,8 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
|
||||
KLMD R2, R8 // b93f0028
|
||||
KIMD R0, R4 // b93e0004
|
||||
KDSA R0, R8 // b93a0008
|
||||
KMA R6, R2, R4 // b9296024
|
||||
KMCTR R6, R2, R4 // b92d6024
|
||||
|
||||
// vector add and sub instructions
|
||||
VAB V3, V4, V4 // e743400000f3
|
||||
|
@ -486,6 +486,8 @@ const (
|
||||
AKLMD
|
||||
AKIMD
|
||||
AKDSA
|
||||
AKMA
|
||||
AKMCTR
|
||||
|
||||
// vector
|
||||
AVA
|
||||
|
@ -212,6 +212,8 @@ var Anames = []string{
|
||||
"KLMD",
|
||||
"KIMD",
|
||||
"KDSA",
|
||||
"KMA",
|
||||
"KMCTR",
|
||||
"VA",
|
||||
"VAB",
|
||||
"VAH",
|
||||
|
@ -347,6 +347,9 @@ var optab = []Optab{
|
||||
// KDSA
|
||||
{i: 125, as: AKDSA, a1: C_REG, a6: C_REG},
|
||||
|
||||
// KMA
|
||||
{i: 126, as: AKMA, a1: C_REG, a2: C_REG, a6: C_REG},
|
||||
|
||||
// vector instructions
|
||||
|
||||
// VRX store
|
||||
@ -1492,6 +1495,8 @@ func buildop(ctxt *obj.Link) {
|
||||
opset(AKMC, r)
|
||||
opset(AKLMD, r)
|
||||
opset(AKIMD, r)
|
||||
case AKMA:
|
||||
opset(AKMCTR, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1896,6 +1901,7 @@ const (
|
||||
op_KM uint32 = 0xB92E // FORMAT_RRE CIPHER MESSAGE
|
||||
op_KMAC uint32 = 0xB91E // FORMAT_RRE COMPUTE MESSAGE AUTHENTICATION CODE
|
||||
op_KMC uint32 = 0xB92F // FORMAT_RRE CIPHER MESSAGE WITH CHAINING
|
||||
op_KMA uint32 = 0xB929 // FORMAT_RRF2 CIPHER MESSAGE WITH AUTHENTICATION
|
||||
op_KMCTR uint32 = 0xB92D // FORMAT_RRF2 CIPHER MESSAGE WITH COUNTER
|
||||
op_KMF uint32 = 0xB92A // FORMAT_RRE CIPHER MESSAGE WITH CFB
|
||||
op_KMO uint32 = 0xB92B // FORMAT_RRE CIPHER MESSAGE WITH OFB
|
||||
@ -4428,6 +4434,40 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
|
||||
}
|
||||
zRRE(op_KDSA, uint32(p.From.Reg), uint32(p.To.Reg), asm)
|
||||
|
||||
case 126: // KMA and KMCTR - CIPHER MESSAGE WITH AUTHENTICATION; CIPHER MESSAGE WITH
|
||||
var opcode uint32
|
||||
switch p.As {
|
||||
default:
|
||||
c.ctxt.Diag("unexpected opcode %v", p.As)
|
||||
case AKMA, AKMCTR:
|
||||
if p.From.Reg == REG_R0 {
|
||||
c.ctxt.Diag("input argument must not be R0 in %v", p)
|
||||
}
|
||||
if p.From.Reg&1 != 0 {
|
||||
c.ctxt.Diag("input argument must be even register in %v", p)
|
||||
}
|
||||
if p.To.Reg == REG_R0 {
|
||||
c.ctxt.Diag("output argument must not be R0 in %v", p)
|
||||
}
|
||||
if p.To.Reg&1 != 0 {
|
||||
c.ctxt.Diag("output argument must be an even register in %v", p)
|
||||
}
|
||||
if p.Reg == REG_R0 {
|
||||
c.ctxt.Diag("third argument must not be R0 in %v", p)
|
||||
}
|
||||
if p.Reg&1 != 0 {
|
||||
c.ctxt.Diag("third argument must be even register in %v", p)
|
||||
}
|
||||
if p.Reg == p.To.Reg || p.Reg == p.From.Reg {
|
||||
c.ctxt.Diag("third argument must not be input or output argument registers in %v", p)
|
||||
}
|
||||
if p.As == AKMA {
|
||||
opcode = op_KMA
|
||||
} else if p.As == AKMCTR {
|
||||
opcode = op_KMCTR
|
||||
}
|
||||
}
|
||||
zRRF(opcode, uint32(p.From.Reg), 0, uint32(p.Reg), uint32(p.To.Reg), asm)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ crypt:
|
||||
MOVD src_base+56(FP), R6 // src
|
||||
MOVD src_len+64(FP), R7 // len
|
||||
loop:
|
||||
WORD $0xB92D2046 // cipher message with counter (KMCTR)
|
||||
KMCTR R6, R2, R4 // cipher message with counter (KMCTR)
|
||||
BVS loop // branch back if interrupted
|
||||
RET
|
||||
crash:
|
||||
@ -180,7 +180,7 @@ TEXT ·kmaGCM(SB),NOSPLIT,$112-120
|
||||
MVC $8, 24(R8), 104(R1)
|
||||
|
||||
kma:
|
||||
WORD $0xb9296024 // kma %r6,%r2,%r4
|
||||
KMA R6, R2, R4 // Cipher Message with Authentication
|
||||
BVS kma
|
||||
|
||||
MOVD tag+104(FP), R2
|
||||
|
@ -30,14 +30,14 @@ TEXT ·kmcQuery(SB), NOSPLIT|NOFRAME, $0-16
|
||||
TEXT ·kmctrQuery(SB), NOSPLIT|NOFRAME, $0-16
|
||||
MOVD $0, R0 // set function code to 0 (KMCTR-Query)
|
||||
MOVD $ret+0(FP), R1 // address of 16-byte return value
|
||||
WORD $0xB92D4024 // cipher message with counter (KMCTR)
|
||||
KMCTR R6, R2, R4 // cipher message with counter (KMCTR)
|
||||
RET
|
||||
|
||||
// func kmaQuery() queryResult
|
||||
TEXT ·kmaQuery(SB), NOSPLIT|NOFRAME, $0-16
|
||||
MOVD $0, R0 // set function code to 0 (KMA-Query)
|
||||
MOVD $ret+0(FP), R1 // address of 16-byte return value
|
||||
WORD $0xb9296024 // cipher message with authentication (KMA)
|
||||
KMA R6, R2, R4 // cipher message with authentication (KMA)
|
||||
RET
|
||||
|
||||
// func kimdQuery() queryResult
|
||||
|
Loading…
Reference in New Issue
Block a user