Skip to contentSkip to conversation

ARM: omap2: throw the die id into the entropy pool

PATCH Superseded Linus Walleij 2 participants 2 messages Sep 4, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: omap2: throw the die id into the entropy pool

Atleast eight bytes of this number are totally unique for the device it seems, so this is a perfect candidate for feeding the entropy pool. One byte more or less of constants does not matter so feed in the entire OID struct.

Cc Theodore Ts'o <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/id.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/mach-omap2/id.c +12 -0
index 2dc62a2..fc03cc6 100644
@@ -18,6 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/random.h>
 #include <linux/slab.h>
 
 #ifdef CONFIG_SOC_BUS
@@ -130,6 +131,17 @@ void omap_get_die_id(struct omap_die_id *odi)
 	odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_3);
 }
 
+static int __init omap_feed_randpool(void)
+{
+	struct omap_die_id odi;
+
+	/* Throw the die ID into the entropy pool at boot */
+	omap_get_die_id(&odi);
+	add_device_randomness(&odi, sizeof(odi));
+	return 0;
+}
+device_initcall(omap_feed_randpool);
+
 void __init omap2xxx_check_revision(void)
 {
 	int i, j;
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/1 ARM: omap2: throw the die id into the entropy pool

Quoted 28 lines · Linus Walleij

Atleast eight bytes of this number are totally unique for the device it seems, so this is a perfect candidate for feeding the entropy pool. One byte more or less of constants does not matter so feed in the entire OID struct.

Cc Theodore Ts'o <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/id.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/mach-omap2/id.c +1 -0
index 2dc62a2..fc03cc6 100644
@@ -18,6 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/random.h>
 #include <linux/slab.h>
 
 #ifdef CONFIG_SOC_BUS
@@ -130,6 +131,17 @@ void omap_get_die_id(struct omap_die_id *odi)
 	odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_3);
 }
 

arch/arm/mach-omap2/id.c void omap_get_die_id(struct omap_die_id *odi) · line 143

Quoted 10 lines
arch/arm/mach-omap2/id.c +10 -0
+static int __init omap_feed_randpool(void)
+{
+	struct omap_die_id odi;
+
+	/* Throw the die ID into the entropy pool at boot */
+	omap_get_die_id(&odi);
+	add_device_randomness(&odi, sizeof(odi));
+	return 0;
+}
+device_initcall(omap_feed_randpool);

Needs to be omap_device_initcall() so it doesn't get called on non-OMAPs in a multi-platform kernel.

Otherwise looks good.

Kevin