summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/alpha/conf/GENERIC1
-rw-r--r--sys/alpha/conf/NOTES1
-rw-r--r--sys/amd64/conf/GENERIC1
-rw-r--r--sys/conf/NOTES3
-rw-r--r--sys/conf/options3
-rw-r--r--sys/dev/random/randomdev.c5
-rw-r--r--sys/i386/conf/GENERIC1
-rw-r--r--sys/i386/conf/NOTES3
-rw-r--r--sys/ia64/conf/GENERIC1
-rw-r--r--sys/modules/random/Makefile11
-rw-r--r--sys/pc98/conf/GENERIC1
11 files changed, 30 insertions, 1 deletions
diff --git a/sys/alpha/conf/GENERIC b/sys/alpha/conf/GENERIC
index aac72b2..bd740b0 100644
--- a/sys/alpha/conf/GENERIC
+++ b/sys/alpha/conf/GENERIC
@@ -153,6 +153,7 @@ device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
# Pseudo devices - the number indicates how many units to allocated.
device random # Entropy device
+options NOBLOCKRANDOM # avoid any blocking on device random
device loop # Network loopback
device ether # Ethernet support
device sl # Kernel SLIP
diff --git a/sys/alpha/conf/NOTES b/sys/alpha/conf/NOTES
index aac72b2..bd740b0 100644
--- a/sys/alpha/conf/NOTES
+++ b/sys/alpha/conf/NOTES
@@ -153,6 +153,7 @@ device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
# Pseudo devices - the number indicates how many units to allocated.
device random # Entropy device
+options NOBLOCKRANDOM # avoid any blocking on device random
device loop # Network loopback
device ether # Ethernet support
device sl # Kernel SLIP
diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC
index 694a55c..34887d3 100644
--- a/sys/amd64/conf/GENERIC
+++ b/sys/amd64/conf/GENERIC
@@ -207,6 +207,7 @@ device lnc
# Pseudo devices - the number indicates how many units to allocated.
device random # Entropy device
+options NOBLOCKRANDOM # avoid any blocking on device random
device loop # Network loopback
device ether # Ethernet support
device sl # Kernel SLIP
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index 1103ccf..3a992c2 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -764,6 +764,9 @@ options ENABLE_VFS_IOOPT
# Cryptographically secure random number generator; /dev/[u]random
device random
+# Avoid blocking the random device
+options NOBLOCKRANDOM
+
#####################################################################
# POSIX P1003.1B
diff --git a/sys/conf/options b/sys/conf/options
index 6f86d74..f888a9f 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -477,3 +477,6 @@ ACPI_NO_ENABLE_ON_BOOT opt_acpi.h
# options for DEVFS, see sys/fs/devfs/devfs.h
NDEVFSINO opt_devfs.h
NDEVFSOVERFLOW opt_devfs.h
+
+# options for device random
+NOBLOCKRANDOM
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c
index c8d2eba..2f3e4a3 100644
--- a/sys/dev/random/randomdev.c
+++ b/sys/dev/random/randomdev.c
@@ -49,6 +49,8 @@
#include <dev/random/hash.h>
#include <dev/random/yarrow.h>
+#include "opt_noblockrandom.h"
+
static d_open_t random_open;
static d_read_t random_read;
static d_write_t random_write;
@@ -109,6 +111,8 @@ random_read(dev_t dev, struct uio *uio, int flag)
int error = 0;
void *random_buf;
+/* XXX Temporary ifndef to allow users to have a nonblocking device */
+#ifndef NOBLOCKRANDOM
while (!random_state.seeded) {
if (flag & IO_NDELAY)
error = EWOULDBLOCK;
@@ -117,6 +121,7 @@ random_read(dev_t dev, struct uio *uio, int flag)
if (error != 0)
return error;
}
+#endif
c = min(uio->uio_resid, PAGE_SIZE);
random_buf = (void *)malloc(c, M_TEMP, M_WAITOK);
while (uio->uio_resid > 0 && error == 0) {
diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC
index 694a55c..34887d3 100644
--- a/sys/i386/conf/GENERIC
+++ b/sys/i386/conf/GENERIC
@@ -207,6 +207,7 @@ device lnc
# Pseudo devices - the number indicates how many units to allocated.
device random # Entropy device
+options NOBLOCKRANDOM # avoid any blocking on device random
device loop # Network loopback
device ether # Ethernet support
device sl # Kernel SLIP
diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES
index 1103ccf..3a992c2 100644
--- a/sys/i386/conf/NOTES
+++ b/sys/i386/conf/NOTES
@@ -764,6 +764,9 @@ options ENABLE_VFS_IOOPT
# Cryptographically secure random number generator; /dev/[u]random
device random
+# Avoid blocking the random device
+options NOBLOCKRANDOM
+
#####################################################################
# POSIX P1003.1B
diff --git a/sys/ia64/conf/GENERIC b/sys/ia64/conf/GENERIC
index 7ba5107..244659e 100644
--- a/sys/ia64/conf/GENERIC
+++ b/sys/ia64/conf/GENERIC
@@ -135,6 +135,7 @@ device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
# Pseudo devices - the number indicates how many units to allocated.
device random # Entropy device
+options NOBLOCKRANDOM # avoid any blocking on device random
device loop # Network loopback
device ether # Ethernet support
device sl # Kernel SLIP
diff --git a/sys/modules/random/Makefile b/sys/modules/random/Makefile
index 5b2a261..d736feb 100644
--- a/sys/modules/random/Makefile
+++ b/sys/modules/random/Makefile
@@ -5,8 +5,17 @@
KMOD = random
SRCS = bus_if.h device_if.h randomdev.c yarrow.c hash.c
SRCS += bf_cbc.c bf_skey.c bf_enc.c
-SRCS += vnode_if.h
+SRCS += vnode_if.h opt_noblockrandom.h
CFLAGS += -I${.CURDIR}/../..
NOMAN = yes
+NOBLOCKRANDOM= yes
+.if defined(NOBLOCKRANDOM)
+RANDOM_OPTS= "\#define NOBLOCKRANDOM"
+.endif
+
+opt_noblockrandom.h:
+ touch opt_noblockrandom.h
+ echo $(RANDOM_OPTS) >> opt_noblockrandom.h
+
.include <bsd.kmod.mk>
diff --git a/sys/pc98/conf/GENERIC b/sys/pc98/conf/GENERIC
index ab7e580..235a56c 100644
--- a/sys/pc98/conf/GENERIC
+++ b/sys/pc98/conf/GENERIC
@@ -222,6 +222,7 @@ device xe
# Pseudo devices - the number indicates how many units to allocated.
device random # Entropy device
+options NOBLOCKRANDOM # avoid any blocking on device random
device loop # Network loopback
device ether # Ethernet support
device sl # Kernel SLIP
OpenPOWER on IntegriCloud