On Tue, 15 Aug 2017, Borislav Petkov wrote: > 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?
Go ahead. What you actually want to do is to replace boot_cpu_has() with a real cpuid() check because boot_cpu_has() is not initialized on real early boot. Thanks, tglx