From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82FABC636D3 for ; Tue, 7 Feb 2023 22:25:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A8B585DF2; Tue, 7 Feb 2023 23:25:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DQMm+f1H"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0752C85E45; Tue, 7 Feb 2023 23:25:33 +0100 (CET) Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 53F9985DF2 for ; Tue, 7 Feb 2023 23:25:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-ej1-x62d.google.com with SMTP id u22so2003912ejj.10 for ; Tue, 07 Feb 2023 14:25:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ICnaQfJKpAX8d+LytQTtS4p8D3ciI2ToAAleyKc7fh0=; b=DQMm+f1HlsbKVq6PDSc0QdDxKbSk5MfUdoX5tml/nHqGe8zx0UVde5Ev21N7XtD5Fq g0PYh3xGX+t4uBJMy/02Cdl2Az58hkTyffL5TzhwkkQrEmYJhFeFeRfXQJwRxZGkVZMg odHpbxdWMvJNqlzF9CwRvynnagypuksoPvXLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ICnaQfJKpAX8d+LytQTtS4p8D3ciI2ToAAleyKc7fh0=; b=FhP6Icki5QHA+3RVTQ5f0uuezf3TstNIwGm6W2U8J1aQQ13xIUzKZJxZf6c9cBkiuX ZKZ+EF8k6fjpIzbtfqew7mJ3+WRMs6vOuPTLsOPaxcrrN0A7p1PSVoq8GwlulvgTLXF0 V/6fITBAcZ47tf0qmPjarzqdzj+JCcymRGOMZRDBy+ZVOahDyCOz96Tt/iYOt/z2ri++ 6DOpegu3kHYziBhdR2joZChszLe4Oqj8d3+NTf2AovDwUaEh8vQxGLFweMGlHElVb6w8 N3Qb7ZiE9TyI4CfHGfhJkUUa2kC0gl+4IUhYA6OwOLdKPSVSPDfvJobOdlO/ChtKaFGz KCaA== X-Gm-Message-State: AO0yUKVJLAHnWLw5RYnUMIy0c2BIxYvT3CUiPeawyzt1I/rdfNPUgb8a CMt5JcEViTeSeA5Sl3PnT+u4vpuVIcQhaw6IYdxo6Q== X-Google-Smtp-Source: AK7set93UXaQfUy6s5L180Jg7IaBDqBJn9Iwo1RXa3z8ktsBTOzBNSyjqfv00U+7iCyfv8Osb/C0oZLyrvnmmTuAZXk= X-Received: by 2002:a17:906:6a94:b0:896:43bd:7915 with SMTP id p20-20020a1709066a9400b0089643bd7915mr1297470ejr.93.1675808729617; Tue, 07 Feb 2023 14:25:29 -0800 (PST) MIME-Version: 1.0 References: <1654107991-598-1-git-send-email-loic.poulain@linaro.org> <1654107991-598-5-git-send-email-loic.poulain@linaro.org> In-Reply-To: From: Simon Glass Date: Tue, 7 Feb 2023 15:25:16 -0700 Message-ID: Subject: Re: [PATCH v2 4/5] lib: sha256: Add support for hardware specific sha256_process To: Loic Poulain Cc: kettenis@openbsd.org, michal.simek@xilinx.com, trini@konsulko.com, u-boot@lists.denx.de Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Hi Loic, On Tue, 7 Feb 2023 at 14:47, Loic Poulain wrote: > > Hi Simon, > > On Tue, 7 Feb 2023 at 05:05, Simon Glass wrote: > > > > Hi Loic, > > > > On Mon, 6 Feb 2023 at 15:12, Loic Poulain wro= te: > > > > > > Hi Simon, > > > > > > Le lun. 6 f=C3=A9vr. 2023 =C3=A0 18:12, Simon Glass a =C3=A9crit : > > >> > > >> Hi Loic, > > >> > > >> On Wed, 1 Jun 2022 at 12:27, Loic Poulain = wrote: > > >> > > > >> > Mark sha256_process as weak to allow hardware specific implementat= ion. > > >> > Add parameter for supporting multiple blocks processing. > > >> > > > >> > Signed-off-by: Loic Poulain > > >> > --- > > >> > lib/sha256.c | 26 +++++++++++++++++++------- > > >> > 1 file changed, 19 insertions(+), 7 deletions(-) > > >> > > [...] > > >> > +__weak void sha256_process(sha256_context *ctx, const unsigned ch= ar *data, > > >> > + unsigned int blocks) > > >> > +{ > > >> > + if (!blocks) > > >> > + return; > > >> > + > > >> > + while (blocks--) { > > >> > + sha256_process_one(ctx, data); > > >> > + data +=3D 64; > > >> > + } > > >> > +} > > >> > + > > >> > void sha256_update(sha256_context *ctx, const uint8_t *input, uin= t32_t length) > > >> > { > > >> > uint32_t left, fill; > > >> > @@ -204,17 +218,15 @@ void sha256_update(sha256_context *ctx, cons= t uint8_t *input, uint32_t length) > > >> > > > >> > if (left && length >=3D fill) { > > >> > memcpy((void *) (ctx->buffer + left), (void *) inp= ut, fill); > > >> > - sha256_process(ctx, ctx->buffer); > > >> > + sha256_process(ctx, ctx->buffer, 1); > > >> > length -=3D fill; > > >> > input +=3D fill; > > >> > left =3D 0; > > >> > } > > >> > > > >> > - while (length >=3D 64) { > > >> > - sha256_process(ctx, input); > > >> > - length -=3D 64; > > >> > - input +=3D 64; > > >> > - } > > >> > + sha256_process(ctx, input, length / 64); > > >> > + input +=3D length / 64 * 64; > > >> > + length =3D length % 64; > > >> > > > >> > if (length) > > >> > memcpy((void *) (ctx->buffer + left), (void *) inp= ut, length); > > >> > -- > > >> > 2.7.4 > > >> > > > >> > > >> I just came across this patch as it broke minnowmax. > > > > > > > > > Ok, is it a build time or runtime break? > > > > Build, but you need the binary blobs to see it :-( > > >> > > >> This should be using driver model, not weak functions. Please can yo= u > > >> take a look? > > Just tested the minnowmax build (b69026c91f2e; minnowmax_defconfig; > gcc-11.3.0), and I've not observed any issue (but I had to fake some > of the binary blobs...). Could you share the build problem/error you Unfortunately you need the blobs! > encountered? As you mentioned it, Is the error specifically related to > _weak function linking? Would like to have a simple and quick fix > before trying to move on to a more proper DM based solution. It is just because of the code size increase, I believe. I am planning to dig into it a bit as Bin Meng asked for more info as to why I sent a revert for his patch moving U-Boot. Regards, Simon > > Thanks, > Loic > > > > > > > > > > > Yes I can look at it in the next few days. I have used weak function = because it=E2=80=99s an architecture feature offered by armv8 instructions,= It=E2=80=99s not strictly speaking an internal device/IP. > > > > Thanks. > > > > Right, same as hardware-accelerated hashing hardware in my book. > > > > See hash.c which has become a mess. We have been trying to make do > > with a list of algos, but given all the updates I think needs a new > > UCLASS_HASH with the same operations as in hash.h > > > > Regards, > > Simon