Skip to content

Commit f0d43b3

Browse files
committed
Merge tag 's390-5.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 updates from Heiko Carstens: "Besides all the small improvements and cleanups the most notable part is the fast vector/SIMD implementation of the ChaCha20 stream cipher, which is an adaptation of Andy Polyakov's code for the kernel. Summary: - add fast vector/SIMD implementation of the ChaCha20 stream cipher, which mainly adapts Andy Polyakov's code for the kernel - add status attribute to AP queue device so users can easily figure out its status - fix race in page table release code, and and lots of documentation - remove uevent suppress from cio device driver, since it turned out that it generated more problems than it solved problems - quite a lot of virtual vs physical address confusion fixes - various other small improvements and cleanups all over the place" * tag 's390-5.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (39 commits) s390/dasd: use default_groups in kobj_type s390/sclp_sd: use default_groups in kobj_type s390/pci: simplify __pciwb_mio() inline asm s390: remove unused TASK_SIZE_OF s390/crash_dump: fix virtual vs physical address handling s390/crypto: fix compile error for ChaCha20 module s390/mm: check 2KB-fragment page on release s390/mm: better annotate 2KB pagetable fragments handling s390/mm: fix 2KB pgtable release race s390/sclp: release SCLP early buffer after kernel initialization s390/nmi: disable interrupts on extended save area update s390/zcrypt: CCA control CPRB sending s390/disassembler: update opcode table s390/uv: fix memblock virtual vs physical address confusion s390/smp: fix memblock_phys_free() vs memblock_free() confusion s390/sclp: fix memblock_phys_free() vs memblock_free() confusion s390/exit: remove dead reference to do_exit from copy_thread s390/ap: add missing virt_to_phys address conversion s390/pgalloc: use pointers instead of unsigned long values s390/pgalloc: add virt/phys address handling to base asce functions ...
2 parents 9b9e211 + 0704a85 commit f0d43b3

Some content is hidden

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

48 files changed

+1703
-373
lines changed

arch/s390/configs/debug_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ CONFIG_CRYPTO_SHA3_256_S390=m
770770
CONFIG_CRYPTO_SHA3_512_S390=m
771771
CONFIG_CRYPTO_DES_S390=m
772772
CONFIG_CRYPTO_AES_S390=m
773+
CONFIG_CRYPTO_CHACHA_S390=m
773774
CONFIG_CRYPTO_GHASH_S390=m
774775
CONFIG_CRYPTO_CRC32_S390=y
775776
CONFIG_CRYPTO_DEV_VIRTIO=m

arch/s390/configs/defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ CONFIG_CRYPTO_SHA3_256_S390=m
757757
CONFIG_CRYPTO_SHA3_512_S390=m
758758
CONFIG_CRYPTO_DES_S390=m
759759
CONFIG_CRYPTO_AES_S390=m
760+
CONFIG_CRYPTO_CHACHA_S390=m
760761
CONFIG_CRYPTO_GHASH_S390=m
761762
CONFIG_CRYPTO_CRC32_S390=y
762763
CONFIG_CRYPTO_DEV_VIRTIO=m

arch/s390/crypto/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ obj-$(CONFIG_CRYPTO_SHA3_512_S390) += sha3_512_s390.o sha_common.o
1111
obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o
1212
obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o
1313
obj-$(CONFIG_CRYPTO_PAES_S390) += paes_s390.o
14+
obj-$(CONFIG_CRYPTO_CHACHA_S390) += chacha_s390.o
1415
obj-$(CONFIG_S390_PRNG) += prng.o
1516
obj-$(CONFIG_CRYPTO_GHASH_S390) += ghash_s390.o
1617
obj-$(CONFIG_CRYPTO_CRC32_S390) += crc32-vx_s390.o
1718
obj-$(CONFIG_ARCH_RANDOM) += arch_random.o
1819

1920
crc32-vx_s390-y := crc32-vx.o crc32le-vx.o crc32be-vx.o
21+
chacha_s390-y := chacha-glue.o chacha-s390.o

arch/s390/crypto/chacha-glue.c

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* s390 ChaCha stream cipher.
4+
*
5+
* Copyright IBM Corp. 2021
6+
*/
7+
8+
#define KMSG_COMPONENT "chacha_s390"
9+
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
10+
11+
#include <crypto/internal/chacha.h>
12+
#include <crypto/internal/skcipher.h>
13+
#include <crypto/algapi.h>
14+
#include <linux/cpufeature.h>
15+
#include <linux/kernel.h>
16+
#include <linux/module.h>
17+
#include <linux/sizes.h>
18+
#include <asm/fpu/api.h>
19+
#include "chacha-s390.h"
20+
21+
static void chacha20_crypt_s390(u32 *state, u8 *dst, const u8 *src,
22+
unsigned int nbytes, const u32 *key,
23+
u32 *counter)
24+
{
25+
struct kernel_fpu vxstate;
26+
27+
kernel_fpu_begin(&vxstate, KERNEL_VXR);
28+
chacha20_vx(dst, src, nbytes, key, counter);
29+
kernel_fpu_end(&vxstate, KERNEL_VXR);
30+
31+
*counter += round_up(nbytes, CHACHA_BLOCK_SIZE) / CHACHA_BLOCK_SIZE;
32+
}
33+
34+
static int chacha20_s390(struct skcipher_request *req)
35+
{
36+
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
37+
struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
38+
u32 state[CHACHA_STATE_WORDS] __aligned(16);
39+
struct skcipher_walk walk;
40+
unsigned int nbytes;
41+
int rc;
42+
43+
rc = skcipher_walk_virt(&walk, req, false);
44+
chacha_init_generic(state, ctx->key, req->iv);
45+
46+
while (walk.nbytes > 0) {
47+
nbytes = walk.nbytes;
48+
if (nbytes < walk.total)
49+
nbytes = round_down(nbytes, walk.stride);
50+
51+
if (nbytes <= CHACHA_BLOCK_SIZE) {
52+
chacha_crypt_generic(state, walk.dst.virt.addr,
53+
walk.src.virt.addr, nbytes,
54+
ctx->nrounds);
55+
} else {
56+
chacha20_crypt_s390(state, walk.dst.virt.addr,
57+
walk.src.virt.addr, nbytes,
58+
&state[4], &state[12]);
59+
}
60+
rc = skcipher_walk_done(&walk, walk.nbytes - nbytes);
61+
}
62+
return rc;
63+
}
64+
65+
static struct skcipher_alg chacha_algs[] = {
66+
{
67+
.base.cra_name = "chacha20",
68+
.base.cra_driver_name = "chacha20-s390",
69+
.base.cra_priority = 900,
70+
.base.cra_blocksize = 1,
71+
.base.cra_ctxsize = sizeof(struct chacha_ctx),
72+
.base.cra_module = THIS_MODULE,
73+
74+
.min_keysize = CHACHA_KEY_SIZE,
75+
.max_keysize = CHACHA_KEY_SIZE,
76+
.ivsize = CHACHA_IV_SIZE,
77+
.chunksize = CHACHA_BLOCK_SIZE,
78+
.setkey = chacha20_setkey,
79+
.encrypt = chacha20_s390,
80+
.decrypt = chacha20_s390,
81+
}
82+
};
83+
84+
static int __init chacha_mod_init(void)
85+
{
86+
return crypto_register_skciphers(chacha_algs, ARRAY_SIZE(chacha_algs));
87+
}
88+
89+
static void __exit chacha_mod_fini(void)
90+
{
91+
crypto_unregister_skciphers(chacha_algs, ARRAY_SIZE(chacha_algs));
92+
}
93+
94+
module_cpu_feature_match(VXRS, chacha_mod_init);
95+
module_exit(chacha_mod_fini);
96+
97+
MODULE_DESCRIPTION("ChaCha20 stream cipher");
98+
MODULE_LICENSE("GPL v2");
99+
100+
MODULE_ALIAS_CRYPTO("chacha20");

0 commit comments

Comments
 (0)