Skip to content

Commit

Permalink
crypto: caam - fix RNG buffer cache alignment
Browse files Browse the repository at this point in the history
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.

Cc: stable@vger.kernel.org
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>
  • Loading branch information
Steve Cornelius authored and Herbert Xu committed Jun 16, 2015
1 parent 6fd4b15 commit 412c98c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/crypto/caam/caamrng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 412c98c

Please sign in to comment.