Re: [PATCH v5 2/3] hw_random: cctrng: introduce Arm CryptoCell driver
From: Rouven Czerwinski
Date: Mon Mar 23 2020 - 10:56:53 EST
Hello Hadar,
On Sun, 2020-03-22 at 17:31 +0200, Hadar Gat wrote:
> Introduce low level Arm CryptoCell TRNG HW support.
>
> Signed-off-by: Hadar Gat <hadar.gat@xxxxxxx>
> ---
> drivers/char/hw_random/Kconfig | 12 +
> drivers/char/hw_random/Makefile | 1 +
> drivers/char/hw_random/cctrng.c | 735
> ++++++++++++++++++++++++++++++++++++++++
> drivers/char/hw_random/cctrng.h | 69 ++++
> 4 files changed, 817 insertions(+)
> create mode 100644 drivers/char/hw_random/cctrng.c
> create mode 100644 drivers/char/hw_random/cctrng.h
>
> [...]
> +static int cctrng_probe(struct platform_device *pdev)
> +{
> + struct resource *req_mem_cc_regs = NULL;
> + struct cctrng_drvdata *drvdata;
> + struct device *dev = &pdev->dev;
> + int rc = 0;
> + u32 val;
> + int irq;
> +
> + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> + if (!drvdata)
> + return -ENOMEM;
> +
> + drvdata->rng.name = devm_kstrdup(dev, dev_name(dev),
> GFP_KERNEL);
> + if (!drvdata->rng.name)
> + return -ENOMEM;
> +
> + drvdata->rng.read = cctrng_read;
> + drvdata->rng.priv = (unsigned long)drvdata;
You are not initializing drvdata->rng.quality to a default value, which
results in the TRNG not being used by the kernel by default. If its a
perfect TRNG this should be set to 1024, i.e. 1024 bits of entropy per
1024 bits of input.
Regards,
Rouven Czerwinski