Received: from eggs.gnu.org ([2001:4830:134:3::10]:53967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bK4vk-0006Lb-Fl for qemu-devel@nongnu.org; Mon, 04 Jul 2016 10:33:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bK4ve-0000YE-3N for qemu-devel@nongnu.org; Mon, 04 Jul 2016 10:32:59 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:32963) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bK4vd-0000Y4-SH for qemu-devel@nongnu.org; Mon, 04 Jul 2016 10:32:54 -0400 Received: by mail-wm0-x243.google.com with SMTP id r201so22084286wme.0 for ; Mon, 04 Jul 2016 07:32:53 -0700 (PDT) Sender: Paolo Bonzini References: <1466495274-5011-1-git-send-email-peterx@redhat.com> <1466495274-5011-17-git-send-email-peterx@redhat.com> From: Paolo Bonzini Message-ID: <32e7b422-5325-5b92-ce5d-bcd036e354db@redhat.com> Date: Mon, 4 Jul 2016 16:32:51 +0200 MIME-Version: 1.0 In-Reply-To: <1466495274-5011-17-git-send-email-peterx@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v10 16/26] intel_iommu: add support for split irqchip List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu , qemu-devel@nongnu.org Cc: ehabkost@redhat.com, mst@redhat.com, jasowang@redhat.com, rkrcmar@redhat.com, alex.williamson@redhat.com, jan.kiszka@web.de, wexu@redhat.com, marcel@redhat.com, imammedo@redhat.com, davidkiarie4@gmail.com, rth@twiddle.net On 21/06/2016 09:47, Peter Xu wrote: > @@ -3323,6 +3325,31 @@ int kvm_device_msix_deassign(KVMState *s, uint32_t dev_id) > int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, > uint64_t address, uint32_t data, PCIDevice *dev) > { > + X86IOMMUState *iommu = x86_iommu_get_default(); > + > + if (iommu) { > + int ret; > + MSIMessage src, dst; > + X86IOMMUClass *class = X86_IOMMU_GET_CLASS(iommu); > + > + src.address = route->u.msi.address_hi; > + src.address <<= VTD_MSI_ADDR_HI_SHIFT; > + src.address |= route->u.msi.address_lo; > + src.data = route->u.msi.data; > + > + ret = class->int_remap(iommu, &src, &dst, dev ? \ > + pci_requester_id(dev) : \ > + X86_IOMMU_SID_INVALID); > + if (ret) { > + trace_kvm_x86_fixup_msi_error(route->gsi); > + return 1; > + } > + > + route->u.msi.address_hi = dst.address >> VTD_MSI_ADDR_HI_SHIFT; > + route->u.msi.address_lo = dst.address & VTD_MSI_ADDR_LO_MASK; > + route->u.msi.data = dst.data; > + } > + > return 0; > } I don't like this particularly. Instead, I think the X86 IOMMU class should implement a new interface "MSIRemapper", and PCIBus should have a pointer to MSIRemapper*. Then this can become: if (dev) { PCIBus *bus = PCI_BUS(qdev_get_parent_bus(DEVICE(dev)); if (bus->remapper) { msi_remapper_fixup_route(bus->remapper, &src, &dst, pci_requester_id(dev)); } } That said, I'm okay with the patch as is because the issue is not with the x86 implementation but with kvm_arch_fixup_msi_route. S390 should be able to do the same, by implementing MSIRemapper in S390pciState (I think). Paolo