Commit fae29f13 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by Herbert Xu

hwrng: core - document the quality field

quality field is currently documented as being 'per mill'.  In fact the
math involved is:

                add_hwgenerator_randomness((void *)rng_fillbuf, rc,
                                           rc * current_quality * 8 >> 10);

thus the actual definition is "bits of entropy per 1024 bits of input".

The current documentation seems to have confused multiple people
in the past, let's fix the documentation to match code.

An alternative is to change core to match driver expectations, replacing
	rc * current_quality * 8 >> 10
with
	rc * current_quality / 1000
but that has performance costs, so probably isn't a good option.

Fixes: 0f734e6e ("hwrng: add per-device entropy derating")
Reported-by: default avatar"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 3512dcb4
...@@ -44,10 +44,10 @@ static unsigned short default_quality; /* = 0; default to "off" */ ...@@ -44,10 +44,10 @@ static unsigned short default_quality; /* = 0; default to "off" */
module_param(current_quality, ushort, 0644); module_param(current_quality, ushort, 0644);
MODULE_PARM_DESC(current_quality, MODULE_PARM_DESC(current_quality,
"current hwrng entropy estimation per mill"); "current hwrng entropy estimation per 1024 bits of input");
module_param(default_quality, ushort, 0644); module_param(default_quality, ushort, 0644);
MODULE_PARM_DESC(default_quality, MODULE_PARM_DESC(default_quality,
"default entropy content of hwrng per mill"); "default entropy content of hwrng per 1024 bits of input");
static void drop_current_rng(void); static void drop_current_rng(void);
static int hwrng_init(struct hwrng *rng); static int hwrng_init(struct hwrng *rng);
......
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
* and max is a multiple of 4 and >= 32 bytes. * and max is a multiple of 4 and >= 32 bytes.
* @priv: Private data, for use by the RNG driver. * @priv: Private data, for use by the RNG driver.
* @quality: Estimation of true entropy in RNG's bitstream * @quality: Estimation of true entropy in RNG's bitstream
* (per mill). * (in bits of entropy per 1024 bits of input;
* valid values: 1 to 1024, or 0 for unknown).
*/ */
struct hwrng { struct hwrng {
const char *name; const char *name;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment