ixp4xx_crypto: fix building wiht 64-bit dma_addr_t
PATCH 1/1 ixp4xx_crypto: fix building wiht 64-bit dma_addr_t
From: Arnd Bergmann <[email protected]>
The crypt_ctl structure must be exactly 64 bytes long to work correctly, and it has to be a power-of-two size to allow turning the 64-bit division in crypt_phys2virt() into a shift operation, avoiding the link failure:
ERROR: modpost: "__aeabi_uldivmod" [drivers/crypto/intel/ixp4xx/ixp4xx_crypto.ko] undefined!
The failure now shows up because the driver is available for compile testing after the move, and a previous fix turned the more descriptive BUILD_BUG_ON() into a link error.
Change the variably-sized dma_addr_t into the expected 'u32' type that is needed for the hardware, and reinstate the size check for all 32-bit architectures to simplify debugging if it hits again.
--- drivers/crypto/intel/ixp4xx/ixp4xx_crypto.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/crypto/intel/ixp4xx/ixp4xx_crypto.c +8 -6
@@ -118,9 +118,9 @@ struct crypt_ctl {u8 mode;/* NPE_OP_* operation mode */ #endif u8 iv[MAX_IVLEN ];/* IV for CBC mode or CTR IV for CTR mode */ -dma_addr_t icv_rev_aes;/* icv or rev aes */ -dma_addr_t src_buf; -dma_addr_t dst_buf; +u32 icv_rev_aes;/* icv or rev aes */ +u32 src_buf; +u32 dst_buf;#ifdef __ARMEB__u16 auth_offs;/* Authentication start offset */ u16 auth_len;/* Authentication data length */
@@ -263,7 +263,8 @@ static int setup_crypt_desc(void) {struct device *dev = &pdev->dev; -BUILD_BUG_ON (!IS_ENABLED (CONFIG_COMPILE_TEST ) && +BUILD_BUG_ON (!(IS_ENABLED (CONFIG_COMPILE_TEST ) && +IS_ENABLED (CONFIG_64BIT )) &&sizeof (struct crypt_ctl ) !=64 ); crypt_virt = dma_alloc_coherent(dev, NPE_QLEN * sizeof(struct crypt_ctl),
@@ -1170,10 +1171,11 @@ static int aead_perform(struct aead_request *req, int encrypt, }if (unlikely (lastlen < authsize)) { +dma_addr_t dma;/* The 12 hmac bytes are scattered, * we need to copy them into a safe buffer */ - req_ctx->hmac_virt =dma_pool_alloc (buffer_pool, flags, - &crypt->icv_rev_aes); + req_ctx->hmac_virt =dma_pool_alloc (buffer_pool, flags, &dma); + crypt->icv_rev_aes = dma;if (unlikely (!req_ctx->hmac_virt)) goto free_buf_dst;if (!encrypt) {
Signature · 1 line
2.39.2
Herbert Xu
maintainerQuoted 17 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The
crypt_ctlstructure must be exactly 64 bytes long to work correctly, and it has to be a power-of-two size to allow turning the 64-bit division incrypt_phys2virt()into a shift operation, avoiding the link failure:ERROR: modpost: "
__aeabi_uldivmod" [drivers/crypto/intel/ixp4xx/ixp4xx_crypto.ko] undefined!The failure now shows up because the driver is available for compile testing after the move, and a previous fix turned the more descriptive
BUILD_BUG_ON()into a link error.Change the variably-sized
dma_addr_tinto the expected 'u32' type that is needed for the hardware, and reinstate the size check for all 32-bit architectures to simplify debugging if it hits again.
Quoted 5 lines
Fixes 1bc7fdbf2677 ("crypto: ixp4xx - Move driver to drivers/crypto/intel/ixp4xx")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/crypto/intel/ixp4xx/ixp4xx_crypto.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt