crypto/fsl: fix BLOB encapsulation and decapsulation
authorClemens Gruber <clemens.gruber@pqgruber.com>
Sun, 7 Jan 2018 19:26:29 +0000 (20:26 +0100)
committerYe Li <ye.li@nxp.com>
Mon, 2 Apr 2018 02:41:33 +0000 (19:41 -0700)
commit1d7f31a55b284ea5bf206ea30e07cc96c851c6ec
tree2f0d1add5dd8d559ead056b5673a36e2700a1535
parentb4b1dc8ed74ce518a02f091b9a26ec88c79b659e
crypto/fsl: fix BLOB encapsulation and decapsulation

The blob_encap and blob_decap functions were not flushing the dcache
before passing data to CAAM/DMA and not invalidating the dcache when
getting data back.
Therefore, blob encapsulation and decapsulation failed with errors like
the following due to data cache incoherency:
"40000006: DECO: desc idx 0: Invalid KEY command"

To ensure coherency, we require the key_mod, src and dst buffers to be
aligned to the cache line size and flush/invalidate the memory regions.
The same requirements apply to the job descriptor.

Tested on an i.MX6Q board.

Reviewed-by: Sumit Garg <sumit.garg@nxp.com>
Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
[Breno: Backported to v2017.03]
Signed-off-by: Breno Lima <breno.lima@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit f4e19b92bc40184eee7d33e53cd190dfb692b196)
drivers/crypto/fsl/fsl_blob.c
include/fsl_sec.h