License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2016-03-17 14:22:12 +00:00
|
|
|
/*
|
|
|
|
* CP Assist for Cryptographic Functions (CPACF)
|
|
|
|
*
|
2017-09-18 10:48:08 +00:00
|
|
|
* Copyright IBM Corp. 2003, 2017
|
2016-03-17 14:22:12 +00:00
|
|
|
* 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 */
|
2016-05-18 13:59:06 +00:00
|
|
|
#define CPACF_PCKMO 0xb928 /* MSA3 */
|
|
|
|
#define CPACF_KMF 0xb92a /* MSA4 */
|
|
|
|
#define CPACF_KMO 0xb92b /* MSA4 */
|
2016-03-17 14:22:12 +00:00
|
|
|
#define CPACF_PCC 0xb92c /* MSA4 */
|
|
|
|
#define CPACF_KMCTR 0xb92d /* MSA4 */
|
2017-02-24 09:11:54 +00:00
|
|
|
#define CPACF_PRNO 0xb93c /* MSA5 */
|
2017-02-02 13:25:19 +00:00
|
|
|
#define CPACF_KMA 0xb929 /* MSA8 */
|
2018-12-28 08:33:35 +00:00
|
|
|
#define CPACF_KDSA 0xb93a /* MSA9 */
|
2016-03-17 14:22:12 +00:00
|
|
|
|
|
|
|
/*
|
2016-11-04 10:57:15 +00:00
|
|
|
* En/decryption modifier bits
|
2016-08-15 07:19:16 +00:00
|
|
|
*/
|
2016-11-04 10:57:15 +00:00
|
|
|
#define CPACF_ENCRYPT 0x00
|
2016-08-15 07:19:16 +00:00
|
|
|
#define CPACF_DECRYPT 0x80
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function codes for the KM (CIPHER MESSAGE) instruction
|
2016-03-17 14:22:12 +00:00
|
|
|
*/
|
|
|
|
#define CPACF_KM_QUERY 0x00
|
2016-08-15 07:19:16 +00:00
|
|
|
#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
|
2016-11-04 10:57:15 +00:00
|
|
|
#define CPACF_KM_PAES_128 0x1a
|
|
|
|
#define CPACF_KM_PAES_192 0x1b
|
|
|
|
#define CPACF_KM_PAES_256 0x1c
|
2016-08-15 07:19:16 +00:00
|
|
|
#define CPACF_KM_XTS_128 0x32
|
|
|
|
#define CPACF_KM_XTS_256 0x34
|
2016-11-04 10:57:15 +00:00
|
|
|
#define CPACF_KM_PXTS_128 0x3a
|
|
|
|
#define CPACF_KM_PXTS_256 0x3c
|
2016-03-17 14:22:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Function codes for the KMC (CIPHER MESSAGE WITH CHAINING)
|
2016-08-15 07:19:16 +00:00
|
|
|
* instruction
|
2016-03-17 14:22:12 +00:00
|
|
|
*/
|
|
|
|
#define CPACF_KMC_QUERY 0x00
|
2016-08-15 07:19:16 +00:00
|
|
|
#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
|
2016-11-04 10:57:15 +00:00
|
|
|
#define CPACF_KMC_PAES_128 0x1a
|
|
|
|
#define CPACF_KMC_PAES_192 0x1b
|
|
|
|
#define CPACF_KMC_PAES_256 0x1c
|
2016-03-17 14:22:12 +00:00
|
|
|
#define CPACF_KMC_PRNG 0x43
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function codes for the KMCTR (CIPHER MESSAGE WITH COUNTER)
|
2016-08-15 07:19:16 +00:00
|
|
|
* instruction
|
2016-03-17 14:22:12 +00:00
|
|
|
*/
|
2016-08-15 07:19:16 +00:00
|
|
|
#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
|
2016-11-04 10:57:15 +00:00
|
|
|
#define CPACF_KMCTR_PAES_128 0x1a
|
|
|
|
#define CPACF_KMCTR_PAES_192 0x1b
|
|
|
|
#define CPACF_KMCTR_PAES_256 0x1c
|
2016-03-17 14:22:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Function codes for the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST)
|
2016-08-15 07:19:16 +00:00
|
|
|
* instruction
|
2016-03-17 14:22:12 +00:00
|
|
|
*/
|
|
|
|
#define CPACF_KIMD_QUERY 0x00
|
|
|
|
#define CPACF_KIMD_SHA_1 0x01
|
|
|
|
#define CPACF_KIMD_SHA_256 0x02
|
|
|
|
#define CPACF_KIMD_SHA_512 0x03
|
2019-08-14 12:56:54 +00:00
|
|
|
#define CPACF_KIMD_SHA3_224 0x20
|
|
|
|
#define CPACF_KIMD_SHA3_256 0x21
|
|
|
|
#define CPACF_KIMD_SHA3_384 0x22
|
|
|
|
#define CPACF_KIMD_SHA3_512 0x23
|
2016-03-17 14:22:12 +00:00
|
|
|
#define CPACF_KIMD_GHASH 0x41
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function codes for the KLMD (COMPUTE LAST MESSAGE DIGEST)
|
2016-08-15 07:19:16 +00:00
|
|
|
* instruction
|
2016-03-17 14:22:12 +00:00
|
|
|
*/
|
|
|
|
#define CPACF_KLMD_QUERY 0x00
|
|
|
|
#define CPACF_KLMD_SHA_1 0x01
|
|
|
|
#define CPACF_KLMD_SHA_256 0x02
|
|
|
|
#define CPACF_KLMD_SHA_512 0x03
|
2019-08-14 12:56:54 +00:00
|
|
|
#define CPACF_KLMD_SHA3_224 0x20
|
|
|
|
#define CPACF_KLMD_SHA3_256 0x21
|
|
|
|
#define CPACF_KLMD_SHA3_384 0x22
|
|
|
|
#define CPACF_KLMD_SHA3_512 0x23
|
2016-03-17 14:22:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* function codes for the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE)
|
2016-08-15 07:19:16 +00:00
|
|
|
* instruction
|
2016-03-17 14:22:12 +00:00
|
|
|
*/
|
|
|
|
#define CPACF_KMAC_QUERY 0x00
|
|
|
|
#define CPACF_KMAC_DEA 0x01
|
|
|
|
#define CPACF_KMAC_TDEA_128 0x02
|
|
|
|
#define CPACF_KMAC_TDEA_192 0x03
|
|
|
|
|
2016-11-02 13:19:48 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2016-03-17 14:22:12 +00:00
|
|
|
/*
|
2017-02-24 09:11:54 +00:00
|
|
|
* Function codes for the PRNO (PERFORM RANDOM NUMBER OPERATION)
|
2016-08-15 07:19:16 +00:00
|
|
|
* instruction
|
2016-03-17 14:22:12 +00:00
|
|
|
*/
|
2017-02-24 09:11:54 +00:00
|
|
|
#define CPACF_PRNO_QUERY 0x00
|
|
|
|
#define CPACF_PRNO_SHA512_DRNG_GEN 0x03
|
|
|
|
#define CPACF_PRNO_SHA512_DRNG_SEED 0x83
|
2017-02-28 07:59:22 +00:00
|
|
|
#define CPACF_PRNO_TRNG_Q_R2C_RATIO 0x70
|
|
|
|
#define CPACF_PRNO_TRNG 0x72
|
2016-03-17 14:22:12 +00:00
|
|
|
|
2017-09-18 10:48:08 +00:00
|
|
|
/*
|
|
|
|
* 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 */
|
|
|
|
|
2016-08-18 10:59:46 +00:00
|
|
|
typedef struct { unsigned char bytes[16]; } cpacf_mask_t;
|
|
|
|
|
2016-03-17 14:22:12 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2019-10-01 20:08:01 +00:00
|
|
|
static __always_inline void __cpacf_query(unsigned int opcode, cpacf_mask_t *mask)
|
2016-03-17 14:22:12 +00:00
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = 0; /* query function */
|
2016-08-18 10:59:46 +00:00
|
|
|
register unsigned long r1 asm("1") = (unsigned long) mask;
|
2016-03-17 14:22:12 +00:00
|
|
|
|
|
|
|
asm volatile(
|
2016-05-18 13:59:06 +00:00
|
|
|
" spm 0\n" /* pckmo doesn't change the cc */
|
2017-02-21 14:00:54 +00:00
|
|
|
/* Parameter regs are ignored, but must be nonzero and unique */
|
|
|
|
"0: .insn rrf,%[opc] << 16,2,4,6,0\n"
|
2016-03-17 14:22:12 +00:00
|
|
|
" brc 1,0b\n" /* handle partial completion */
|
2016-08-18 10:59:46 +00:00
|
|
|
: "=m" (*mask)
|
2016-03-17 14:22:12 +00:00
|
|
|
: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (opcode)
|
|
|
|
: "cc");
|
|
|
|
}
|
|
|
|
|
2019-05-17 06:54:24 +00:00
|
|
|
static __always_inline int __cpacf_check_opcode(unsigned int opcode)
|
2016-03-17 14:22:12 +00:00
|
|
|
{
|
|
|
|
switch (opcode) {
|
|
|
|
case CPACF_KMAC:
|
|
|
|
case CPACF_KM:
|
|
|
|
case CPACF_KMC:
|
|
|
|
case CPACF_KIMD:
|
|
|
|
case CPACF_KLMD:
|
2016-08-18 10:59:46 +00:00
|
|
|
return test_facility(17); /* check for MSA */
|
2016-05-18 13:59:06 +00:00
|
|
|
case CPACF_PCKMO:
|
2016-08-18 10:59:46 +00:00
|
|
|
return test_facility(76); /* check for MSA3 */
|
2016-05-18 13:59:06 +00:00
|
|
|
case CPACF_KMF:
|
|
|
|
case CPACF_KMO:
|
2016-03-17 14:22:12 +00:00
|
|
|
case CPACF_PCC:
|
|
|
|
case CPACF_KMCTR:
|
2016-08-18 10:59:46 +00:00
|
|
|
return test_facility(77); /* check for MSA4 */
|
2017-02-24 09:11:54 +00:00
|
|
|
case CPACF_PRNO:
|
2016-08-18 10:59:46 +00:00
|
|
|
return test_facility(57); /* check for MSA5 */
|
2017-09-18 10:48:08 +00:00
|
|
|
case CPACF_KMA:
|
|
|
|
return test_facility(146); /* check for MSA8 */
|
2016-03-17 14:22:12 +00:00
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
2016-08-18 10:59:46 +00:00
|
|
|
}
|
|
|
|
|
2019-05-14 22:41:59 +00:00
|
|
|
static __always_inline int cpacf_query(unsigned int opcode, cpacf_mask_t *mask)
|
2016-08-18 10:59:46 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-05-17 06:54:24 +00:00
|
|
|
static __always_inline int cpacf_query_func(unsigned int opcode, unsigned int func)
|
2016-08-18 10:59:46 +00:00
|
|
|
{
|
|
|
|
cpacf_mask_t mask;
|
|
|
|
|
|
|
|
if (cpacf_query(opcode, &mask))
|
|
|
|
return cpacf_test_func(&mask, func);
|
|
|
|
return 0;
|
2016-03-17 14:22:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2016-08-15 07:19:16 +00:00
|
|
|
static inline int cpacf_km(unsigned long func, void *param,
|
2016-03-17 14:22:12 +00:00
|
|
|
u8 *dest, const u8 *src, long src_len)
|
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = (unsigned long) func;
|
|
|
|
register unsigned long r1 asm("1") = (unsigned long) param;
|
|
|
|
register unsigned long r2 asm("2") = (unsigned long) src;
|
|
|
|
register unsigned long r3 asm("3") = (unsigned long) src_len;
|
|
|
|
register unsigned long r4 asm("4") = (unsigned long) dest;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
"0: .insn rre,%[opc] << 16,%[dst],%[src]\n"
|
|
|
|
" brc 1,0b\n" /* handle partial completion */
|
|
|
|
: [src] "+a" (r2), [len] "+d" (r3), [dst] "+a" (r4)
|
|
|
|
: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KM)
|
|
|
|
: "cc", "memory");
|
|
|
|
|
|
|
|
return src_len - r3;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2016-08-15 07:19:16 +00:00
|
|
|
static inline int cpacf_kmc(unsigned long func, void *param,
|
2016-03-17 14:22:12 +00:00
|
|
|
u8 *dest, const u8 *src, long src_len)
|
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = (unsigned long) func;
|
|
|
|
register unsigned long r1 asm("1") = (unsigned long) param;
|
|
|
|
register unsigned long r2 asm("2") = (unsigned long) src;
|
|
|
|
register unsigned long r3 asm("3") = (unsigned long) src_len;
|
|
|
|
register unsigned long r4 asm("4") = (unsigned long) dest;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
"0: .insn rre,%[opc] << 16,%[dst],%[src]\n"
|
|
|
|
" brc 1,0b\n" /* handle partial completion */
|
|
|
|
: [src] "+a" (r2), [len] "+d" (r3), [dst] "+a" (r4)
|
|
|
|
: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KMC)
|
|
|
|
: "cc", "memory");
|
|
|
|
|
|
|
|
return src_len - r3;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2016-08-15 08:41:52 +00:00
|
|
|
static inline void cpacf_kimd(unsigned long func, void *param,
|
|
|
|
const u8 *src, long src_len)
|
2016-03-17 14:22:12 +00:00
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = (unsigned long) func;
|
|
|
|
register unsigned long r1 asm("1") = (unsigned long) param;
|
|
|
|
register unsigned long r2 asm("2") = (unsigned long) src;
|
|
|
|
register unsigned long r3 asm("3") = (unsigned long) src_len;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
"0: .insn rre,%[opc] << 16,0,%[src]\n"
|
|
|
|
" brc 1,0b\n" /* handle partial completion */
|
|
|
|
: [src] "+a" (r2), [len] "+d" (r3)
|
|
|
|
: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KIMD)
|
|
|
|
: "cc", "memory");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2016-08-15 08:41:52 +00:00
|
|
|
static inline void cpacf_klmd(unsigned long func, void *param,
|
|
|
|
const u8 *src, long src_len)
|
2016-03-17 14:22:12 +00:00
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = (unsigned long) func;
|
|
|
|
register unsigned long r1 asm("1") = (unsigned long) param;
|
|
|
|
register unsigned long r2 asm("2") = (unsigned long) src;
|
|
|
|
register unsigned long r3 asm("3") = (unsigned long) src_len;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
"0: .insn rre,%[opc] << 16,0,%[src]\n"
|
|
|
|
" brc 1,0b\n" /* handle partial completion */
|
|
|
|
: [src] "+a" (r2), [len] "+d" (r3)
|
|
|
|
: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KLMD)
|
|
|
|
: "cc", "memory");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2016-08-15 07:19:16 +00:00
|
|
|
static inline int cpacf_kmac(unsigned long func, void *param,
|
2016-03-17 14:22:12 +00:00
|
|
|
const u8 *src, long src_len)
|
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = (unsigned long) func;
|
|
|
|
register unsigned long r1 asm("1") = (unsigned long) param;
|
|
|
|
register unsigned long r2 asm("2") = (unsigned long) src;
|
|
|
|
register unsigned long r3 asm("3") = (unsigned long) src_len;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
"0: .insn rre,%[opc] << 16,0,%[src]\n"
|
|
|
|
" brc 1,0b\n" /* handle partial completion */
|
|
|
|
: [src] "+a" (r2), [len] "+d" (r3)
|
|
|
|
: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KMAC)
|
|
|
|
: "cc", "memory");
|
|
|
|
|
|
|
|
return src_len - r3;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2016-08-15 07:19:16 +00:00
|
|
|
static inline int cpacf_kmctr(unsigned long func, void *param, u8 *dest,
|
2016-03-17 14:22:12 +00:00
|
|
|
const u8 *src, long src_len, u8 *counter)
|
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = (unsigned long) func;
|
|
|
|
register unsigned long r1 asm("1") = (unsigned long) param;
|
|
|
|
register unsigned long r2 asm("2") = (unsigned long) src;
|
|
|
|
register unsigned long r3 asm("3") = (unsigned long) src_len;
|
|
|
|
register unsigned long r4 asm("4") = (unsigned long) dest;
|
|
|
|
register unsigned long r6 asm("6") = (unsigned long) counter;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
"0: .insn rrf,%[opc] << 16,%[dst],%[src],%[ctr],0\n"
|
|
|
|
" brc 1,0b\n" /* handle partial completion */
|
|
|
|
: [src] "+a" (r2), [len] "+d" (r3),
|
|
|
|
[dst] "+a" (r4), [ctr] "+a" (r6)
|
|
|
|
: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KMCTR)
|
|
|
|
: "cc", "memory");
|
|
|
|
|
|
|
|
return src_len - r3;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-02-24 09:11:54 +00:00
|
|
|
* cpacf_prno() - executes the PRNO (PERFORM RANDOM NUMBER OPERATION)
|
2016-03-17 14:22:12 +00:00
|
|
|
* instruction
|
2017-02-24 09:11:54 +00:00
|
|
|
* @func: the function code passed to PRNO; see CPACF_PRNO_xxx defines
|
2016-03-17 14:22:12 +00:00
|
|
|
* @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
|
|
|
|
*/
|
2017-02-24 09:11:54 +00:00
|
|
|
static inline void cpacf_prno(unsigned long func, void *param,
|
2017-02-28 07:59:22 +00:00
|
|
|
u8 *dest, unsigned long dest_len,
|
|
|
|
const u8 *seed, unsigned long seed_len)
|
2016-03-17 14:22:12 +00:00
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = (unsigned long) func;
|
|
|
|
register unsigned long r1 asm("1") = (unsigned long) param;
|
|
|
|
register unsigned long r2 asm("2") = (unsigned long) dest;
|
|
|
|
register unsigned long r3 asm("3") = (unsigned long) dest_len;
|
|
|
|
register unsigned long r4 asm("4") = (unsigned long) seed;
|
|
|
|
register unsigned long r5 asm("5") = (unsigned long) seed_len;
|
|
|
|
|
|
|
|
asm volatile (
|
|
|
|
"0: .insn rre,%[opc] << 16,%[dst],%[seed]\n"
|
|
|
|
" brc 1,0b\n" /* handle partial completion */
|
|
|
|
: [dst] "+a" (r2), [dlen] "+d" (r3)
|
|
|
|
: [fc] "d" (r0), [pba] "a" (r1),
|
2017-02-24 09:11:54 +00:00
|
|
|
[seed] "a" (r4), [slen] "d" (r5), [opc] "i" (CPACF_PRNO)
|
2016-03-17 14:22:12 +00:00
|
|
|
: "cc", "memory");
|
|
|
|
}
|
|
|
|
|
2017-02-28 07:59:22 +00:00
|
|
|
/**
|
|
|
|
* 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");
|
|
|
|
}
|
|
|
|
|
2016-03-17 14:22:12 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2016-08-15 08:41:52 +00:00
|
|
|
static inline void cpacf_pcc(unsigned long func, void *param)
|
2016-03-17 14:22:12 +00:00
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = (unsigned long) func;
|
|
|
|
register unsigned long r1 asm("1") = (unsigned long) param;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
"0: .insn rre,%[opc] << 16,0,0\n" /* PCC opcode */
|
|
|
|
" brc 1,0b\n" /* handle partial completion */
|
|
|
|
:
|
|
|
|
: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_PCC)
|
|
|
|
: "cc", "memory");
|
|
|
|
}
|
|
|
|
|
2016-11-02 13:19:48 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = (unsigned long) func;
|
|
|
|
register unsigned long r1 asm("1") = (unsigned long) param;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
" .insn rre,%[opc] << 16,0,0\n" /* PCKMO opcode */
|
|
|
|
:
|
|
|
|
: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_PCKMO)
|
|
|
|
: "cc", "memory");
|
|
|
|
}
|
|
|
|
|
2017-09-18 10:48:08 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = (unsigned long) func;
|
|
|
|
register unsigned long r1 asm("1") = (unsigned long) param;
|
|
|
|
register unsigned long r2 asm("2") = (unsigned long) src;
|
|
|
|
register unsigned long r3 asm("3") = (unsigned long) src_len;
|
|
|
|
register unsigned long r4 asm("4") = (unsigned long) aad;
|
|
|
|
register unsigned long r5 asm("5") = (unsigned long) aad_len;
|
|
|
|
register unsigned long r6 asm("6") = (unsigned long) dest;
|
|
|
|
|
|
|
|
asm volatile(
|
|
|
|
"0: .insn rrf,%[opc] << 16,%[dst],%[src],%[aad],0\n"
|
|
|
|
" brc 1,0b\n" /* handle partial completion */
|
|
|
|
: [dst] "+a" (r6), [src] "+a" (r2), [slen] "+d" (r3),
|
|
|
|
[aad] "+a" (r4), [alen] "+d" (r5)
|
|
|
|
: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KMA)
|
|
|
|
: "cc", "memory");
|
|
|
|
}
|
|
|
|
|
2016-03-17 14:22:12 +00:00
|
|
|
#endif /* _ASM_S390_CPACF_H */
|