Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1314011imi; Fri, 1 Jul 2022 07:18:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tgwRfU6Wt9gKPBbmNEarBb3IPvkkL/U3ISWLJcJAZAkiHMpZoTps/w5Nqw0WIyeW3eobvt X-Received: by 2002:a17:90b:1a84:b0:1ec:c46f:e150 with SMTP id ng4-20020a17090b1a8400b001ecc46fe150mr18812972pjb.36.1656685101249; Fri, 01 Jul 2022 07:18:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656685101; cv=none; d=google.com; s=arc-20160816; b=WwjIlZDpYNu9nHIXO011RBM4fFl3IPzYexShWKRmQRAzWBXQvlEucixFpljHdgW+Bg PxpmnK0Lz7DHbvfab93VI4seBLQdLBh7zlHlOmd1AFjcIjfDmRIvAfMzy9dUtH7KaCLt 2tjwAPDQLdiC5SEdfW0vvaqurAhoeyfph9RJi41ELgGjCDfE+yb5EDsZTn4nCnbiK0hl IiQEWt9hkw1mFPMcrzSAZLuf2sSJcae7Z3tkuDpXl5dCSp7vLNH/S3f6xKAstmLKRDQC X/9YEM8U7PHmYK9avd3weTPb0FybfD4P8PVLBuczNwNGg/78G4FVApcTOYeUFYI04DUT 40TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id; bh=tx4TEKXXhKXRts1/WFHTHkXxcEJSoKgIncR2Go7OgCY=; b=LkKd4KzfSsqDYk+KEY6nriA4pTZsqyVSHkMbWGEejUJxscQf2VqY0gYVekMfoJjOxo wqLWQZH3xc/oDBT3RdPeo/ZIu9+ZnMRoL6BPGDJI7FNLvepvzmJcMuGdY1inTY5D/D6I 2S8h5R3OF6iwwk/rfvcOWpbsHApPoZNi+9xjxdwx0zfrxDhCTIkaihOQ0r7/3lyXJrjU q98FMliJ8Vhh7MYVdP/Ip44fcYXfC8M2SJG2BoGuSDqt+FjHOPuTDJGxT0tluJupnAid t6FXbHE4bsIjSgx46Ii9LwJsWEwuxmYkcfIRgq15aTtB1XIo6nKZPFMejeDPfqsxLBye 0KAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a170902ce8200b00161e9f72b11si32108231plg.540.2022.07.01.07.17.51; Fri, 01 Jul 2022 07:18:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230232AbiGAOJG (ORCPT + 99 others); Fri, 1 Jul 2022 10:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbiGAOJF (ORCPT ); Fri, 1 Jul 2022 10:09:05 -0400 X-Greylist: delayed 1994 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 01 Jul 2022 07:09:04 PDT Received: from imap2.colo.codethink.co.uk (imap2.colo.codethink.co.uk [78.40.148.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7AF434655 for ; Fri, 1 Jul 2022 07:09:04 -0700 (PDT) Received: from [167.98.27.226] (helo=[10.35.4.171]) by imap2.colo.codethink.co.uk with esmtpsa (Exim 4.92 #3 (Debian)) id 1o7Go9-00077s-ML; Fri, 01 Jul 2022 14:35:41 +0100 Message-ID: <4570f6d8-251f-2cdb-1ea6-c3a8d6bb9fcf@codethink.co.uk> Date: Fri, 1 Jul 2022 14:35:41 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [RFC PATCH] crypto: flush poison data Content-Language: en-GB To: Corentin Labbe , herbert@gondor.apana.org.au, hch@lst.de, heiko@sntech.de Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sunxi@lists.linux.dev References: <20220701132735.1594822-1-clabbe@baylibre.com> From: Ben Dooks Organization: Codethink Limited. In-Reply-To: <20220701132735.1594822-1-clabbe@baylibre.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 01/07/2022 14:27, Corentin Labbe wrote: > On my Allwinner D1 nezha, the sun8i-ce fail self-tests due to: > alg: skcipher: cbc-des3-sun8i-ce encryption overran dst buffer on test vector 0 > > In fact the buffer is not overran by device but by the dma_map_single() operation. > > To prevent any corruption of the poisoned data, simply flush them before > giving the buffer to the tested driver. > > Signed-off-by: Corentin Labbe > --- > > Hello > > I put this patch as RFC, since this behavour happen only on non yet merged RISCV code. > (Mostly riscv: implement Zicbom-based CMO instructions + the t-head variant) > > Regards > > crypto/testmgr.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/crypto/testmgr.c b/crypto/testmgr.c > index c59bd9e07978..187163e2e593 100644 > --- a/crypto/testmgr.c > +++ b/crypto/testmgr.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -205,6 +206,8 @@ static void testmgr_free_buf(char *buf[XBUFSIZE]) > static inline void testmgr_poison(void *addr, size_t len) > { > memset(addr, TESTMGR_POISON_BYTE, len); > + /* Be sure data is written to prevent corruption from some DMA sync */ > + flush_icache_range((unsigned long)addr, (unsigned long)addr + len); > } > > /* Is the memory region still fully poisoned? */ why are you flushing the instruction cache and not the data-cache? -- Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius https://www.codethink.co.uk/privacy.html