From: Richard Mortimer <richm@oldelvet.org.uk>
To: sparclinux@vger.kernel.org
Subject: /dev/random lacks entropy on sparc64
Date: Mon, 09 Aug 2004 22:59:20 +0000 [thread overview]
Message-ID: <1092092360.7938.50.camel@duncow> (raw)
Whilst creating a new gpg key I noticed that there is typically very
little entropy in /dev/random.
cat /proc/sys/kernel/random/entropy_avail
was always showing numbers < 100. After a bit of digging I worked out
that this was due to add_timer_randomness() using jiffies to measure
time rather than a hires timesource (i386 and x86_64 use tsc). I knocked
the following patch and have tried this on 2.4.26 and this solves the
problem.
I suspect that the patch needs some more work (probably shouldn't use
assembly directly in drivers/char/random.c). I'm not sure whether we
should really be calling something like tick_ops->get_tick(). But
actually tick_get_tick() would probably be appropriate on all machines
because we know that %tick is available on all v9 machines and
/dev/random doesn't absolutely need a common tick value across all cpus.
How does this sound?
Richard
shirehall:/tmp# diff -u linux-2.4.26.orig/drivers/char/random.c
linux-2.4.26/drivers/char/random.c
--- linux-2.4.26.orig/drivers/char/random.c 2004-02-18
13:36:31.000000000 +0000
+++ linux-2.4.26/drivers/char/random.c 2004-08-04 00:38:04.000000000
+0100
@@ -750,6 +750,17 @@
__u32 high;
rdtsc(time, high);
num ^= high;
+#elif defined (__sparc_v9__)
+ unsigned long tmp;
+ unsigned high;
+
+ __asm__ __volatile__("rd %%tick, %0\n\t"
+ "srlx %0, 32, %1\n\t"
+ "srl %1, 1, %1"
+ : "=r" (tmp), "=r" (high));
+
+ time = (unsigned)tmp;
+ num ^= high;
#else
time = jiffies;
#endif
--
richm@oldelvet.org.uk
next reply other threads:[~2004-08-09 22:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-09 22:59 Richard Mortimer [this message]
2004-08-09 23:20 ` /dev/random lacks entropy on sparc64 David S. Miller
2004-08-10 0:06 ` Richard Mortimer
2004-08-10 0:28 ` David S. Miller
2004-08-10 16:23 ` Anton Blanchard
2004-08-10 17:55 ` David S. Miller
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=1092092360.7938.50.camel@duncow \
--to=richm@oldelvet.org.uk \
--cc=sparclinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.