Received: from eggs.gnu.org ([2001:4830:134:3::10]:50124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur69t-0008Mv-UO for qemu-devel@nongnu.org; Mon, 24 Jun 2013 08:46:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ur69r-00083Z-9o for qemu-devel@nongnu.org; Mon, 24 Jun 2013 08:46:13 -0400 Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: <87sj07bsf3.fsf@codemonkey.ws> Date: Mon, 24 Jun 2013 14:37:43 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1371737338-25148-1-git-send-email-aik@ozlabs.ru> <1371747090.32709.61.camel@ul30vt.home> <51C3B2E4.7000807@ozlabs.ru> <1371782063.30572.74.camel@ul30vt.home> <51C3BF3E.20901@ozlabs.ru> <1371789981.30572.114.camel@ul30vt.home> <20130624071338.GZ5832@redhat.com> <87sj07bsf3.fsf@codemonkey.ws> Subject: Re: [Qemu-devel] [PATCH] RFC kvm irqfd: add directly mapped MSI IRQ support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Gleb Natapov , "Michael S . Tsirkin" , Alexey Kardashevskiy , qemu-devel , qemu-trivial@nongnu.org, Alex Williamson , qemu-ppc@nongnu.org, Paolo Bonzini , Paul Mackerras , David Gibson On 24.06.2013, at 14:32, Anthony Liguori wrote: > Gleb Natapov writes: >=20 >> On Sun, Jun 23, 2013 at 10:06:05AM -0500, Anthony Liguori wrote: >>> On Thu, Jun 20, 2013 at 11:46 PM, Alex Williamson >>> wrote: >>>> On Fri, 2013-06-21 at 12:49 +1000, Alexey Kardashevskiy wrote: >>>>> On 06/21/2013 12:34 PM, Alex Williamson wrote: >>>>>=20 >>>>>=20 >>>>> Do not follow you, sorry. For x86, is it that MSI routing table = which is >>>>> updated via KVM_SET_GSI_ROUTING in KVM? When there is no KVM, what = piece of >>>>> code responds on msi_notify() in qemu-x86 and does = qemu_irq_pulse()? >>>>=20 >>>> vfio_msi_interrupt->msi[x]_notify->stl_le_phys(msg.address, = msg.data) >>>>=20 >>>> This writes directly to the interrupt block on the vCPU. With KVM, = the >>>> in-kernel APIC does the same write, where the pin to MSIMessage is = setup >>>> by kvm_irqchip_add_msi_route and the pin is pulled by an irqfd. >>>=20 >>> What is this "interrupt block on the vCPU" you speak of? I reviewed >> FEE00000H address as seen from PCI bus is a special address range = (see >> 10.11.1 in SDM). >=20 > Ack. >=20 >> Any write by a PCI device to that address range is >> interpreted as MSI. We do not model this correctly in QEMU yet since >> all devices, including vcpus, see exactly same memory map. >=20 > This should be a per-device mapping, yes. But I'm not sure that VCPUs > should even see anything. I don't think a VCPU can generate an MSI > interrupt by writing to this location. >=20 >>> the SDM and see nothing in the APIC protocol or the brief = description >>> of MSI as a PCI concept that would indicate anything except that the >>> PHB handles MSI writes and feeds them to the I/O APIC. >>>=20 >> I/O APIC? Did you mean APIC, but even that will probably be = incorrect. >> I'd say it translates the data to APIC bus message. And with = interrupt >> remapping there is more magic happens between MSI and APIC bus. >=20 > I think the wording in the SDM allows either. >=20 >>> In fact, the wikipedia article on MSI has: >>>=20 >>> "A common misconception with Message Signaled Interrupts is that = they >>> allow the device to send data to a processor as part of the = interrupt. >>> The data that is sent as part of the write is used by the chipset to >>> determine which interrupt to trigger on which processor; it is not >>> available for the device to communicate additional information to = the >>> interrupt handler." >>>=20 >> Not sure who claimed otherwise. >=20 > So to summarize: >=20 > 1) MSI writes are intercepted by the PHB and generates an appropriate > IRQ. >=20 > 2) The PHB has a tuple of (src device, address, data) plus whatever > information it maintains to do the translation. >=20 > 3) On Power, we can have multiple PHBs. >=20 > 4) The kernel interface assumes a single flat table mapping (address, > data) to interrupts. We try to keep that table up-to-date in QEMU. >=20 > 5) The reason the kernel has MSI info at all is to allow for IRQFDs to > generate MSI interrupts. >=20 > Is there anything that prevents us from using IRQFDs corresponding to > the target of an MSI mapping and get rid of the MSI info in the = kernel? What would that interface look like? An MSI does not arrive at an I/O = APIC pin, so we can't use the existing "give me an irqfd for this pin" = command. Alex