~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/s390/include/asm/cpacf.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/s390/include/asm/cpacf.h (Architecture alpha) and /arch/ppc/include/asm-ppc/cpacf.h (Architecture ppc)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2 /*                                                
  3  * CP Assist for Cryptographic Functions (CPAC    
  4  *                                                
  5  * Copyright IBM Corp. 2003, 2023                 
  6  * Author(s): Thomas Spatzier                     
  7  *            Jan Glauber                         
  8  *            Harald Freudenberger (freude@de.    
  9  *            Martin Schwidefsky <schwidefsky@    
 10  */                                               
 11 #ifndef _ASM_S390_CPACF_H                         
 12 #define _ASM_S390_CPACF_H                         
 13                                                   
 14 #include <asm/facility.h>                         
 15 #include <linux/kmsan-checks.h>                   
 16                                                   
 17 /*                                                
 18  * Instruction opcodes for the CPACF instructi    
 19  */                                               
 20 #define CPACF_KMAC              0xb91e            
 21 #define CPACF_KM                0xb92e            
 22 #define CPACF_KMC               0xb92f            
 23 #define CPACF_KIMD              0xb93e            
 24 #define CPACF_KLMD              0xb93f            
 25 #define CPACF_PCKMO             0xb928            
 26 #define CPACF_KMF               0xb92a            
 27 #define CPACF_KMO               0xb92b            
 28 #define CPACF_PCC               0xb92c            
 29 #define CPACF_KMCTR             0xb92d            
 30 #define CPACF_PRNO              0xb93c            
 31 #define CPACF_KMA               0xb929            
 32 #define CPACF_KDSA              0xb93a            
 33                                                   
 34 /*                                                
 35  * En/decryption modifier bits                    
 36  */                                               
 37 #define CPACF_ENCRYPT           0x00              
 38 #define CPACF_DECRYPT           0x80              
 39                                                   
 40 /*                                                
 41  * Function codes for the KM (CIPHER MESSAGE)     
 42  */                                               
 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                                                   
 60 /*                                                
 61  * Function codes for the KMC (CIPHER MESSAGE     
 62  * instruction                                    
 63  */                                               
 64 #define CPACF_KMC_QUERY         0x00              
 65 #define CPACF_KMC_DEA           0x01              
 66 #define CPACF_KMC_TDEA_128      0x02              
 67 #define CPACF_KMC_TDEA_192      0x03              
 68 #define CPACF_KMC_AES_128       0x12              
 69 #define CPACF_KMC_AES_192       0x13              
 70 #define CPACF_KMC_AES_256       0x14              
 71 #define CPACF_KMC_PAES_128      0x1a              
 72 #define CPACF_KMC_PAES_192      0x1b              
 73 #define CPACF_KMC_PAES_256      0x1c              
 74 #define CPACF_KMC_PRNG          0x43              
 75                                                   
 76 /*                                                
 77  * Function codes for the KMCTR (CIPHER MESSAG    
 78  * instruction                                    
 79  */                                               
 80 #define CPACF_KMCTR_QUERY       0x00              
 81 #define CPACF_KMCTR_DEA         0x01              
 82 #define CPACF_KMCTR_TDEA_128    0x02              
 83 #define CPACF_KMCTR_TDEA_192    0x03              
 84 #define CPACF_KMCTR_AES_128     0x12              
 85 #define CPACF_KMCTR_AES_192     0x13              
 86 #define CPACF_KMCTR_AES_256     0x14              
 87 #define CPACF_KMCTR_PAES_128    0x1a              
 88 #define CPACF_KMCTR_PAES_192    0x1b              
 89 #define CPACF_KMCTR_PAES_256    0x1c              
 90                                                   
 91 /*                                                
 92  * Function codes for the KIMD (COMPUTE INTERM    
 93  * instruction                                    
 94  */                                               
 95 #define CPACF_KIMD_QUERY        0x00              
 96 #define CPACF_KIMD_SHA_1        0x01              
 97 #define CPACF_KIMD_SHA_256      0x02              
 98 #define CPACF_KIMD_SHA_512      0x03              
 99 #define CPACF_KIMD_SHA3_224     0x20              
100 #define CPACF_KIMD_SHA3_256     0x21              
101 #define CPACF_KIMD_SHA3_384     0x22              
102 #define CPACF_KIMD_SHA3_512     0x23              
103 #define CPACF_KIMD_GHASH        0x41              
104                                                   
105 /*                                                
106  * Function codes for the KLMD (COMPUTE LAST M    
107  * instruction                                    
108  */                                               
109 #define CPACF_KLMD_QUERY        0x00              
110 #define CPACF_KLMD_SHA_1        0x01              
111 #define CPACF_KLMD_SHA_256      0x02              
112 #define CPACF_KLMD_SHA_512      0x03              
113 #define CPACF_KLMD_SHA3_224     0x20              
114 #define CPACF_KLMD_SHA3_256     0x21              
115 #define CPACF_KLMD_SHA3_384     0x22              
116 #define CPACF_KLMD_SHA3_512     0x23              
117                                                   
118 /*                                                
119  * function codes for the KMAC (COMPUTE MESSAG    
120  * instruction                                    
121  */                                               
122 #define CPACF_KMAC_QUERY        0x00              
123 #define CPACF_KMAC_DEA          0x01              
124 #define CPACF_KMAC_TDEA_128     0x02              
125 #define CPACF_KMAC_TDEA_192     0x03              
126 #define CPACF_KMAC_HMAC_SHA_224 0x70              
127 #define CPACF_KMAC_HMAC_SHA_256 0x71              
128 #define CPACF_KMAC_HMAC_SHA_384 0x72              
129 #define CPACF_KMAC_HMAC_SHA_512 0x73              
130                                                   
131 /*                                                
132  * Function codes for the PCKMO (PERFORM CRYPT    
133  * instruction                                    
134  */                                               
135 #define CPACF_PCKMO_QUERY                         
136 #define CPACF_PCKMO_ENC_DES_KEY                   
137 #define CPACF_PCKMO_ENC_TDES_128_KEY              
138 #define CPACF_PCKMO_ENC_TDES_192_KEY              
139 #define CPACF_PCKMO_ENC_AES_128_KEY               
140 #define CPACF_PCKMO_ENC_AES_192_KEY               
141 #define CPACF_PCKMO_ENC_AES_256_KEY               
142 #define CPACF_PCKMO_ENC_AES_XTS_128_DOUBLE_KEY    
143 #define CPACF_PCKMO_ENC_AES_XTS_256_DOUBLE_KEY    
144 #define CPACF_PCKMO_ENC_ECC_P256_KEY              
145 #define CPACF_PCKMO_ENC_ECC_P384_KEY              
146 #define CPACF_PCKMO_ENC_ECC_P521_KEY              
147 #define CPACF_PCKMO_ENC_ECC_ED25519_KEY           
148 #define CPACF_PCKMO_ENC_ECC_ED448_KEY             
149 #define CPACF_PCKMO_ENC_HMAC_512_KEY              
150 #define CPACF_PCKMO_ENC_HMAC_1024_KEY             
151                                                   
152 /*                                                
153  * Function codes for the PRNO (PERFORM RANDOM    
154  * instruction                                    
155  */                                               
156 #define CPACF_PRNO_QUERY                0x00      
157 #define CPACF_PRNO_SHA512_DRNG_GEN      0x03      
158 #define CPACF_PRNO_SHA512_DRNG_SEED     0x83      
159 #define CPACF_PRNO_TRNG_Q_R2C_RATIO     0x70      
160 #define CPACF_PRNO_TRNG                 0x72      
161                                                   
162 /*                                                
163  * Function codes for the KMA (CIPHER MESSAGE     
164  * instruction                                    
165  */                                               
166 #define CPACF_KMA_QUERY         0x00              
167 #define CPACF_KMA_GCM_AES_128   0x12              
168 #define CPACF_KMA_GCM_AES_192   0x13              
169 #define CPACF_KMA_GCM_AES_256   0x14              
170                                                   
171 /*                                                
172  * Flags for the KMA (CIPHER MESSAGE WITH AUTH    
173  */                                               
174 #define CPACF_KMA_LPC   0x100   /* Last-Plaint    
175 #define CPACF_KMA_LAAD  0x200   /* Last-AAD */    
176 #define CPACF_KMA_HS    0x400   /* Hash-subkey    
177                                                   
178 /*                                                
179  * Flags for the KIMD/KLMD (COMPUTE INTERMEDIA    
180  * instructions                                   
181  */                                               
182 #define CPACF_KIMD_NIP          0x8000            
183 #define CPACF_KLMD_DUFOP        0x4000            
184 #define CPACF_KLMD_NIP          0x8000            
185                                                   
186 /*                                                
187  * Function codes for KDSA (COMPUTE DIGITAL SI    
188  * instruction                                    
189  */                                               
190 #define CPACF_KDSA_QUERY 0x00                     
191 #define CPACF_KDSA_ECDSA_VERIFY_P256 0x01         
192 #define CPACF_KDSA_ECDSA_VERIFY_P384 0x02         
193 #define CPACF_KDSA_ECDSA_VERIFY_P521 0x03         
194 #define CPACF_KDSA_ECDSA_SIGN_P256 0x09           
195 #define CPACF_KDSA_ECDSA_SIGN_P384 0x0a           
196 #define CPACF_KDSA_ECDSA_SIGN_P521 0x0b           
197 #define CPACF_KDSA_ENC_ECDSA_SIGN_P256 0x11       
198 #define CPACF_KDSA_ENC_ECDSA_SIGN_P384 0x12       
199 #define CPACF_KDSA_ENC_ECDSA_SIGN_P521 0x13       
200 #define CPACF_KDSA_EDDSA_VERIFY_ED25519 0x20      
201 #define CPACF_KDSA_EDDSA_VERIFY_ED448 0x24        
202 #define CPACF_KDSA_EDDSA_SIGN_ED25519 0x28        
203 #define CPACF_KDSA_EDDSA_SIGN_ED448 0x2c          
204 #define CPACF_KDSA_ENC_EDDSA_SIGN_ED25519 0x30    
205 #define CPACF_KDSA_ENC_EDDSA_SIGN_ED448 0x34      
206                                                   
207 #define CPACF_FC_QUERY 0x00                       
208 #define CPACF_FC_QUERY_AUTH_INFO 0x7F             
209                                                   
210 typedef struct { unsigned char bytes[16]; } cp    
211 typedef struct { unsigned char bytes[256]; } c    
212                                                   
213 /*                                                
214  * Prototype for a not existing function to pr    
215  * error if __cpacf_query() or __cpacf_check_o    
216  * with an invalid compile time const opcode.     
217  */                                               
218 void __cpacf_bad_opcode(void);                    
219                                                   
220 static __always_inline void __cpacf_query_rre(    
221                                                   
222 {                                                 
223         asm volatile(                             
224                 "       la      %%r1,%[pb]\n"     
225                 "       lghi    %%r0,%[fc]\n"     
226                 "       .insn   rre,%[opc] <<     
227                 : [pb] "=R" (*pb)                 
228                 : [opc] "i" (opc), [fc] "i" (f    
229                   [r1] "i" (r1), [r2] "i" (r2)    
230                 : "cc", "memory", "r0", "r1");    
231 }                                                 
232                                                   
233 static __always_inline void __cpacf_query_rrf(    
234                                                   
235 {                                                 
236         asm volatile(                             
237                 "       la      %%r1,%[pb]\n"     
238                 "       lghi    %%r0,%[fc]\n"     
239                 "       .insn   rrf,%[opc] <<     
240                 : [pb] "=R" (*pb)                 
241                 : [opc] "i" (opc), [fc] "i" (f    
242                   [r2] "i" (r2), [r3] "i" (r3)    
243                 : "cc", "memory", "r0", "r1");    
244 }                                                 
245                                                   
246 static __always_inline void __cpacf_query_insn    
247                                                   
248 {                                                 
249         switch (opcode) {                         
250         case CPACF_KDSA:                          
251                 __cpacf_query_rre(CPACF_KDSA,     
252                 break;                            
253         case CPACF_KIMD:                          
254                 __cpacf_query_rre(CPACF_KIMD,     
255                 break;                            
256         case CPACF_KLMD:                          
257                 __cpacf_query_rre(CPACF_KLMD,     
258                 break;                            
259         case CPACF_KM:                            
260                 __cpacf_query_rre(CPACF_KM, 2,    
261                 break;                            
262         case CPACF_KMA:                           
263                 __cpacf_query_rrf(CPACF_KMA, 2    
264                 break;                            
265         case CPACF_KMAC:                          
266                 __cpacf_query_rre(CPACF_KMAC,     
267                 break;                            
268         case CPACF_KMC:                           
269                 __cpacf_query_rre(CPACF_KMC, 2    
270                 break;                            
271         case CPACF_KMCTR:                         
272                 __cpacf_query_rrf(CPACF_KMCTR,    
273                 break;                            
274         case CPACF_KMF:                           
275                 __cpacf_query_rre(CPACF_KMF, 2    
276                 break;                            
277         case CPACF_KMO:                           
278                 __cpacf_query_rre(CPACF_KMO, 2    
279                 break;                            
280         case CPACF_PCC:                           
281                 __cpacf_query_rre(CPACF_PCC, 0    
282                 break;                            
283         case CPACF_PCKMO:                         
284                 __cpacf_query_rre(CPACF_PCKMO,    
285                 break;                            
286         case CPACF_PRNO:                          
287                 __cpacf_query_rre(CPACF_PRNO,     
288                 break;                            
289         default:                                  
290                 __cpacf_bad_opcode();             
291         }                                         
292 }                                                 
293                                                   
294 static __always_inline void __cpacf_query(unsi    
295                                           cpac    
296 {                                                 
297         __cpacf_query_insn(opcode, mask, CPACF    
298 }                                                 
299                                                   
300 static __always_inline int __cpacf_check_opcod    
301 {                                                 
302         switch (opcode) {                         
303         case CPACF_KMAC:                          
304         case CPACF_KM:                            
305         case CPACF_KMC:                           
306         case CPACF_KIMD:                          
307         case CPACF_KLMD:                          
308                 return test_facility(17);         
309         case CPACF_PCKMO:                         
310                 return test_facility(76);         
311         case CPACF_KMF:                           
312         case CPACF_KMO:                           
313         case CPACF_PCC:                           
314         case CPACF_KMCTR:                         
315                 return test_facility(77);         
316         case CPACF_PRNO:                          
317                 return test_facility(57);         
318         case CPACF_KMA:                           
319                 return test_facility(146);        
320         case CPACF_KDSA:                          
321                 return test_facility(155);        
322         default:                                  
323                 __cpacf_bad_opcode();             
324                 return 0;                         
325         }                                         
326 }                                                 
327                                                   
328 /**                                               
329  * cpacf_query() - Query the function code mas    
330  * @opcode: the opcode of the crypto instructi    
331  * @mask: ptr to struct cpacf_mask_t              
332  *                                                
333  * Executes the query function for the given c    
334  * and checks if @func is available               
335  *                                                
336  * On success 1 is returned and the mask is fi    
337  * code mask for this CPACF opcode, otherwise     
338  */                                               
339 static __always_inline int cpacf_query(unsigne    
340 {                                                 
341         if (__cpacf_check_opcode(opcode)) {       
342                 __cpacf_query(opcode, mask);      
343                 return 1;                         
344         }                                         
345         memset(mask, 0, sizeof(*mask));           
346         return 0;                                 
347 }                                                 
348                                                   
349 static inline int cpacf_test_func(cpacf_mask_t    
350 {                                                 
351         return (mask->bytes[func >> 3] & (0x80    
352 }                                                 
353                                                   
354 static __always_inline int cpacf_query_func(un    
355                                             un    
356 {                                                 
357         cpacf_mask_t mask;                        
358                                                   
359         if (cpacf_query(opcode, &mask))           
360                 return cpacf_test_func(&mask,     
361         return 0;                                 
362 }                                                 
363                                                   
364 static __always_inline void __cpacf_qai(unsign    
365 {                                                 
366         __cpacf_query_insn(opcode, qai, CPACF_    
367 }                                                 
368                                                   
369 /**                                               
370  * cpacf_qai() - Get the query authentication     
371  * @opcode: the opcode of the crypto instructi    
372  * @mask: ptr to struct cpacf_qai_t               
373  *                                                
374  * Executes the query authentication informati    
375  * instruction @opcode and checks if @func is     
376  *                                                
377  * On success 1 is returned and the mask is fi    
378  * information for this CPACF opcode, otherwis    
379  */                                               
380 static __always_inline int cpacf_qai(unsigned     
381 {                                                 
382         if (cpacf_query_func(opcode, CPACF_FC_    
383                 __cpacf_qai(opcode, qai);         
384                 return 1;                         
385         }                                         
386         memset(qai, 0, sizeof(*qai));             
387         return 0;                                 
388 }                                                 
389                                                   
390 /**                                               
391  * cpacf_km() - executes the KM (CIPHER MESSAG    
392  * @func: the function code passed to KM; see     
393  * @param: address of parameter block; see POP    
394  * @dest: address of destination memory area      
395  * @src: address of source memory area            
396  * @src_len: length of src operand in bytes       
397  *                                                
398  * Returns 0 for the query func, number of pro    
399  * encryption/decryption funcs                    
400  */                                               
401 static inline int cpacf_km(unsigned long func,    
402                            u8 *dest, const u8     
403 {                                                 
404         union register_pair d, s;                 
405                                                   
406         d.even = (unsigned long)dest;             
407         s.even = (unsigned long)src;              
408         s.odd  = (unsigned long)src_len;          
409         asm volatile(                             
410                 "       lgr     0,%[fc]\n"        
411                 "       lgr     1,%[pba]\n"       
412                 "0:     .insn   rre,%[opc] <<     
413                 "       brc     1,0b\n" /* han    
414                 : [src] "+&d" (s.pair), [dst]     
415                 : [fc] "d" (func), [pba] "d" (    
416                   [opc] "i" (CPACF_KM)            
417                 : "cc", "memory", "", "1");       
418                                                   
419         return src_len - s.odd;                   
420 }                                                 
421                                                   
422 /**                                               
423  * cpacf_kmc() - executes the KMC (CIPHER MESS    
424  * @func: the function code passed to KM; see     
425  * @param: address of parameter block; see POP    
426  * @dest: address of destination memory area      
427  * @src: address of source memory area            
428  * @src_len: length of src operand in bytes       
429  *                                                
430  * Returns 0 for the query func, number of pro    
431  * encryption/decryption funcs                    
432  */                                               
433 static inline int cpacf_kmc(unsigned long func    
434                             u8 *dest, const u8    
435 {                                                 
436         union register_pair d, s;                 
437                                                   
438         d.even = (unsigned long)dest;             
439         s.even = (unsigned long)src;              
440         s.odd  = (unsigned long)src_len;          
441         asm volatile(                             
442                 "       lgr     0,%[fc]\n"        
443                 "       lgr     1,%[pba]\n"       
444                 "0:     .insn   rre,%[opc] <<     
445                 "       brc     1,0b\n" /* han    
446                 : [src] "+&d" (s.pair), [dst]     
447                 : [fc] "d" (func), [pba] "d" (    
448                   [opc] "i" (CPACF_KMC)           
449                 : "cc", "memory", "", "1");       
450                                                   
451         return src_len - s.odd;                   
452 }                                                 
453                                                   
454 /**                                               
455  * cpacf_kimd() - executes the KIMD (COMPUTE I    
456  *                instruction                     
457  * @func: the function code passed to KM; see     
458  * @param: address of parameter block; see POP    
459  * @src: address of source memory area            
460  * @src_len: length of src operand in bytes       
461  */                                               
462 static inline void cpacf_kimd(unsigned long fu    
463                               const u8 *src, l    
464 {                                                 
465         union register_pair s;                    
466                                                   
467         s.even = (unsigned long)src;              
468         s.odd  = (unsigned long)src_len;          
469         asm volatile(                             
470                 "       lgr     0,%[fc]\n"        
471                 "       lgr     1,%[pba]\n"       
472                 "0:     .insn   rrf,%[opc] <<     
473                 "       brc     1,0b\n" /* han    
474                 : [src] "+&d" (s.pair)            
475                 : [fc] "d" (func), [pba] "d" (    
476                   [opc] "i" (CPACF_KIMD)          
477                 : "cc", "memory", "", "1");       
478 }                                                 
479                                                   
480 /**                                               
481  * cpacf_klmd() - executes the KLMD (COMPUTE L    
482  * @func: the function code passed to KM; see     
483  * @param: address of parameter block; see POP    
484  * @src: address of source memory area            
485  * @src_len: length of src operand in bytes       
486  */                                               
487 static inline void cpacf_klmd(unsigned long fu    
488                               const u8 *src, l    
489 {                                                 
490         union register_pair s;                    
491                                                   
492         s.even = (unsigned long)src;              
493         s.odd  = (unsigned long)src_len;          
494         asm volatile(                             
495                 "       lgr     0,%[fc]\n"        
496                 "       lgr     1,%[pba]\n"       
497                 "0:     .insn   rrf,%[opc] <<     
498                 "       brc     1,0b\n" /* han    
499                 : [src] "+&d" (s.pair)            
500                 : [fc] "d" (func), [pba] "d" (    
501                   [opc] "i" (CPACF_KLMD)          
502                 : "cc", "memory", "", "1");       
503 }                                                 
504                                                   
505 /**                                               
506  * _cpacf_kmac() - executes the KMAC (COMPUTE     
507  * instruction and updates flags in gr0           
508  * @gr0: pointer to gr0 (fc and flags) passed     
509  * @param: address of parameter block; see POP    
510  * @src: address of source memory area            
511  * @src_len: length of src operand in bytes       
512  *                                                
513  * Returns 0 for the query func, number of pro    
514  */                                               
515 static inline int _cpacf_kmac(unsigned long *g    
516                               const u8 *src, l    
517 {                                                 
518         union register_pair s;                    
519                                                   
520         s.even = (unsigned long)src;              
521         s.odd  = (unsigned long)src_len;          
522         asm volatile(                             
523                 "       lgr     0,%[r0]\n"        
524                 "       lgr     1,%[pba]\n"       
525                 "0:     .insn   rre,%[opc] <<     
526                 "       brc     1,0b\n" /* han    
527                 "       lgr     %[r0],0\n"        
528                 : [r0] "+d" (*gr0), [src] "+&d    
529                 : [pba] "d" ((unsigned long)pa    
530                   [opc] "i" (CPACF_KMAC)          
531                 : "cc", "memory", "", "1");       
532                                                   
533         return src_len - s.odd;                   
534 }                                                 
535                                                   
536 /**                                               
537  * cpacf_kmac() - executes the KMAC (COMPUTE M    
538  * instruction                                    
539  * @func: function code passed to KMAC; see CP    
540  * @param: address of parameter block; see POP    
541  * @src: address of source memory area            
542  * @src_len: length of src operand in bytes       
543  *                                                
544  * Returns 0 for the query func, number of pro    
545  */                                               
546 static inline int cpacf_kmac(unsigned long fun    
547                              const u8 *src, lo    
548 {                                                 
549         return _cpacf_kmac(&func, param, src,     
550 }                                                 
551                                                   
552 /**                                               
553  * cpacf_kmctr() - executes the KMCTR (CIPHER     
554  * @func: the function code passed to KMCTR; s    
555  * @param: address of parameter block; see POP    
556  * @dest: address of destination memory area      
557  * @src: address of source memory area            
558  * @src_len: length of src operand in bytes       
559  * @counter: address of counter value             
560  *                                                
561  * Returns 0 for the query func, number of pro    
562  * encryption/decryption funcs                    
563  */                                               
564 static inline int cpacf_kmctr(unsigned long fu    
565                               const u8 *src, l    
566 {                                                 
567         union register_pair d, s, c;              
568                                                   
569         d.even = (unsigned long)dest;             
570         s.even = (unsigned long)src;              
571         s.odd  = (unsigned long)src_len;          
572         c.even = (unsigned long)counter;          
573         asm volatile(                             
574                 "       lgr     0,%[fc]\n"        
575                 "       lgr     1,%[pba]\n"       
576                 "0:     .insn   rrf,%[opc] <<     
577                 "       brc     1,0b\n" /* han    
578                 : [src] "+&d" (s.pair), [dst]     
579                   [ctr] "+&d" (c.pair)            
580                 : [fc] "d" (func), [pba] "d" (    
581                   [opc] "i" (CPACF_KMCTR)         
582                 : "cc", "memory", "", "1");       
583                                                   
584         return src_len - s.odd;                   
585 }                                                 
586                                                   
587 /**                                               
588  * cpacf_prno() - executes the PRNO (PERFORM R    
589  *                instruction                     
590  * @func: the function code passed to PRNO; se    
591  * @param: address of parameter block; see POP    
592  * @dest: address of destination memory area      
593  * @dest_len: size of destination memory area     
594  * @seed: address of seed data                    
595  * @seed_len: size of seed data in bytes          
596  */                                               
597 static inline void cpacf_prno(unsigned long fu    
598                               u8 *dest, unsign    
599                               const u8 *seed,     
600 {                                                 
601         union register_pair d, s;                 
602                                                   
603         d.even = (unsigned long)dest;             
604         d.odd  = (unsigned long)dest_len;         
605         s.even = (unsigned long)seed;             
606         s.odd  = (unsigned long)seed_len;         
607         asm volatile (                            
608                 "       lgr     0,%[fc]\n"        
609                 "       lgr     1,%[pba]\n"       
610                 "0:     .insn   rre,%[opc] <<     
611                 "       brc     1,0b\n"   /* h    
612                 : [dst] "+&d" (d.pair)            
613                 : [fc] "d" (func), [pba] "d" (    
614                   [seed] "d" (s.pair), [opc] "    
615                 : "cc", "memory", "", "1");       
616 }                                                 
617                                                   
618 /**                                               
619  * cpacf_trng() - executes the TRNG subfunctio    
620  * @ucbuf: buffer for unconditioned data          
621  * @ucbuf_len: amount of unconditioned data to    
622  * @cbuf: buffer for conditioned data             
623  * @cbuf_len: amount of conditioned data to fe    
624  */                                               
625 static inline void cpacf_trng(u8 *ucbuf, unsig    
626                               u8 *cbuf, unsign    
627 {                                                 
628         union register_pair u, c;                 
629                                                   
630         u.even = (unsigned long)ucbuf;            
631         u.odd  = (unsigned long)ucbuf_len;        
632         c.even = (unsigned long)cbuf;             
633         c.odd  = (unsigned long)cbuf_len;         
634         asm volatile (                            
635                 "       lghi    0,%[fc]\n"        
636                 "0:     .insn   rre,%[opc] <<     
637                 "       brc     1,0b\n"   /* h    
638                 : [ucbuf] "+&d" (u.pair), [cbu    
639                 : [fc] "K" (CPACF_PRNO_TRNG),     
640                 : "cc", "memory", "");            
641         kmsan_unpoison_memory(ucbuf, ucbuf_len    
642         kmsan_unpoison_memory(cbuf, cbuf_len);    
643 }                                                 
644                                                   
645 /**                                               
646  * cpacf_pcc() - executes the PCC (PERFORM CRY    
647  *               instruction                      
648  * @func: the function code passed to PCC; see    
649  * @param: address of parameter block; see POP    
650  */                                               
651 static inline void cpacf_pcc(unsigned long fun    
652 {                                                 
653         asm volatile(                             
654                 "       lgr     0,%[fc]\n"        
655                 "       lgr     1,%[pba]\n"       
656                 "0:     .insn   rre,%[opc] <<     
657                 "       brc     1,0b\n" /* han    
658                 :                                 
659                 : [fc] "d" (func), [pba] "d" (    
660                   [opc] "i" (CPACF_PCC)           
661                 : "cc", "memory", "", "1");       
662 }                                                 
663                                                   
664 /**                                               
665  * cpacf_pckmo() - executes the PCKMO (PERFORM    
666  *                MANAGEMENT) instruction         
667  * @func: the function code passed to PCKMO; s    
668  * @param: address of parameter block; see POP    
669  *                                                
670  * Returns 0.                                     
671  */                                               
672 static inline void cpacf_pckmo(long func, void    
673 {                                                 
674         asm volatile(                             
675                 "       lgr     0,%[fc]\n"        
676                 "       lgr     1,%[pba]\n"       
677                 "       .insn   rre,%[opc] <<     
678                 :                                 
679                 : [fc] "d" (func), [pba] "d" (    
680                   [opc] "i" (CPACF_PCKMO)         
681                 : "cc", "memory", "", "1");       
682 }                                                 
683                                                   
684 /**                                               
685  * cpacf_kma() - executes the KMA (CIPHER MESS    
686  *               instruction                      
687  * @func: the function code passed to KMA; see    
688  * @param: address of parameter block; see POP    
689  * @dest: address of destination memory area      
690  * @src: address of source memory area            
691  * @src_len: length of src operand in bytes       
692  * @aad: address of additional authenticated d    
693  * @aad_len: length of aad operand in bytes       
694  */                                               
695 static inline void cpacf_kma(unsigned long fun    
696                              const u8 *src, un    
697                              const u8 *aad, un    
698 {                                                 
699         union register_pair d, s, a;              
700                                                   
701         d.even = (unsigned long)dest;             
702         s.even = (unsigned long)src;              
703         s.odd  = (unsigned long)src_len;          
704         a.even = (unsigned long)aad;              
705         a.odd  = (unsigned long)aad_len;          
706         asm volatile(                             
707                 "       lgr     0,%[fc]\n"        
708                 "       lgr     1,%[pba]\n"       
709                 "0:     .insn   rrf,%[opc] <<     
710                 "       brc     1,0b\n" /* han    
711                 : [dst] "+&d" (d.pair), [src]     
712                   [aad] "+&d" (a.pair)            
713                 : [fc] "d" (func), [pba] "d" (    
714                   [opc] "i" (CPACF_KMA)           
715                 : "cc", "memory", "", "1");       
716 }                                                 
717                                                   
718 #endif  /* _ASM_S390_CPACF_H */                   
719                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php