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 1244DC05027 for ; Wed, 8 Feb 2023 18:28:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 313A485F1A; Wed, 8 Feb 2023 19:28:43 +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="Veu/vN7J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B76FF85F1B; Wed, 8 Feb 2023 19:28:39 +0100 (CET) Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (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 435F385F0F for ; Wed, 8 Feb 2023 19:28:34 +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-x62e.google.com with SMTP id dr8so53252753ejc.12 for ; Wed, 08 Feb 2023 10:28:34 -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=e55b1DU4TWgj3FE4OvqcOLkNqzDefXi0/x4Z8RkyiHI=; b=Veu/vN7JpdvObuBMGgovQKYpX0SzE0nYTEgOeeCqjsDCOV27Wwv0rpvWr6xI3knGiE R8tE4lzBQx+A0dq4qZoqtuWeAzPCbkqyJfdbVcwi9MOOX7EK2k2QetASvr/gnm+lSfru T+lQzBZJk0tSALh0NDYzu0Lq40DAEeV3I9UK4= 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=e55b1DU4TWgj3FE4OvqcOLkNqzDefXi0/x4Z8RkyiHI=; b=jLnopIaMBCIQrqBDk7iynVSoD//axkATaVTr1x47qfkeD7kmgqKBGhgG93il2KRHK0 ZmPAPrrHboC/8L6y9EPFxavJzZJGEjzhTBYZieeITD6VLxusxbfNiABqdduulxQGxXgr OaGT17r9qUwStBdPl9UDFPEiViPokPbza2VZl1ZcV4Ihmjlgq1soaOV6aFaTGGsTm1q+ GthCusD7dFis+C+sENUwLcYcfsSw9dAPWi09ahZpQtKZk2QsvuDK+Nb4LdW70g0Iankj Nf4Z0PNVgGN1k4LnB/V+eGs+n3D0a7CtgSfVlemDAjI1As1D8FrJcuAhnfQy7og9hW6d 6adg== X-Gm-Message-State: AO0yUKWUkjC7+i3IA0rcjaQo8fKTUK8Eb5GF3JtPAfeypULpBjQ8mj3q WpG4H8d3+kmjWJur0BU9D76zRFY7//xXje7C7BqLYg== X-Google-Smtp-Source: AK7set/vER7eaio+6ymSB79WsfHXmkvzgr3BWgWjucWzNuswh2INAcxiPV+5rf1YVGiuNoRnGqk/982mLfgq0g5M9sA= X-Received: by 2002:a17:906:6a94:b0:896:43bd:7915 with SMTP id p20-20020a1709066a9400b0089643bd7915mr2034757ejr.93.1675880913692; Wed, 08 Feb 2023 10:28:33 -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: Wed, 8 Feb 2023 11:28:21 -0700 Message-ID: Subject: Re: [PATCH v2 4/5] lib: sha256: Add support for hardware specific sha256_process To: Tom Rini Cc: Loic Poulain , kettenis@openbsd.org, michal.simek@xilinx.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 Tom, On Tue, 7 Feb 2023 at 17:10, Tom Rini wrote: > > On Tue, Feb 07, 2023 at 03:25:16PM -0700, Simon Glass wrote: > > Hi Loic, > > > > On Tue, 7 Feb 2023 at 14:47, Loic Poulain wro= te: > > > > > > 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 wrote: > > > > >> > > > > > >> > Mark sha256_process as weak to allow hardware specific impleme= ntation. > > > > >> > 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 unsigne= d 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,= uint32_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 ca= n 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 > > > > Unfortunately you need the blobs! > > > > > encountered? As you mentioned it, Is the error specifically related t= o > > > _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. > > That honestly makes more sense, having stared at the commit in > question. Perhaps Minnow needs LTO enabled. Yes, that would likely help. But Bin's point is that it should be possible to move the text base. Anyway, the point of this thread is that this needs to be done as drivers rather than weak functions. Unfortunately hash.c has grown a few appendages...this is yet another. Regards, Simon