Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/random/random_harvestq.c
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | |||||
#if defined(RANDOM_LOADABLE) | #if defined(RANDOM_LOADABLE) | ||||
RANDOM_CONFIG_S_LOCK(); | RANDOM_CONFIG_S_LOCK(); | ||||
if (p_random_alg_context) | if (p_random_alg_context) | ||||
#endif | #endif | ||||
p_random_alg_context->ra_event_processor(event); | p_random_alg_context->ra_event_processor(event); | ||||
#if defined(RANDOM_LOADABLE) | #if defined(RANDOM_LOADABLE) | ||||
RANDOM_CONFIG_S_UNLOCK(); | RANDOM_CONFIG_S_UNLOCK(); | ||||
#endif | #endif | ||||
explicit_bzero(event, sizeof(*event)); | |||||
} | } | ||||
static void | static void | ||||
random_kthread(void) | random_kthread(void) | ||||
{ | { | ||||
u_int maxloop, ring_out, i; | u_int maxloop, ring_out, i; | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | if (data != NULL && size != 0) { | ||||
count = sizeof(event.he_entropy); | count = sizeof(event.he_entropy); | ||||
event.he_somecounter = (uint32_t)get_cyclecount(); | event.he_somecounter = (uint32_t)get_cyclecount(); | ||||
event.he_size = count; | event.he_size = count; | ||||
event.he_source = RANDOM_CACHED; | event.he_source = RANDOM_CACHED; | ||||
event.he_destination = | event.he_destination = | ||||
harvest_context.hc_destination[RANDOM_CACHED]++; | harvest_context.hc_destination[RANDOM_CACHED]++; | ||||
memcpy(event.he_entropy, data + i, sizeof(event.he_entropy)); | memcpy(event.he_entropy, data + i, sizeof(event.he_entropy)); | ||||
random_harvestq_fast_process_event(&event); | random_harvestq_fast_process_event(&event); | ||||
explicit_bzero(&event, sizeof(event)); | |||||
} | } | ||||
explicit_bzero(data, size); | explicit_bzero(data, size); | ||||
if (bootverbose) | if (bootverbose) | ||||
printf("random: read %zu bytes from preloaded cache\n", size); | printf("random: read %zu bytes from preloaded cache\n", size); | ||||
} else | } else | ||||
if (bootverbose) | if (bootverbose) | ||||
printf("random: no preloaded entropy cache\n"); | printf("random: no preloaded entropy cache\n"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | random_harvest_direct_(const void *entropy, u_int size, enum random_entropy_source origin) | ||||
KASSERT(origin >= RANDOM_START && origin < ENTROPYSOURCE, ("%s: origin %d invalid\n", __func__, origin)); | KASSERT(origin >= RANDOM_START && origin < ENTROPYSOURCE, ("%s: origin %d invalid\n", __func__, origin)); | ||||
size = MIN(size, sizeof(event.he_entropy)); | size = MIN(size, sizeof(event.he_entropy)); | ||||
event.he_somecounter = (uint32_t)get_cyclecount(); | event.he_somecounter = (uint32_t)get_cyclecount(); | ||||
event.he_size = size; | event.he_size = size; | ||||
event.he_source = origin; | event.he_source = origin; | ||||
event.he_destination = harvest_context.hc_destination[origin]++; | event.he_destination = harvest_context.hc_destination[origin]++; | ||||
memcpy(event.he_entropy, entropy, size); | memcpy(event.he_entropy, entropy, size); | ||||
random_harvestq_fast_process_event(&event); | random_harvestq_fast_process_event(&event); | ||||
explicit_bzero(&event, sizeof(event)); | |||||
} | } | ||||
void | void | ||||
random_harvest_register_source(enum random_entropy_source source) | random_harvest_register_source(enum random_entropy_source source) | ||||
{ | { | ||||
hc_source_mask |= (1 << source); | hc_source_mask |= (1 << source); | ||||
} | } | ||||
Show All 9 Lines |