From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] Enabling IA32_TSC_ADJUST for guest VM Date: Wed, 10 Oct 2012 09:52:42 -0300 Message-ID: <20121010125242.GA15137@amt.cnet> References: <96EC5A4F3149B74492D2D9B9B1602C2728B61A0D@ORSMSX108.amr.corp.intel.com> <20121008173055.GC12735@amt.cnet> <507414A2.2090706@redhat.com> <96EC5A4F3149B74492D2D9B9B1602C2728B708F3@ORSMSX108.amr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Avi Kivity , "kvm@vger.kernel.org" , "Zhang, Xiantao" , "Liu, Jinsong" To: "Auld, Will" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34991 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755972Ab2JJMxA convert rfc822-to-8bit (ORCPT ); Wed, 10 Oct 2012 08:53:00 -0400 Content-Disposition: inline In-Reply-To: <96EC5A4F3149B74492D2D9B9B1602C2728B708F3@ORSMSX108.amr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Oct 09, 2012 at 04:10:30PM +0000, Auld, Will wrote: > I am just testing the second version of this patch. It addresses all = the comments so far except Marcelo's issue with breaking the function c= ompute_guest_tsc().=20 Lets try to merge the missing patch from Zachary first (that'll make it clear). >=20 > I needed to put the call for updating the TSC_ADJUST_MSR in kvm_write= _tsc() to ensure it is only called from user space. Other changes added= to vmcs offset should not be tracked in TSC_ADJUST_MSR.=20 Please have a separate, earlier patch making that explicit (by passing = a bool to kvm_x86_ops->set_msr then to kvm_set_msr_common). "that" =3D whether msr write is guest initiated or not. > I had some trouble with the order of initialization during live migra= tion. TSC_ADJUST is initialized first but then wiped out by multiple in= itializations of tsc. The fix for this is to not update TSC_ADJUST if t= he vmcs offset is not actually changing with the tsc write. So, after m= igration outcome is that vmcs offset gets defined independent from the = migrating value of TSC_ADJUST. I believe this is what we want to happen= =2E Can you please be more explicit regarding "wiped out by multiple initializations of tsc" ?=20 It is probably best to maintain TSC_ADJUST separately, in software, and then calculate TSC_OFFSET. > Thanks, >=20 > Will=20 >=20 > -----Original Message----- > From: Avi Kivity [mailto:avi@redhat.com]=20 > Sent: Tuesday, October 09, 2012 5:12 AM > To: Marcelo Tosatti > Cc: Auld, Will; kvm@vger.kernel.org; Zhang, Xiantao > Subject: Re: [PATCH] Enabling IA32_TSC_ADJUST for guest VM >=20 > On 10/08/2012 07:30 PM, Marcelo Tosatti wrote: > >=20 > > From Intel's manual: > >=20 > > =E2=80=A2 If an execution of WRMSR to the IA32_TIME_STAMP_COUNTER M= SR adds (or > > subtracts) value X from the TSC, > > the logical processor also adds (or subtracts) value X from the=20 > > IA32_TSC_ADJUST MSR. > >=20 > > This is not handled in the patch.=20 > >=20 > > To support migration, it will be necessary to differentiate between= =20 > > guest initiated and userspace-model initiated msr write. That is, o= nly=20 > > guest initiated TSC writes should affect the value of IA32_TSC_ADJU= ST=20 > > MSR. > >=20 > > Avi, any better idea? > >=20 >=20 > I think we need that anyway, since there are some read-only MSRs that= need to be configured by the host (nvmx capabilities). So if we add t= hat feature it will be useful elsewhere. I don't think it's possible t= o do it in any other way: >=20 > "Local offset value of the IA32_TSC for a logical processor. Reset va= lue is Zero. A write to IA32_TSC will modify the local offset in IA32_T= SC_ADJUST and the content of IA32_TSC, but does not affect the internal= invariant TSC hardware." >=20 > What we want to do is affect the internal invariant TSC hardware, so = we can't do that through the normal means. >=20 > btw, will tsc writes from userspace (after live migration) cause tsc = skew? If so we should think how to model a guest-wide tsc. >=20 > -- > error compiling committee.c: too many arguments to function > N?????r??y????b?X??=C7=A7v?^?)=DE=BA{.n?+????h??=17??=DC=A8}???=C6=A0= z?&j:+v???=07????zZ+??+zf???h???~????i???z?=1E?w?????????&?)=DF=A2=1Bf