1 /* SPDX-License-Identifier: GPL-2.0 */
3 * CP Assist for Cryptographic Functions (CPACF)
5 * Copyright IBM Corp. 2003, 2023
6 * Author(s): Thomas Spatzier
11 #ifndef _ASM_S390_CPACF_H
12 #define _ASM_S390_CPACF_H
14 #include <asm/facility.h>
15 #include <linux/kmsan-checks.h>
18 * Instruction opcodes for the CPACF instructions
20 #define CPACF_KMAC 0xb91e /* MSA */
21 #define CPACF_KM 0xb92e /* MSA */
22 #define CPACF_KMC 0xb92f /* MSA */
23 #define CPACF_KIMD 0xb93e /* MSA */
24 #define CPACF_KLMD 0xb93f /* MSA */
25 #define CPACF_PCKMO 0xb928 /* MSA3 */
26 #define CPACF_KMF 0xb92a /* MSA4 */
27 #define CPACF_KMO 0xb92b /* MSA4 */
28 #define CPACF_PCC 0xb92c /* MSA4 */
29 #define CPACF_KMCTR 0xb92d /* MSA4 */
30 #define CPACF_PRNO 0xb93c /* MSA5 */
31 #define CPACF_KMA 0xb929 /* MSA8 */
32 #define CPACF_KDSA 0xb93a /* MSA9 */
35 * En/decryption modifier bits
37 #define CPACF_ENCRYPT 0x00
38 #define CPACF_DECRYPT 0x80
41 * Function codes for the KM (CIPHER MESSAGE) instruction
43 #define CPACF_KM_QUERY 0x00
44 #define CPACF_KM_DEA 0x01
45 #define CPACF_KM_TDEA_128 0x02
46 #define CPACF_KM_TDEA_192 0x03
47 #define CPACF_KM_AES_128 0x12
48 #define CPACF_KM_AES_192 0x13
49 #define CPACF_KM_AES_256 0x14
50 #define CPACF_KM_PAES_128 0x1a
51 #define CPACF_KM_PAES_192 0x1b
52 #define CPACF_KM_PAES_256 0x1c
53 #define CPACF_KM_XTS_128 0x32
54 #define CPACF_KM_XTS_256 0x34
55 #define CPACF_KM_PXTS_128 0x3a
56 #define CPACF_KM_PXTS_256 0x3c
57 #define CPACF_KM_XTS_128_FULL 0x52
58 #define CPACF_KM_XTS_256_FULL 0x54
59 #define CPACF_KM_PXTS_128_FULL 0x5a
60 #define CPACF_KM_PXTS_256_FULL 0x5c
63 * Function codes for the KMC (CIPHER MESSAGE WITH CHAINING)
66 #define CPACF_KMC_QUERY 0x00
67 #define CPACF_KMC_DEA 0x01
68 #define CPACF_KMC_TDEA_128 0x02
69 #define CPACF_KMC_TDEA_192 0x03
70 #define CPACF_KMC_AES_128 0x12
71 #define CPACF_KMC_AES_192 0x13
72 #define CPACF_KMC_AES_256 0x14
73 #define CPACF_KMC_PAES_128 0x1a
74 #define CPACF_KMC_PAES_192 0x1b
75 #define CPACF_KMC_PAES_256 0x1c
76 #define CPACF_KMC_PRNG 0x43
79 * Function codes for the KMCTR (CIPHER MESSAGE WITH COUNTER)
82 #define CPACF_KMCTR_QUERY 0x00
83 #define CPACF_KMCTR_DEA 0x01
84 #define CPACF_KMCTR_TDEA_128 0x02
85 #define CPACF_KMCTR_TDEA_192 0x03
86 #define CPACF_KMCTR_AES_128 0x12
87 #define CPACF_KMCTR_AES_192 0x13
88 #define CPACF_KMCTR_AES_256 0x14
89 #define CPACF_KMCTR_PAES_128 0x1a
90 #define CPACF_KMCTR_PAES_192 0x1b
91 #define CPACF_KMCTR_PAES_256 0x1c
94 * Function codes for the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST)
97 #define CPACF_KIMD_QUERY 0x00
98 #define CPACF_KIMD_SHA_1 0x01
99 #define CPACF_KIMD_SHA_256 0x02
100 #define CPACF_KIMD_SHA_512 0x03
101 #define CPACF_KIMD_SHA3_224 0x20
102 #define CPACF_KIMD_SHA3_256 0x21
103 #define CPACF_KIMD_SHA3_384 0x22
104 #define CPACF_KIMD_SHA3_512 0x23
105 #define CPACF_KIMD_GHASH 0x41
108 * Function codes for the KLMD (COMPUTE LAST MESSAGE DIGEST)
111 #define CPACF_KLMD_QUERY 0x00
112 #define CPACF_KLMD_SHA_1 0x01
113 #define CPACF_KLMD_SHA_256 0x02
114 #define CPACF_KLMD_SHA_512 0x03
115 #define CPACF_KLMD_SHA3_224 0x20
116 #define CPACF_KLMD_SHA3_256 0x21
117 #define CPACF_KLMD_SHA3_384 0x22
118 #define CPACF_KLMD_SHA3_512 0x23
121 * function codes for the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE)
124 #define CPACF_KMAC_QUERY 0x00
125 #define CPACF_KMAC_DEA 0x01
126 #define CPACF_KMAC_TDEA_128 0x02
127 #define CPACF_KMAC_TDEA_192 0x03
128 #define CPACF_KMAC_HMAC_SHA_224 0x70
129 #define CPACF_KMAC_HMAC_SHA_256 0x71
130 #define CPACF_KMAC_HMAC_SHA_384 0x72
131 #define CPACF_KMAC_HMAC_SHA_512 0x73
134 * Function codes for the PCKMO (PERFORM CRYPTOGRAPHIC KEY MANAGEMENT)
137 #define CPACF_PCKMO_QUERY 0x00
138 #define CPACF_PCKMO_ENC_DES_KEY 0x01
139 #define CPACF_PCKMO_ENC_TDES_128_KEY 0x02
140 #define CPACF_PCKMO_ENC_TDES_192_KEY 0x03
141 #define CPACF_PCKMO_ENC_AES_128_KEY 0x12
142 #define CPACF_PCKMO_ENC_AES_192_KEY 0x13
143 #define CPACF_PCKMO_ENC_AES_256_KEY 0x14
144 #define CPACF_PCKMO_ENC_AES_XTS_128_DOUBLE_KEY 0x15
145 #define CPACF_PCKMO_ENC_AES_XTS_256_DOUBLE_KEY 0x16
146 #define CPACF_PCKMO_ENC_ECC_P256_KEY 0x20
147 #define CPACF_PCKMO_ENC_ECC_P384_KEY 0x21
148 #define CPACF_PCKMO_ENC_ECC_P521_KEY 0x22
149 #define CPACF_PCKMO_ENC_ECC_ED25519_KEY 0x28
150 #define CPACF_PCKMO_ENC_ECC_ED448_KEY 0x29
151 #define CPACF_PCKMO_ENC_HMAC_512_KEY 0x76
152 #define CPACF_PCKMO_ENC_HMAC_1024_KEY 0x7a
155 * Function codes for the PRNO (PERFORM RANDOM NUMBER OPERATION)
158 #define CPACF_PRNO_QUERY 0x00
159 #define CPACF_PRNO_SHA512_DRNG_GEN 0x03
160 #define CPACF_PRNO_SHA512_DRNG_SEED 0x83
161 #define CPACF_PRNO_TRNG_Q_R2C_RATIO 0x70
162 #define CPACF_PRNO_TRNG 0x72
165 * Function codes for the KMA (CIPHER MESSAGE WITH AUTHENTICATION)
168 #define CPACF_KMA_QUERY 0x00
169 #define CPACF_KMA_GCM_AES_128 0x12
170 #define CPACF_KMA_GCM_AES_192 0x13
171 #define CPACF_KMA_GCM_AES_256 0x14
174 * Flags for the KMA (CIPHER MESSAGE WITH AUTHENTICATION) instruction
176 #define CPACF_KMA_LPC 0x100 /* Last-Plaintext/Ciphertext */
177 #define CPACF_KMA_LAAD 0x200 /* Last-AAD */
178 #define CPACF_KMA_HS 0x400 /* Hash-subkey Supplied */
181 * Flags for the KIMD/KLMD (COMPUTE INTERMEDIATE/LAST MESSAGE DIGEST)
184 #define CPACF_KIMD_NIP 0x8000
185 #define CPACF_KLMD_DUFOP 0x4000
186 #define CPACF_KLMD_NIP 0x8000
189 * Function codes for KDSA (COMPUTE DIGITAL SIGNATURE AUTHENTICATION)
192 #define CPACF_KDSA_QUERY 0x00
193 #define CPACF_KDSA_ECDSA_VERIFY_P256 0x01
194 #define CPACF_KDSA_ECDSA_VERIFY_P384 0x02
195 #define CPACF_KDSA_ECDSA_VERIFY_P521 0x03
196 #define CPACF_KDSA_ECDSA_SIGN_P256 0x09
197 #define CPACF_KDSA_ECDSA_SIGN_P384 0x0a
198 #define CPACF_KDSA_ECDSA_SIGN_P521 0x0b
199 #define CPACF_KDSA_ENC_ECDSA_SIGN_P256 0x11
200 #define CPACF_KDSA_ENC_ECDSA_SIGN_P384 0x12
201 #define CPACF_KDSA_ENC_ECDSA_SIGN_P521 0x13
202 #define CPACF_KDSA_EDDSA_VERIFY_ED25519 0x20
203 #define CPACF_KDSA_EDDSA_VERIFY_ED448 0x24
204 #define CPACF_KDSA_EDDSA_SIGN_ED25519 0x28
205 #define CPACF_KDSA_EDDSA_SIGN_ED448 0x2c
206 #define CPACF_KDSA_ENC_EDDSA_SIGN_ED25519 0x30
207 #define CPACF_KDSA_ENC_EDDSA_SIGN_ED448 0x34
209 #define CPACF_FC_QUERY 0x00
210 #define CPACF_FC_QUERY_AUTH_INFO 0x7F
212 typedef struct { unsigned char bytes[16]; } cpacf_mask_t;
213 typedef struct { unsigned char bytes[256]; } cpacf_qai_t;
216 * Prototype for a not existing function to produce a link
217 * error if __cpacf_query() or __cpacf_check_opcode() is used
218 * with an invalid compile time const opcode.
220 void __cpacf_bad_opcode(void);
222 static __always_inline void __cpacf_query_rre(u32 opc, u8 r1, u8 r2,
228 " .insn rre,%[opc] << 16,%[r1],%[r2]\n"
230 : [opc] "i" (opc), [fc] "i" (fc),
231 [r1] "i" (r1), [r2] "i" (r2)
232 : "cc", "memory", "r0", "r1");
235 static __always_inline void __cpacf_query_rrf(u32 opc, u8 r1, u8 r2, u8 r3,
236 u8 m4, u8 *pb, u8 fc)
241 " .insn rrf,%[opc] << 16,%[r1],%[r2],%[r3],%[m4]\n"
243 : [opc] "i" (opc), [fc] "i" (fc), [r1] "i" (r1),
244 [r2] "i" (r2), [r3] "i" (r3), [m4] "i" (m4)
245 : "cc", "memory", "r0", "r1");
248 static __always_inline void __cpacf_query_insn(unsigned int opcode, void *pb,
253 __cpacf_query_rre(CPACF_KDSA, 0, 2, pb, fc);
256 __cpacf_query_rre(CPACF_KIMD, 0, 2, pb, fc);
259 __cpacf_query_rre(CPACF_KLMD, 0, 2, pb, fc);
262 __cpacf_query_rre(CPACF_KM, 2, 4, pb, fc);
265 __cpacf_query_rrf(CPACF_KMA, 2, 4, 6, 0, pb, fc);
268 __cpacf_query_rre(CPACF_KMAC, 0, 2, pb, fc);
271 __cpacf_query_rre(CPACF_KMC, 2, 4, pb, fc);
274 __cpacf_query_rrf(CPACF_KMCTR, 2, 4, 6, 0, pb, fc);
277 __cpacf_query_rre(CPACF_KMF, 2, 4, pb, fc);
280 __cpacf_query_rre(CPACF_KMO, 2, 4, pb, fc);
283 __cpacf_query_rre(CPACF_PCC, 0, 0, pb, fc);
286 __cpacf_query_rre(CPACF_PCKMO, 0, 0, pb, fc);
289 __cpacf_query_rre(CPACF_PRNO, 2, 4, pb, fc);
292 __cpacf_bad_opcode();
296 static __always_inline void __cpacf_query(unsigned int opcode,
299 __cpacf_query_insn(opcode, mask, CPACF_FC_QUERY);
302 static __always_inline int __cpacf_check_opcode(unsigned int opcode)
310 return test_facility(17); /* check for MSA */
312 return test_facility(76); /* check for MSA3 */
317 return test_facility(77); /* check for MSA4 */
319 return test_facility(57); /* check for MSA5 */
321 return test_facility(146); /* check for MSA8 */
323 return test_facility(155); /* check for MSA9 */
325 __cpacf_bad_opcode();
331 * cpacf_query() - Query the function code mask for this CPACF opcode
332 * @opcode: the opcode of the crypto instruction
333 * @mask: ptr to struct cpacf_mask_t
335 * Executes the query function for the given crypto instruction @opcode
336 * and checks if @func is available
338 * On success 1 is returned and the mask is filled with the function
339 * code mask for this CPACF opcode, otherwise 0 is returned.
341 static __always_inline int cpacf_query(unsigned int opcode, cpacf_mask_t *mask)
343 if (__cpacf_check_opcode(opcode)) {
344 __cpacf_query(opcode, mask);
347 memset(mask, 0, sizeof(*mask));
351 static inline int cpacf_test_func(cpacf_mask_t *mask, unsigned int func)
353 return (mask->bytes[func >> 3] & (0x80 >> (func & 7))) != 0;
356 static __always_inline int cpacf_query_func(unsigned int opcode,
361 if (cpacf_query(opcode, &mask))
362 return cpacf_test_func(&mask, func);
366 static __always_inline void __cpacf_qai(unsigned int opcode, cpacf_qai_t *qai)
368 __cpacf_query_insn(opcode, qai, CPACF_FC_QUERY_AUTH_INFO);
372 * cpacf_qai() - Get the query authentication information for a CPACF opcode
373 * @opcode: the opcode of the crypto instruction
374 * @mask: ptr to struct cpacf_qai_t
376 * Executes the query authentication information function for the given crypto
377 * instruction @opcode and checks if @func is available
379 * On success 1 is returned and the mask is filled with the query authentication
380 * information for this CPACF opcode, otherwise 0 is returned.
382 static __always_inline int cpacf_qai(unsigned int opcode, cpacf_qai_t *qai)
384 if (cpacf_query_func(opcode, CPACF_FC_QUERY_AUTH_INFO)) {
385 __cpacf_qai(opcode, qai);
388 memset(qai, 0, sizeof(*qai));
393 * cpacf_km() - executes the KM (CIPHER MESSAGE) instruction
394 * @func: the function code passed to KM; see CPACF_KM_xxx defines
395 * @param: address of parameter block; see POP for details on each func
396 * @dest: address of destination memory area
397 * @src: address of source memory area
398 * @src_len: length of src operand in bytes
400 * Returns 0 for the query func, number of processed bytes for
401 * encryption/decryption funcs
403 static inline int cpacf_km(unsigned long func, void *param,
404 u8 *dest, const u8 *src, long src_len)
406 union register_pair d, s;
408 d.even = (unsigned long)dest;
409 s.even = (unsigned long)src;
410 s.odd = (unsigned long)src_len;
414 "0: .insn rre,%[opc] << 16,%[dst],%[src]\n"
415 " brc 1,0b\n" /* handle partial completion */
416 : [src] "+&d" (s.pair), [dst] "+&d" (d.pair)
417 : [fc] "d" (func), [pba] "d" ((unsigned long)param),
419 : "cc", "memory", "0", "1");
421 return src_len - s.odd;
425 * cpacf_kmc() - executes the KMC (CIPHER MESSAGE WITH CHAINING) instruction
426 * @func: the function code passed to KM; see CPACF_KMC_xxx defines
427 * @param: address of parameter block; see POP for details on each func
428 * @dest: address of destination memory area
429 * @src: address of source memory area
430 * @src_len: length of src operand in bytes
432 * Returns 0 for the query func, number of processed bytes for
433 * encryption/decryption funcs
435 static inline int cpacf_kmc(unsigned long func, void *param,
436 u8 *dest, const u8 *src, long src_len)
438 union register_pair d, s;
440 d.even = (unsigned long)dest;
441 s.even = (unsigned long)src;
442 s.odd = (unsigned long)src_len;
446 "0: .insn rre,%[opc] << 16,%[dst],%[src]\n"
447 " brc 1,0b\n" /* handle partial completion */
448 : [src] "+&d" (s.pair), [dst] "+&d" (d.pair)
449 : [fc] "d" (func), [pba] "d" ((unsigned long)param),
450 [opc] "i" (CPACF_KMC)
451 : "cc", "memory", "0", "1");
453 return src_len - s.odd;
457 * cpacf_kimd() - executes the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST)
459 * @func: the function code passed to KM; see CPACF_KIMD_xxx defines
460 * @param: address of parameter block; see POP for details on each func
461 * @src: address of source memory area
462 * @src_len: length of src operand in bytes
464 static inline void cpacf_kimd(unsigned long func, void *param,
465 const u8 *src, long src_len)
467 union register_pair s;
469 s.even = (unsigned long)src;
470 s.odd = (unsigned long)src_len;
474 "0: .insn rrf,%[opc] << 16,0,%[src],8,0\n"
475 " brc 1,0b\n" /* handle partial completion */
476 : [src] "+&d" (s.pair)
477 : [fc] "d" (func), [pba] "d" ((unsigned long)(param)),
478 [opc] "i" (CPACF_KIMD)
479 : "cc", "memory", "0", "1");
483 * cpacf_klmd() - executes the KLMD (COMPUTE LAST MESSAGE DIGEST) instruction
484 * @func: the function code passed to KM; see CPACF_KLMD_xxx defines
485 * @param: address of parameter block; see POP for details on each func
486 * @src: address of source memory area
487 * @src_len: length of src operand in bytes
489 static inline void cpacf_klmd(unsigned long func, void *param,
490 const u8 *src, long src_len)
492 union register_pair s;
494 s.even = (unsigned long)src;
495 s.odd = (unsigned long)src_len;
499 "0: .insn rrf,%[opc] << 16,0,%[src],8,0\n"
500 " brc 1,0b\n" /* handle partial completion */
501 : [src] "+&d" (s.pair)
502 : [fc] "d" (func), [pba] "d" ((unsigned long)param),
503 [opc] "i" (CPACF_KLMD)
504 : "cc", "memory", "0", "1");
508 * _cpacf_kmac() - executes the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE)
509 * instruction and updates flags in gr0
510 * @gr0: pointer to gr0 (fc and flags) passed to KMAC; see CPACF_KMAC_xxx defines
511 * @param: address of parameter block; see POP for details on each func
512 * @src: address of source memory area
513 * @src_len: length of src operand in bytes
515 * Returns 0 for the query func, number of processed bytes for digest funcs
517 static inline int _cpacf_kmac(unsigned long *gr0, void *param,
518 const u8 *src, long src_len)
520 union register_pair s;
522 s.even = (unsigned long)src;
523 s.odd = (unsigned long)src_len;
527 "0: .insn rre,%[opc] << 16,0,%[src]\n"
528 " brc 1,0b\n" /* handle partial completion */
530 : [r0] "+d" (*gr0), [src] "+&d" (s.pair)
531 : [pba] "d" ((unsigned long)param),
532 [opc] "i" (CPACF_KMAC)
533 : "cc", "memory", "0", "1");
535 return src_len - s.odd;
539 * cpacf_kmac() - executes the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE)
541 * @func: function code passed to KMAC; see CPACF_KMAC_xxx defines
542 * @param: address of parameter block; see POP for details on each func
543 * @src: address of source memory area
544 * @src_len: length of src operand in bytes
546 * Returns 0 for the query func, number of processed bytes for digest funcs
548 static inline int cpacf_kmac(unsigned long func, void *param,
549 const u8 *src, long src_len)
551 return _cpacf_kmac(&func, param, src, src_len);
555 * cpacf_kmctr() - executes the KMCTR (CIPHER MESSAGE WITH COUNTER) instruction
556 * @func: the function code passed to KMCTR; see CPACF_KMCTR_xxx defines
557 * @param: address of parameter block; see POP for details on each func
558 * @dest: address of destination memory area
559 * @src: address of source memory area
560 * @src_len: length of src operand in bytes
561 * @counter: address of counter value
563 * Returns 0 for the query func, number of processed bytes for
564 * encryption/decryption funcs
566 static inline int cpacf_kmctr(unsigned long func, void *param, u8 *dest,
567 const u8 *src, long src_len, u8 *counter)
569 union register_pair d, s, c;
571 d.even = (unsigned long)dest;
572 s.even = (unsigned long)src;
573 s.odd = (unsigned long)src_len;
574 c.even = (unsigned long)counter;
578 "0: .insn rrf,%[opc] << 16,%[dst],%[src],%[ctr],0\n"
579 " brc 1,0b\n" /* handle partial completion */
580 : [src] "+&d" (s.pair), [dst] "+&d" (d.pair),
582 : [fc] "d" (func), [pba] "d" ((unsigned long)param),
583 [opc] "i" (CPACF_KMCTR)
584 : "cc", "memory", "0", "1");
586 return src_len - s.odd;
590 * cpacf_prno() - executes the PRNO (PERFORM RANDOM NUMBER OPERATION)
592 * @func: the function code passed to PRNO; see CPACF_PRNO_xxx defines
593 * @param: address of parameter block; see POP for details on each func
594 * @dest: address of destination memory area
595 * @dest_len: size of destination memory area in bytes
596 * @seed: address of seed data
597 * @seed_len: size of seed data in bytes
599 static inline void cpacf_prno(unsigned long func, void *param,
600 u8 *dest, unsigned long dest_len,
601 const u8 *seed, unsigned long seed_len)
603 union register_pair d, s;
605 d.even = (unsigned long)dest;
606 d.odd = (unsigned long)dest_len;
607 s.even = (unsigned long)seed;
608 s.odd = (unsigned long)seed_len;
612 "0: .insn rre,%[opc] << 16,%[dst],%[seed]\n"
613 " brc 1,0b\n" /* handle partial completion */
614 : [dst] "+&d" (d.pair)
615 : [fc] "d" (func), [pba] "d" ((unsigned long)param),
616 [seed] "d" (s.pair), [opc] "i" (CPACF_PRNO)
617 : "cc", "memory", "0", "1");
621 * cpacf_trng() - executes the TRNG subfunction of the PRNO instruction
622 * @ucbuf: buffer for unconditioned data
623 * @ucbuf_len: amount of unconditioned data to fetch in bytes
624 * @cbuf: buffer for conditioned data
625 * @cbuf_len: amount of conditioned data to fetch in bytes
627 static inline void cpacf_trng(u8 *ucbuf, unsigned long ucbuf_len,
628 u8 *cbuf, unsigned long cbuf_len)
630 union register_pair u, c;
632 u.even = (unsigned long)ucbuf;
633 u.odd = (unsigned long)ucbuf_len;
634 c.even = (unsigned long)cbuf;
635 c.odd = (unsigned long)cbuf_len;
638 "0: .insn rre,%[opc] << 16,%[ucbuf],%[cbuf]\n"
639 " brc 1,0b\n" /* handle partial completion */
640 : [ucbuf] "+&d" (u.pair), [cbuf] "+&d" (c.pair)
641 : [fc] "K" (CPACF_PRNO_TRNG), [opc] "i" (CPACF_PRNO)
642 : "cc", "memory", "0");
643 kmsan_unpoison_memory(ucbuf, ucbuf_len);
644 kmsan_unpoison_memory(cbuf, cbuf_len);
648 * cpacf_pcc() - executes the PCC (PERFORM CRYPTOGRAPHIC COMPUTATION)
650 * @func: the function code passed to PCC; see CPACF_KM_xxx defines
651 * @param: address of parameter block; see POP for details on each func
653 static inline void cpacf_pcc(unsigned long func, void *param)
658 "0: .insn rre,%[opc] << 16,0,0\n" /* PCC opcode */
659 " brc 1,0b\n" /* handle partial completion */
661 : [fc] "d" (func), [pba] "d" ((unsigned long)param),
662 [opc] "i" (CPACF_PCC)
663 : "cc", "memory", "0", "1");
667 * cpacf_pckmo() - executes the PCKMO (PERFORM CRYPTOGRAPHIC KEY
668 * MANAGEMENT) instruction
669 * @func: the function code passed to PCKMO; see CPACF_PCKMO_xxx defines
670 * @param: address of parameter block; see POP for details on each func
674 static inline void cpacf_pckmo(long func, void *param)
679 " .insn rre,%[opc] << 16,0,0\n" /* PCKMO opcode */
681 : [fc] "d" (func), [pba] "d" ((unsigned long)param),
682 [opc] "i" (CPACF_PCKMO)
683 : "cc", "memory", "0", "1");
687 * cpacf_kma() - executes the KMA (CIPHER MESSAGE WITH AUTHENTICATION)
689 * @func: the function code passed to KMA; see CPACF_KMA_xxx defines
690 * @param: address of parameter block; see POP for details on each func
691 * @dest: address of destination memory area
692 * @src: address of source memory area
693 * @src_len: length of src operand in bytes
694 * @aad: address of additional authenticated data memory area
695 * @aad_len: length of aad operand in bytes
697 static inline void cpacf_kma(unsigned long func, void *param, u8 *dest,
698 const u8 *src, unsigned long src_len,
699 const u8 *aad, unsigned long aad_len)
701 union register_pair d, s, a;
703 d.even = (unsigned long)dest;
704 s.even = (unsigned long)src;
705 s.odd = (unsigned long)src_len;
706 a.even = (unsigned long)aad;
707 a.odd = (unsigned long)aad_len;
711 "0: .insn rrf,%[opc] << 16,%[dst],%[src],%[aad],0\n"
712 " brc 1,0b\n" /* handle partial completion */
713 : [dst] "+&d" (d.pair), [src] "+&d" (s.pair),
715 : [fc] "d" (func), [pba] "d" ((unsigned long)param),
716 [opc] "i" (CPACF_KMA)
717 : "cc", "memory", "0", "1");
720 #endif /* _ASM_S390_CPACF_H */