summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-09-21 13:58:22 -0400
committerBen Hutchings <ben@decadent.org.uk>2013-11-28 14:02:03 +0000
commitee698d67a4af1fd37ba5b40733f103a62f223774 (patch)
tree37238290039918cfdc4765548ae8dd5e026cbcf4 /include
parent52d4f668a2ebb3d33b2ece452d4f3bcec6c87b7d (diff)
random: allow architectures to optionally define random_get_entropy()
commit 61875f30daf60305712e25b209ef41ced2635bad upstream. Allow architectures which have a disabled get_cycles() function to provide a random_get_entropy() function which provides a fine-grained, rapidly changing counter that can be used by the /dev/random driver. For example, an architecture might have a rapidly changing register used to control random TLB cache eviction, or DRAM refresh that doesn't meet the requirements of get_cycles(), but which is good enough for the needs of the random driver. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'include')
-rw-r--r--include/linux/timex.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/timex.h b/include/linux/timex.h
index 08e90fb81acc..5fee575ebccf 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -173,6 +173,20 @@ struct timex {
#include <asm/timex.h>
+#ifndef random_get_entropy
+/*
+ * The random_get_entropy() function is used by the /dev/random driver
+ * in order to extract entropy via the relative unpredictability of
+ * when an interrupt takes places versus a high speed, fine-grained
+ * timing source or cycle counter. Since it will be occurred on every
+ * single interrupt, it must have a very low cost/overhead.
+ *
+ * By default we use get_cycles() for this purpose, but individual
+ * architectures may override this in their asm/timex.h header file.
+ */
+#define random_get_entropy() get_cycles()
+#endif
+
/*
* SHIFT_PLL is used as a dampening factor to define how much we
* adjust the frequency correction for a given offset in PLL mode.