[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6af2f61ff6a1a0dc83690bb39f4e3270174264f4.camel@amazon.com>
Date: Fri, 28 May 2021 10:44:51 +0000
From: "Stamatis, Ilias" <ilstam@...zon.com>
To: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"pbonzini@...hat.com" <pbonzini@...hat.com>
CC: "jmattson@...gle.com" <jmattson@...gle.com>,
"Woodhouse, David" <dwmw@...zon.co.uk>,
"vkuznets@...hat.com" <vkuznets@...hat.com>,
"joro@...tes.org" <joro@...tes.org>,
"mtosatti@...hat.com" <mtosatti@...hat.com>,
"zamsden@...il.com" <zamsden@...il.com>,
"seanjc@...gle.com" <seanjc@...gle.com>,
"mlevitsk@...hat.com" <mlevitsk@...hat.com>,
"wanpengli@...cent.com" <wanpengli@...cent.com>
Subject: Re: [PATCH v4 09/11] KVM: X86: Add vendor callbacks for writing the TSC
multiplier
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
Powered by blists - more mailing lists