Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F164581130
D51113.id157897.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D51113.id157897.diff
View Options
diff --git a/sys/dev/random/random_harvestq.h b/sys/dev/random/random_harvestq.h
--- a/sys/dev/random/random_harvestq.h
+++ b/sys/dev/random/random_harvestq.h
@@ -27,6 +27,9 @@
#ifndef SYS_DEV_RANDOM_RANDOM_HARVESTQ_H_INCLUDED
#define SYS_DEV_RANDOM_RANDOM_HARVESTQ_H_INCLUDED
+#include <sys/types.h>
+#include <machine/cpu.h>
+
#define HARVESTSIZE 2 /* Max length in words of each harvested entropy unit */
/* These are used to queue harvested packets of entropy. The entropy
@@ -40,4 +43,10 @@
uint8_t he_source; /* origin of the entropy */
};
+static inline uint32_t
+random_get_cyclecount(void)
+{
+ return ((uint32_t)get_cyclecount());
+}
+
#endif /* SYS_DEV_RANDOM_RANDOM_HARVESTQ_H_INCLUDED */
diff --git a/sys/dev/random/random_harvestq.c b/sys/dev/random/random_harvestq.c
--- a/sys/dev/random/random_harvestq.c
+++ b/sys/dev/random/random_harvestq.c
@@ -459,7 +459,7 @@
return (0);
for (i = 0; i < len; i += sizeof(event.he_entropy)) {
- event.he_somecounter = (uint32_t)get_cyclecount();
+ event.he_somecounter = random_get_cyclecount();
event.he_size = sizeof(event.he_entropy);
event.he_source = RANDOM_CACHED;
event.he_destination =
@@ -566,7 +566,7 @@
if (ring_in != harvest_context.hc_entropy_ring.out) {
/* The ring is not full */
event = harvest_context.hc_entropy_ring.ring + ring_in;
- event->he_somecounter = (uint32_t)get_cyclecount();
+ event->he_somecounter = random_get_cyclecount();
event->he_source = origin;
event->he_destination = harvest_context.hc_destination[origin]++;
if (size <= sizeof(event->he_entropy)) {
@@ -595,7 +595,8 @@
u_int pos;
pos = harvest_context.hc_entropy_fast_accumulator.pos;
- harvest_context.hc_entropy_fast_accumulator.buf[pos] ^= jenkins_hash(entropy, size, (uint32_t)get_cyclecount());
+ harvest_context.hc_entropy_fast_accumulator.buf[pos] ^=
+ jenkins_hash(entropy, size, random_get_cyclecount());
harvest_context.hc_entropy_fast_accumulator.pos = (pos + 1)%RANDOM_ACCUM_MAX;
}
@@ -612,7 +613,7 @@
KASSERT(origin >= RANDOM_START && origin < ENTROPYSOURCE, ("%s: origin %d invalid\n", __func__, origin));
size = MIN(size, sizeof(event.he_entropy));
- event.he_somecounter = (uint32_t)get_cyclecount();
+ event.he_somecounter = random_get_cyclecount();
event.he_size = size;
event.he_source = origin;
event.he_destination = harvest_context.hc_destination[origin]++;
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c
--- a/sys/dev/random/randomdev.c
+++ b/sys/dev/random/randomdev.c
@@ -303,14 +303,14 @@
/* Extra timing here is helpful to scrape scheduler jitter entropy */
randomdev_hash_init(&hash);
- timestamp = (uint32_t)get_cyclecount();
+ timestamp = random_get_cyclecount();
randomdev_hash_iterate(&hash, ×tamp, sizeof(timestamp));
randomdev_hash_iterate(&hash, buf, count);
- timestamp = (uint32_t)get_cyclecount();
+ timestamp = random_get_cyclecount();
randomdev_hash_iterate(&hash, ×tamp, sizeof(timestamp));
randomdev_hash_finish(&hash, entropy_data);
for (i = 0; i < RANDOM_KEYSIZE_WORDS; i += sizeof(event.he_entropy)/sizeof(event.he_entropy[0])) {
- event.he_somecounter = (uint32_t)get_cyclecount();
+ event.he_somecounter = random_get_cyclecount();
event.he_size = sizeof(event.he_entropy);
event.he_source = RANDOM_CACHED;
event.he_destination = destination++; /* Harmless cheating */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Aug 3, 4:56 AM (1 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35895389
Default Alt Text
D51113.id157897.diff (3 KB)
Attached To
Mode
D51113: random: Define a macro for getting the CPU cycle count
Attached
Detach File
Event Timeline
Log In to Comment