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 D675AC433EF for ; Wed, 15 Jun 2022 12:42:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 117CC8442E; Wed, 15 Jun 2022 14:42:56 +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=1655296976; bh=1NhDpmDc58TgsBTc3AVX8aEWuAXbdRbcYfRhFaeMMzM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=n+RonRxHdm1vz2IczT0HsqHvZinBKGjkIzAgoyB+hy9/COEoMc/Sdu0RYswczlQtb qXOUDBUtTDJbXzmNwtL2r2053IpfdKX6IRBFSMjWG+mE7YwvazknLm8nvlAWGUoPQj sH+a9cIHnwcGmYLjNz60bA8r0/dBy8l+kzNW1TIaDY0M58lIMgw7nI9PhzVGtz+Bnt y6yqjt4dUb9W96/qFEhQZO3jdWxtd0BYqLJiwTgpcHOPAV2Hy+deop3WhEcoFROhYj wDGYMapNVcAroWkcJ2GbU0a5p6MOrGo8Q+FySozxLdxokF+cpY2c0F6gl+0+jvPBP5 9Ejl22l+HtiDA== Received: from [192.168.178.101] (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sbabic@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 9200784485; Wed, 15 Jun 2022 14:42:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1655296975; bh=1NhDpmDc58TgsBTc3AVX8aEWuAXbdRbcYfRhFaeMMzM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=QH7t/Wi3TLkpCJYQGAJYL8qHpfbXq7KBNmwbOMQGmHih7qfXiZW2lZ8dz2F4XkuEZ vAWXjBIA2j583vX/Y5NQMCz/ES9Fk+7woaJimoI1gWy9e6yf9SoZaLVn8Phkj+ot/9 HAAjbE+BUsWkHsxv/hpnqPnIRLqyFq3FbvJUzJKDBek5zhztadRblMeKkF9iOms7yB NeF3opXibsspwep3WN7yZTLf0wxYKh3e58ZSSIhA5nzTJMS18Lsy+wm5iUbeqRfF4n ElvVKuWdrM5yXl2MMkaJydV3yGP7qXFJ1orVCcXVvKaW0lxBQ5sOGd3Bp2S3ku/Ae7 zTzHXYxKasFUw== Message-ID: <86641acc-9185-d74e-4fc3-6b756e78f360@denx.de> Date: Wed, 15 Jun 2022 14:42:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v3] crypto/fsl: fsl_rsa: Fix dcache issue in the driver Content-Language: en-US To: Gaurav Jain , u-boot@lists.denx.de, Stefano Babic Cc: Peng Fan , Fabio Estevam , "NXP i . MX U-Boot Team" , Horia Geanta , Varun Sethi , Ye Li References: <20220615123447.4087910-1-gaurav.jain@nxp.com> From: Stefano Babic In-Reply-To: <20220615123447.4087910-1-gaurav.jain@nxp.com> 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 Gaurav, thanks for fix, I will put into u-boot-imx and trigger a new CI. Stefano On 15.06.22 14:34, Gaurav Jain wrote: > From: Ye Li > > issue: > CAAM fails with key error when perform Modular Exponentiation > using PKHA Block in CAAM > > Fix: > add flush and invalidate dcache for keys, signature > and output decrypted data processed by CAAM. > > Fixes: 34276478f7 (DM: crypto/fsl - Add Freescale rsa DM driver) > Signed-off-by: Ye Li > Reviewed-by: Gaurav Jain > Acked-by: Peng Fan > --- > drivers/crypto/fsl/fsl_rsa.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/crypto/fsl/fsl_rsa.c b/drivers/crypto/fsl/fsl_rsa.c > index 897ee855ea..335b7fe25a 100644 > --- a/drivers/crypto/fsl/fsl_rsa.c > +++ b/drivers/crypto/fsl/fsl_rsa.c > @@ -6,6 +6,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -36,12 +37,21 @@ int fsl_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len, > > inline_cnstr_jobdesc_pkha_rsaexp(desc, &pkin, out, sig_len); > > + flush_dcache_range((ulong)sig, (ulong)sig + sig_len); > + flush_dcache_range((ulong)prop->modulus, (ulong)(prop->modulus) + keylen); > + flush_dcache_range((ulong)prop->public_exponent, > + (ulong)(prop->public_exponent) + prop->exp_len); > + flush_dcache_range((ulong)desc, (ulong)desc + (sizeof(uint32_t) * MAX_CAAM_DESCSIZE)); > + flush_dcache_range((ulong)out, (ulong)out + sig_len); > + > ret = run_descriptor_jr(desc); > if (ret) { > debug("%s: RSA failed to verify: %d\n", __func__, ret); > return -EFAULT; > } > > + invalidate_dcache_range((ulong)out, (ulong)out + sig_len); > + > return 0; > } >