crypto: sun4i-ss - fix kmap usage
authorCorentin Labbe <clabbe@baylibre.com>
Mon, 14 Dec 2020 20:02:30 +0000 (20:02 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Mar 2021 10:37:37 +0000 (11:37 +0100)
commit2f7287fbcb9f86a4fbf93f83d0dd4a4888828308
treef97ba21cb66fc43f95107f9981a99e080b5872be
parent99e9cb7bc13befed01303354e05cba713ac617b0
crypto: sun4i-ss - fix kmap usage

[ Upstream commit 9bc3dd24e7dccd50757db743a3635ad5b0497e6e ]

With the recent kmap change, some tests which were conditional on
CONFIG_DEBUG_HIGHMEM now are enabled by default.
This permit to detect a problem in sun4i-ss usage of kmap.

sun4i-ss uses two kmap via sg_miter (one for input, one for output), but
using two kmap at the same time is hard:
"the ordering has to be correct and with sg_miter that's probably hard to get
right." (quoting Tlgx)

So the easiest solution is to never have two sg_miter/kmap open at the same time.
After each use of sg_miter, I store the current index, for being able to
resume sg_miter to the right place.

Fixes: 6298e948215f ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator")
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c