]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: caam - double the entropy delay interval for retry
authorGaurav Jain <gaurav.jain@nxp.com>
Fri, 5 Sep 2025 10:11:48 +0000 (15:41 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:21 +0000 (15:37 -0500)
[ Upstream commit 9048beca9c5614d486e2b492c0a7867164bf56a8 ]

during entropy evaluation, if the generated samples fail
any statistical test, then, all of the bits will be discarded,
and a second set of samples will be generated and tested.

the entropy delay interval should be doubled before performing the
retry.

also, ctrlpriv->rng4_sh_init and inst_handles both reads RNG DRNG
status register, but only inst_handles is updated before every retry.
so only check inst_handles and removing ctrlpriv->rng4_sh_init

Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/caam/ctrl.c

index a93be395c878ce7499a8aef34b782e59beaaf36c..18a850cf0f9714c2274bddb3844d64982bee5935 100644 (file)
@@ -703,12 +703,12 @@ static int caam_ctrl_rng_init(struct device *dev)
                         */
                        if (needs_entropy_delay_adjustment())
                                ent_delay = 12000;
-                       if (!(ctrlpriv->rng4_sh_init || inst_handles)) {
+                       if (!inst_handles) {
                                dev_info(dev,
                                         "Entropy delay = %u\n",
                                         ent_delay);
                                kick_trng(dev, ent_delay);
-                               ent_delay += 400;
+                               ent_delay = ent_delay * 2;
                        }
                        /*
                         * if instantiate_rng(...) fails, the loop will rerun