public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tpm: Add module parameter for hwrng quality.
@ 2018-06-08  6:54 Louis Collard
  2018-06-18 18:07 ` Jarkko Sakkinen
  0 siblings, 1 reply; 8+ messages in thread
From: Louis Collard @ 2018-06-08  6:54 UTC (permalink / raw)
  To: linux-integrity
  Cc: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe, Arnd Bergmann,
	Greg Kroah-Hartman, linux-kernel, apronin

It is now possible for drivers to easily specify a hwrng quality, however
most do not currently do this, and in cases where they do, it may be
desirable to override the driver-specified value with a user-specified
one. This patch adds a parameter to set or override the hwrng quality.

Signed-off-by: Louis Collard <louiscollard@chromium.org>
---
 drivers/char/tpm/tpm-chip.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 0a62c19937b6..4def49cfc634 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -33,6 +33,11 @@
 DEFINE_IDR(dev_nums_idr);
 static DEFINE_MUTEX(idr_lock);
 
+static short override_rng_quality = -1;
+module_param(override_rng_quality, short, 0644);
+MODULE_PARM_DESC(override_rng_quality,
+		 "tpm-rng quality (overrides values provided by drivers)");
+
 struct class *tpm_class;
 struct class *tpmrm_class;
 dev_t tpm_devt;
@@ -409,6 +414,13 @@ static int tpm_add_hwrng(struct tpm_chip *chip)
 		 "tpm-rng-%d", chip->dev_num);
 	chip->hwrng.name = chip->hwrng_name;
 	chip->hwrng.read = tpm_hwrng_read;
+	if (override_rng_quality > -1) {
+		dev_info(&chip->dev,
+			 "Overriding hwrng quality for %s: driver default=%d, override=%d",
+			 chip->hwrng.name, chip->hwrng.quality,
+			 override_rng_quality);
+		chip->hwrng.quality = override_rng_quality;
+	}
 	return hwrng_register(&chip->hwrng);
 }
 
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-07-18  2:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-08  6:54 [PATCH] tpm: Add module parameter for hwrng quality Louis Collard
2018-06-18 18:07 ` Jarkko Sakkinen
2018-06-18 19:33   ` Jason Gunthorpe
2018-06-21 16:21     ` Jarkko Sakkinen
2018-06-27  6:11       ` Louis Collard
2018-06-29 13:03         ` David R. Bild
2018-07-04  6:54           ` Louis Collard
2018-07-18  2:43             ` David R. Bild

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox