[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170815134514.r6qjotjgfmurwh64@pd.tnic>
Date: Tue, 15 Aug 2017 15:45:14 +0200
From: Borislav Petkov <bp@...en8.de>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...nel.org>, Willy Tarreau <w@....eu>,
Theodore Ts'o <tytso@....edu>,
Linus Torvalds <torvalds@...ux-foundation.org>,
x86-ml <x86@...nel.org>, "Jason A. Donenfeld" <Jason@...c4.com>,
lkml <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Nicholas Mc Guire <der.herr@...r.at>
Subject: Re: early x86 unseeded randomness
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.
Powered by blists - more mailing lists