summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorFranck LENORMAND <franck.lenormand@nxp.com>2018-09-14 10:31:57 +0200
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:34:14 +0800
commitdc0d0dc42d1b90e7f5af420b74cdf330bebf11b4 (patch)
tree27909cc8f0ab921abc4853d967d018d5dffff123 /crypto
parent0ebb5c33746bbb98697a1e30dd5c7fd820e6a1f8 (diff)
MLK-19365: crypto: gcm: Cache aligned auth_data
Generic GCM is likely to end up using a hardware accelerator to do part of the job. Allocating hash, iv and result in a contiguous memory area increases the risk of dma mapping multiple ranges on the same cacheline. Also having dma and cpu written data on the same cacheline will cause coherence issues. Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/gcm.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/crypto/gcm.c b/crypto/gcm.c
index cd9591285233..95b12541c49a 100644
--- a/crypto/gcm.c
+++ b/crypto/gcm.c
@@ -66,7 +66,18 @@ struct crypto_gcm_ghash_ctx {
struct crypto_gcm_req_priv_ctx {
u8 iv[16];
- u8 auth_tag[16];
+
+ /*
+ * We need to force auth_tag to be on its own cacheline.
+ *
+ * We put it on its cacheline with the macro ____cacheline_aligned.
+ * The next fields must be on another cacheline so we add a dummy field
+ * which is located on another cacheline to enforce that.
+ */
+ u8 auth_tag[16] ____cacheline_aligned;
+
+ u8 dummy_align_auth_tag ____cacheline_aligned;
+
u8 iauth_tag[16];
struct scatterlist src[3];
struct scatterlist dst[3];