Commit Graph

17 Commits

Author SHA1 Message Date
riastradh
b93e5db80e Use rnd_getmore as intended. No more essay needed here.
Workaround for buffering got pushed into rnd_getmore, closer to the
actual cause of the problem.
2016-05-21 15:33:40 +00:00
riastradh
01adfe9a57 Save some space: use one condvar for all rndsinks. Not a hot spot. 2015-04-21 04:24:16 +00:00
riastradh
5a7cf63bf5 Gather rndsinks global state into a cacheline-aligned struct. 2015-04-21 04:19:25 +00:00
riastradh
b5cd74a06e Make rnd_getmore acquire rndpool_mtx itself. 2015-04-14 13:08:22 +00:00
riastradh
5c5f06b858 More rnd.h user cleanup. 2015-04-13 22:43:41 +00:00
riastradh
6f03865532 Gather rnd-private declarations into <dev/rnd_private.h>.
Let's try to avoid putting externs in .c files where the compiler
can't check them.
2015-04-13 15:13:50 +00:00
riastradh
2a2eccb11d Move rndpool_(maybe_)extract to rndq, rename to rnd_(try)extract.
Make rnd_extract_data static.
2015-04-13 14:41:06 +00:00
tls
9b3a62bd20 Fixes and enhancements for polled entropy sources:
Add explicit enable/disable hooks for callout-driven sources (be more
	power friendly).

	Make "skew" source polled so it runs only when there is entropy
	demand.

	Adjust entropy collection from polled sources so it's processed
	sooner.
2014-10-26 18:22:32 +00:00
matt
a35d1a8c7c Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.
2014-09-05 05:57:21 +00:00
riastradh
84bbdd5611 Kick on-demand entropy sources in rndsinks_distribute.
Partial workaround for indefinite hangs when entropy is scarce or
buffered up.  We need to do more to handle entropy that has been
buffered up -- see the comment for details -- but this will help for
now.

Problem noted by pooka.
2014-03-01 14:15:15 +00:00
martin
6a2419fedf Turn a few __unused into __diagused 2013-10-25 11:35:55 +00:00
martin
f6c835fd37 Move a few CTASSERT to global scope 2013-09-14 20:47:48 +00:00
riastradh
b1574872b8 Back out the recent rnd stop-gap/stop-gap/stop-gap measures.
This reverts

sys/dev/rnd_private.h -> r1.1
sys/kern/init_main.c -> r1.450
sys/kern/kern_rndq.c -> r1.14
sys/kern/kern_rndsink.c -> r1.2

Parts of these changes will be added back, and the rndsource
callbacks will be fixed to avoid the lock recursion bug that
motivated the stop-gaps in the first place.

ok tls
2013-08-27 19:30:10 +00:00
tls
a92176cb34 Temporary fix for previous: avoid recursion through rnd_wakeup_readers()
when entropy first becomes available.
2013-08-26 23:41:24 +00:00
tls
38648a41ea Attempt to resolve locking issues at kernel startup on platforms with
hardware RNGs using the polling mode of operation:

1) Initialize the rng subsystem soft interrupts as early in kernel startup
   as seems safe (we have no MI guarantee that softints are working at all
   until configure2() returns, AFAICT).

   This should have the rnd subsystem able to process events via softint
   before the network subsystem (a notorious early user of entropy) starts.

2) Remove the shortcut calls to rnd_process_events() from
   rnd_schedule_process(), with the result that until the softint is installed
   rnd_process_events() is a NOP.

3) Directly call rnd_process_events() in rnd_extract_data(),
   rnd_maybe_extract(), and rnd_init_softint().  This should suck up any
   samples actually collected as early as possible.
2013-08-25 21:12:56 +00:00
riastradh
82db4b9858 Replace consttime_bcmp/explicit_bzero by consttime_memequal/explicit_memset.
consttime_memequal is the same as the old consttime_bcmp.
explicit_memset is to memset as explicit_bzero was to bcmp.

Passes amd64 release and i386/ALL, but I'm sure I missed some spots,
so please let me know.
2013-06-24 04:21:19 +00:00
riastradh
6290b0987e Rework rndsink(9) abstraction and adapt arc4random(9) and cprng(9).
rndsink(9):
- Simplify API.
- Simplify locking scheme.
- Add a man page.
- Avoid races in destruction.
- Avoid races in requesting entropy now and scheduling entropy later.

Periodic distribution of entropy to sinks reduces the need for the
last one, but this way we don't need to rely on periodic distribution
(e.g., in a future tickless NetBSD).

rndsinks_lock should probably eventually merge with the rndpool lock,
but we'll put that off for now.

cprng(9):
- Make struct cprng_strong opaque.
- Move rndpseudo.c parts that futz with cprng guts to subr_cprng.c.
- Fix kevent locking.  (Is kevent locking documented anywhere?)
- Stub out rump cprng further until we can rumpify rndsink instead.
- Strip code to grovel through struct cprng_strong in fstat.
2013-06-23 02:35:23 +00:00