From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9pbA-0001bz-Ba for qemu-devel@nongnu.org; Mon, 06 Jun 2016 04:09:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9pb7-0003I6-2r for qemu-devel@nongnu.org; Mon, 06 Jun 2016 04:09:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9pb6-0003I1-T2 for qemu-devel@nongnu.org; Mon, 06 Jun 2016 04:09:20 -0400 Date: Mon, 6 Jun 2016 16:09:11 +0800 From: Peter Xu Message-ID: <20160606080911.GI21254@pxdev.xzpeter.org> References: <20160523115342.636a5164@ul30vt.home> <20160526145844.552b21fb@t450s.home> <20160528100220.2d48ff2d@ul30vt.home> <20160528113936.48e67fac@ul30vt.home> <20160528134800.1af926d1@ul30vt.home> <20160602073417.43735ed3@ul30vt.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160602073417.43735ed3@ul30vt.home> Subject: Re: [Qemu-devel] [PATCH v3 3/3] IOMMU: Integrate between VFIO and vIOMMU to support device assignment List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: "Aviv B.D." , Jan Kiszka , qemu-devel@nongnu.org, "Michael S. Tsirkin" On Thu, Jun 02, 2016 at 07:34:17AM -0600, Alex Williamson wrote: > On Thu, 02 Jun 2016 13:09:27 +0000 > "Aviv B.D." wrote: > > > Hi, > > > > In case of hot plug vfio device there should not be any active mapping > > to this device prior the device addition. > > Counter example - a device is hot added to a guest booted with iommu=pt. I got the same question with Aviv... For hot-plug devices, even if it is using iommu=pt, shouldn't it still follow the steps that first init vfio device, then configure device context entry? Let me list the steps for device addition in case I got any mistake: 1. user add new VFIO device A 2. vfio_listener_region_add() called for device A on the IOMMU mr, here we should create the iommu notifier. However since the context entry still does not exist, memory_region_iommu_replay() will got all invalid IOTLB (IOMMU_NONE entries) 3. guest kernel found the device, enabled the device, filled in context entry for device A with "pass-through" (so the SLPTPTR is invalid) 4. guest sent context invalidation to QEMU vIOMMU since we have CM=1 set for guest vIOMMU 5. QEMU vIOMMU handle the invalidation, trigger VFIO notify to do correct VFIO mapping for device A Though here step 5 should still be missing (IIUC Aviv's patch 3 still not handled context invalidation). Just want to know whether we can avoid the replay operation for Intel vIOMMUs (for Intel only, because Intel has context invalidation and cache mode support, not sure about other platform)? Thanks, -- peterx