Skip to content

Commit d075c0c

Browse files
committed
Merge tag 'v5.19-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto updates from Herbert Xu: "API: - Test in-place en/decryption with two sglists in testmgr - Fix process vs softirq race in cryptd Algorithms: - Add arm64 acceleration for sm4 - Add s390 acceleration for chacha20 Drivers: - Add polarfire soc hwrng support in mpsf - Add support for TI SoC AM62x in sa2ul - Add support for ATSHA204 cryptochip in atmel-sha204a - Add support for PRNG in caam - Restore support for storage encryption in qat - Restore support for storage encryption in hisilicon/sec" * tag 'v5.19-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (116 commits) hwrng: omap3-rom - fix using wrong clk_disable() in omap_rom_rng_runtime_resume() crypto: hisilicon/sec - delete the flag CRYPTO_ALG_ALLOCATES_MEMORY crypto: qat - add support for 401xx devices crypto: qat - re-enable registration of algorithms crypto: qat - honor CRYPTO_TFM_REQ_MAY_SLEEP flag crypto: qat - add param check for DH crypto: qat - add param check for RSA crypto: qat - remove dma_free_coherent() for DH crypto: qat - remove dma_free_coherent() for RSA crypto: qat - fix memory leak in RSA crypto: qat - add backlog mechanism crypto: qat - refactor submission logic crypto: qat - use pre-allocated buffers in datapath crypto: qat - set to zero DH parameters before free crypto: s390 - add crypto library interface for ChaCha20 crypto: talitos - Uniform coding style with defined variable crypto: octeontx2 - simplify the return expression of otx2_cpt_aead_cbc_aes_sha_setkey() crypto: cryptd - Protect per-CPU resource by disabling BH. crypto: sun8i-ce - do not fallback if cryptlen is less than sg length crypto: sun8i-ce - rework debugging ...
2 parents bf27246 + e4e62bb commit d075c0c

118 files changed

Lines changed: 5534 additions & 1058 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/ABI/testing/debugfs-hisi-hpre

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,20 @@ Description: Dump the status of the QM.
104104
Four states: initiated, started, stopped and closed.
105105
Available for both PF and VF, and take no other effect on HPRE.
106106

107+
What: /sys/kernel/debug/hisi_hpre/<bdf>/qm/diff_regs
108+
Date: Mar 2022
109+
Contact: linux-crypto@vger.kernel.org
110+
Description: QM debug registers(regs) read hardware register value. This
111+
node is used to show the change of the qm register values. This
112+
node can be help users to check the change of register values.
113+
114+
What: /sys/kernel/debug/hisi_hpre/<bdf>/hpre_dfx/diff_regs
115+
Date: Mar 2022
116+
Contact: linux-crypto@vger.kernel.org
117+
Description: HPRE debug registers(regs) read hardware register value. This
118+
node is used to show the change of the register values. This
119+
node can be help users to check the change of register values.
120+
107121
What: /sys/kernel/debug/hisi_hpre/<bdf>/hpre_dfx/send_cnt
108122
Date: Apr 2020
109123
Contact: linux-crypto@vger.kernel.org

Documentation/ABI/testing/debugfs-hisi-sec

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ Description: Dump the status of the QM.
8484
Four states: initiated, started, stopped and closed.
8585
Available for both PF and VF, and take no other effect on SEC.
8686

87+
What: /sys/kernel/debug/hisi_sec2/<bdf>/qm/diff_regs
88+
Date: Mar 2022
89+
Contact: linux-crypto@vger.kernel.org
90+
Description: QM debug registers(regs) read hardware register value. This
91+
node is used to show the change of the qm register values. This
92+
node can be help users to check the change of register values.
93+
94+
What: /sys/kernel/debug/hisi_sec2/<bdf>/sec_dfx/diff_regs
95+
Date: Mar 2022
96+
Contact: linux-crypto@vger.kernel.org
97+
Description: SEC debug registers(regs) read hardware register value. This
98+
node is used to show the change of the register values. This
99+
node can be help users to check the change of register values.
100+
87101
What: /sys/kernel/debug/hisi_sec2/<bdf>/sec_dfx/send_cnt
88102
Date: Apr 2020
89103
Contact: linux-crypto@vger.kernel.org

Documentation/ABI/testing/debugfs-hisi-zip

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ Description: Dump the status of the QM.
9797
Four states: initiated, started, stopped and closed.
9898
Available for both PF and VF, and take no other effect on ZIP.
9999

100+
What: /sys/kernel/debug/hisi_zip/<bdf>/qm/diff_regs
101+
Date: Mar 2022
102+
Contact: linux-crypto@vger.kernel.org
103+
Description: QM debug registers(regs) read hardware register value. This
104+
node is used to show the change of the qm registers value. This
105+
node can be help users to check the change of register values.
106+
107+
What: /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/diff_regs
108+
Date: Mar 2022
109+
Contact: linux-crypto@vger.kernel.org
110+
Description: ZIP debug registers(regs) read hardware register value. This
111+
node is used to show the change of the registers value. this
112+
node can be help users to check the change of register values.
113+
100114
What: /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/send_cnt
101115
Date: Apr 2020
102116
Contact: linux-crypto@vger.kernel.org
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
What: /sys/bus/pci/devices/<BDF>/fused_part
2+
Date: June 2022
3+
KernelVersion: 5.19
4+
Contact: mario.limonciello@amd.com
5+
Description:
6+
The /sys/bus/pci/devices/<BDF>/fused_part file reports
7+
whether the CPU or APU has been fused to prevent tampering.
8+
0: Not fused
9+
1: Fused
10+
11+
What: /sys/bus/pci/devices/<BDF>/debug_lock_on
12+
Date: June 2022
13+
KernelVersion: 5.19
14+
Contact: mario.limonciello@amd.com
15+
Description:
16+
The /sys/bus/pci/devices/<BDF>/debug_lock_on reports
17+
whether the AMD CPU or APU has been unlocked for debugging.
18+
Possible values:
19+
0: Not locked
20+
1: Locked
21+
22+
What: /sys/bus/pci/devices/<BDF>/tsme_status
23+
Date: June 2022
24+
KernelVersion: 5.19
25+
Contact: mario.limonciello@amd.com
26+
Description:
27+
The /sys/bus/pci/devices/<BDF>/tsme_status file reports
28+
the status of transparent secure memory encryption on AMD systems.
29+
Possible values:
30+
0: Not active
31+
1: Active
32+
33+
What: /sys/bus/pci/devices/<BDF>/anti_rollback_status
34+
Date: June 2022
35+
KernelVersion: 5.19
36+
Contact: mario.limonciello@amd.com
37+
Description:
38+
The /sys/bus/pci/devices/<BDF>/anti_rollback_status file reports
39+
whether the PSP is enforcing rollback protection.
40+
Possible values:
41+
0: Not enforcing
42+
1: Enforcing
43+
44+
What: /sys/bus/pci/devices/<BDF>/rpmc_production_enabled
45+
Date: June 2022
46+
KernelVersion: 5.19
47+
Contact: mario.limonciello@amd.com
48+
Description:
49+
The /sys/bus/pci/devices/<BDF>/rpmc_production_enabled file reports
50+
whether Replay Protected Monotonic Counter support has been enabled.
51+
Possible values:
52+
0: Not enabled
53+
1: Enabled
54+
55+
What: /sys/bus/pci/devices/<BDF>/rpmc_spirom_available
56+
Date: June 2022
57+
KernelVersion: 5.19
58+
Contact: mario.limonciello@amd.com
59+
Description:
60+
The /sys/bus/pci/devices/<BDF>/rpmc_spirom_available file reports
61+
whether an Replay Protected Monotonic Counter supported SPI is installed
62+
on the system.
63+
Possible values:
64+
0: Not present
65+
1: Present
66+
67+
What: /sys/bus/pci/devices/<BDF>/hsp_tpm_available
68+
Date: June 2022
69+
KernelVersion: 5.19
70+
Contact: mario.limonciello@amd.com
71+
Description:
72+
The /sys/bus/pci/devices/<BDF>/hsp_tpm_available file reports
73+
whether the HSP TPM has been activated.
74+
Possible values:
75+
0: Not activated or present
76+
1: Activated
77+
78+
What: /sys/bus/pci/devices/<BDF>/rom_armor_enforced
79+
Date: June 2022
80+
KernelVersion: 5.19
81+
Contact: mario.limonciello@amd.com
82+
Description:
83+
The /sys/bus/pci/devices/<BDF>/rom_armor_enforced file reports
84+
whether RomArmor SPI protection is enforced.
85+
Possible values:
86+
0: Not enforced
87+
1: Enforced

Documentation/devicetree/bindings/crypto/ti,sa2ul.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ properties:
1515
- ti,j721e-sa2ul
1616
- ti,am654-sa2ul
1717
- ti,am64-sa2ul
18+
- ti,am62-sa3ul
1819

1920
reg:
2021
maxItems: 1

Documentation/devicetree/bindings/trivial-devices.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ properties:
4747
- at,24c08
4848
# i2c trusted platform module (TPM)
4949
- atmel,at97sc3204t
50-
# i2c h/w symmetric crypto module
50+
# ATSHA204 - i2c h/w symmetric crypto module
51+
- atmel,atsha204
52+
# ATSHA204A - i2c h/w symmetric crypto module
5153
- atmel,atsha204a
5254
# i2c h/w elliptic curve crypto module
5355
- atmel,atecc508a

arch/arm64/crypto/Kconfig

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,25 @@ config CRYPTO_SM3_ARM64_CE
4545
tristate "SM3 digest algorithm (ARMv8.2 Crypto Extensions)"
4646
depends on KERNEL_MODE_NEON
4747
select CRYPTO_HASH
48-
select CRYPTO_LIB_SM3
48+
select CRYPTO_SM3
4949

5050
config CRYPTO_SM4_ARM64_CE
5151
tristate "SM4 symmetric cipher (ARMv8.2 Crypto Extensions)"
5252
depends on KERNEL_MODE_NEON
5353
select CRYPTO_ALGAPI
54-
select CRYPTO_LIB_SM4
54+
select CRYPTO_SM4
55+
56+
config CRYPTO_SM4_ARM64_CE_BLK
57+
tristate "SM4 in ECB/CBC/CFB/CTR modes using ARMv8 Crypto Extensions"
58+
depends on KERNEL_MODE_NEON
59+
select CRYPTO_SKCIPHER
60+
select CRYPTO_SM4
61+
62+
config CRYPTO_SM4_ARM64_NEON_BLK
63+
tristate "SM4 in ECB/CBC/CFB/CTR modes using NEON instructions"
64+
depends on KERNEL_MODE_NEON
65+
select CRYPTO_SKCIPHER
66+
select CRYPTO_SM4
5567

5668
config CRYPTO_GHASH_ARM64_CE
5769
tristate "GHASH/AES-GCM using ARMv8 Crypto Extensions"

arch/arm64/crypto/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ sha3-ce-y := sha3-ce-glue.o sha3-ce-core.o
2020
obj-$(CONFIG_CRYPTO_SM3_ARM64_CE) += sm3-ce.o
2121
sm3-ce-y := sm3-ce-glue.o sm3-ce-core.o
2222

23-
obj-$(CONFIG_CRYPTO_SM4_ARM64_CE) += sm4-ce.o
23+
obj-$(CONFIG_CRYPTO_SM4_ARM64_CE) += sm4-ce-cipher.o
24+
sm4-ce-cipher-y := sm4-ce-cipher-glue.o sm4-ce-cipher-core.o
25+
26+
obj-$(CONFIG_CRYPTO_SM4_ARM64_CE_BLK) += sm4-ce.o
2427
sm4-ce-y := sm4-ce-glue.o sm4-ce-core.o
2528

29+
obj-$(CONFIG_CRYPTO_SM4_ARM64_NEON_BLK) += sm4-neon.o
30+
sm4-neon-y := sm4-neon-glue.o sm4-neon-core.o
31+
2632
obj-$(CONFIG_CRYPTO_GHASH_ARM64_CE) += ghash-ce.o
2733
ghash-ce-y := ghash-ce-glue.o ghash-ce-core.o
2834

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/linkage.h>
4+
#include <asm/assembler.h>
5+
6+
.irp b, 0, 1, 2, 3, 4, 5, 6, 7, 8
7+
.set .Lv\b\().4s, \b
8+
.endr
9+
10+
.macro sm4e, rd, rn
11+
.inst 0xcec08400 | .L\rd | (.L\rn << 5)
12+
.endm
13+
14+
/*
15+
* void sm4_ce_do_crypt(const u32 *rk, u32 *out, const u32 *in);
16+
*/
17+
.text
18+
SYM_FUNC_START(sm4_ce_do_crypt)
19+
ld1 {v8.4s}, [x2]
20+
ld1 {v0.4s-v3.4s}, [x0], #64
21+
CPU_LE( rev32 v8.16b, v8.16b )
22+
ld1 {v4.4s-v7.4s}, [x0]
23+
sm4e v8.4s, v0.4s
24+
sm4e v8.4s, v1.4s
25+
sm4e v8.4s, v2.4s
26+
sm4e v8.4s, v3.4s
27+
sm4e v8.4s, v4.4s
28+
sm4e v8.4s, v5.4s
29+
sm4e v8.4s, v6.4s
30+
sm4e v8.4s, v7.4s
31+
rev64 v8.4s, v8.4s
32+
ext v8.16b, v8.16b, v8.16b, #8
33+
CPU_LE( rev32 v8.16b, v8.16b )
34+
st1 {v8.4s}, [x1]
35+
ret
36+
SYM_FUNC_END(sm4_ce_do_crypt)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <asm/neon.h>
4+
#include <asm/simd.h>
5+
#include <crypto/sm4.h>
6+
#include <crypto/internal/simd.h>
7+
#include <linux/module.h>
8+
#include <linux/cpufeature.h>
9+
#include <linux/crypto.h>
10+
#include <linux/types.h>
11+
12+
MODULE_ALIAS_CRYPTO("sm4");
13+
MODULE_ALIAS_CRYPTO("sm4-ce");
14+
MODULE_DESCRIPTION("SM4 symmetric cipher using ARMv8 Crypto Extensions");
15+
MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
16+
MODULE_LICENSE("GPL v2");
17+
18+
asmlinkage void sm4_ce_do_crypt(const u32 *rk, void *out, const void *in);
19+
20+
static int sm4_ce_setkey(struct crypto_tfm *tfm, const u8 *key,
21+
unsigned int key_len)
22+
{
23+
struct sm4_ctx *ctx = crypto_tfm_ctx(tfm);
24+
25+
return sm4_expandkey(ctx, key, key_len);
26+
}
27+
28+
static void sm4_ce_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
29+
{
30+
const struct sm4_ctx *ctx = crypto_tfm_ctx(tfm);
31+
32+
if (!crypto_simd_usable()) {
33+
sm4_crypt_block(ctx->rkey_enc, out, in);
34+
} else {
35+
kernel_neon_begin();
36+
sm4_ce_do_crypt(ctx->rkey_enc, out, in);
37+
kernel_neon_end();
38+
}
39+
}
40+
41+
static void sm4_ce_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
42+
{
43+
const struct sm4_ctx *ctx = crypto_tfm_ctx(tfm);
44+
45+
if (!crypto_simd_usable()) {
46+
sm4_crypt_block(ctx->rkey_dec, out, in);
47+
} else {
48+
kernel_neon_begin();
49+
sm4_ce_do_crypt(ctx->rkey_dec, out, in);
50+
kernel_neon_end();
51+
}
52+
}
53+
54+
static struct crypto_alg sm4_ce_alg = {
55+
.cra_name = "sm4",
56+
.cra_driver_name = "sm4-ce",
57+
.cra_priority = 300,
58+
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
59+
.cra_blocksize = SM4_BLOCK_SIZE,
60+
.cra_ctxsize = sizeof(struct sm4_ctx),
61+
.cra_module = THIS_MODULE,
62+
.cra_u.cipher = {
63+
.cia_min_keysize = SM4_KEY_SIZE,
64+
.cia_max_keysize = SM4_KEY_SIZE,
65+
.cia_setkey = sm4_ce_setkey,
66+
.cia_encrypt = sm4_ce_encrypt,
67+
.cia_decrypt = sm4_ce_decrypt
68+
}
69+
};
70+
71+
static int __init sm4_ce_mod_init(void)
72+
{
73+
return crypto_register_alg(&sm4_ce_alg);
74+
}
75+
76+
static void __exit sm4_ce_mod_fini(void)
77+
{
78+
crypto_unregister_alg(&sm4_ce_alg);
79+
}
80+
81+
module_cpu_feature_match(SM4, sm4_ce_mod_init);
82+
module_exit(sm4_ce_mod_fini);

0 commit comments

Comments
 (0)