Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/crypto: Renaming PPNO to PRNO.

The PPNO (Perform Pseudorandom Number Operation) instruction
has been renamed to PRNO (Perform Random Number Operation).
To avoid confusion and conflicts with future extensions with
this instruction (like e.g. provide a true random number
generator) this patch renames all occurences in cpacf.h and
adjusts the only exploiter code which is the prng device
driver and one line in the s390 kvm feature check.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Harald Freudenberger and committed by
Martin Schwidefsky
985a9d20 1366def3

+32 -32
+21 -21
arch/s390/crypto/prng.c
··· 81 81 u64 byte_counter; 82 82 }; 83 83 84 - struct ppno_ws_s { 84 + struct prno_ws_s { 85 85 u32 res; 86 86 u32 reseed_counter; 87 87 u64 stream_bytes; ··· 93 93 struct mutex mutex; 94 94 union { 95 95 struct prng_ws_s prngws; 96 - struct ppno_ws_s ppnows; 96 + struct prno_ws_s prnows; 97 97 }; 98 98 u8 *buf; 99 99 u32 rest; ··· 306 306 0x36, 0x8c, 0x5a, 0x9f, 0x7a, 0x4b, 0x3e, 0xe2 }; 307 307 308 308 u8 buf[sizeof(random)]; 309 - struct ppno_ws_s ws; 309 + struct prno_ws_s ws; 310 310 311 311 memset(&ws, 0, sizeof(ws)); 312 312 313 313 /* initial seed */ 314 - cpacf_ppno(CPACF_PPNO_SHA512_DRNG_SEED, 314 + cpacf_prno(CPACF_PRNO_SHA512_DRNG_SEED, 315 315 &ws, NULL, 0, seed, sizeof(seed)); 316 316 317 317 /* check working states V and C */ ··· 324 324 } 325 325 326 326 /* generate random bytes */ 327 - cpacf_ppno(CPACF_PPNO_SHA512_DRNG_GEN, 327 + cpacf_prno(CPACF_PRNO_SHA512_DRNG_GEN, 328 328 &ws, buf, sizeof(buf), NULL, 0); 329 - cpacf_ppno(CPACF_PPNO_SHA512_DRNG_GEN, 329 + cpacf_prno(CPACF_PRNO_SHA512_DRNG_GEN, 330 330 &ws, buf, sizeof(buf), NULL, 0); 331 331 332 332 /* check against expected data */ ··· 374 374 /* followed by 16 bytes of unique nonce */ 375 375 get_tod_clock_ext(seed + 64 + 32); 376 376 377 - /* initial seed of the ppno drng */ 378 - cpacf_ppno(CPACF_PPNO_SHA512_DRNG_SEED, 379 - &prng_data->ppnows, NULL, 0, seed, sizeof(seed)); 377 + /* initial seed of the prno drng */ 378 + cpacf_prno(CPACF_PRNO_SHA512_DRNG_SEED, 379 + &prng_data->prnows, NULL, 0, seed, sizeof(seed)); 380 380 381 381 /* if fips mode is enabled, generate a first block of random 382 382 bytes for the FIPS 140-2 Conditional Self Test */ 383 383 if (fips_enabled) { 384 384 prng_data->prev = prng_data->buf + prng_chunk_size; 385 - cpacf_ppno(CPACF_PPNO_SHA512_DRNG_GEN, 386 - &prng_data->ppnows, 385 + cpacf_prno(CPACF_PRNO_SHA512_DRNG_GEN, 386 + &prng_data->prnows, 387 387 prng_data->prev, prng_chunk_size, NULL, 0); 388 388 } 389 389 ··· 412 412 if (ret != sizeof(seed)) 413 413 return ret; 414 414 415 - /* do a reseed of the ppno drng with this bytestring */ 416 - cpacf_ppno(CPACF_PPNO_SHA512_DRNG_SEED, 417 - &prng_data->ppnows, NULL, 0, seed, sizeof(seed)); 415 + /* do a reseed of the prno drng with this bytestring */ 416 + cpacf_prno(CPACF_PRNO_SHA512_DRNG_SEED, 417 + &prng_data->prnows, NULL, 0, seed, sizeof(seed)); 418 418 419 419 return 0; 420 420 } ··· 425 425 int ret; 426 426 427 427 /* reseed needed ? */ 428 - if (prng_data->ppnows.reseed_counter > prng_reseed_limit) { 428 + if (prng_data->prnows.reseed_counter > prng_reseed_limit) { 429 429 ret = prng_sha512_reseed(); 430 430 if (ret) 431 431 return ret; 432 432 } 433 433 434 - /* PPNO generate */ 435 - cpacf_ppno(CPACF_PPNO_SHA512_DRNG_GEN, 436 - &prng_data->ppnows, buf, nbytes, NULL, 0); 434 + /* PRNO generate */ 435 + cpacf_prno(CPACF_PRNO_SHA512_DRNG_GEN, 436 + &prng_data->prnows, buf, nbytes, NULL, 0); 437 437 438 438 /* FIPS 140-2 Conditional Self Test */ 439 439 if (fips_enabled) { ··· 653 653 if (mutex_lock_interruptible(&prng_data->mutex)) 654 654 return -ERESTARTSYS; 655 655 if (prng_mode == PRNG_MODE_SHA512) 656 - counter = prng_data->ppnows.stream_bytes; 656 + counter = prng_data->prnows.stream_bytes; 657 657 else 658 658 counter = prng_data->prngws.byte_counter; 659 659 mutex_unlock(&prng_data->mutex); ··· 774 774 775 775 /* choose prng mode */ 776 776 if (prng_mode != PRNG_MODE_TDES) { 777 - /* check for MSA5 support for PPNO operations */ 778 - if (!cpacf_query_func(CPACF_PPNO, CPACF_PPNO_SHA512_DRNG_GEN)) { 777 + /* check for MSA5 support for PRNO operations */ 778 + if (!cpacf_query_func(CPACF_PRNO, CPACF_PRNO_SHA512_DRNG_GEN)) { 779 779 if (prng_mode == PRNG_MODE_SHA512) { 780 780 pr_err("The prng module cannot " 781 781 "start in SHA-512 mode\n");
+10 -10
arch/s390/include/asm/cpacf.h
··· 25 25 #define CPACF_KMO 0xb92b /* MSA4 */ 26 26 #define CPACF_PCC 0xb92c /* MSA4 */ 27 27 #define CPACF_KMCTR 0xb92d /* MSA4 */ 28 - #define CPACF_PPNO 0xb93c /* MSA5 */ 28 + #define CPACF_PRNO 0xb93c /* MSA5 */ 29 29 30 30 /* 31 31 * En/decryption modifier bits ··· 123 123 #define CPACF_PCKMO_ENC_AES_256_KEY 0x14 124 124 125 125 /* 126 - * Function codes for the PPNO (PERFORM PSEUDORANDOM NUMBER OPERATION) 126 + * Function codes for the PRNO (PERFORM RANDOM NUMBER OPERATION) 127 127 * instruction 128 128 */ 129 - #define CPACF_PPNO_QUERY 0x00 130 - #define CPACF_PPNO_SHA512_DRNG_GEN 0x03 131 - #define CPACF_PPNO_SHA512_DRNG_SEED 0x83 129 + #define CPACF_PRNO_QUERY 0x00 130 + #define CPACF_PRNO_SHA512_DRNG_GEN 0x03 131 + #define CPACF_PRNO_SHA512_DRNG_SEED 0x83 132 132 133 133 typedef struct { unsigned char bytes[16]; } cpacf_mask_t; 134 134 ··· 173 173 case CPACF_PCC: 174 174 case CPACF_KMCTR: 175 175 return test_facility(77); /* check for MSA4 */ 176 - case CPACF_PPNO: 176 + case CPACF_PRNO: 177 177 return test_facility(57); /* check for MSA5 */ 178 178 default: 179 179 BUG(); ··· 373 373 } 374 374 375 375 /** 376 - * cpacf_ppno() - executes the PPNO (PERFORM PSEUDORANDOM NUMBER OPERATION) 376 + * cpacf_prno() - executes the PRNO (PERFORM RANDOM NUMBER OPERATION) 377 377 * instruction 378 - * @func: the function code passed to PPNO; see CPACF_PPNO_xxx defines 378 + * @func: the function code passed to PRNO; see CPACF_PRNO_xxx defines 379 379 * @param: address of parameter block; see POP for details on each func 380 380 * @dest: address of destination memory area 381 381 * @dest_len: size of destination memory area in bytes 382 382 * @seed: address of seed data 383 383 * @seed_len: size of seed data in bytes 384 384 */ 385 - static inline void cpacf_ppno(unsigned long func, void *param, 385 + static inline void cpacf_prno(unsigned long func, void *param, 386 386 u8 *dest, long dest_len, 387 387 const u8 *seed, long seed_len) 388 388 { ··· 398 398 " brc 1,0b\n" /* handle partial completion */ 399 399 : [dst] "+a" (r2), [dlen] "+d" (r3) 400 400 : [fc] "d" (r0), [pba] "a" (r1), 401 - [seed] "a" (r4), [slen] "d" (r5), [opc] "i" (CPACF_PPNO) 401 + [seed] "a" (r4), [slen] "d" (r5), [opc] "i" (CPACF_PRNO) 402 402 : "cc", "memory"); 403 403 } 404 404
+1 -1
arch/s390/kvm/kvm-s390.c
··· 273 273 kvm_s390_available_subfunc.pcc); 274 274 } 275 275 if (test_facility(57)) /* MSA5 */ 276 - __cpacf_query(CPACF_PPNO, (cpacf_mask_t *) 276 + __cpacf_query(CPACF_PRNO, (cpacf_mask_t *) 277 277 kvm_s390_available_subfunc.ppno); 278 278 279 279 if (MACHINE_HAS_ESOP)