Message ID | 20180618141259.23141-4-vkoul@kernel.org |
---|---|
State | New |
Headers | show |
Series | [1/3] hwrng: msm - Move hwrng to a table | expand |
Hi Herbert, On 06/19/2018 05:28 PM, Herbert Xu wrote: > On Mon, Jun 18, 2018 at 07:42:59PM +0530, Vinod Koul wrote: >> Qcom 8996 and later chips support prng v2 where we need to only >> implement .read callback for hwrng. >> >> Add a new table for v2 which supports this and get version required for >> driver data. >> >> Signed-off-by: Vinod Koul <vkoul@kernel.org> > > Is this really a pseudo-RNG? If so it needs to be moved over to > the algif_rng interface. Despite the register name (PRNG_ registers prefix) the IP is using FIPS approved algorithm and we can claim that this is true hardware entropy generator. I don't think that we need to move to algif_rng. -- regards, Stan
On Fri, Jun 22, 2018 at 11:27:59AM +0300, Stanimir Varbanov wrote: > Hi Herbert, > > On 06/21/2018 02:53 PM, Herbert Xu wrote: > > On Thu, Jun 21, 2018 at 02:27:10PM +0300, Stanimir Varbanov wrote: > >> > >> OK, I just wanted to say that it is _not_ PRNG and the register names > >> gives us wrong impression. > > > > So does it generate one bit of output for each bit of hardware- > > generated entropy like /dev/random? Or does it use a hardware- > > generated seed to power a PRNG? > > I believe it is the second one. Isn't the second one SP 800-90A? In that case it should switch over to algif_rng. Thanks, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
On Fri, Jun 22, 2018 at 08:18:09PM +0530, Vinod wrote: > > Okay I am doing the port taking the exynos-rng as a ref. > Question is how to test it, how is one supposed to exercise the rng, any > test utils/apps for that? Sorry for noob question, new to crypto > interfaces. algif_rng is available through the af_alg socket interface. Ccing Stephan as he has a library that may help you. Cheers, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
diff --git a/drivers/char/hw_random/msm-rng.c b/drivers/char/hw_random/msm-rng.c index 7644474035e5..3f509072a6c6 100644 --- a/drivers/char/hw_random/msm-rng.c +++ b/drivers/char/hw_random/msm-rng.c @@ -17,6 +17,7 @@ #include <linux/io.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/platform_device.h> /* Device specific register offsets */ @@ -132,10 +133,16 @@ static struct hwrng msm_rng = { .read = msm_rng_read, }; +static struct hwrng msm_rng_v2 = { + .name = KBUILD_MODNAME, + .read = msm_rng_read, +}; + static int msm_rng_probe(struct platform_device *pdev) { struct resource *res; struct msm_rng *rng; + unsigned int version; int ret; rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); @@ -154,6 +161,9 @@ static int msm_rng_probe(struct platform_device *pdev) return PTR_ERR(rng->clk); rng->hwrng = &msm_rng; + version = (unsigned long)of_device_get_match_data(&pdev->dev); + if (version) + rng->hwrng = &msm_rng_v2; rng->hwrng->priv = (unsigned long)rng; ret = devm_hwrng_register(&pdev->dev, rng->hwrng); @@ -166,7 +176,8 @@ static int msm_rng_probe(struct platform_device *pdev) } static const struct of_device_id msm_rng_of_match[] = { - { .compatible = "qcom,prng", }, + { .compatible = "qcom,prng", .data = (void *)0}, + { .compatible = "qcom,prng-v2", .data = (void *)1}, {} }; MODULE_DEVICE_TABLE(of, msm_rng_of_match);
Qcom 8996 and later chips support prng v2 where we need to only implement .read callback for hwrng. Add a new table for v2 which supports this and get version required for driver data. Signed-off-by: Vinod Koul <vkoul@kernel.org> --- drivers/char/hw_random/msm-rng.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) -- 2.14.4