mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-19 10:53:58 +00:00
Storing to a pointer is (effectively) atomic; no need to protect this
with splhigh(). However, the entropy-harvesting routine needs pretty serious irq-protection, as it is called out of irq handlers etc. Clues given by: bde
This commit is contained in:
parent
d4c1816924
commit
4d0e6f79d6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=62969
@ -47,22 +47,14 @@ static void (*reap)(struct timespec *, u_int64_t, u_int, u_int, u_int) = NULL;
|
||||
void
|
||||
random_init_harvester(void (*reaper)(struct timespec *, u_int64_t, u_int, u_int, u_int))
|
||||
{
|
||||
intrmask_t mask;
|
||||
|
||||
mask = splhigh();
|
||||
reap = reaper;
|
||||
splx(mask);
|
||||
}
|
||||
|
||||
/* Deinitialise the harvester at unload time */
|
||||
void
|
||||
random_deinit_harvester(void)
|
||||
{
|
||||
intrmask_t mask;
|
||||
|
||||
mask = splhigh();
|
||||
reap = NULL;
|
||||
splx(mask);
|
||||
}
|
||||
|
||||
/* Entropy harvesting routine. This is supposed to be fast; do */
|
||||
|
@ -320,8 +320,8 @@ random_harvest_internal(struct timespec *nanotime, u_int64_t entropy,
|
||||
#endif
|
||||
if (origin < ENTROPYSOURCE) {
|
||||
|
||||
/* The reseed task must not be jumped on */
|
||||
mask = splsofttq();
|
||||
/* Called inside irq handlers; protect from interference */
|
||||
mask = splhigh();
|
||||
|
||||
which = random_state.which;
|
||||
pool = &random_state.pool[which];
|
||||
|
@ -47,22 +47,14 @@ static void (*reap)(struct timespec *, u_int64_t, u_int, u_int, u_int) = NULL;
|
||||
void
|
||||
random_init_harvester(void (*reaper)(struct timespec *, u_int64_t, u_int, u_int, u_int))
|
||||
{
|
||||
intrmask_t mask;
|
||||
|
||||
mask = splhigh();
|
||||
reap = reaper;
|
||||
splx(mask);
|
||||
}
|
||||
|
||||
/* Deinitialise the harvester at unload time */
|
||||
void
|
||||
random_deinit_harvester(void)
|
||||
{
|
||||
intrmask_t mask;
|
||||
|
||||
mask = splhigh();
|
||||
reap = NULL;
|
||||
splx(mask);
|
||||
}
|
||||
|
||||
/* Entropy harvesting routine. This is supposed to be fast; do */
|
||||
|
@ -320,8 +320,8 @@ random_harvest_internal(struct timespec *nanotime, u_int64_t entropy,
|
||||
#endif
|
||||
if (origin < ENTROPYSOURCE) {
|
||||
|
||||
/* The reseed task must not be jumped on */
|
||||
mask = splsofttq();
|
||||
/* Called inside irq handlers; protect from interference */
|
||||
mask = splhigh();
|
||||
|
||||
which = random_state.which;
|
||||
pool = &random_state.pool[which];
|
||||
|
Loading…
Reference in New Issue
Block a user