On 10/10/19 09:30, Suleiman Souhlal wrote: > +kvm_hostclock_enable(struct clocksource *cs) > +{ > + pv_timekeeper_enabled = 1; > + > + old_vclock_mode = kvm_clock.archdata.vclock_mode; > + kvm_clock.archdata.vclock_mode = VCLOCK_TSC; > + return 0; > +} > + > +static void > +kvm_hostclock_disable(struct clocksource *cs) > +{ > + pv_timekeeper_enabled = 0; > + kvm_clock.archdata.vclock_mode = old_vclock_mode; > +} > + Why do you poke at kvm_clock? Instead you should add .archdata = { .vclock_mode = VCLOCK_TSC }, to the kvm_hostclock declaration. Please also check that the invariant TSC CPUID bit CPUID[0x80000007].EDX[8] is set before enabling this feature. Paolo > + pvtk = &pv_timekeeper; > + do { > + gen = pvtk_read_begin(pvtk); > + if (!(pv_timekeeper.flags & PVCLOCK_TIMEKEEPER_ENABLED)) > + return; > + > + pvclock_copy_into_read_base(pvtk, &tk->tkr_mono, > + &pvtk->tkr_mono); > + pvclock_copy_into_read_base(pvtk, &tk->tkr_raw, &pvtk->tkr_raw); > + > + tk->xtime_sec = pvtk->xtime_sec; > + tk->ktime_sec = pvtk->ktime_sec; > + tk->wall_to_monotonic.tv_sec = pvtk->wall_to_monotonic_sec; > + tk->wall_to_monotonic.tv_nsec = pvtk->wall_to_monotonic_nsec; > + tk->offs_real = pvtk->offs_real; > + tk->offs_boot = pvtk->offs_boot; > + tk->offs_tai = pvtk->offs_tai; > + tk->raw_sec = pvtk->raw_sec; > + } while (pvtk_read_retry(pvtk, gen)); > +} > + Should you write an "enabled value" (basically the flags) into pvtk as well? > > +kvm_hostclock_init(void) > +{ > + unsigned long pa; > + > + pa = __pa(&pv_timekeeper); > + wrmsrl(MSR_KVM_TIMEKEEPER_EN, pa); As Vitaly said, a new CPUID bit must be defined in Documentation/virt/kvm/cpuid.txt, and used here. Also please make bit 0 an enable bit.