Message ID | 20231022081100.123613-1-ebiggers@kernel.org |
---|---|
Headers | show |
Series | crypto: reduce ahash API overhead | expand |
Eric Biggers <ebiggers@kernel.org> wrote: > This patch series first removes the alignmask support from ahash. As is > the case with shash, the alignmask support of ahash has no real point. > Removing it reduces API overhead and complexity. > > Second, this patch series optimizes the common case where the ahash API > uses an shash algorithm, by eliminating unnecessary indirect calls. > > This series can be retrieved from git at > https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git > tag "crypto-ahash-2023-10-22". Note that it depends on my other series > "crypto: stop supporting alignmask in shash" > (https://lore.kernel.org/r/20231019055343.588846-1-ebiggers@kernel.org). > > Patch 1 cleans up after removal of alignmask support from shash. > > Patches 2-12 make drivers stop setting an alignmask for ahashes. > > Patch 13 removes alignmask support from ahash. > > Patches 14-23 remove checks of ahash alignmasks that became unnecessary. > > Patches 24-25 are other ahash related cleanups. > > Patches 26-29 prepare for optimizing the ahash-using-shash case. > > Patches 30 optimizes the ahash-using-shash case. > > Eric Biggers (30): > crypto: shash - remove crypto_shash_ctx_aligned() > crypto: sun4i-ss - remove unnecessary alignmask for ahashes > crypto: sun8i-ce - remove unnecessary alignmask for ahashes > crypto: sun8i-ss - remove unnecessary alignmask for ahashes > crypto: atmel - remove unnecessary alignmask for ahashes > crypto: artpec6 - stop setting alignmask for ahashes > crypto: mxs-dcp - remove unnecessary alignmask for ahashes > crypto: s5p-sss - remove unnecessary alignmask for ahashes > crypto: talitos - remove unnecessary alignmask for ahashes > crypto: omap-sham - stop setting alignmask for ahashes > crypto: rockchip - remove unnecessary alignmask for ahashes > crypto: starfive - remove unnecessary alignmask for ahashes > crypto: stm32 - remove unnecessary alignmask for ahashes > crypto: ahash - remove support for nonzero alignmask > crypto: authenc - stop using alignmask of ahash > crypto: authencesn - stop using alignmask of ahash > crypto: testmgr - stop checking crypto_ahash_alignmask > net: ipv4: stop checking crypto_ahash_alignmask > net: ipv6: stop checking crypto_ahash_alignmask > crypto: ccm - stop using alignmask of ahash > crypto: chacha20poly1305 - stop using alignmask of ahash > crypto: gcm - stop using alignmask of ahash > crypto: ahash - remove crypto_ahash_alignmask > crypto: ahash - remove struct ahash_request_priv > crypto: ahash - improve file comment > crypto: chelsio - stop using crypto_ahash::init > crypto: talitos - stop using crypto_ahash::init > crypto: hash - move "ahash wrapping shash" functions to ahash.c > crypto: ahash - check for shash type instead of not ahash type > crypto: ahash - optimize performance when wrapping shash > > Documentation/crypto/devel-algos.rst | 4 +- > crypto/ahash.c | 406 +++++++++++------- > crypto/authenc.c | 12 +- > crypto/authencesn.c | 20 +- > crypto/ccm.c | 3 +- > crypto/chacha20poly1305.c | 3 +- > crypto/gcm.c | 3 +- > crypto/hash.h | 14 +- > crypto/shash.c | 205 +-------- > crypto/testmgr.c | 9 +- > .../crypto/allwinner/sun4i-ss/sun4i-ss-core.c | 2 - > .../crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 6 - > .../crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 5 - > drivers/crypto/atmel-sha.c | 2 - > drivers/crypto/axis/artpec6_crypto.c | 3 - > drivers/crypto/chelsio/chcr_algo.c | 9 +- > drivers/crypto/mxs-dcp.c | 2 - > drivers/crypto/omap-sham.c | 16 +- > drivers/crypto/rockchip/rk3288_crypto_ahash.c | 3 - > drivers/crypto/s5p-sss.c | 6 - > drivers/crypto/starfive/jh7110-hash.c | 13 +- > drivers/crypto/stm32/stm32-hash.c | 20 - > drivers/crypto/talitos.c | 17 +- > include/crypto/algapi.h | 5 - > include/crypto/hash.h | 74 +--- > include/crypto/internal/hash.h | 9 +- > include/linux/crypto.h | 27 +- > net/ipv4/ah4.c | 17 +- > net/ipv6/ah6.c | 17 +- > 29 files changed, 339 insertions(+), 593 deletions(-) > > > base-commit: a2786e8bdd0242d7f00abf452a572de7464d177b > prerequisite-patch-id: e447f81a392f2f3955206357d72032cf691c7e11 > prerequisite-patch-id: 71947e05e23fb176da3ca898720b9e3332e891d7 > prerequisite-patch-id: 98d070bdaf3cfaf88553ab707cc3bfe85371c006 > prerequisite-patch-id: 9e4287b71c1129edb1ba162e2a1f641a9ac4385f > prerequisite-patch-id: 22a4cda4ae529854e55627c55d3f35b035871f3b > prerequisite-patch-id: f67b194e37338a4715850686b2f02bbf0a47cbe1 > prerequisite-patch-id: bcb547f4c9be4b022b824f9bff6b919b2d37d60f > prerequisite-patch-id: 20a8c2663a94c2d49217c5158a6bc588881fb9ad > prerequisite-patch-id: e45e43c487d75c87fd713a5ef57a584cf947950e > prerequisite-patch-id: bb211c1b59f73b22319aee6fafd14b07bc5d1460 > prerequisite-patch-id: 5f033ce643ba7d1f219dee490abd21e1e0958a51 > prerequisite-patch-id: 2173122570085246d5f4e5d3c4a920f7b7c528f9 > prerequisite-patch-id: 3fe1bc3b93e9502f874c485c5f2e39eec4899222 > prerequisite-patch-id: 982ed5e31a6616f9788d4641c3757342e9f15576 > prerequisite-patch-id: 6a207af4a7044cc47ab3f797e9c865fdbdb5d20c > prerequisite-patch-id: f34ad579025354af65a73c1497dc967e2e834a55 > prerequisite-patch-id: 5ad384179da558ff3359baabda588731ed2e90a4 > prerequisite-patch-id: d3d243977afb4f574fb289eddf0e71becda1ae2b All applied. Thanks.
Le 22/10/2023 à 10:10, Eric Biggers a écrit : > From: Eric Biggers <ebiggers@google.com> > > The crypto API's support for alignmasks for ahash algorithms is nearly > useless, as its only effect is to cause the API to align the key and > result buffers. The drivers that happen to be specifying an alignmask > for ahash rarely actually need it. When they do, it's easily fixable, > especially considering that these buffers cannot be used for DMA. > > In preparation for removing alignmask support from ahash, this patch > makes the talitos driver no longer use it. This driver didn't actually > rely on it; it only writes to the result buffer in > common_nonsnoop_hash_unmap(), simply using memcpy(). And this driver's > "ahash_setkey()" function does not assume any alignment for the key > buffer. I can't really see the link between your explanation and commit c9cca7034b34 ("crypto: talitos - Align SEC1 accesses to 32 bits boundaries."). Was that commit wrong ? Christophe > > Signed-off-by: Eric Biggers <ebiggers@google.com> > --- > drivers/crypto/talitos.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c > index 4ca4fbd227bce..e8f710d87007b 100644 > --- a/drivers/crypto/talitos.c > +++ b/drivers/crypto/talitos.c > @@ -3252,21 +3252,21 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev, > dev_err(dev, "unknown algorithm type %d\n", t_alg->algt.type); > devm_kfree(dev, t_alg); > return ERR_PTR(-EINVAL); > } > > alg->cra_module = THIS_MODULE; > if (t_alg->algt.priority) > alg->cra_priority = t_alg->algt.priority; > else > alg->cra_priority = TALITOS_CRA_PRIORITY; > - if (has_ftr_sec1(priv)) > + if (has_ftr_sec1(priv) && t_alg->algt.type != CRYPTO_ALG_TYPE_AHASH) > alg->cra_alignmask = 3; > else > alg->cra_alignmask = 0; > alg->cra_ctxsize = sizeof(struct talitos_ctx); > alg->cra_flags |= CRYPTO_ALG_KERN_DRIVER_ONLY; > > t_alg->dev = dev; > > return t_alg; > }