All of lore.kernel.org
 help / color / mirror / Atom feed
* /dev/random lacks entropy on sparc64
@ 2004-08-09 22:59 Richard Mortimer
  2004-08-09 23:20 ` David S. Miller
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Richard Mortimer @ 2004-08-09 22:59 UTC (permalink / raw)
  To: sparclinux

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


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

end of thread, other threads:[~2004-08-10 17:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-09 22:59 /dev/random lacks entropy on sparc64 Richard Mortimer
2004-08-09 23:20 ` 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

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.