OSDN Git Service

crypto: caam - fix S/G table passing page boundary
authorHoria Geantă <horia.geanta@nxp.com>
Fri, 3 May 2019 14:17:38 +0000 (17:17 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 23 May 2019 06:01:03 +0000 (14:01 +0800)
commita5e5c13398f353bb7ebbe913a7bb0c2a77b2ae10
tree81a97f828dbecd401d927245d0d966d0dae54ca2
parentdcd9c76e5a183af4f793beb5141efcd260b8d09f
crypto: caam - fix S/G table passing page boundary

According to CAAM RM:
-crypto engine reads 4 S/G entries (64 bytes) at a time,
even if the S/G table has fewer entries
-it's the responsibility of the user / programmer to make sure
this HW behaviour has no side effect

The drivers do not take care of this currently, leading to IOMMU faults
when the S/G table ends close to a page boundary - since only one page
is DMA mapped, while CAAM's DMA engine accesses two pages.

Fix this by rounding up the number of allocated S/G table entries
to a multiple of 4.
Note that in case of two *contiguous* S/G tables, only the last table
might needs extra entries.

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg.c
drivers/crypto/caam/caamalg_qi.c
drivers/crypto/caam/caamalg_qi2.c
drivers/crypto/caam/caamhash.c
drivers/crypto/caam/caampkc.c
drivers/crypto/caam/desc_constr.h