From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH v9 2/3] x86, apicv: add virtual x2apic support Date: Thu, 10 Jan 2013 14:34:53 +0200 Message-ID: <20130110123453.GB11529@redhat.com> References: <1357802768-15816-1-git-send-email-yang.z.zhang@intel.com> <1357802768-15816-3-git-send-email-yang.z.zhang@intel.com> <20130110075547.GI700@redhat.com> <20130110085200.GL700@redhat.com> <20130110121627.GA11529@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "kvm@vger.kernel.org" , "Shan, Haitao" , "mtosatti@redhat.com" , "Tian, Kevin" To: "Zhang, Yang Z" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:4089 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753002Ab3AJMe5 (ORCPT ); Thu, 10 Jan 2013 07:34:57 -0500 Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Jan 10, 2013 at 12:22:51PM +0000, Zhang, Yang Z wrote: > Gleb Natapov wrote on 2013-01-10: > > On Thu, Jan 10, 2013 at 11:54:21AM +0000, Zhang, Yang Z wrote: > >>>> The right logic should be: > >>>> When register virtualization enabled, read all apic msr(except apic id reg and > >>> tmcct which have the hook) not cause vmexit and only write TPR not cause > >>> vmexit. > >>>> When vid enabled, write to TPR, EOI and SELF IPI not cause vmexit. > >>>> It's better to put the patch of envirtualize x2apic mode as first patch. > >>>> > >>> There is no point whatsoever to enable virtualize x2apic without > >>> allowing at least one non intercepted access to x2apic MSR range and > >>> this is what your patch is doing when run on cpu without vid capability. > >> No, at least read/write TPR will not cause vmexit if virtualize x2apic mode is > > enabled. > > For that you need to disable 808H MSR intercept, which your patch does not do. > I want to do this in next patch. > Then don't. There is no point in the patch that enables virtualize x2apic and does not allow at least one non-intercepted MSR access. > >> I am not sure whether I understand your comments right in previous > >> discussion, here is my thinking: 1. enable virtualize x2apic mode if > >> guest is really using x2apic and clear TPR in msr read and write > >> bitmap. This will benefit reading TPR. 2. If APIC registers > >> virtualization is enabled, clear all bit in rang > > 0x800-0x8ff(except apic id reg and tmcct). > > Clear all read bits in the range. > > > >> 3. If vid is enabled, clear EOI and SELF IPI in msr write map. > >> > > Looks OK. > > > >> One concern you mentioned is that vid enabled and virtualize x2apic is disabled > > but guest still use x2apic. In this case, we still use MSR bitmap to intercept x2apic. > > This means the vEOI update will never happen. But we still can benefit from > > interrupt window. > >> > > What interrupt windows? Without virtualized x2apic TPR/EOI > > virtualization will not happen and we rely on that in the code. > Yes, but we can eliminate vmexit of interrupt window. Interrupt still can delivery to guest without vmexit when guest enables interrupt if vid is enabled. See SDM vol 3, 29.2.2. > What does it matter that you eliminated vmexit of interrupt window if you broke everything else? The vid patch assumes that apic emulation either entirely happens in a software when vid is disabled or in a CPU if vid is enabled. Mixed mode will not work (apic->isr_count = 1 trick will break things for instance). And it is not worth it to complicate the code to make it work. -- Gleb.