]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.10.82/crypto-caam-fix-rng-buffer-cache-alignment.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.10.82 / crypto-caam-fix-rng-buffer-cache-alignment.patch
1 From 412c98c1bef65fe7589f1300e93735d96130307c Mon Sep 17 00:00:00 2001
2 From: Steve Cornelius <steve.cornelius@freescale.com>
3 Date: Mon, 15 Jun 2015 16:52:59 -0700
4 Subject: crypto: caam - fix RNG buffer cache alignment
5
6 From: Steve Cornelius <steve.cornelius@freescale.com>
7
8 commit 412c98c1bef65fe7589f1300e93735d96130307c upstream.
9
10 The hwrng output buffers (2) are cast inside of a a struct (caam_rng_ctx)
11 allocated in one DMA-tagged region. While the kernel's heap allocator
12 should place the overall struct on a cacheline aligned boundary, the 2
13 buffers contained within may not necessarily align. Consenquently, the ends
14 of unaligned buffers may not fully flush, and if so, stale data will be left
15 behind, resulting in small repeating patterns.
16
17 This fix aligns the buffers inside the struct.
18
19 Note that not all of the data inside caam_rng_ctx necessarily needs to be
20 DMA-tagged, only the buffers themselves require this. However, a fix would
21 incur the expense of error-handling bloat in the case of allocation failure.
22
23 Signed-off-by: Steve Cornelius <steve.cornelius@freescale.com>
24 Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>
25 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28 ---
29 drivers/crypto/caam/caamrng.c | 2 +-
30 1 file changed, 1 insertion(+), 1 deletion(-)
31
32 --- a/drivers/crypto/caam/caamrng.c
33 +++ b/drivers/crypto/caam/caamrng.c
34 @@ -56,7 +56,7 @@
35
36 /* Buffer, its dma address and lock */
37 struct buf_data {
38 - u8 buf[RN_BUF_SIZE];
39 + u8 buf[RN_BUF_SIZE] ____cacheline_aligned;
40 dma_addr_t addr;
41 struct completion filled;
42 u32 hw_desc[DESC_JOB_O_LEN];