Received: from eggs.gnu.org ([2001:4830:134:3::10]:48198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clbWn-0003In-N5 for qemu-devel@nongnu.org; Wed, 08 Mar 2017 08:21:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clbWj-0004LX-KW for qemu-devel@nongnu.org; Wed, 08 Mar 2017 08:21:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8443) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1clbWj-0004LS-By for qemu-devel@nongnu.org; Wed, 08 Mar 2017 08:21:13 -0500 References: <1488425538-13785-1-git-send-email-peterx@redhat.com> <20170302071100-mutt-send-email-mst@kernel.org> <213ff4bb-b3b9-fe00-6f0e-b75114e1a5ef@redhat.com> <1149211275.29885713.1488962150826.JavaMail.zimbra@redhat.com> From: Marcel Apfelbaum Message-ID: <37ddf664-4620-a2d4-e4aa-57e8de0dfe95@redhat.com> Date: Wed, 8 Mar 2017 15:20:57 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3] intel_iommu: check misordered init when realize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang , Paolo Bonzini Cc: yi l liu , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Peter Xu , Alex Williamson , Jintack Lim , Laine Stump On 03/08/2017 12:08 PM, Jason Wang wrote: > > > On 2017=E5=B9=B403=E6=9C=8808=E6=97=A5 16:35, Paolo Bonzini wrote: >> >> ----- Original Message ----- >>> From: "Marcel Apfelbaum" >>> To: "Michael S. Tsirkin" , "Peter Xu" >>> Cc: qemu-devel@nongnu.org, "Paolo Bonzini" , "yi= l liu" , "Jintack Lim" >>> , "Jason Wang" , "Alex = Williamson" >>> Sent: Thursday, March 2, 2017 7:24:44 AM >>> Subject: Re: [PATCH v3] intel_iommu: check misordered init when reali= ze >>> >>> On 03/02/2017 07:13 AM, Michael S. Tsirkin wrote: >>>> On Thu, Mar 02, 2017 at 11:32:18AM +0800, Peter Xu wrote: >>>>> Intel vIOMMU devices are created with "-device" parameter, while he= re >>>>> actually we need to make sure the dmar device be created before oth= er >>>>> PCI devices (like vfio-pci, virtio-pci ones) so that we know iommu_= fn >>>>> will be setup correctly before realizations of those PCI devices (i= t is >>>>> legal that PCI device fetch these info during its realization). Now= this >>>>> ordering yet cannot be achieved elsewhere, and devices will be crea= ted >>>>> in the order that user specified. We need to avoid that. >>>>> >>>>> This patch tries to detect this kind of misordering issue during in= it of >>>>> VT-d device, then report to guest if misordering happened. In the >>>>> future, we can provide something better to solve it, e.g., to suppo= rt >>>>> device init ordering, then we can live without this patch. >>>>> >>>>> Signed-off-by: Peter Xu >>>> Unfortunately with virtio it's a regression, as it used to >>>> work with iommu. So I'm afraid we need to look into supporting >>>> arbitrary order right now :( >>>> >>> Hi, >>> >>> A fast way to do it is to initialize iommu with a new keyword, like >>> -iommu intel-iommu >>> Or maybe use the existing "-object" somehow ? >>> From vl.c comments: >>> "Initial object creation happens before all other >>> QEMU data types are created.... " >>> >>> Another idea is to add a third run on QEMU cmd line arguments, >>> but this would affect the whole system. >>> >>> However having an ordering system beats all other ideas. >> The ordering should be explicit in the command line. Since we do not = have >> cycles, it should be possible. >> >> The best solution would have been to add something like >> >> -device intel-iommu,id=3Droot-complex-iommu -global mch.iommu=3Dro= ot-complex-iommu >> >> but it's too late for that. >> >> Paolo >> > > Yes, it's probably too late other than having workarounds for 2.9. I suggested to Laine to require libvirt to initialize first the iommu dev= ice. and since most QEMU users use libvirt anyway, we may just be OK (kind of)= . > And to eliminate similar issues, we may initializing the pci devices by= traversing the PCI tree from root complex in level order. Interesting idea, we'll explore it for 2.10. But we need initialization order for all machine components, not only PCI= . Thanks, Marcel > > Thanks