From patchwork Thu Aug 10 17:20:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9894291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AEEE060352 for ; Thu, 10 Aug 2017 17:20:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92FFA2785D for ; Thu, 10 Aug 2017 17:20:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8765E28727; Thu, 10 Aug 2017 17:20:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF9082624A for ; Thu, 10 Aug 2017 17:20:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752520AbdHJRU5 (ORCPT ); Thu, 10 Aug 2017 13:20:57 -0400 Received: from mout.gmx.net ([212.227.17.20]:63053 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752486AbdHJRU4 (ORCPT ); Thu, 10 Aug 2017 13:20:56 -0400 Received: from ls3530.fritz.box ([193.159.17.217]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0LbxQO-1dEFXy0vFU-00jM7o; Thu, 10 Aug 2017 19:20:50 +0200 Date: Thu, 10 Aug 2017 19:20:47 +0200 From: Helge Deller To: linux-parisc@vger.kernel.org, James Bottomley , John David Anglin Subject: [PATCH] parisc/random: Add machine specific randomness Message-ID: <20170810172047.GA3119@ls3530.fritz.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) X-Provags-ID: V03:K0:X1hR8a+uPAmSPuSQQiXlU27aWAPnpsN3J6tF51VGosrKN3GpVYq JxluV39gQcxrdlctZnS95PFlOnm/6STMUULNFin9HPcnBKNO2qXnKRaCOMTHKidKfVbKjcW RoPEnNelTAfANpzRXFmiOrQwGB+FMC3XFWTxUXS/uohPRLJ/N1Q7H23wjmaRozZowf/KW0Y wQPTwDe+hedX5ptDYJAvQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:JopnT+UP7n0=:Djg2bDufHaMyaDPbglQPyb KJUi2PvWPNa7GFJQGpT3RcVLBDz0OMhI5Fxtev4+BLhQkE5Lj3KzLk/D4Wum/WjHipSSFLJ5o DkLvZh5EVHWC+vupqjS3c6mwTradpE+v4FmmlmGjPgeFMrlhfM4weecVp40cBSXSpt1OTD6A1 RK9XC0EQmI3Zx5ZllijtKG0cVicalxtBS+PG4Zk/Fx2/6qbfxnaLh8WpS/3u66CGtuqtMgz8g SeTdXVwWaqXJ+3QMevT4Q2kaSnSZkpkc5eQUIkhGLPZ/VBd4qigK6g+h5dfrn+YnGMQl4KwXB 3Kg6hg/wmXGt6ud89KQrb7QEzP47r+W7oMXYUDhsYv37auLrjgIVb/0KJh07dRoRTFbpgBTek cGJ41PaB5kJpvzgONtO73n7VQIE0BeCAXoXba/cUNcBOlefHc52rApt+nwkA0UoTPbSbrbIMn OahDQtKIoniNODCGMiY//tASCPZKg8Hta04caHLbJqC2NwsbtJoKoeWY5KOplypGAxPKqPF0m 0e8MEnSQ7q//SIpdpExknaqPOwjk7G1Dh1e0fUI1PW5YxjEHBZmUmfZ02/qKLTUY4BN+/vOj4 ckaoW/Nzt0j7tb/WsM9XMz75RseM7eK+cIJxjL4tsN4xiK6w5IR3ZUR+MkJY58U7QzRwtPWE4 MyjFKVlvObeenShYc3Mxfb7q0tSgc7Bty0FwjkVproxC33B/cJeDx24vo3tP41BEoPH7tyWTM FqlhCYq17Xb/t3OkSEB1oCZJGyqeywlxme/xT0Tm1PQyq1enVWEXxg7D5Zhvz8CdeiwUjssR1 zpvt4HWUVqNiOTXB5MvRM6/nfycWw== Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add some machine-specific information like values of cr16 cycle counter, machine-specific software ID and machine model to the random generator. Signed-off-by: Helge Deller --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/kernel/processor.c b/arch/parisc/kernel/processor.c index 0ab3277..6b6fe8d 100644 --- a/arch/parisc/kernel/processor.c +++ b/arch/parisc/kernel/processor.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -237,28 +238,45 @@ static int processor_probe(struct parisc_device *dev) */ void __init collect_boot_cpu_data(void) { + unsigned long cr16_seed; + memset(&boot_cpu_data, 0, sizeof(boot_cpu_data)); + cr16_seed = get_cycles(); + add_device_randomness(&cr16_seed, sizeof(cr16_seed)); + boot_cpu_data.cpu_hz = 100 * PAGE0->mem_10msec; /* Hz of this PARISC */ /* get CPU-Model Information... */ #define p ((unsigned long *)&boot_cpu_data.pdc.model) - if (pdc_model_info(&boot_cpu_data.pdc.model) == PDC_OK) + if (pdc_model_info(&boot_cpu_data.pdc.model) == PDC_OK) { printk(KERN_INFO "model %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8]); + + add_device_randomness(&boot_cpu_data.pdc.model, + sizeof(boot_cpu_data.pdc.model)); + } #undef p - if (pdc_model_versions(&boot_cpu_data.pdc.versions, 0) == PDC_OK) + if (pdc_model_versions(&boot_cpu_data.pdc.versions, 0) == PDC_OK) { printk(KERN_INFO "vers %08lx\n", boot_cpu_data.pdc.versions); - if (pdc_model_cpuid(&boot_cpu_data.pdc.cpuid) == PDC_OK) + add_device_randomness(&boot_cpu_data.pdc.versions, + sizeof(boot_cpu_data.pdc.versions)); + } + + if (pdc_model_cpuid(&boot_cpu_data.pdc.cpuid) == PDC_OK) { printk(KERN_INFO "CPUID vers %ld rev %ld (0x%08lx)\n", (boot_cpu_data.pdc.cpuid >> 5) & 127, boot_cpu_data.pdc.cpuid & 31, boot_cpu_data.pdc.cpuid); + add_device_randomness(&boot_cpu_data.pdc.cpuid, + sizeof(boot_cpu_data.pdc.cpuid)); + } + if (pdc_model_capabilities(&boot_cpu_data.pdc.capabilities) == PDC_OK) printk(KERN_INFO "capabilities 0x%lx\n", boot_cpu_data.pdc.capabilities);