powerpc: Feed entire flattened device tree into the random pool
Subsystems (2)
PATCH 1/1 powerpc: Feed entire flattened device tree into the random pool
We feed the entire DMI table into the random pool to provide better random data during early boot, so do the same with the flattened device tree.
---
It might be worth doing this somewhere common, but the only place I could find (unflatten_device_tree) is almost certainly too early in the boot process.
arch/powerpc/kernel/setup-common.c +11 -0
@@ -35,6 +35,7 @@#include <linux/percpu.h> #include <linux/memblock.h> #include <linux/of_platform.h> +#include <linux/random.h> #include <asm/io.h> #include <asm/paca.h> #include <asm/prom.h>
@@ -752,3 +753,13 @@ void arch_setup_pdev_archdata(struct platform_device *pdev) pdev->dev.dma_mask = &pdev->archdata.dma_mask;set_dma_ops (&pdev->dev, &dma_direct_ops); } + +/* Feed entire flattened device tree into the random pool */ +static int __init add_fdt_randomness (void ) +{ +add_device_randomness (initial_boot_params, + initial_boot_params->totalsize); + +return 0 ; +} +core_initcall (add_fdt_randomness);
Quoted 11 lines · Anton Blanchard
We feed the entire DMI table into the random pool to provide better random data during early boot, so do the same with the flattened device tree.
Signed-off-by Anton Blanchard <[email protected]>---
It might be worth doing this somewhere common, but the only place I could find (
unflatten_device_tree) is almost certainly too early in the boot process.
Nice.
But why not put the initcall in drivers/of/fdt.c, that way it's not early but it's still common ?
cheers
PATCH 1/1 of: Feed entire flattened device tree into the random pool
Hi Michael,
Quoted 2 lines
But why not put the initcall in
drivers/of/fdt.c, that way it's not early but it's still common ?
Good idea! How does this look? So long as it happens before module_init(rand_initialize) we should be good.
Anton
--
We feed the entire DMI table into the random pool to provide better random data during early boot, so do the same with the flattened device tree.
---
v2: move to drivers/of/fdt.c as suggested by Michael Ellerman
drivers/of/fdt.c +12 -0
@@ -17,6 +17,7 @@#include <linux/string.h> #include <linux/errno.h> #include <linux/slab.h> +#include <linux/random.h> #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ #ifdef CONFIG_PPC
@@ -714,3 +715,14 @@ void __init unflatten_device_tree(void) }#endif /* CONFIG_OF_EARLY_FLATTREE */ + +/* Feed entire flattened device tree into the random pool */ +static int __init add_fdt_randomness (void ) +{ +if (initial_boot_params) +add_device_randomness (initial_boot_params, + initial_boot_params->totalsize); + +return 0 ; +} +core_initcall (add_fdt_randomness);
Re: [PATCH] of: Feed entire flattened device tree into the random pool
Quoted 8 lines · Anton Blanchard
Hi Michael,
Quoted 2 lines
But why not put the initcall in
drivers/of/fdt.c, that way it's not early but it's still common ?Good idea! How does this look? So long as it happens before
module_init(rand_initialize)we should be good.
This must be some strange new meaning of the word "random" of which I was not previously aware. But I guess it's marginally better than nothing.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [PATCH] of: Feed entire flattened device tree into the random pool
In reply to Anton BlanchardQuoted 34 lines · Anton Blanchard
Hi Michael,
Quoted 2 lines
But why not put the initcall in
drivers/of/fdt.c, that way it's not early but it's still common ?Good idea! How does this look? So long as it happens before
module_init(rand_initialize)we should be good.Anton
--We feed the entire DMI table into the random pool to provide better random data during early boot, so do the same with the flattened device tree.
Signed-off-by Anton Blanchard <[email protected]>---
v2: move to
drivers/of/fdt.cas suggested by Michael EllermanIndex:
b/drivers/of/fdt.c
===================================================================drivers/of/fdt.c +1
-0@@ -17,6 +17,7 @@#include <linux/string.h> #include <linux/errno.h> #include <linux/slab.h> +#include <linux/random.h> #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ #ifdef CONFIG_PPC
drivers/of/fdt.c void __init unflatten_device_tree(void) · line 724
Quoted 10 lines
drivers/of/fdt.c +7
-0@@ -714,3 +715,14 @@ void __init unflatten_device_tree(void) }#endif /* CONFIG_OF_EARLY_FLATTREE */ + +/* Feed entire flattened device tree into the random pool */ +static int __init add_fdt_randomness (void ) +{ +if (initial_boot_params) +add_device_randomness (initial_boot_params, + initial_boot_params->totalsize);
be32_to_cpu(initial_boot_params->totalsize);
g.
Re: [PATCH] of: Feed entire flattened device tree into the random pool
Hi,
Quoted 1 line
be32_to_cpu(initial_boot_params->totalsize);
Ouch, thanks Grant.
Anton
--
We feed the entire DMI table into the random pool to provide better random data during early boot, so do the same with the flattened device tree.
---
v3: Fix endian issues as noted by Grant
drivers/of/fdt.c +12 -0
@@ -17,6 +17,7 @@#include <linux/string.h> #include <linux/errno.h> #include <linux/slab.h> +#include <linux/random.h> #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ #ifdef CONFIG_PPC
@@ -714,3 +715,14 @@ void __init unflatten_device_tree(void) }#endif /* CONFIG_OF_EARLY_FLATTREE */ + +/* Feed entire flattened device tree into the random pool */ +static int __init add_fdt_randomness (void ) +{ +if (initial_boot_params) +add_device_randomness (initial_boot_params, +be32_to_cpu (initial_boot_params->totalsize)); + +return 0 ; +} +core_initcall (add_fdt_randomness);
Grant Likely
AppliedRe: [PATCH] of: Feed entire flattened device tree into the random pool
Quoted 7 lines · Anton Blanchard
Hi,
Quoted 1 line
be32_to_cpu(initial_boot_params->totalsize);Ouch, thanks Grant.
Quoted 8 lines
Anton
--We feed the entire DMI table into the random pool to provide better random data during early boot, so do the same with the flattened device tree.
Signed-off-by Anton Blanchard <[email protected]>
Applied, thanks
g.