diff options
Diffstat (limited to 'sys/dev/random')
-rwxr-xr-x | sys/dev/random/build.sh | 4 | ||||
-rw-r--r-- | sys/dev/random/fortuna.c | 17 | ||||
-rw-r--r-- | sys/dev/random/random_harvestq.c | 4 | ||||
-rw-r--r-- | sys/dev/random/unit_test.c | 2 | ||||
-rw-r--r-- | sys/dev/random/yarrow.c | 21 |
5 files changed, 19 insertions, 29 deletions
diff --git a/sys/dev/random/build.sh b/sys/dev/random/build.sh index d1351c4..2b4052d 100755 --- a/sys/dev/random/build.sh +++ b/sys/dev/random/build.sh @@ -35,7 +35,7 @@ # <(sed -e 's/fortuna/wombat/g' \ # -e 's/FORTUNA/WOMBAT/g' fortuna.c) | less # -cc -g -O0 -pthread -DRANDOM_DEBUG \ +cc -g -O0 -pthread \ -I../.. -lstdthreads -Wall \ unit_test.c \ yarrow.c \ @@ -46,7 +46,7 @@ cc -g -O0 -pthread -DRANDOM_DEBUG \ ../../crypto/sha2/sha256c.c \ -lz \ -o yunit_test -cc -g -O0 -pthread -DRANDOM_DEBUG \ +cc -g -O0 -pthread \ -I../.. -lstdthreads -Wall \ unit_test.c \ fortuna.c \ diff --git a/sys/dev/random/fortuna.c b/sys/dev/random/fortuna.c index 0b03931..4ae006b 100644 --- a/sys/dev/random/fortuna.c +++ b/sys/dev/random/fortuna.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <sys/mutex.h> #include <sys/random.h> +#include <sys/sdt.h> #include <sys/sysctl.h> #include <sys/systm.h> @@ -94,6 +95,11 @@ CTASSERT(RANDOM_FORTUNA_DEFPOOLSIZE <= RANDOM_FORTUNA_MAXPOOLSIZE); CTASSERT(RANDOM_BLOCKSIZE == sizeof(uint128_t)); CTASSERT(RANDOM_KEYSIZE == 2*RANDOM_BLOCKSIZE); +/* Probes for dtrace(1) */ +SDT_PROVIDER_DECLARE(random); +SDT_PROVIDER_DEFINE(random); +SDT_PROBE_DEFINE2(random, fortuna, event_processor, debug, "u_int", "struct fs_pool *"); + /* * This is the beastie that needs protecting. It contains all of the * state that we are excited about. Exactly one is instantiated. @@ -379,16 +385,7 @@ random_fortuna_pre_read(void) } else break; } -#ifdef RANDOM_DEBUG - { - u_int j; - - printf("random: reseedcount [%d]", fortuna_state.fs_reseedcount); - for (j = 0; j < RANDOM_FORTUNA_NPOOLS; j++) - printf(" %X", fortuna_state.fs_pool[j].fsp_length); - printf("\n"); - } -#endif + SDT_PROBE2(random, fortuna, event_processor, debug, fortuna_state.fs_reseedcount, fortuna_state.fs_pool); /* FS&K */ random_fortuna_reseed_internal(s, i < RANDOM_FORTUNA_NPOOLS ? i + 1 : RANDOM_FORTUNA_NPOOLS); /* Clean up and secure */ diff --git a/sys/dev/random/random_harvestq.c b/sys/dev/random/random_harvestq.c index 255136c..aad6763 100644 --- a/sys/dev/random/random_harvestq.c +++ b/sys/dev/random/random_harvestq.c @@ -170,7 +170,7 @@ random_kthread(void) /* XXX: FIX!! Increase the high-performance data rate? Need some measurements first. */ for (i = 0; i < RANDOM_ACCUM_MAX; i++) { if (harvest_context.hc_entropy_fast_accumulator.buf[i]) { - random_harvest_direct(harvest_context.hc_entropy_fast_accumulator.buf + i, sizeof(harvest_context.hc_entropy_fast_accumulator.buf[0]), 4, RANDOM_FAST); + random_harvest_direct(harvest_context.hc_entropy_fast_accumulator.buf + i, sizeof(harvest_context.hc_entropy_fast_accumulator.buf[0]), 4, RANDOM_UMA); harvest_context.hc_entropy_fast_accumulator.buf[i] = 0; } } @@ -261,7 +261,7 @@ static const char *(random_source_descr[]) = { "INTERRUPT", "SWI", "FS_ATIME", - "HIGH_PERFORMANCE", /* ENVIRONMENTAL_END */ + "UMA", /* ENVIRONMENTAL_END */ "PURE_OCTEON", "PURE_SAFE", "PURE_GLXSB", diff --git a/sys/dev/random/unit_test.c b/sys/dev/random/unit_test.c index fac4c8d..f682d17 100644 --- a/sys/dev/random/unit_test.c +++ b/sys/dev/random/unit_test.c @@ -29,7 +29,7 @@ /* Build this by going: -cc -g -O0 -pthread -DRANDOM_<alg> -DRANDOM_DEBUG -I../.. -lstdthreads -Wall \ +cc -g -O0 -pthread -DRANDOM_<alg> -I../.. -lstdthreads -Wall \ unit_test.c \ yarrow.c \ fortuna.c \ diff --git a/sys/dev/random/yarrow.c b/sys/dev/random/yarrow.c index 2ef15a4..5cb1bce 100644 --- a/sys/dev/random/yarrow.c +++ b/sys/dev/random/yarrow.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <sys/mutex.h> #include <sys/random.h> +#include <sys/sdt.h> #include <sys/sysctl.h> #include <sys/systm.h> @@ -77,6 +78,11 @@ __FBSDID("$FreeBSD$"); CTASSERT(RANDOM_BLOCKSIZE == sizeof(uint128_t)); CTASSERT(RANDOM_KEYSIZE == 2*RANDOM_BLOCKSIZE); +/* Probes for dtrace(1) */ +SDT_PROVIDER_DECLARE(random); +SDT_PROVIDER_DEFINE(random); +SDT_PROBE_DEFINE3(random, yarrow, event_processor, debug, "boolean", "u_int", "struct ys_pool *"); + /* * This is the beastie that needs protecting. It contains all of the * state that we are excited about. Exactly one is instantiated. @@ -261,20 +267,7 @@ random_yarrow_reseed_internal(u_int fastslow) KASSERT(yarrow_state.ys_pool[RANDOM_YARROW_FAST].ysp_thresh > 0, ("random: Yarrow fast threshold = 0")); KASSERT(yarrow_state.ys_pool[RANDOM_YARROW_SLOW].ysp_thresh > 0, ("random: Yarrow slow threshold = 0")); RANDOM_RESEED_ASSERT_LOCK_OWNED(); -#ifdef RANDOM_DEBUG - /* WARNING! This is dangerously tedious to do with mutexes held! */ - printf("random: %s ", __func__); - printf("type/pool = %s ", fastslow == RANDOM_YARROW_FAST ? "RANDOM_YARROW_FAST" : "RANDOM_YARROW_SLOW"); - printf("seeded = %s\n", yarrow_state.ys_seeded ? "true" : "false"); - printf("random: fast - thresh %d,1 - ", yarrow_state.ys_pool[RANDOM_YARROW_FAST].ysp_thresh); - for (i = RANDOM_START; i < ENTROPYSOURCE; i++) - printf(" %d", yarrow_state.ys_pool[RANDOM_YARROW_FAST].ysp_source_bits[i]); - printf("\n"); - printf("random: slow - thresh %d,%d - ", yarrow_state.ys_pool[RANDOM_YARROW_SLOW].ysp_thresh, yarrow_state.ys_slowoverthresh); - for (i = RANDOM_START; i < ENTROPYSOURCE; i++) - printf(" %d", yarrow_state.ys_pool[RANDOM_YARROW_SLOW].ysp_source_bits[i]); - printf("\n"); -#endif + SDT_PROBE3(random, yarrow, event_processor, debug, yarrow_state.ys_seeded, yarrow_state.ys_slowoverthresh, yarrow_state.ys_pool); /* 1. Hash the accumulated entropy into v[0] */ randomdev_hash_init(&context); /* Feed the slow pool hash in if slow */ |