From patchwork Mon Jul 29 03:11:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 262650 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 485512C0125 for ; Mon, 29 Jul 2013 13:12:34 +1000 (EST) Received: from kryten (ppp121-44-48-234.lns20.syd6.internode.on.net [121.44.48.234]) (using SSLv3 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id E98A82C0099; Mon, 29 Jul 2013 13:12:04 +1000 (EST) Date: Mon, 29 Jul 2013 13:11:50 +1000 From: Anton Blanchard To: Grant Likely Subject: Re: [PATCH] of: Feed entire flattened device tree into the random pool Message-ID: <20130729131150.591926c3@kryten> In-Reply-To: <20130728044942.A58793E0A24@localhost> References: <20130725125122.78accf44@kryten> <20130725031717.GB15673@concordia> <20130725143031.16af0a96@kryten> <20130728044942.A58793E0A24@localhost> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.17; x86_64-pc-linux-gnu) Mime-Version: 1.0 Cc: devicetree@vger.kernel.org, Rob Herring , Paul Mackerras , linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Hi, > 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. Signed-off-by: Anton Blanchard --- v3: Fix endian issues as noted by Grant Index: b/drivers/of/fdt.c =================================================================== --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -17,6 +17,7 @@ #include #include #include +#include #include /* 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);