From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 2/2] x86, apicv: Add Posted Interrupt supporting Date: Tue, 22 Jan 2013 20:59:22 -0200 Message-ID: <20130122225922.GA19011@amt.cnet> References: <1355383780-1367-1-git-send-email-yang.z.zhang@intel.com> <1355383780-1367-3-git-send-email-yang.z.zhang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, gleb@redhat.com, haitao.shan@intel.com, xiantao.zhang@intel.com, jun.nakajima@intel.com, h.peter.anvin@intel.com To: Yang Zhang Return-path: Received: from mx1.redhat.com ([209.132.183.28]:32344 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752439Ab3AVXGy (ORCPT ); Tue, 22 Jan 2013 18:06:54 -0500 Content-Disposition: inline In-Reply-To: <1355383780-1367-3-git-send-email-yang.z.zhang@intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Dec 13, 2012 at 03:29:40PM +0800, Yang Zhang wrote: > From: Yang Zhang > > Posted Interrupt allows APIC interrupts to inject into guest directly > without any vmexit. > > - When delivering a interrupt to guest, if target vcpu is running, > update Posted-interrupt requests bitmap and send a notification event > to the vcpu. Then the vcpu will handle this interrupt automatically, > without any software involvemnt. > > - If target vcpu is not running or there already a notification event > pending in the vcpu, do nothing. The interrupt will be handled by > next vm entry. > > Signed-off-by: Yang Zhang > --- > +static void pi_handler(void) > +{ > + ; > +} > + > +static int vmx_has_posted_interrupt(struct kvm_vcpu *vcpu) > +{ > + return irqchip_in_kernel(vcpu->kvm) && enable_apicv_pi; > +} > + > +static int vmx_send_nv(struct kvm_vcpu *vcpu, > + int vector) > +{ > + struct vcpu_vmx *vmx = to_vmx(vcpu); > + > + pi_set_pir(vector, vmx->pi); Section 29.6 "Posted interrupt processing": "No other agent can read or write a PIR bit (or groups of bits) between the time it is read (to determine what to OR into VIRR) and when it is cleared". > + if (!pi_test_and_set_on(vmx->pi) && (vcpu->mode == IN_GUEST_MODE)) { > + apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), POSTED_INTR_VECTOR); > + return 1; > + } > + return 0; What is the purpose of outstanding-notification bit? At first, its use as a "lock" for PIR posted-interrupt bits is limited because its cleared on step 3. before PIR is cleared. If it were cleared after step 5. then software could if (!pi_test_and_set_on(vmx->pi)) { pi_set_pir(vector, vmx->pi); apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), POSTED_INTR_VECTOR); } Does this mean software has to read PIR _and_ outstanding notification bit to know when its possible to set bits in PIR + send IPI? Or is it really cleared after step 5?