cpacf.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * CP Assist for Cryptographic Functions (CPACF)
  4. *
  5. * Copyright IBM Corp. 2003, 2017
  6. * Author(s): Thomas Spatzier
  7. * Jan Glauber
  8. * Harald Freudenberger (freude@de.ibm.com)
  9. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  10. */
  11. #ifndef _ASM_S390_CPACF_H
  12. #define _ASM_S390_CPACF_H
  13. #include <asm/facility.h>
  14. /*
  15. * Instruction opcodes for the CPACF instructions
  16. */
  17. #define CPACF_KMAC 0xb91e /* MSA */
  18. #define CPACF_KM 0xb92e /* MSA */
  19. #define CPACF_KMC 0xb92f /* MSA */
  20. #define CPACF_KIMD 0xb93e /* MSA */
  21. #define CPACF_KLMD 0xb93f /* MSA */
  22. #define CPACF_PCKMO 0xb928 /* MSA3 */
  23. #define CPACF_KMF 0xb92a /* MSA4 */
  24. #define CPACF_KMO 0xb92b /* MSA4 */
  25. #define CPACF_PCC 0xb92c /* MSA4 */
  26. #define CPACF_KMCTR 0xb92d /* MSA4 */
  27. #define CPACF_PRNO 0xb93c /* MSA5 */
  28. #define CPACF_KMA 0xb929 /* MSA8 */
  29. /*
  30. * En/decryption modifier bits
  31. */
  32. #define CPACF_ENCRYPT 0x00
  33. #define CPACF_DECRYPT 0x80
  34. /*
  35. * Function codes for the KM (CIPHER MESSAGE) instruction
  36. */
  37. #define CPACF_KM_QUERY 0x00
  38. #define CPACF_KM_DEA 0x01
  39. #define CPACF_KM_TDEA_128 0x02
  40. #define CPACF_KM_TDEA_192 0x03
  41. #define CPACF_KM_AES_128 0x12
  42. #define CPACF_KM_AES_192 0x13
  43. #define CPACF_KM_AES_256 0x14
  44. #define CPACF_KM_PAES_128 0x1a
  45. #define CPACF_KM_PAES_192 0x1b
  46. #define CPACF_KM_PAES_256 0x1c
  47. #define CPACF_KM_XTS_128 0x32
  48. #define CPACF_KM_XTS_256 0x34
  49. #define CPACF_KM_PXTS_128 0x3a
  50. #define CPACF_KM_PXTS_256 0x3c
  51. /*
  52. * Function codes for the KMC (CIPHER MESSAGE WITH CHAINING)
  53. * instruction
  54. */
  55. #define CPACF_KMC_QUERY 0x00
  56. #define CPACF_KMC_DEA 0x01
  57. #define CPACF_KMC_TDEA_128 0x02
  58. #define CPACF_KMC_TDEA_192 0x03
  59. #define CPACF_KMC_AES_128 0x12
  60. #define CPACF_KMC_AES_192 0x13
  61. #define CPACF_KMC_AES_256 0x14
  62. #define CPACF_KMC_PAES_128 0x1a
  63. #define CPACF_KMC_PAES_192 0x1b
  64. #define CPACF_KMC_PAES_256 0x1c
  65. #define CPACF_KMC_PRNG 0x43
  66. /*
  67. * Function codes for the KMCTR (CIPHER MESSAGE WITH COUNTER)
  68. * instruction
  69. */
  70. #define CPACF_KMCTR_QUERY 0x00
  71. #define CPACF_KMCTR_DEA 0x01
  72. #define CPACF_KMCTR_TDEA_128 0x02
  73. #define CPACF_KMCTR_TDEA_192 0x03
  74. #define CPACF_KMCTR_AES_128 0x12
  75. #define CPACF_KMCTR_AES_192 0x13
  76. #define CPACF_KMCTR_AES_256 0x14
  77. #define CPACF_KMCTR_PAES_128 0x1a
  78. #define CPACF_KMCTR_PAES_192 0x1b
  79. #define CPACF_KMCTR_PAES_256 0x1c
  80. /*
  81. * Function codes for the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST)
  82. * instruction
  83. */
  84. #define CPACF_KIMD_QUERY 0x00
  85. #define CPACF_KIMD_SHA_1 0x01
  86. #define CPACF_KIMD_SHA_256 0x02
  87. #define CPACF_KIMD_SHA_512 0x03
  88. #define CPACF_KIMD_GHASH 0x41
  89. /*
  90. * Function codes for the KLMD (COMPUTE LAST MESSAGE DIGEST)
  91. * instruction
  92. */
  93. #define CPACF_KLMD_QUERY 0x00
  94. #define CPACF_KLMD_SHA_1 0x01
  95. #define CPACF_KLMD_SHA_256 0x02
  96. #define CPACF_KLMD_SHA_512 0x03
  97. /*
  98. * function codes for the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE)
  99. * instruction
  100. */
  101. #define CPACF_KMAC_QUERY 0x00
  102. #define CPACF_KMAC_DEA 0x01
  103. #define CPACF_KMAC_TDEA_128 0x02
  104. #define CPACF_KMAC_TDEA_192 0x03
  105. /*
  106. * Function codes for the PCKMO (PERFORM CRYPTOGRAPHIC KEY MANAGEMENT)
  107. * instruction
  108. */
  109. #define CPACF_PCKMO_QUERY 0x00
  110. #define CPACF_PCKMO_ENC_DES_KEY 0x01
  111. #define CPACF_PCKMO_ENC_TDES_128_KEY 0x02
  112. #define CPACF_PCKMO_ENC_TDES_192_KEY 0x03
  113. #define CPACF_PCKMO_ENC_AES_128_KEY 0x12
  114. #define CPACF_PCKMO_ENC_AES_192_KEY 0x13
  115. #define CPACF_PCKMO_ENC_AES_256_KEY 0x14
  116. /*
  117. * Function codes for the PRNO (PERFORM RANDOM NUMBER OPERATION)
  118. * instruction
  119. */
  120. #define CPACF_PRNO_QUERY 0x00
  121. #define CPACF_PRNO_SHA512_DRNG_GEN 0x03
  122. #define CPACF_PRNO_SHA512_DRNG_SEED 0x83
  123. #define CPACF_PRNO_TRNG_Q_R2C_RATIO 0x70
  124. #define CPACF_PRNO_TRNG 0x72
  125. /*
  126. * Function codes for the KMA (CIPHER MESSAGE WITH AUTHENTICATION)
  127. * instruction
  128. */
  129. #define CPACF_KMA_QUERY 0x00
  130. #define CPACF_KMA_GCM_AES_128 0x12
  131. #define CPACF_KMA_GCM_AES_192 0x13
  132. #define CPACF_KMA_GCM_AES_256 0x14
  133. /*
  134. * Flags for the KMA (CIPHER MESSAGE WITH AUTHENTICATION) instruction
  135. */
  136. #define CPACF_KMA_LPC 0x100 /* Last-Plaintext/Ciphertext */
  137. #define CPACF_KMA_LAAD 0x200 /* Last-AAD */
  138. #define CPACF_KMA_HS 0x400 /* Hash-subkey Supplied */
  139. typedef struct { unsigned char bytes[16]; } cpacf_mask_t;
  140. /**
  141. * cpacf_query() - check if a specific CPACF function is available
  142. * @opcode: the opcode of the crypto instruction
  143. * @func: the function code to test for
  144. *
  145. * Executes the query function for the given crypto instruction @opcode
  146. * and checks if @func is available
  147. *
  148. * Returns 1 if @func is available for @opcode, 0 otherwise
  149. */
  150. static inline void __cpacf_query(unsigned int opcode, cpacf_mask_t *mask)
  151. {
  152. register unsigned long r0 asm("0") = 0; /* query function */
  153. register unsigned long r1 asm("1") = (unsigned long) mask;
  154. asm volatile(
  155. " spm 0\n" /* pckmo doesn't change the cc */
  156. /* Parameter regs are ignored, but must be nonzero and unique */
  157. "0: .insn rrf,%[opc] << 16,2,4,6,0\n"
  158. " brc 1,0b\n" /* handle partial completion */
  159. : "=m" (*mask)
  160. : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (opcode)
  161. : "cc");
  162. }
  163. static inline int __cpacf_check_opcode(unsigned int opcode)
  164. {
  165. switch (opcode) {
  166. case CPACF_KMAC:
  167. case CPACF_KM:
  168. case CPACF_KMC:
  169. case CPACF_KIMD:
  170. case CPACF_KLMD:
  171. return test_facility(17); /* check for MSA */
  172. case CPACF_PCKMO:
  173. return test_facility(76); /* check for MSA3 */
  174. case CPACF_KMF:
  175. case CPACF_KMO:
  176. case CPACF_PCC:
  177. case CPACF_KMCTR:
  178. return test_facility(77); /* check for MSA4 */
  179. case CPACF_PRNO:
  180. return test_facility(57); /* check for MSA5 */
  181. case CPACF_KMA:
  182. return test_facility(146); /* check for MSA8 */
  183. default:
  184. BUG();
  185. }
  186. }
  187. static inline int cpacf_query(unsigned int opcode, cpacf_mask_t *mask)
  188. {
  189. if (__cpacf_check_opcode(opcode)) {
  190. __cpacf_query(opcode, mask);
  191. return 1;
  192. }
  193. memset(mask, 0, sizeof(*mask));
  194. return 0;
  195. }
  196. static inline int cpacf_test_func(cpacf_mask_t *mask, unsigned int func)
  197. {
  198. return (mask->bytes[func >> 3] & (0x80 >> (func & 7))) != 0;
  199. }
  200. static inline int cpacf_query_func(unsigned int opcode, unsigned int func)
  201. {
  202. cpacf_mask_t mask;
  203. if (cpacf_query(opcode, &mask))
  204. return cpacf_test_func(&mask, func);
  205. return 0;
  206. }
  207. /**
  208. * cpacf_km() - executes the KM (CIPHER MESSAGE) instruction
  209. * @func: the function code passed to KM; see CPACF_KM_xxx defines
  210. * @param: address of parameter block; see POP for details on each func
  211. * @dest: address of destination memory area
  212. * @src: address of source memory area
  213. * @src_len: length of src operand in bytes
  214. *
  215. * Returns 0 for the query func, number of processed bytes for
  216. * encryption/decryption funcs
  217. */
  218. static inline int cpacf_km(unsigned long func, void *param,
  219. u8 *dest, const u8 *src, long src_len)
  220. {
  221. register unsigned long r0 asm("0") = (unsigned long) func;
  222. register unsigned long r1 asm("1") = (unsigned long) param;
  223. register unsigned long r2 asm("2") = (unsigned long) src;
  224. register unsigned long r3 asm("3") = (unsigned long) src_len;
  225. register unsigned long r4 asm("4") = (unsigned long) dest;
  226. asm volatile(
  227. "0: .insn rre,%[opc] << 16,%[dst],%[src]\n"
  228. " brc 1,0b\n" /* handle partial completion */
  229. : [src] "+a" (r2), [len] "+d" (r3), [dst] "+a" (r4)
  230. : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KM)
  231. : "cc", "memory");
  232. return src_len - r3;
  233. }
  234. /**
  235. * cpacf_kmc() - executes the KMC (CIPHER MESSAGE WITH CHAINING) instruction
  236. * @func: the function code passed to KM; see CPACF_KMC_xxx defines
  237. * @param: address of parameter block; see POP for details on each func
  238. * @dest: address of destination memory area
  239. * @src: address of source memory area
  240. * @src_len: length of src operand in bytes
  241. *
  242. * Returns 0 for the query func, number of processed bytes for
  243. * encryption/decryption funcs
  244. */
  245. static inline int cpacf_kmc(unsigned long func, void *param,
  246. u8 *dest, const u8 *src, long src_len)
  247. {
  248. register unsigned long r0 asm("0") = (unsigned long) func;
  249. register unsigned long r1 asm("1") = (unsigned long) param;
  250. register unsigned long r2 asm("2") = (unsigned long) src;
  251. register unsigned long r3 asm("3") = (unsigned long) src_len;
  252. register unsigned long r4 asm("4") = (unsigned long) dest;
  253. asm volatile(
  254. "0: .insn rre,%[opc] << 16,%[dst],%[src]\n"
  255. " brc 1,0b\n" /* handle partial completion */
  256. : [src] "+a" (r2), [len] "+d" (r3), [dst] "+a" (r4)
  257. : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KMC)
  258. : "cc", "memory");
  259. return src_len - r3;
  260. }
  261. /**
  262. * cpacf_kimd() - executes the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST)
  263. * instruction
  264. * @func: the function code passed to KM; see CPACF_KIMD_xxx defines
  265. * @param: address of parameter block; see POP for details on each func
  266. * @src: address of source memory area
  267. * @src_len: length of src operand in bytes
  268. */
  269. static inline void cpacf_kimd(unsigned long func, void *param,
  270. const u8 *src, long src_len)
  271. {
  272. register unsigned long r0 asm("0") = (unsigned long) func;
  273. register unsigned long r1 asm("1") = (unsigned long) param;
  274. register unsigned long r2 asm("2") = (unsigned long) src;
  275. register unsigned long r3 asm("3") = (unsigned long) src_len;
  276. asm volatile(
  277. "0: .insn rre,%[opc] << 16,0,%[src]\n"
  278. " brc 1,0b\n" /* handle partial completion */
  279. : [src] "+a" (r2), [len] "+d" (r3)
  280. : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KIMD)
  281. : "cc", "memory");
  282. }
  283. /**
  284. * cpacf_klmd() - executes the KLMD (COMPUTE LAST MESSAGE DIGEST) instruction
  285. * @func: the function code passed to KM; see CPACF_KLMD_xxx defines
  286. * @param: address of parameter block; see POP for details on each func
  287. * @src: address of source memory area
  288. * @src_len: length of src operand in bytes
  289. */
  290. static inline void cpacf_klmd(unsigned long func, void *param,
  291. const u8 *src, long src_len)
  292. {
  293. register unsigned long r0 asm("0") = (unsigned long) func;
  294. register unsigned long r1 asm("1") = (unsigned long) param;
  295. register unsigned long r2 asm("2") = (unsigned long) src;
  296. register unsigned long r3 asm("3") = (unsigned long) src_len;
  297. asm volatile(
  298. "0: .insn rre,%[opc] << 16,0,%[src]\n"
  299. " brc 1,0b\n" /* handle partial completion */
  300. : [src] "+a" (r2), [len] "+d" (r3)
  301. : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KLMD)
  302. : "cc", "memory");
  303. }
  304. /**
  305. * cpacf_kmac() - executes the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE)
  306. * instruction
  307. * @func: the function code passed to KM; see CPACF_KMAC_xxx defines
  308. * @param: address of parameter block; see POP for details on each func
  309. * @src: address of source memory area
  310. * @src_len: length of src operand in bytes
  311. *
  312. * Returns 0 for the query func, number of processed bytes for digest funcs
  313. */
  314. static inline int cpacf_kmac(unsigned long func, void *param,
  315. const u8 *src, long src_len)
  316. {
  317. register unsigned long r0 asm("0") = (unsigned long) func;
  318. register unsigned long r1 asm("1") = (unsigned long) param;
  319. register unsigned long r2 asm("2") = (unsigned long) src;
  320. register unsigned long r3 asm("3") = (unsigned long) src_len;
  321. asm volatile(
  322. "0: .insn rre,%[opc] << 16,0,%[src]\n"
  323. " brc 1,0b\n" /* handle partial completion */
  324. : [src] "+a" (r2), [len] "+d" (r3)
  325. : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KMAC)
  326. : "cc", "memory");
  327. return src_len - r3;
  328. }
  329. /**
  330. * cpacf_kmctr() - executes the KMCTR (CIPHER MESSAGE WITH COUNTER) instruction
  331. * @func: the function code passed to KMCTR; see CPACF_KMCTR_xxx defines
  332. * @param: address of parameter block; see POP for details on each func
  333. * @dest: address of destination memory area
  334. * @src: address of source memory area
  335. * @src_len: length of src operand in bytes
  336. * @counter: address of counter value
  337. *
  338. * Returns 0 for the query func, number of processed bytes for
  339. * encryption/decryption funcs
  340. */
  341. static inline int cpacf_kmctr(unsigned long func, void *param, u8 *dest,
  342. const u8 *src, long src_len, u8 *counter)
  343. {
  344. register unsigned long r0 asm("0") = (unsigned long) func;
  345. register unsigned long r1 asm("1") = (unsigned long) param;
  346. register unsigned long r2 asm("2") = (unsigned long) src;
  347. register unsigned long r3 asm("3") = (unsigned long) src_len;
  348. register unsigned long r4 asm("4") = (unsigned long) dest;
  349. register unsigned long r6 asm("6") = (unsigned long) counter;
  350. asm volatile(
  351. "0: .insn rrf,%[opc] << 16,%[dst],%[src],%[ctr],0\n"
  352. " brc 1,0b\n" /* handle partial completion */
  353. : [src] "+a" (r2), [len] "+d" (r3),
  354. [dst] "+a" (r4), [ctr] "+a" (r6)
  355. : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KMCTR)
  356. : "cc", "memory");
  357. return src_len - r3;
  358. }
  359. /**
  360. * cpacf_prno() - executes the PRNO (PERFORM RANDOM NUMBER OPERATION)
  361. * instruction
  362. * @func: the function code passed to PRNO; see CPACF_PRNO_xxx defines
  363. * @param: address of parameter block; see POP for details on each func
  364. * @dest: address of destination memory area
  365. * @dest_len: size of destination memory area in bytes
  366. * @seed: address of seed data
  367. * @seed_len: size of seed data in bytes
  368. */
  369. static inline void cpacf_prno(unsigned long func, void *param,
  370. u8 *dest, unsigned long dest_len,
  371. const u8 *seed, unsigned long seed_len)
  372. {
  373. register unsigned long r0 asm("0") = (unsigned long) func;
  374. register unsigned long r1 asm("1") = (unsigned long) param;
  375. register unsigned long r2 asm("2") = (unsigned long) dest;
  376. register unsigned long r3 asm("3") = (unsigned long) dest_len;
  377. register unsigned long r4 asm("4") = (unsigned long) seed;
  378. register unsigned long r5 asm("5") = (unsigned long) seed_len;
  379. asm volatile (
  380. "0: .insn rre,%[opc] << 16,%[dst],%[seed]\n"
  381. " brc 1,0b\n" /* handle partial completion */
  382. : [dst] "+a" (r2), [dlen] "+d" (r3)
  383. : [fc] "d" (r0), [pba] "a" (r1),
  384. [seed] "a" (r4), [slen] "d" (r5), [opc] "i" (CPACF_PRNO)
  385. : "cc", "memory");
  386. }
  387. /**
  388. * cpacf_trng() - executes the TRNG subfunction of the PRNO instruction
  389. * @ucbuf: buffer for unconditioned data
  390. * @ucbuf_len: amount of unconditioned data to fetch in bytes
  391. * @cbuf: buffer for conditioned data
  392. * @cbuf_len: amount of conditioned data to fetch in bytes
  393. */
  394. static inline void cpacf_trng(u8 *ucbuf, unsigned long ucbuf_len,
  395. u8 *cbuf, unsigned long cbuf_len)
  396. {
  397. register unsigned long r0 asm("0") = (unsigned long) CPACF_PRNO_TRNG;
  398. register unsigned long r2 asm("2") = (unsigned long) ucbuf;
  399. register unsigned long r3 asm("3") = (unsigned long) ucbuf_len;
  400. register unsigned long r4 asm("4") = (unsigned long) cbuf;
  401. register unsigned long r5 asm("5") = (unsigned long) cbuf_len;
  402. asm volatile (
  403. "0: .insn rre,%[opc] << 16,%[ucbuf],%[cbuf]\n"
  404. " brc 1,0b\n" /* handle partial completion */
  405. : [ucbuf] "+a" (r2), [ucbuflen] "+d" (r3),
  406. [cbuf] "+a" (r4), [cbuflen] "+d" (r5)
  407. : [fc] "d" (r0), [opc] "i" (CPACF_PRNO)
  408. : "cc", "memory");
  409. }
  410. /**
  411. * cpacf_pcc() - executes the PCC (PERFORM CRYPTOGRAPHIC COMPUTATION)
  412. * instruction
  413. * @func: the function code passed to PCC; see CPACF_KM_xxx defines
  414. * @param: address of parameter block; see POP for details on each func
  415. */
  416. static inline void cpacf_pcc(unsigned long func, void *param)
  417. {
  418. register unsigned long r0 asm("0") = (unsigned long) func;
  419. register unsigned long r1 asm("1") = (unsigned long) param;
  420. asm volatile(
  421. "0: .insn rre,%[opc] << 16,0,0\n" /* PCC opcode */
  422. " brc 1,0b\n" /* handle partial completion */
  423. :
  424. : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_PCC)
  425. : "cc", "memory");
  426. }
  427. /**
  428. * cpacf_pckmo() - executes the PCKMO (PERFORM CRYPTOGRAPHIC KEY
  429. * MANAGEMENT) instruction
  430. * @func: the function code passed to PCKMO; see CPACF_PCKMO_xxx defines
  431. * @param: address of parameter block; see POP for details on each func
  432. *
  433. * Returns 0.
  434. */
  435. static inline void cpacf_pckmo(long func, void *param)
  436. {
  437. register unsigned long r0 asm("0") = (unsigned long) func;
  438. register unsigned long r1 asm("1") = (unsigned long) param;
  439. asm volatile(
  440. " .insn rre,%[opc] << 16,0,0\n" /* PCKMO opcode */
  441. :
  442. : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_PCKMO)
  443. : "cc", "memory");
  444. }
  445. /**
  446. * cpacf_kma() - executes the KMA (CIPHER MESSAGE WITH AUTHENTICATION)
  447. * instruction
  448. * @func: the function code passed to KMA; see CPACF_KMA_xxx defines
  449. * @param: address of parameter block; see POP for details on each func
  450. * @dest: address of destination memory area
  451. * @src: address of source memory area
  452. * @src_len: length of src operand in bytes
  453. * @aad: address of additional authenticated data memory area
  454. * @aad_len: length of aad operand in bytes
  455. */
  456. static inline void cpacf_kma(unsigned long func, void *param, u8 *dest,
  457. const u8 *src, unsigned long src_len,
  458. const u8 *aad, unsigned long aad_len)
  459. {
  460. register unsigned long r0 asm("0") = (unsigned long) func;
  461. register unsigned long r1 asm("1") = (unsigned long) param;
  462. register unsigned long r2 asm("2") = (unsigned long) src;
  463. register unsigned long r3 asm("3") = (unsigned long) src_len;
  464. register unsigned long r4 asm("4") = (unsigned long) aad;
  465. register unsigned long r5 asm("5") = (unsigned long) aad_len;
  466. register unsigned long r6 asm("6") = (unsigned long) dest;
  467. asm volatile(
  468. "0: .insn rrf,%[opc] << 16,%[dst],%[src],%[aad],0\n"
  469. " brc 1,0b\n" /* handle partial completion */
  470. : [dst] "+a" (r6), [src] "+a" (r2), [slen] "+d" (r3),
  471. [aad] "+a" (r4), [alen] "+d" (r5)
  472. : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KMA)
  473. : "cc", "memory");
  474. }
  475. #endif /* _ASM_S390_CPACF_H */