linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ARM: omap2: throw the die id into the entropy pool
@ 2013-09-05  7:29 Linus Walleij
  2013-09-09 19:14 ` Paul Walmsley
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2013-09-05  7:29 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-arm-kernel, linux-omap, Linus Walleij, Theodore Ts'o,
	Paul Walmsley

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 <tytso@mit.edu>
Cc: Paul Walmsley <paul@pwsan.com>
Reviewed-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Use omap_device_initcall() to avoid calling on non-OMAPs.
---
 arch/arm/mach-omap2/id.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 2dc62a2..9260d09 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -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;
+}
+omap_device_initcall(omap_feed_randpool);
+
 void __init omap2xxx_check_revision(void)
 {
 	int i, j;
-- 
1.8.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ARM: omap2: throw the die id into the entropy pool
  2013-09-05  7:29 [PATCH v2] ARM: omap2: throw the die id into the entropy pool Linus Walleij
@ 2013-09-09 19:14 ` Paul Walmsley
  2013-09-09 20:15   ` Paul Walmsley
  2013-09-10  8:20   ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Paul Walmsley @ 2013-09-09 19:14 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Tony Lindgren, linux-arm-kernel, linux-omap, Theodore Ts'o

Hi Linus,

On Thu, 5 Sep 2013, Linus Walleij wrote:

> 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 <tytso@mit.edu>
> Cc: Paul Walmsley <paul@pwsan.com>
> Reviewed-by: Kevin Hilman <khilman@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Heh, that function name "add_device_randomness()" is a bit misleading.  
It's not actually intended to add "randomness": from 
drivers/char/random.c:

/*
 * Add device- or boot-specific data to the input and nonblocking
 * pools to help initialize them to unique values.
 *
 * None of this adds any entropy, it is meant to avoid the
 * problem of the nonblocking pool having similar initial state
 * across largely identical devices.
 */

But of course the function name is not your fault :-)  The entropy count 
isn't increased by this, so:

Reviewed-by: Paul Walmsley <paul@pwsan.com>

Thanks Linus.


- Paul

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ARM: omap2: throw the die id into the entropy pool
  2013-09-09 19:14 ` Paul Walmsley
@ 2013-09-09 20:15   ` Paul Walmsley
  2013-09-10  8:20   ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Walmsley @ 2013-09-09 20:15 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Tony Lindgren, linux-arm-kernel, linux-omap, Theodore Ts'o


By the way, if anyone wants to expand on Linus' patch for OMAP, there are 
several other register fields that could be mixed in, which, based on 
their names, might vary on a per-chip basis.  For example, on OMAP4, the 
CONTROL_STD_FUSE_OPP* and CONTROL_DPLL_NWELL_TRIM* registers.



- Paul

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ARM: omap2: throw the die id into the entropy pool
  2013-09-09 19:14 ` Paul Walmsley
  2013-09-09 20:15   ` Paul Walmsley
@ 2013-09-10  8:20   ` Linus Walleij
  2013-10-03 18:13     ` Tony Lindgren
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2013-09-10  8:20 UTC (permalink / raw)
  To: Paul Walmsley
  Cc: Tony Lindgren, linux-arm-kernel@lists.infradead.org, Linux-OMAP,
	Theodore Ts'o

On Mon, Sep 9, 2013 at 9:14 PM, Paul Walmsley <paul@pwsan.com> wrote:

> Heh, that function name "add_device_randomness()" is a bit misleading.
> It's not actually intended to add "randomness": from
> drivers/char/random.c:

Yeah you're right...

Tony feel free to edit the commit message when applying.

>  * None of this adds any entropy, it is meant to avoid the
>  * problem of the nonblocking pool having similar initial state
>  * across largely identical devices.

It's noble enough, just a few years back I ran into the problem where
all boards in a test farm came up with the same ethernet MAC
address due to the initialization of the nonblocking pool being
constant.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ARM: omap2: throw the die id into the entropy pool
  2013-09-10  8:20   ` Linus Walleij
@ 2013-10-03 18:13     ` Tony Lindgren
  0 siblings, 0 replies; 5+ messages in thread
From: Tony Lindgren @ 2013-10-03 18:13 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Paul Walmsley, linux-arm-kernel@lists.infradead.org, Linux-OMAP,
	Theodore Ts'o

* Linus Walleij <linus.walleij@linaro.org> [130910 01:28]:
> On Mon, Sep 9, 2013 at 9:14 PM, Paul Walmsley <paul@pwsan.com> wrote:
> 
> > Heh, that function name "add_device_randomness()" is a bit misleading.
> > It's not actually intended to add "randomness": from
> > drivers/char/random.c:
> 
> Yeah you're right...
> 
> Tony feel free to edit the commit message when applying.
> 
> >  * None of this adds any entropy, it is meant to avoid the
> >  * problem of the nonblocking pool having similar initial state
> >  * across largely identical devices.
> 
> It's noble enough, just a few years back I ran into the problem where
> all boards in a test farm came up with the same ethernet MAC
> address due to the initialization of the nonblocking pool being
> constant.

Thanks, I'll apply this into omap-for-v3.13/fixes-not-urgent
with updated comments.

Tony


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-10-03 18:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-05  7:29 [PATCH v2] ARM: omap2: throw the die id into the entropy pool Linus Walleij
2013-09-09 19:14 ` Paul Walmsley
2013-09-09 20:15   ` Paul Walmsley
2013-09-10  8:20   ` Linus Walleij
2013-10-03 18:13     ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).