crypto: omap-crypto - Verify page zone scatterlists before starting DMA
authorTero Kristo <t-kristo@ti.com>
Tue, 27 Feb 2018 13:30:35 +0000 (15:30 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 9 Mar 2018 14:45:36 +0000 (22:45 +0800)
In certain platforms like DRA7xx having memory > 2GB with LPAE enabled
has a constraint that DMA can be done with the initial 2GB and marks it
as ZONE_DMA. But openssl when used with cryptodev does not make sure that
input buffer is DMA capable. So, adding a check to verify if the input
buffer is capable of DMA.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/omap-crypto.c

index 23e37779317e435769f3a6734801bc6f31e388fb..2c42e4b4a6e9d15f3c84c985096dd772b6884db7 100644 (file)
@@ -104,6 +104,10 @@ static int omap_crypto_check_sg(struct scatterlist *sg, int total, int bs,
                        return OMAP_CRYPTO_NOT_ALIGNED;
                if (!IS_ALIGNED(sg->length, bs))
                        return OMAP_CRYPTO_NOT_ALIGNED;
+#ifdef CONFIG_ZONE_DMA
+               if (page_zonenum(sg_page(sg)) != ZONE_DMA)
+                       return OMAP_CRYPTO_NOT_ALIGNED;
+#endif
 
                len += sg->length;
                sg = sg_next(sg);