From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751344AbdHONpW (ORCPT ); Tue, 15 Aug 2017 09:45:22 -0400 Received: from mail.skyhub.de ([5.9.137.197]:57012 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750827AbdHONpV (ORCPT ); Tue, 15 Aug 2017 09:45:21 -0400 Date: Tue, 15 Aug 2017 15:45:14 +0200 From: Borislav Petkov To: Thomas Gleixner Cc: Ingo Molnar , Willy Tarreau , "Theodore Ts'o" , Linus Torvalds , x86-ml , "Jason A. Donenfeld" , lkml , Peter Zijlstra , Nicholas Mc Guire Subject: Re: early x86 unseeded randomness Message-ID: <20170815134514.r6qjotjgfmurwh64@pd.tnic> References: <20170814173515.n3vcpz37xh33ayuq@pd.tnic> <20170814180048.m3igiaiunlyb5wur@pd.tnic> <20170814190013.zixopgjyq26ukxcj@pd.tnic> <20170815013124.2afytkibspxrikdn@thunk.org> <20170815064437.GA1986@1wt.eu> <20170815074254.6byayhspc5tdtjb5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 15, 2017 at 12:47:36PM +0200, Thomas Gleixner wrote: > 8<------------------- > > --- a/arch/x86/kernel/tsc.c > +++ b/arch/x86/kernel/tsc.c > @@ -1360,3 +1360,19 @@ unsigned long calibrate_delay_is_known(v > return 0; > } > #endif > + > +u64 __init tsc_early_random(void) > +{ > + u64 uninitialized_var(res); > + int i; > + > + if (!boot_cpu_has(X86_FEATURE_TSC)) > + return res; > + > + res ^= rdtsc(); > + for (i = 0; i < BITS_PER_LONG; i++) { > + res ^= ((rdtsc() & 0x04) >> 2) << i; > + udelay(2); > + } > + return res; > +} Something like this is exactly what I was aiming at with my dumb patch. We could use this for early boot randomness on x86. Should I turn it into proper patches or you want to? -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.