On Thu, 2021-05-27 at 15:08 +0200, Paolo Bonzini wrote: > On 27/05/21 10:33, Stamatis, Ilias wrote: > > > #ifdef CONFIG_X86_64 > > > @@ -10444,6 +10461,7 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) > > > return; > > > vcpu_load(vcpu); > > > kvm_synchronize_tsc(vcpu, 0); > > > + kvm_vcpu_write_tsc_multiplier(vcpu, kvm_default_tsc_scaling_ratio); > > > > Hmm, I'm actually thinking now that this might not be correct. For example in > > case we hotplug a new vCPU but the other vCPUs don't use the default ratio. > > It is correct, the TSC frequency can be set per CPU (which is useless > except possibly for debugging OS timekeeping, but still). So, the > default kHz after hotplug is the host frequency. > > It doesn't really matter because it only affects the fixed delta between > the hotplugged CPU and the others as soon as userspace sets the > frequency to the correct value. > > Paolo > So this patch is wrong anyway. kvm_arch_vcpu_create() does a kvm_set_tsc_khz(vcpu, max_tsc_khz) when initializing the vcpu. This wouldn't normally result in a VMWRITE, but now (after applying patch 9) it does. The problem is that this write now happens too early and it raises an exception. To fix this, that line needs to be moved to kvm_arch_vcpu_postcreate() (like above) but before calling kvm_synchronize_tsc(vcpu, 0). I will re-submit this patch with the fix. Best, Ilias