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 5C33EC433FE for ; Fri, 29 Apr 2022 13:26:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0265883F0F; Fri, 29 Apr 2022 15:26:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1651238777; bh=NVm0+qKnopf2oQEp8e9tot3R8s/PXVM9lfTG8Yf7UgU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=a9RWbyYS559gkf2PeOMtBjlneMPS+Ra/fGRpg0PTfGa9ojrNX+rI1D0OpJ6ZStD+m CxwjfzQgb2DpERg3bcWJLxc8yJYCoQhILAhjk8SuY3nTLFI7vcQ2ZDg51I/XAu60kZ n6Zhq0vKysDQ81WhoHwuPH22nA80NifxuSRWOhZlmObfaZ8PuElNvH7slUxUqioRJG VmjkvWhAqMI3n0+h2oiJUeGCyj7tzIBoLFqkWR/rWIJV67KJgYRD2YQDjnqTqmL8SM C47NbJq/KCqLhGMdxQKcaaNf3/P+YqP7EHTNHkZKt5fp4fGAMJ3+9cRLhO3fAQeHOZ qkiFmnpfwcHpg== Received: by phobos.denx.de (Postfix, from userid 109) id 5C78B83F1F; Fri, 29 Apr 2022 15:26:15 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [91.198.250.253]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 37A9683F0F for ; Fri, 29 Apr 2022 15:26:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4KqYCh5p7Tz9sYd; Fri, 29 Apr 2022 15:26:08 +0200 (CEST) Message-ID: <9fb8507f-9a5e-e53a-0d64-e4bcbb6663eb@denx.de> Date: Fri, 29 Apr 2022 15:26:03 +0200 MIME-Version: 1.0 Subject: Re: [EXT] fsl_hash.c: Alignment problem when using caam_hash() for FIT images Content-Language: en-US To: Gaurav Jain , U-Boot Mailing List Cc: "dullfire@yahoo.com" References: <84e7fa45-4783-2be5-8367-1818b6c92dab@denx.de> From: Stefan Roese In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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.5 at phobos.denx.de X-Virus-Status: Clean On 4/29/22 15:22, Gaurav Jain wrote: > Hello Stefan > >> -----Original Message----- >> From: Stefan Roese >> Sent: Friday, April 29, 2022 6:24 PM >> To: U-Boot Mailing List >> Cc: Gaurav Jain ; 'dullfire@yahoo.com >> Subject: [EXT] fsl_hash.c: Alignment problem when using caam_hash() for FIT >> images >> >> Caution: EXT Email >> >> Hi, >> >> while working on an LX2160 based board and updating to latest mainline I >> noticed problems using the HW accelerated hash functions on this platform, >> when trying to boot a FIT Kernel image. Here the resulting error message: >> >> ## Loading kernel from FIT Image at a0000000 ... >> Using 'conf-freescale_lx2160a.dtb' configuration >> Trying 'kernel-1' kernel subimage >> Verifying Hash Integrity ... sha256Error: Address arguments are not aligned >> CAAM was not setup properly or it is faulty >> error! >> Bad hash value for 'hash-1' hash node in 'kernel-1' image node Bad Data Hash >> ERROR: can't get kernel image! >> >> And here the addresses, printed from caam_hash(): >> caam_hash (171): pbuf=00000000a00000fc pout=00000000fbde6f80 >> buf_len=5291241 ARCH_DMA_MINALIGN=64 >> >> pbuf points to an area in the FIT image itself. So its not easy to change this. >> >> In some quick tests I've dropped the alignment check and have not seen any >> problems yet. The hash is calculated without any problems and seems to be okay. >> I might be just lucky though, not sure. >> >> So my basic question is: Is this alignment really necessary and required for both >> addresses in this function? > You are right, Alignment is not necessary and can be removed. Perfect, thanks. Let me generate a patch for this. Stay tuned... ;) Thanks, Stefan >> >> If yes, do you have some suggestions on how to handle this? Other than >> allocating new aligned buffers in caam_hash() and memcpy'ing to those new >> buffers instead. BTW, this is not a preferred solution for me, as boot-time is >> crucial for my platform. >> >> Thanks, >> Stefan Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de