]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: caam - fix RNG buffer cache alignment
authorSteve Cornelius <steve.cornelius@freescale.com>
Mon, 15 Jun 2015 23:52:59 +0000 (16:52 -0700)
committerLuis Henriques <luis.henriques@canonical.com>
Tue, 30 Jun 2015 16:15:29 +0000 (17:15 +0100)
commit 412c98c1bef65fe7589f1300e93735d96130307c upstream.

The hwrng output buffers (2) are cast inside of a a struct (caam_rng_ctx)
allocated in one DMA-tagged region. While the kernel's heap allocator
should place the overall struct on a cacheline aligned boundary, the 2
buffers contained within may not necessarily align. Consenquently, the ends
of unaligned buffers may not fully flush, and if so, stale data will be left
behind, resulting in small repeating patterns.

This fix aligns the buffers inside the struct.

Note that not all of the data inside caam_rng_ctx necessarily needs to be
DMA-tagged, only the buffers themselves require this. However, a fix would
incur the expense of error-handling bloat in the case of allocation failure.

Signed-off-by: Steve Cornelius <steve.cornelius@freescale.com>
Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
drivers/crypto/caam/caamrng.c

index 8c07d3153f125df158301f0e13226c597b2babc8..18c05cae36a4d0211c9ef75e00d486d9be4e5112 100644 (file)
@@ -56,7 +56,7 @@
 
 /* Buffer, its dma address and lock */
 struct buf_data {
-       u8 buf[RN_BUF_SIZE];
+       u8 buf[RN_BUF_SIZE] ____cacheline_aligned;
        dma_addr_t addr;
        struct completion filled;
        u32 hw_desc[DESC_JOB_O_LEN];