/
usr
/
src
/
linux-headers-5.15.0-190
/
arch
/
s390
/
include
/
asm
/
/usr/src/linux-headers-5.15.0-190/arch/s390/include/asm
mkdir
upload
Name
Size
Mode
Actions
fpu/
-
0755
rm
trace/
-
0755
rm
vdso/
-
0755
rm
airq.h
3421
0644
edit
dl
rm
alternative-asm.h
3148
0644
edit
dl
rm
alternative.h
5742
0644
edit
dl
rm
ap.h
13098
0644
edit
dl
rm
appldata.h
1593
0644
edit
dl
rm
archrandom.h
1319
0644
edit
dl
rm
asm-const.h
376
0644
edit
dl
rm
asm-prototypes.h
227
0644
edit
dl
rm
atomic.h
4225
0644
edit
dl
rm
atomic_ops.h
5100
0644
edit
dl
rm
barrier.h
1892
0644
edit
dl
rm
bitops.h
10153
0644
edit
dl
rm
boot_data.h
481
0644
edit
dl
rm
bug.h
1562
0644
edit
dl
rm
bugs.h
441
0644
edit
dl
rm
cache.h
389
0644
edit
dl
rm
ccwdev.h
8506
0644
edit
dl
rm
ccwgroup.h
2301
0644
edit
dl
rm
checksum.h
3352
0644
edit
dl
rm
chpid.h
979
0644
edit
dl
rm
chsc.h
1384
0644
edit
dl
rm
cio.h
9083
0644
edit
dl
rm
clocksource.h
184
0644
edit
dl
rm
clp.h
1426
0644
edit
dl
rm
cmb.h
425
0644
edit
dl
rm
cmpxchg.h
5195
0644
edit
dl
rm
compat.h
5333
0644
edit
dl
rm
cpacf.h
17759
0644
edit
dl
rm
cpcmd.h
1135
0644
edit
dl
rm
cpu.h
549
0644
edit
dl
rm
cpufeature.h
958
0644
edit
dl
rm
cputime.h
840
0644
edit
dl
rm
cpu_mcf.h
3064
0644
edit
dl
rm
cpu_mf-insn.h
478
0644
edit
dl
rm
cpu_mf.h
9606
0644
edit
dl
rm
crw.h
1907
0644
edit
dl
rm
css_chars.h
904
0644
edit
dl
rm
ctl_reg.h
3715
0644
edit
dl
rm
current.h
405
0644
edit
dl
rm
debug.h
14318
0644
edit
dl
rm
delay.h
647
0644
edit
dl
rm
diag.h
7017
0644
edit
dl
rm
dis.h
636
0644
edit
dl
rm
dma.h
456
0644
edit
dl
rm
dwarf.h
952
0644
edit
dl
rm
eadm.h
2082
0644
edit
dl
rm
ebcdic.h
1442
0644
edit
dl
rm
elf.h
11210
0644
edit
dl
rm
entry-common.h
1590
0644
edit
dl
rm
exec.h
269
0644
edit
dl
rm
extable.h
2184
0644
edit
dl
rm
extmem.h
804
0644
edit
dl
rm
facility.h
2760
0644
edit
dl
rm
fcx.h
8102
0644
edit
dl
rm
ftrace.h
1875
0644
edit
dl
rm
ftrace.lds.h
720
0644
edit
dl
rm
futex.h
1927
0644
edit
dl
rm
gmap.h
5760
0644
edit
dl
rm
hardirq.h
777
0644
edit
dl
rm
hugetlb.h
2966
0644
edit
dl
rm
hw_irq.h
210
0644
edit
dl
rm
idals.h
5317
0644
edit
dl
rm
idle.h
753
0644
edit
dl
rm
io.h
2153
0644
edit
dl
rm
ipl.h
3708
0644
edit
dl
rm
irq.h
2635
0644
edit
dl
rm
irqflags.h
1810
0644
edit
dl
rm
irq_work.h
204
0644
edit
dl
rm
isc.h
1036
0644
edit
dl
rm
itcw.h
950
0644
edit
dl
rm
jump_label.h
1411
0644
edit
dl
rm
kasan.h
1772
0644
edit
dl
rm
Kbuild
253
0644
edit
dl
rm
kdebug.h
386
0644
edit
dl
rm
kexec.h
2620
0644
edit
dl
rm
kfence.h
1148
0644
edit
dl
rm
kprobes.h
2175
0644
edit
dl
rm
kvm_host.h
27155
0644
edit
dl
rm
kvm_para.h
3761
0644
edit
dl
rm
linkage.h
729
0644
edit
dl
rm
livepatch.h
474
0644
edit
dl
rm
lowcore.h
6595
0644
edit
dl
rm
mem_detect.h
2589
0644
edit
dl
rm
mem_encrypt.h
365
0644
edit
dl
rm
mmu.h
1515
0644
edit
dl
rm
mmu_context.h
3491
0644
edit
dl
rm
mmzone.h
316
0644
edit
dl
rm
module.h
1209
0644
edit
dl
rm
nmi.h
3698
0644
edit
dl
rm
nospec-branch.h
342
0644
edit
dl
rm
nospec-insn.h
3616
0644
edit
dl
rm
numa.h
386
0644
edit
dl
rm
os_info.h
1136
0644
edit
dl
rm
page-states.h
486
0644
edit
dl
rm
page.h
5194
0644
edit
dl
rm
pci.h
8691
0644
edit
dl
rm
pci_clp.h
5346
0644
edit
dl
rm
pci_debug.h
608
0644
edit
dl
rm
pci_dma.h
5541
0644
edit
dl
rm
pci_insn.h
4089
0644
edit
dl
rm
pci_io.h
4405
0644
edit
dl
rm
percpu.h
6638
0644
edit
dl
rm
perf_event.h
3245
0644
edit
dl
rm
pgalloc.h
4024
0644
edit
dl
rm
pgtable.h
51845
0644
edit
dl
rm
pkey.h
737
0644
edit
dl
rm
pnet.h
325
0644
edit
dl
rm
preempt.h
3218
0644
edit
dl
rm
processor.h
9637
0644
edit
dl
rm
ptdump.h
255
0644
edit
dl
rm
ptrace.h
5865
0644
edit
dl
rm
purgatory.h
329
0644
edit
dl
rm
qdio.h
10011
0644
edit
dl
rm
runtime_instr.h
634
0644
edit
dl
rm
schid.h
525
0644
edit
dl
rm
sclp.h
4332
0644
edit
dl
rm
scsw.h
24630
0644
edit
dl
rm
seccomp.h
808
0644
edit
dl
rm
sections.h
1357
0644
edit
dl
rm
serial.h
147
0644
edit
dl
rm
setup.h
5156
0644
edit
dl
rm
set_memory.h
989
0644
edit
dl
rm
shmparam.h
285
0644
edit
dl
rm
signal.h
644
0644
edit
dl
rm
sigp.h
1900
0644
edit
dl
rm
smp.h
1932
0644
edit
dl
rm
softirq_stack.h
329
0644
edit
dl
rm
sparsemem.h
214
0644
edit
dl
rm
spinlock.h
3525
0644
edit
dl
rm
spinlock_types.h
407
0644
edit
dl
rm
stacktrace.h
6168
0644
edit
dl
rm
stp.h
1706
0644
edit
dl
rm
string.h
5847
0644
edit
dl
rm
switch_to.h
1400
0644
edit
dl
rm
syscall.h
4148
0644
edit
dl
rm
syscall_wrapper.h
5506
0644
edit
dl
rm
sysinfo.h
4339
0644
edit
dl
rm
termios.h
685
0644
edit
dl
rm
thread_info.h
3605
0644
edit
dl
rm
timex.h
6538
0644
edit
dl
rm
tlb.h
4296
0644
edit
dl
rm
tlbflush.h
3233
0644
edit
dl
rm
topology.h
2876
0644
edit
dl
rm
tpi.h
736
0644
edit
dl
rm
types.h
318
0644
edit
dl
rm
uaccess.h
10049
0644
edit
dl
rm
unistd.h
1030
0644
edit
dl
rm
unwind.h
3360
0644
edit
dl
rm
uprobes.h
588
0644
edit
dl
rm
user.h
3384
0644
edit
dl
rm
uv.h
10977
0644
edit
dl
rm
vdso.h
746
0644
edit
dl
rm
vga.h
170
0644
edit
dl
rm
vmalloc.h
90
0644
edit
dl
rm
vmlinux.lds.h
1167
0644
edit
dl
rm
vtime.h
718
0644
edit
dl
rm
vtimer.h
830
0644
edit
dl
rm
vx-insn.h
13477
0644
edit
dl
rm
xor.h
454
0644
edit
dl
rm
Edit:
/usr/src/linux-headers-5.15.0-190/arch/s390/include/asm/cpacf.h
(17759B)
/* SPDX-License-Identifier: GPL-2.0 */ /* * CP Assist for Cryptographic Functions (CPACF) * * Copyright IBM Corp. 2003, 2017 * Author(s): Thomas Spatzier * Jan Glauber * Harald Freudenberger (freude@de.ibm.com) * Martin Schwidefsky <schwidefsky@de.ibm.com> */ #ifndef _ASM_S390_CPACF_H #define _ASM_S390_CPACF_H #include <asm/facility.h> /* * Instruction opcodes for the CPACF instructions */ #define CPACF_KMAC 0xb91e /* MSA */ #define CPACF_KM 0xb92e /* MSA */ #define CPACF_KMC 0xb92f /* MSA */ #define CPACF_KIMD 0xb93e /* MSA */ #define CPACF_KLMD 0xb93f /* MSA */ #define CPACF_PCKMO 0xb928 /* MSA3 */ #define CPACF_KMF 0xb92a /* MSA4 */ #define CPACF_KMO 0xb92b /* MSA4 */ #define CPACF_PCC 0xb92c /* MSA4 */ #define CPACF_KMCTR 0xb92d /* MSA4 */ #define CPACF_PRNO 0xb93c /* MSA5 */ #define CPACF_KMA 0xb929 /* MSA8 */ #define CPACF_KDSA 0xb93a /* MSA9 */ /* * En/decryption modifier bits */ #define CPACF_ENCRYPT 0x00 #define CPACF_DECRYPT 0x80 /* * Function codes for the KM (CIPHER MESSAGE) instruction */ #define CPACF_KM_QUERY 0x00 #define CPACF_KM_DEA 0x01 #define CPACF_KM_TDEA_128 0x02 #define CPACF_KM_TDEA_192 0x03 #define CPACF_KM_AES_128 0x12 #define CPACF_KM_AES_192 0x13 #define CPACF_KM_AES_256 0x14 #define CPACF_KM_PAES_128 0x1a #define CPACF_KM_PAES_192 0x1b #define CPACF_KM_PAES_256 0x1c #define CPACF_KM_XTS_128 0x32 #define CPACF_KM_XTS_256 0x34 #define CPACF_KM_PXTS_128 0x3a #define CPACF_KM_PXTS_256 0x3c /* * Function codes for the KMC (CIPHER MESSAGE WITH CHAINING) * instruction */ #define CPACF_KMC_QUERY 0x00 #define CPACF_KMC_DEA 0x01 #define CPACF_KMC_TDEA_128 0x02 #define CPACF_KMC_TDEA_192 0x03 #define CPACF_KMC_AES_128 0x12 #define CPACF_KMC_AES_192 0x13 #define CPACF_KMC_AES_256 0x14 #define CPACF_KMC_PAES_128 0x1a #define CPACF_KMC_PAES_192 0x1b #define CPACF_KMC_PAES_256 0x1c #define CPACF_KMC_PRNG 0x43 /* * Function codes for the KMCTR (CIPHER MESSAGE WITH COUNTER) * instruction */ #define CPACF_KMCTR_QUERY 0x00 #define CPACF_KMCTR_DEA 0x01 #define CPACF_KMCTR_TDEA_128 0x02 #define CPACF_KMCTR_TDEA_192 0x03 #define CPACF_KMCTR_AES_128 0x12 #define CPACF_KMCTR_AES_192 0x13 #define CPACF_KMCTR_AES_256 0x14 #define CPACF_KMCTR_PAES_128 0x1a #define CPACF_KMCTR_PAES_192 0x1b #define CPACF_KMCTR_PAES_256 0x1c /* * Function codes for the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) * instruction */ #define CPACF_KIMD_QUERY 0x00 #define CPACF_KIMD_SHA_1 0x01 #define CPACF_KIMD_SHA_256 0x02 #define CPACF_KIMD_SHA_512 0x03 #define CPACF_KIMD_SHA3_224 0x20 #define CPACF_KIMD_SHA3_256 0x21 #define CPACF_KIMD_SHA3_384 0x22 #define CPACF_KIMD_SHA3_512 0x23 #define CPACF_KIMD_GHASH 0x41 /* * Function codes for the KLMD (COMPUTE LAST MESSAGE DIGEST) * instruction */ #define CPACF_KLMD_QUERY 0x00 #define CPACF_KLMD_SHA_1 0x01 #define CPACF_KLMD_SHA_256 0x02 #define CPACF_KLMD_SHA_512 0x03 #define CPACF_KLMD_SHA3_224 0x20 #define CPACF_KLMD_SHA3_256 0x21 #define CPACF_KLMD_SHA3_384 0x22 #define CPACF_KLMD_SHA3_512 0x23 /* * function codes for the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) * instruction */ #define CPACF_KMAC_QUERY 0x00 #define CPACF_KMAC_DEA 0x01 #define CPACF_KMAC_TDEA_128 0x02 #define CPACF_KMAC_TDEA_192 0x03 /* * Function codes for the PCKMO (PERFORM CRYPTOGRAPHIC KEY MANAGEMENT) * instruction */ #define CPACF_PCKMO_QUERY 0x00 #define CPACF_PCKMO_ENC_DES_KEY 0x01 #define CPACF_PCKMO_ENC_TDES_128_KEY 0x02 #define CPACF_PCKMO_ENC_TDES_192_KEY 0x03 #define CPACF_PCKMO_ENC_AES_128_KEY 0x12 #define CPACF_PCKMO_ENC_AES_192_KEY 0x13 #define CPACF_PCKMO_ENC_AES_256_KEY 0x14 /* * Function codes for the PRNO (PERFORM RANDOM NUMBER OPERATION) * instruction */ #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 /* * Function codes for the KMA (CIPHER MESSAGE WITH AUTHENTICATION) * instruction */ #define CPACF_KMA_QUERY 0x00 #define CPACF_KMA_GCM_AES_128 0x12 #define CPACF_KMA_GCM_AES_192 0x13 #define CPACF_KMA_GCM_AES_256 0x14 /* * Flags for the KMA (CIPHER MESSAGE WITH AUTHENTICATION) instruction */ #define CPACF_KMA_LPC 0x100 /* Last-Plaintext/Ciphertext */ #define CPACF_KMA_LAAD 0x200 /* Last-AAD */ #define CPACF_KMA_HS 0x400 /* Hash-subkey Supplied */ typedef struct { unsigned char bytes[16]; } cpacf_mask_t; /* * Prototype for a not existing function to produce a link * error if __cpacf_query() or __cpacf_check_opcode() is used * with an invalid compile time const opcode. */ void __cpacf_bad_opcode(void); static __always_inline void __cpacf_query_rre(u32 opc, u8 r1, u8 r2, cpacf_mask_t *mask) { asm volatile( " la %%r1,%[mask]\n" " xgr %%r0,%%r0\n" " .insn rre,%[opc] << 16,%[r1],%[r2]\n" : [mask] "=R" (*mask) : [opc] "i" (opc), [r1] "i" (r1), [r2] "i" (r2) : "cc", "r0", "r1"); } static __always_inline void __cpacf_query_rrf(u32 opc, u8 r1, u8 r2, u8 r3, u8 m4, cpacf_mask_t *mask) { asm volatile( " la %%r1,%[mask]\n" " xgr %%r0,%%r0\n" " .insn rrf,%[opc] << 16,%[r1],%[r2],%[r3],%[m4]\n" : [mask] "=R" (*mask) : [opc] "i" (opc), [r1] "i" (r1), [r2] "i" (r2), [r3] "i" (r3), [m4] "i" (m4) : "cc", "r0", "r1"); } static __always_inline void __cpacf_query(unsigned int opcode, cpacf_mask_t *mask) { switch (opcode) { case CPACF_KDSA: __cpacf_query_rre(CPACF_KDSA, 0, 2, mask); break; case CPACF_KIMD: __cpacf_query_rre(CPACF_KIMD, 0, 2, mask); break; case CPACF_KLMD: __cpacf_query_rre(CPACF_KLMD, 0, 2, mask); break; case CPACF_KM: __cpacf_query_rre(CPACF_KM, 2, 4, mask); break; case CPACF_KMA: __cpacf_query_rrf(CPACF_KMA, 2, 4, 6, 0, mask); break; case CPACF_KMAC: __cpacf_query_rre(CPACF_KMAC, 0, 2, mask); break; case CPACF_KMC: __cpacf_query_rre(CPACF_KMC, 2, 4, mask); break; case CPACF_KMCTR: __cpacf_query_rrf(CPACF_KMCTR, 2, 4, 6, 0, mask); break; case CPACF_KMF: __cpacf_query_rre(CPACF_KMF, 2, 4, mask); break; case CPACF_KMO: __cpacf_query_rre(CPACF_KMO, 2, 4, mask); break; case CPACF_PCC: __cpacf_query_rre(CPACF_PCC, 0, 0, mask); break; case CPACF_PCKMO: __cpacf_query_rre(CPACF_PCKMO, 0, 0, mask); break; case CPACF_PRNO: __cpacf_query_rre(CPACF_PRNO, 2, 4, mask); break; default: __cpacf_bad_opcode(); } } static __always_inline int __cpacf_check_opcode(unsigned int opcode) { switch (opcode) { case CPACF_KMAC: case CPACF_KM: case CPACF_KMC: case CPACF_KIMD: case CPACF_KLMD: return test_facility(17); /* check for MSA */ case CPACF_PCKMO: return test_facility(76); /* check for MSA3 */ case CPACF_KMF: case CPACF_KMO: case CPACF_PCC: case CPACF_KMCTR: return test_facility(77); /* check for MSA4 */ case CPACF_PRNO: return test_facility(57); /* check for MSA5 */ case CPACF_KMA: return test_facility(146); /* check for MSA8 */ default: __cpacf_bad_opcode(); return 0; } } /** * cpacf_query() - check if a specific CPACF function is available * @opcode: the opcode of the crypto instruction * @func: the function code to test for * * Executes the query function for the given crypto instruction @opcode * and checks if @func is available * * Returns 1 if @func is available for @opcode, 0 otherwise */ static __always_inline int cpacf_query(unsigned int opcode, cpacf_mask_t *mask) { if (__cpacf_check_opcode(opcode)) { __cpacf_query(opcode, mask); return 1; } memset(mask, 0, sizeof(*mask)); return 0; } static inline int cpacf_test_func(cpacf_mask_t *mask, unsigned int func) { return (mask->bytes[func >> 3] & (0x80 >> (func & 7))) != 0; } static __always_inline int cpacf_query_func(unsigned int opcode, unsigned int func) { cpacf_mask_t mask; if (cpacf_query(opcode, &mask)) return cpacf_test_func(&mask, func); return 0; } /** * cpacf_km() - executes the KM (CIPHER MESSAGE) instruction * @func: the function code passed to KM; see CPACF_KM_xxx defines * @param: address of parameter block; see POP for details on each func * @dest: address of destination memory area * @src: address of source memory area * @src_len: length of src operand in bytes * * Returns 0 for the query func, number of processed bytes for * encryption/decryption funcs */ static inline int cpacf_km(unsigned long func, void *param, u8 *dest, const u8 *src, long src_len) { union register_pair d, s; d.even = (unsigned long)dest; s.even = (unsigned long)src; s.odd = (unsigned long)src_len; asm volatile( " lgr 0,%[fc]\n" " lgr 1,%[pba]\n" "0: .insn rre,%[opc] << 16,%[dst],%[src]\n" " brc 1,0b\n" /* handle partial completion */ : [src] "+&d" (s.pair), [dst] "+&d" (d.pair) : [fc] "d" (func), [pba] "d" ((unsigned long)param), [opc] "i" (CPACF_KM) : "cc", "memory", "0", "1"); return src_len - s.odd; } /** * cpacf_kmc() - executes the KMC (CIPHER MESSAGE WITH CHAINING) instruction * @func: the function code passed to KM; see CPACF_KMC_xxx defines * @param: address of parameter block; see POP for details on each func * @dest: address of destination memory area * @src: address of source memory area * @src_len: length of src operand in bytes * * Returns 0 for the query func, number of processed bytes for * encryption/decryption funcs */ static inline int cpacf_kmc(unsigned long func, void *param, u8 *dest, const u8 *src, long src_len) { union register_pair d, s; d.even = (unsigned long)dest; s.even = (unsigned long)src; s.odd = (unsigned long)src_len; asm volatile( " lgr 0,%[fc]\n" " lgr 1,%[pba]\n" "0: .insn rre,%[opc] << 16,%[dst],%[src]\n" " brc 1,0b\n" /* handle partial completion */ : [src] "+&d" (s.pair), [dst] "+&d" (d.pair) : [fc] "d" (func), [pba] "d" ((unsigned long)param), [opc] "i" (CPACF_KMC) : "cc", "memory", "0", "1"); return src_len - s.odd; } /** * cpacf_kimd() - executes the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) * instruction * @func: the function code passed to KM; see CPACF_KIMD_xxx defines * @param: address of parameter block; see POP for details on each func * @src: address of source memory area * @src_len: length of src operand in bytes */ static inline void cpacf_kimd(unsigned long func, void *param, const u8 *src, long src_len) { union register_pair s; s.even = (unsigned long)src; s.odd = (unsigned long)src_len; asm volatile( " lgr 0,%[fc]\n" " lgr 1,%[pba]\n" "0: .insn rre,%[opc] << 16,0,%[src]\n" " brc 1,0b\n" /* handle partial completion */ : [src] "+&d" (s.pair) : [fc] "d" (func), [pba] "d" ((unsigned long)(param)), [opc] "i" (CPACF_KIMD) : "cc", "memory", "0", "1"); } /** * cpacf_klmd() - executes the KLMD (COMPUTE LAST MESSAGE DIGEST) instruction * @func: the function code passed to KM; see CPACF_KLMD_xxx defines * @param: address of parameter block; see POP for details on each func * @src: address of source memory area * @src_len: length of src operand in bytes */ static inline void cpacf_klmd(unsigned long func, void *param, const u8 *src, long src_len) { union register_pair s; s.even = (unsigned long)src; s.odd = (unsigned long)src_len; asm volatile( " lgr 0,%[fc]\n" " lgr 1,%[pba]\n" "0: .insn rre,%[opc] << 16,0,%[src]\n" " brc 1,0b\n" /* handle partial completion */ : [src] "+&d" (s.pair) : [fc] "d" (func), [pba] "d" ((unsigned long)param), [opc] "i" (CPACF_KLMD) : "cc", "memory", "0", "1"); } /** * cpacf_kmac() - executes the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) * instruction * @func: the function code passed to KM; see CPACF_KMAC_xxx defines * @param: address of parameter block; see POP for details on each func * @src: address of source memory area * @src_len: length of src operand in bytes * * Returns 0 for the query func, number of processed bytes for digest funcs */ static inline int cpacf_kmac(unsigned long func, void *param, const u8 *src, long src_len) { union register_pair s; s.even = (unsigned long)src; s.odd = (unsigned long)src_len; asm volatile( " lgr 0,%[fc]\n" " lgr 1,%[pba]\n" "0: .insn rre,%[opc] << 16,0,%[src]\n" " brc 1,0b\n" /* handle partial completion */ : [src] "+&d" (s.pair) : [fc] "d" (func), [pba] "d" ((unsigned long)param), [opc] "i" (CPACF_KMAC) : "cc", "memory", "0", "1"); return src_len - s.odd; } /** * cpacf_kmctr() - executes the KMCTR (CIPHER MESSAGE WITH COUNTER) instruction * @func: the function code passed to KMCTR; see CPACF_KMCTR_xxx defines * @param: address of parameter block; see POP for details on each func * @dest: address of destination memory area * @src: address of source memory area * @src_len: length of src operand in bytes * @counter: address of counter value * * Returns 0 for the query func, number of processed bytes for * encryption/decryption funcs */ static inline int cpacf_kmctr(unsigned long func, void *param, u8 *dest, const u8 *src, long src_len, u8 *counter) { union register_pair d, s, c; d.even = (unsigned long)dest; s.even = (unsigned long)src; s.odd = (unsigned long)src_len; c.even = (unsigned long)counter; asm volatile( " lgr 0,%[fc]\n" " lgr 1,%[pba]\n" "0: .insn rrf,%[opc] << 16,%[dst],%[src],%[ctr],0\n" " brc 1,0b\n" /* handle partial completion */ : [src] "+&d" (s.pair), [dst] "+&d" (d.pair), [ctr] "+&d" (c.pair) : [fc] "d" (func), [pba] "d" ((unsigned long)param), [opc] "i" (CPACF_KMCTR) : "cc", "memory", "0", "1"); return src_len - s.odd; } /** * cpacf_prno() - executes the PRNO (PERFORM RANDOM NUMBER OPERATION) * instruction * @func: the function code passed to PRNO; see CPACF_PRNO_xxx defines * @param: address of parameter block; see POP for details on each func * @dest: address of destination memory area * @dest_len: size of destination memory area in bytes * @seed: address of seed data * @seed_len: size of seed data in bytes */ static inline void cpacf_prno(unsigned long func, void *param, u8 *dest, unsigned long dest_len, const u8 *seed, unsigned long seed_len) { union register_pair d, s; d.even = (unsigned long)dest; d.odd = (unsigned long)dest_len; s.even = (unsigned long)seed; s.odd = (unsigned long)seed_len; asm volatile ( " lgr 0,%[fc]\n" " lgr 1,%[pba]\n" "0: .insn rre,%[opc] << 16,%[dst],%[seed]\n" " brc 1,0b\n" /* handle partial completion */ : [dst] "+&d" (d.pair) : [fc] "d" (func), [pba] "d" ((unsigned long)param), [seed] "d" (s.pair), [opc] "i" (CPACF_PRNO) : "cc", "memory", "0", "1"); } /** * 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) { union register_pair u, c; u.even = (unsigned long)ucbuf; u.odd = (unsigned long)ucbuf_len; c.even = (unsigned long)cbuf; c.odd = (unsigned long)cbuf_len; asm volatile ( " lghi 0,%[fc]\n" "0: .insn rre,%[opc] << 16,%[ucbuf],%[cbuf]\n" " brc 1,0b\n" /* handle partial completion */ : [ucbuf] "+&d" (u.pair), [cbuf] "+&d" (c.pair) : [fc] "K" (CPACF_PRNO_TRNG), [opc] "i" (CPACF_PRNO) : "cc", "memory", "0"); } /** * cpacf_pcc() - executes the PCC (PERFORM CRYPTOGRAPHIC COMPUTATION) * instruction * @func: the function code passed to PCC; see CPACF_KM_xxx defines * @param: address of parameter block; see POP for details on each func */ static inline void cpacf_pcc(unsigned long func, void *param) { asm volatile( " lgr 0,%[fc]\n" " lgr 1,%[pba]\n" "0: .insn rre,%[opc] << 16,0,0\n" /* PCC opcode */ " brc 1,0b\n" /* handle partial completion */ : : [fc] "d" (func), [pba] "d" ((unsigned long)param), [opc] "i" (CPACF_PCC) : "cc", "memory", "0", "1"); } /** * cpacf_pckmo() - executes the PCKMO (PERFORM CRYPTOGRAPHIC KEY * MANAGEMENT) instruction * @func: the function code passed to PCKMO; see CPACF_PCKMO_xxx defines * @param: address of parameter block; see POP for details on each func * * Returns 0. */ static inline void cpacf_pckmo(long func, void *param) { asm volatile( " lgr 0,%[fc]\n" " lgr 1,%[pba]\n" " .insn rre,%[opc] << 16,0,0\n" /* PCKMO opcode */ : : [fc] "d" (func), [pba] "d" ((unsigned long)param), [opc] "i" (CPACF_PCKMO) : "cc", "memory", "0", "1"); } /** * cpacf_kma() - executes the KMA (CIPHER MESSAGE WITH AUTHENTICATION) * instruction * @func: the function code passed to KMA; see CPACF_KMA_xxx defines * @param: address of parameter block; see POP for details on each func * @dest: address of destination memory area * @src: address of source memory area * @src_len: length of src operand in bytes * @aad: address of additional authenticated data memory area * @aad_len: length of aad operand in bytes */ static inline void cpacf_kma(unsigned long func, void *param, u8 *dest, const u8 *src, unsigned long src_len, const u8 *aad, unsigned long aad_len) { union register_pair d, s, a; d.even = (unsigned long)dest; s.even = (unsigned long)src; s.odd = (unsigned long)src_len; a.even = (unsigned long)aad; a.odd = (unsigned long)aad_len; asm volatile( " lgr 0,%[fc]\n" " lgr 1,%[pba]\n" "0: .insn rrf,%[opc] << 16,%[dst],%[src],%[aad],0\n" " brc 1,0b\n" /* handle partial completion */ : [dst] "+&d" (d.pair), [src] "+&d" (s.pair), [aad] "+&d" (a.pair) : [fc] "d" (func), [pba] "d" ((unsigned long)param), [opc] "i" (CPACF_KMA) : "cc", "memory", "0", "1"); } #endif /* _ASM_S390_CPACF_H */
Save
cmd:
run