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 6C384C433EF for ; Fri, 29 Apr 2022 12:54:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C60A783EFB; Fri, 29 Apr 2022 14:54:21 +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=1651236862; bh=HKDS+hknzaESZ8O4wz1yYmjwghc9Rba0nb1rDm6Z3wk=; h=Date:To:Cc:From:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Ct2ee2Z+R+9qmL5DKp1zimyGVaoDyrNEV08Udpnkl/f7VizRq42ChGgWE9i8tXNIG emDiS1C/rFBckRxRoFFUZnfuVuzPTR3WkGnTyRX5zLeyrK+zP5ltLvNEIf0V9IOYaS C9PUKEw/47lJUSwklu1mHWHFi8sBaGyTN6ptvmCmTUQwMMFpoUTtzmZJQYcqhItcp+ xazBqREKel3h6qLnrl2XNPOcCikMWPpnK5Baypj91yo4H4lLqVyzrGzL74100qTYnx c+i4aR1rTuqAJpHNyo2lNsejIg42N8Ck9yj/ENkq9l8wl5Z0rjeFwEf2M8eFefEG5v QtxsGahZLcEsw== Received: by phobos.denx.de (Postfix, from userid 109) id 3E92C83F03; Fri, 29 Apr 2022 14:54:19 +0200 (CEST) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [IPv6:2001:67c:2050:101:465::107]) (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 DC4DD80542 for ; Fri, 29 Apr 2022 14:54:16 +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 smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (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-107.mailbox.org (Postfix) with ESMTPS id 4KqXVw3W1fz9sSs; Fri, 29 Apr 2022 14:54:16 +0200 (CEST) Message-ID: <84e7fa45-4783-2be5-8367-1818b6c92dab@denx.de> Date: Fri, 29 Apr 2022 14:54:12 +0200 MIME-Version: 1.0 Content-Language: en-US To: U-Boot Mailing List Cc: Gaurav Jain , 'dullfire@yahoo.com From: Stefan Roese Subject: fsl_hash.c: Alignment problem when using caam_hash() for FIT images Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 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? 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