Skip to content

Commit 586d492

Browse files
arndbherbertx
authored andcommitted
crypto: ixp4xx - fix building wiht 64-bit dma_addr_t
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. Fixes: 1bc7fdb ("crypto: ixp4xx - Move driver to drivers/crypto/intel/ixp4xx") Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 0489929 commit 586d492

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/crypto/intel/ixp4xx/ixp4xx_crypto.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ struct crypt_ctl {
118118
u8 mode; /* NPE_OP_* operation mode */
119119
#endif
120120
u8 iv[MAX_IVLEN]; /* IV for CBC mode or CTR IV for CTR mode */
121-
dma_addr_t icv_rev_aes; /* icv or rev aes */
122-
dma_addr_t src_buf;
123-
dma_addr_t dst_buf;
121+
u32 icv_rev_aes; /* icv or rev aes */
122+
u32 src_buf;
123+
u32 dst_buf;
124124
#ifdef __ARMEB__
125125
u16 auth_offs; /* Authentication start offset */
126126
u16 auth_len; /* Authentication data length */
@@ -263,7 +263,8 @@ static int setup_crypt_desc(void)
263263
{
264264
struct device *dev = &pdev->dev;
265265

266-
BUILD_BUG_ON(!IS_ENABLED(CONFIG_COMPILE_TEST) &&
266+
BUILD_BUG_ON(!(IS_ENABLED(CONFIG_COMPILE_TEST) &&
267+
IS_ENABLED(CONFIG_64BIT)) &&
267268
sizeof(struct crypt_ctl) != 64);
268269
crypt_virt = dma_alloc_coherent(dev,
269270
NPE_QLEN * sizeof(struct crypt_ctl),
@@ -1170,10 +1171,11 @@ static int aead_perform(struct aead_request *req, int encrypt,
11701171
}
11711172

11721173
if (unlikely(lastlen < authsize)) {
1174+
dma_addr_t dma;
11731175
/* The 12 hmac bytes are scattered,
11741176
* we need to copy them into a safe buffer */
1175-
req_ctx->hmac_virt = dma_pool_alloc(buffer_pool, flags,
1176-
&crypt->icv_rev_aes);
1177+
req_ctx->hmac_virt = dma_pool_alloc(buffer_pool, flags, &dma);
1178+
crypt->icv_rev_aes = dma;
11771179
if (unlikely(!req_ctx->hmac_virt))
11781180
goto free_buf_dst;
11791181
if (!encrypt) {

0 commit comments

Comments
 (0)