diff options
author | markm <markm@FreeBSD.org> | 2013-10-08 22:14:07 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2013-10-08 22:14:07 +0000 |
commit | 96f5566b8ee5cc7af6b65612eb13e6c52d7c6f2d (patch) | |
tree | 9a54587031c0869dab8a48ecf0c7bcf4ba6bcc0d /sys/dev | |
parent | 7334895900372a7f012c15ba12cfd3a9875ea182 (diff) | |
download | FreeBSD-src-96f5566b8ee5cc7af6b65612eb13e6c52d7c6f2d.zip FreeBSD-src-96f5566b8ee5cc7af6b65612eb13e6c52d7c6f2d.tar.gz |
Fix some just-noticed problems:
o Allow this to work with "nodevice random" by fixing where the MALLOC pool is defined.
o Fix the explicit reseed code. This was correct as submitted, but in the project branch doesn't need to set the "seeded" bit as this is done correctly in the "unblock" function.
o Remove some debug ifdeffing.
o Adjust comments.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/random/ivy.c | 15 | ||||
-rw-r--r-- | sys/dev/random/nehemiah.c | 7 | ||||
-rw-r--r-- | sys/dev/random/random_adaptors.c | 6 | ||||
-rw-r--r-- | sys/dev/random/random_adaptors.h | 2 | ||||
-rw-r--r-- | sys/dev/random/random_harvestq.c | 1 | ||||
-rw-r--r-- | sys/dev/random/randomdev.c | 2 | ||||
-rw-r--r-- | sys/dev/random/randomdev.h | 2 |
7 files changed, 11 insertions, 24 deletions
diff --git a/sys/dev/random/ivy.c b/sys/dev/random/ivy.c index 8eb5501..e1a42c4 100644 --- a/sys/dev/random/ivy.c +++ b/sys/dev/random/ivy.c @@ -57,15 +57,6 @@ struct random_hardware_source random_ivy = { .read = random_ivy_read }; -#if 1 -static inline int -ivy_rng_store(uint64_t *tmp) -{ - *tmp = 0xF001FACE; - - return (sizeof(uint64_t)); -} -#else static inline int ivy_rng_store(uint64_t *tmp) { @@ -91,7 +82,6 @@ ivy_rng_store(uint64_t *tmp) return (0); #endif } -#endif static int random_ivy_read(void *buf, int c) @@ -124,10 +114,6 @@ rdrand_modevent(module_t mod, int type, void *unused) switch (type) { case MOD_LOAD: -#if 1 - live_entropy_source_register(&random_ivy); - printf("%s: CRAP RDRAND is present\n", random_ivy.ident); -#else if (cpu_feature2 & CPUID2_RDRAND) live_entropy_source_register(&random_ivy); else @@ -136,7 +122,6 @@ rdrand_modevent(module_t mod, int type, void *unused) #endif printf("%s: RDRAND is not present\n", random_ivy.ident); -#endif break; case MOD_UNLOAD: diff --git a/sys/dev/random/nehemiah.c b/sys/dev/random/nehemiah.c index 133fe9d..e134ad0 100644 --- a/sys/dev/random/nehemiah.c +++ b/sys/dev/random/nehemiah.c @@ -57,10 +57,13 @@ struct random_hardware_source random_nehemiah = { .read = random_nehemiah_read }; -/* This H/W RNG never stores more than 8 bytes in one go */ - +/* TODO: now that the Davies-Meyer hash is gone and we only use + * the 'xstore' instruction, do we still need to preserve the + * FPU state with fpu_kern_(enter|leave)() ? + */ static struct fpu_kern_ctx *fpu_ctx_save; +/* This H/W source never stores more than 8 bytes in one go */ /* ARGSUSED */ static __inline size_t VIA_RNG_store(void *buf) diff --git a/sys/dev/random/random_adaptors.c b/sys/dev/random/random_adaptors.c index 8cbebbc..e62b2c0 100644 --- a/sys/dev/random/random_adaptors.c +++ b/sys/dev/random/random_adaptors.c @@ -55,6 +55,8 @@ static struct sysctl_ctx_list random_clist; struct random_adaptor *random_adaptor; +MALLOC_DEFINE(M_ENTROPY, "entropy", "Entropy harvesting buffers and data structures"); + int random_adaptor_register(const char *name, struct random_adaptor *rsp) { @@ -233,10 +235,8 @@ random_adaptors_reseed(void *unused) { (void)unused; - if (random_adaptor != NULL) { + if (random_adaptor != NULL) (*random_adaptor->reseed)(); - random_adaptor->seeded = 1; - } arc4rand(NULL, 0, 1); } SYSINIT(random_reseed, SI_SUB_INTRINSIC_POST, SI_ORDER_SECOND, diff --git a/sys/dev/random/random_adaptors.h b/sys/dev/random/random_adaptors.h index fa5f7c8..fb3d6e4 100644 --- a/sys/dev/random/random_adaptors.h +++ b/sys/dev/random/random_adaptors.h @@ -31,6 +31,8 @@ #include <sys/eventhandler.h> +MALLOC_DECLARE(M_ENTROPY); + struct random_adaptors { LIST_ENTRY(random_adaptors) entries; /* list of providers */ const char *name; /* name of random adaptor */ diff --git a/sys/dev/random/random_harvestq.c b/sys/dev/random/random_harvestq.c index e5e2c5a..264a3c7 100644 --- a/sys/dev/random/random_harvestq.c +++ b/sys/dev/random/random_harvestq.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include <dev/random/randomdev.h> #include <dev/random/randomdev_soft.h> +#include <dev/random/random_adaptors.h> #include <dev/random/random_harvestq.h> #include <dev/random/live_entropy_sources.h> #include <dev/random/rwfile.h> diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c index f37da70..0593f39 100644 --- a/sys/dev/random/randomdev.c +++ b/sys/dev/random/randomdev.c @@ -74,8 +74,6 @@ static struct cdevsw random_cdevsw = { .d_name = "random", }; -MALLOC_DEFINE(M_ENTROPY, "entropy", "Entropy harvesting buffers"); - /* For use with make_dev(9)/destroy_dev(9). */ static struct cdev *random_dev; diff --git a/sys/dev/random/randomdev.h b/sys/dev/random/randomdev.h index 3afa943..a0e002f 100644 --- a/sys/dev/random/randomdev.h +++ b/sys/dev/random/randomdev.h @@ -30,8 +30,6 @@ * and non algorithm-specific for the entropy processor */ -MALLOC_DECLARE(M_ENTROPY); - typedef void random_init_func_t(void); typedef void random_deinit_func_t(void); typedef int random_block_func_t(int); |