diff options
author | Harald Freudenberger <freude@linux.vnet.ibm.com> | 2017-02-28 08:59:22 +0100 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2017-04-26 13:41:34 +0200 |
commit | f75fa65d70e2423a03c1b7391bfca410d554b1c5 (patch) | |
tree | 54f56707adb0363fc9b2396597bedec01a7175d2 /arch/s390/include/asm/cpacf.h | |
parent | 985a9d20daa67e1983910fcf6e4f348ce8eed086 (diff) |
s390/crypto: Add new subfunctions to the cpacf PRNO function.
There is a new TRNG extension in the subcodes for the cpacf
PRNO function. This patch introduces new defines and a new
cpacf_trng inline function to provide these new features for
other kernel code parts.
Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/include/asm/cpacf.h')
-rw-r--r-- | arch/s390/include/asm/cpacf.h | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/arch/s390/include/asm/cpacf.h b/arch/s390/include/asm/cpacf.h index ba4aecc2dac7..7707a35176c4 100644 --- a/arch/s390/include/asm/cpacf.h +++ b/arch/s390/include/asm/cpacf.h @@ -129,6 +129,8 @@ #define CPACF_PRNO_QUERY 0x00 #define CPACF_PRNO_SHA512_DRNG_GEN 0x03 #define CPACF_PRNO_SHA512_DRNG_SEED 0x83 +#define CPACF_PRNO_TRNG_Q_R2C_RATIO 0x70 +#define CPACF_PRNO_TRNG 0x72 typedef struct { unsigned char bytes[16]; } cpacf_mask_t; @@ -383,8 +385,8 @@ static inline int cpacf_kmctr(unsigned long func, void *param, u8 *dest, * @seed_len: size of seed data in bytes */ static inline void cpacf_prno(unsigned long func, void *param, - u8 *dest, long dest_len, - const u8 *seed, long seed_len) + u8 *dest, unsigned long dest_len, + const u8 *seed, unsigned long seed_len) { register unsigned long r0 asm("0") = (unsigned long) func; register unsigned long r1 asm("1") = (unsigned long) param; @@ -403,6 +405,31 @@ static inline void cpacf_prno(unsigned long func, void *param, } /** + * cpacf_trng() - executes the TRNG subfunction of the PRNO instruction + * @ucbuf: buffer for unconditioned data + * @ucbuf_len: amount of unconditioned data to fetch in bytes + * @cbuf: buffer for conditioned data + * @cbuf_len: amount of conditioned data to fetch in bytes + */ +static inline void cpacf_trng(u8 *ucbuf, unsigned long ucbuf_len, + u8 *cbuf, unsigned long cbuf_len) +{ + register unsigned long r0 asm("0") = (unsigned long) CPACF_PRNO_TRNG; + register unsigned long r2 asm("2") = (unsigned long) ucbuf; + register unsigned long r3 asm("3") = (unsigned long) ucbuf_len; + register unsigned long r4 asm("4") = (unsigned long) cbuf; + register unsigned long r5 asm("5") = (unsigned long) cbuf_len; + + asm volatile ( + "0: .insn rre,%[opc] << 16,%[ucbuf],%[cbuf]\n" + " brc 1,0b\n" /* handle partial completion */ + : [ucbuf] "+a" (r2), [ucbuflen] "+d" (r3), + [cbuf] "+a" (r4), [cbuflen] "+d" (r5) + : [fc] "d" (r0), [opc] "i" (CPACF_PRNO) + : "cc", "memory"); +} + +/** * cpacf_pcc() - executes the PCC (PERFORM CRYPTOGRAPHIC COMPUTATION) * instruction * @func: the function code passed to PCC; see CPACF_KM_xxx defines |