Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp979899imw; Tue, 5 Jul 2022 01:28:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vwDwxegZwEc8NDC/aShRVA2HZlDLMI7W3+ebiEUw9OLsnnlCDCGWBJe8p5GPbLMrA8fCTM X-Received: by 2002:a05:6402:1d4b:b0:435:cac5:1957 with SMTP id dz11-20020a0564021d4b00b00435cac51957mr44569598edb.109.1657009703746; Tue, 05 Jul 2022 01:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657009703; cv=none; d=google.com; s=arc-20160816; b=xrWbLI76WpBI5I/n+SXznB+lKNRUttLiyT3sw9nCTALbJe+CwXFFQjzXB/aSWEM1pZ AMJKVc7G3GHWwG51iq7yIOCHmS5JU4ztnhw1E8+qeXGL8pJG3S/HoMaH2/Nl9WZ2w3n5 e7UGTEX1l2pPJZHvrJzTsWSZlbGI0d+wCxbDySblfIB4ofstjSeW/wC7XNY8JyLCp/aA t8aUxc98MBf0fdoexfv5Lc+k4h2YH/WDem1UFsAATmcbauM57/PHaOPsN5bcdYfDGE2s WFLxz4uDGRLFhijOzjhjRP+oIDHkA3Xawf3Ezr/10yrVhrR3QBsgp+oset04xoWo42Mq ww6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wfqoXVK+YfH3izkn1ZIOXk7M9UJ/gOHJBL54VlMil1E=; b=M3tM5EP4Bn5Xrd0Tcqll+zXbku/UysUxnDQlJuIjzJS5YWiZyplu/VrutbtxQ26DQe I5RRdiLyLmY3Nqzd0VUENAmHZwIrg7DK1t68fVeABLOERXy6sVmx5KN3yTxTBiG3Abxx msEFh8qZpzhi2RRooODah5/jcY/EWW3vg2RlQLFAB1kmTFxejTpFXdVTrRPo+ZSmJem6 C7jpri8OS5SE3dsfpJM8txBME7c8qAwxAhUTMI5M5k/j4D6xyd8dfXVWryGInEqrA4N8 hqAUKCUXZ0IiRPmxqTTQmOED9PB1sYC+tWRolMgkCP5kf38HF0XgUGRcBbkaCtA6g9VL rt9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=xUkNuB6s; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ej27-20020a056402369b00b00437749846e0si14493611edb.574.2022.07.05.01.27.40; Tue, 05 Jul 2022 01:28:23 -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; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=xUkNuB6s; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbiGEIVU (ORCPT + 99 others); Tue, 5 Jul 2022 04:21:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbiGEIVU (ORCPT ); Tue, 5 Jul 2022 04:21:20 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE7ACD3 for ; Tue, 5 Jul 2022 01:21:18 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id o16-20020a05600c379000b003a02eaea815so7502823wmr.0 for ; Tue, 05 Jul 2022 01:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=wfqoXVK+YfH3izkn1ZIOXk7M9UJ/gOHJBL54VlMil1E=; b=xUkNuB6sThZg8/L+TCfTHvgqmve+3X2XTscpzPB8Tdd347qOEdLnpGh+mxdoEih7j+ LWCL7OdboRbOwv0QIsWPxwLkyW60r6irie07Mr+8PkDgDPCIjcWUhcM+RlBKaOlzwpiL I9oZqLzvc1EQwqvJkJygFu1TJthBVJpGZQo0/Xe8hUr8QpCPFrsHLL6F/ySU1L6krew6 KDXsXBtTB9BWPKMq81vsoGDHHMUFq1YO/k86zB55BlddKyc4GChaRZ8aTpAIERpcpLcE 1WndJcUi28Js1hwgiup05QRq/MZn02FUl9eX0YYVgkR7sZW3++szGVyA8qXWoGF0PzuR st7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=wfqoXVK+YfH3izkn1ZIOXk7M9UJ/gOHJBL54VlMil1E=; b=ujp6lO9vG3ZMjXkAsxudqnlFFJdpsv2Hm1jsRj3zcsNOJMPaWISPlQ2jra5F/D5F21 crZBBxszHriBJEna2US8g3XN5QQB60ZQV+jejnAnU7k7O+4QwukP6WvbXBHsHyF4ccSA OI5sR4ugdcEAX6yQg/BrbVPXn4435pYm12rk8Efcq3mMwYY+rKZsXsLNv4szV200W/Vh n++G4yV7dE77UE0MjQFr1Fxta+Zn+8dD/ck+VNl76RuVQCCDlhE/LVAUCmbWLbpZ9s1V CPR8ejvICPifTbvopektgHvRwuZE1I/TqcUzm2ENIMLVAKn4OjAGZ+QTkPze4/u3SYDc nmsA== X-Gm-Message-State: AJIora/qTrcgAQ2NgbYG7sH9CADOKWaUk2xQwjXFqzGMNrgTWW5UVt2u nyplo8wV/+rQNdobMya70ZVqhA== X-Received: by 2002:a05:600c:4ece:b0:3a1:7816:31a9 with SMTP id g14-20020a05600c4ece00b003a1781631a9mr30790692wmq.100.1657009277148; Tue, 05 Jul 2022 01:21:17 -0700 (PDT) Received: from Red ([2a01:cb1d:3d5:a100:264b:feff:fe03:2806]) by smtp.googlemail.com with ESMTPSA id m123-20020a1ca381000000b003942a244f47sm19512608wme.32.2022.07.05.01.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 01:21:16 -0700 (PDT) Date: Tue, 5 Jul 2022 10:21:13 +0200 From: LABBE Corentin To: Ben Dooks Cc: herbert@gondor.apana.org.au, hch@lst.de, heiko@sntech.de, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [RFC PATCH] crypto: flush poison data Message-ID: References: <20220701132735.1594822-1-clabbe@baylibre.com> <4570f6d8-251f-2cdb-1ea6-c3a8d6bb9fcf@codethink.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4570f6d8-251f-2cdb-1ea6-c3a8d6bb9fcf@codethink.co.uk> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 Le Fri, Jul 01, 2022 at 02:35:41PM +0100, Ben Dooks a ?crit : > 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? > I just copied what did drivers/crypto/xilinx/zynqmp-sha.c. I tried to do flush_dcache_range() but it seems to not be implemented on riscV. And flush_dcache_page(virt_to_page(addr), len) produce a kernel panic. Any advice on how to go further ?