From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqG1r-0006Lh-Qt for barebox@lists.infradead.org; Tue, 21 Mar 2017 09:24:39 +0000 From: Oleksij Rempel Date: Tue, 21 Mar 2017 10:24:09 +0100 Message-Id: <20170321092411.8844-6-o.rempel@pengutronix.de> In-Reply-To: <20170321092411.8844-1-o.rempel@pengutronix.de> References: <20170321092411.8844-1-o.rempel@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v4 5/7] crypto: caam - fix RNG buffer cache alignment To: barebox@lists.infradead.org Cc: Oleksij Rempel , Victoria Milhoan , Steve Cornelius , stable@vger.kernel.org, Herbert Xu this is alternate version of linux fix: --------------------------------------------------------------------- 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 Signed-off-by: Victoria Milhoan Signed-off-by: Herbert Xu --------------------------------------------------------------------- instead we will use just dma_alloc() Signed-off-by: Oleksij Rempel --- drivers/crypto/caam/caamrng.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c index aabad0416..31a92731d 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c @@ -55,7 +55,7 @@ /* Buffer, its dma address and lock */ struct buf_data { - u8 buf[RN_BUF_SIZE]; + u8 *buf; dma_addr_t addr; u32 hw_desc[DESC_JOB_O_LEN]; #define BUF_NOT_EMPTY 0 @@ -218,6 +218,8 @@ static int caam_init_buf(struct caam_rng_ctx *ctx, int buf_id) struct buf_data *bd = &ctx->bufs[buf_id]; int err; + bd->buf = dma_alloc(RN_BUF_SIZE); + err = rng_create_job_desc(ctx, buf_id); if (err) return err; -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox