From: Stephen Rothwell <sfr@canb•auug.org.au>
To: Theodore Ts'o <tytso@mit•edu>, Herbert Xu <herbert@gondor•apana.org.au>
Cc: linux-next@vger•kernel.org, linux-kernel@vger•kernel.org,
Amit Shah <amit.shah@redhat•com>, Torsten Duwe <duwe@lst•de>
Subject: linux-next: manual merge of the random tree with the crypto-current tree
Date: Tue, 15 Jul 2014 17:30:25 +1000 [thread overview]
Message-ID: <20140715173025.0aaa9a51@canb.auug.org.au> (raw)
[-- Attachment #1: Type: text/plain, Size: 2675 bytes --]
Hi Theodore,
Today's linux-next merge of the random tree got a conflict in
drivers/char/hw_random/core.c between commit d3cc7996473a ("hwrng:
fetch randomness only after device init") from the crypto-current tree
and commit b77e62203be2 ("hwrng: create filler thread") and
53f52341d87b ("hwrng: add per-device entropy derating") from the random
tree.
I fixed it up (I think - see below) and can carry the fix as necessary
(no action is required).
--
Cheers,
Stephen Rothwell sfr@canb•auug.org.au
diff --cc drivers/char/hw_random/core.c
index c4419ea1ab07,349a3b852be9..000000000000
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@@ -53,42 -55,42 +55,62 @@@ static struct task_struct *hwrng_fill
static LIST_HEAD(rng_list);
static DEFINE_MUTEX(rng_mutex);
static int data_avail;
- static u8 *rng_buffer;
+ static u8 *rng_buffer, *rng_fillbuf;
+ static unsigned short current_quality;
+ static unsigned short default_quality; /* = 0; default to "off" */
+
+ module_param(current_quality, ushort, 0644);
+ MODULE_PARM_DESC(current_quality,
+ "current hwrng entropy estimation per mill");
+ module_param(default_quality, ushort, 0644);
+ MODULE_PARM_DESC(default_quality,
+ "default entropy content of hwrng per mill");
+
+ static void start_khwrngd(void);
+static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size,
+ int wait);
+
static size_t rng_buffer_size(void)
{
return SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES;
}
-static inline int hwrng_init(struct hwrng *rng)
+static void add_early_randomness(struct hwrng *rng)
{
- int err;
+ unsigned char bytes[16];
+ int bytes_read;
+
+ /*
+ * Currently only virtio-rng cannot return data during device
+ * probe, and that's handled in virtio-rng.c itself. If there
+ * are more such devices, this call to rng_get_data can be
+ * made conditional here instead of doing it per-device.
+ */
+ bytes_read = rng_get_data(rng, bytes, sizeof(bytes), 1);
+ if (bytes_read > 0)
+ add_device_randomness(bytes, bytes_read);
+}
+static inline int hwrng_init(struct hwrng *rng)
+{
if (rng->init) {
- err = rng->init(rng);
- if (err)
- return err;
+ int ret;
+
+ ret = rng->init(rng);
+ if (ret)
+ return ret;
}
+ add_early_randomness(rng);
+
+ current_quality = rng->quality ? : default_quality;
+ current_quality &= 1023;
+
+ if (current_quality == 0 && hwrng_fill)
+ kthread_stop(hwrng_fill);
+ if (current_quality > 0 && !hwrng_fill)
+ start_khwrngd();
+
return 0;
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
reply other threads:[~2014-07-15 7:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140715173025.0aaa9a51@canb.auug.org.au \
--to=sfr@canb$(echo .)auug.org.au \
--cc=amit.shah@redhat$(echo .)com \
--cc=duwe@lst$(echo .)de \
--cc=herbert@gondor$(echo .)apana.org.au \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-next@vger$(echo .)kernel.org \
--cc=tytso@mit$(echo .)edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox