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 D5FD9C636CC for ; Tue, 7 Feb 2023 21:47:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 010D585E14; Tue, 7 Feb 2023 22:47:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="HIDqud2B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF7F683623; Tue, 7 Feb 2023 22:47:55 +0100 (CET) Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) (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 7348A85E16 for ; Tue, 7 Feb 2023 22:47:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=loic.poulain@linaro.org Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-16a10138faeso14476027fac.11 for ; Tue, 07 Feb 2023 13:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.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=GNCKXc24J2Zugody7lyvFATGTFzfrxlgw0gqHBc5Sw0=; b=HIDqud2BNVmNDIbDp9qNkAUZ6If0g74ZVVJtexgpGtbElDw227LG0shwBvrV7FcWjn EC4a3s2Qm9EnA+TmoHj1rmSsv+/qNtOKRd1REEVittPFh4GghJLgnwyLIe++P1BS+xWu PufB5IHB5GPnzWcEX6fBB3dCRpee59AaN5WnzIrVbWkAZGzfRVSWZ/NQUReThnJbLEpA 1/WiTpDpMetCa2uydrxeWUYgYjTnb948+WcTAoLE2EJLCkX7CL069TkGtoN2baVIk2oF cOQmXM4soicyssFg4/pbnWnSrW7Np7GqYNj8HjvjPLQM93813Cdu12XYT8Pw3jKmwaCk aaoA== 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=GNCKXc24J2Zugody7lyvFATGTFzfrxlgw0gqHBc5Sw0=; b=dQyHK06wHUp0scJuWKTq+xYRHveiMy99NhkGdZYDtnF+c3FKGsXV8m4M3ujCnkcNeP ECQdhbmvwqQZaLj2AnieTAP+qeL/GH4Q+1g4I/PNZ7jVnSi4BBdHxQ+O1adHjZQMKo4X SLC4B7rCVaDc1RHrN6w/5L2AQ/Ys4EFfrYIAhB1HFlp3jI0gKShrMjsdyxlka1RjZ27z x25p0dttND4o3mrH9T587pykhYWeRh7hPRKmeuhmtS8W2jlDZiFmV+M7gldV3H4BtN2+ MR7LFpN1S/fEFhEi6GiKpimAA7gpqJw/EWHTCHeN36xmPaHMGizG700njdvZ87jmaQoY 2ADA== X-Gm-Message-State: AO0yUKXdzx4/O+jVGvU7c4wZl7gRHCKAX6s4aIItVwOtPO/otq59PqdF +jRrZFDq0x5GF403j6sp365moYq1Qk2uO05W+MauRw== X-Google-Smtp-Source: AK7set8NgaHsrmH31eUHXAyG2hxFQkg859y1Cb8K6OxPDKf8CpMoBkUZWhkRkfQLiIPe9hnIVrLtOgD0dFrhsc/HZ44= X-Received: by 2002:a05:6870:ec8d:b0:15f:1ad9:6c2c with SMTP id eo13-20020a056870ec8d00b0015f1ad96c2cmr75548oab.184.1675806471012; Tue, 07 Feb 2023 13:47:51 -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: Loic Poulain Date: Tue, 7 Feb 2023 22:47:13 +0100 Message-ID: Subject: Re: [PATCH v2 4/5] lib: sha256: Add support for hardware specific sha256_process To: Simon Glass 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 Simon, On Tue, 7 Feb 2023 at 05:05, Simon Glass wrote: > > Hi Loic, > > On Mon, 6 Feb 2023 at 15:12, Loic Poulain wrote= : > > > > 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 wr= ote: > >> > > >> > Mark sha256_process as weak to allow hardware specific implementatio= n. > >> > 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 char= *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, uint3= 2_t length) > >> > { > >> > uint32_t left, fill; > >> > @@ -204,17 +218,15 @@ void sha256_update(sha256_context *ctx, const = uint8_t *input, uint32_t length) > >> > > >> > if (left && length >=3D fill) { > >> > memcpy((void *) (ctx->buffer + left), (void *) input= , 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 *) input= , 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 you > >> 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 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. Thanks, Loic > > > > > > Yes I can look at it in the next few days. I have used weak function be= cause it=E2=80=99s an architecture feature offered by armv8 instructions, I= t=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