Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-26 Thread Peter Xu
On Thu, Jan 26, 2017 at 11:55:22AM +0100, Paolo Bonzini wrote: > > > On 26/01/2017 08:12, Peter Xu wrote: > > > > /* > > * Here, we need to have the lock not only for vfio_get_vaddr(), > > * but also needs to make sure that the vaddr will be valid for > > * further operations.

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-26 Thread Paolo Bonzini
On 26/01/2017 08:12, Peter Xu wrote: > > /* > * Here, we need to have the lock not only for vfio_get_vaddr(), > * but also needs to make sure that the vaddr will be valid for > * further operations. > * > * When we map new pages, we need the lock to make sure that va

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Peter Xu
On Wed, Jan 25, 2017 at 06:11:37PM +0100, Paolo Bonzini wrote: [...] > > The comment from v4 still needs input from Paolo, is it valid to make > > use of vaddr (based on address_space_translate -> > > memory_region_get_ram_ptr) outside of the rcu read lock or could future > > BQL reduction effort

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Peter Xu
On Wed, Jan 25, 2017 at 01:09:47PM -0700, Alex Williamson wrote: > On Wed, 25 Jan 2017 20:42:19 +0100 > Paolo Bonzini wrote: > > > On 25/01/2017 19:36, Alex Williamson wrote: > > >> It depends of what happens if they aren't. I think it's fine (see other > > >> message), but taking a reference fo

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Peter Xu
On Wed, Jan 25, 2017 at 06:16:44PM +0100, Paolo Bonzini wrote: > > > On 25/01/2017 17:43, Alex Williamson wrote: > > On Wed, 25 Jan 2017 12:32:21 +0800 > > Peter Xu wrote: > >> I have similar question as well above - IIUC the RCU read lock > >> protects us from not losing the references of memor

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Alex Williamson
On Wed, 25 Jan 2017 20:42:19 +0100 Paolo Bonzini wrote: > On 25/01/2017 19:36, Alex Williamson wrote: > >> It depends of what happens if they aren't. I think it's fine (see other > >> message), but taking a reference for each mapping entry isn't so easy > >> because the unmap case doesn't know t

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Paolo Bonzini
On 25/01/2017 19:36, Alex Williamson wrote: >> It depends of what happens if they aren't. I think it's fine (see other >> message), but taking a reference for each mapping entry isn't so easy >> because the unmap case doesn't know the old memory region. > If we held a reference to the memory reg

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Alex Williamson
On Wed, 25 Jan 2017 18:40:56 +0100 Paolo Bonzini wrote: > On 25/01/2017 18:36, Alex Williamson wrote: > >> You probably should also put a comment about why VFIO does *not* need to > >> keep a reference between vfio_dma_map and vfio_dma_unmap (which doesn't > >> sound easy to do either). Would an

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Paolo Bonzini
On 25/01/2017 18:36, Alex Williamson wrote: >> You probably should also put a comment about why VFIO does *not* need to >> keep a reference between vfio_dma_map and vfio_dma_unmap (which doesn't >> sound easy to do either). Would any well-behaved guest invalidate the >> IOMMU page tables before

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Alex Williamson
On Wed, 25 Jan 2017 18:11:37 +0100 Paolo Bonzini wrote: > On 24/01/2017 17:29, Alex Williamson wrote: > > On Tue, 24 Jan 2017 18:25:55 +0800 > > Peter Xu wrote: > > > >> A cleanup for vfio_iommu_map_notify(). Should have no functional change, > >> just to make the function shorter and easier

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Paolo Bonzini
On 25/01/2017 17:43, Alex Williamson wrote: > On Wed, 25 Jan 2017 12:32:21 +0800 > Peter Xu wrote: >> I have similar question as well above - IIUC the RCU read lock >> protects us from not losing the references of memory objects, however >> in our case even after we release the lock, we are stil

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Paolo Bonzini
On 24/01/2017 17:29, Alex Williamson wrote: > On Tue, 24 Jan 2017 18:25:55 +0800 > Peter Xu wrote: > >> A cleanup for vfio_iommu_map_notify(). Should have no functional change, >> just to make the function shorter and easier to understand. >> >> Signed-off-by: Peter Xu >> --- >> hw/vfio/commo

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-25 Thread Alex Williamson
On Wed, 25 Jan 2017 12:32:21 +0800 Peter Xu wrote: > On Tue, Jan 24, 2017 at 09:29:05AM -0700, Alex Williamson wrote: > > On Tue, 24 Jan 2017 18:25:55 +0800 > > Peter Xu wrote: > > > > > A cleanup for vfio_iommu_map_notify(). Should have no functional change, > > > just to make the function s

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-24 Thread Peter Xu
On Tue, Jan 24, 2017 at 09:29:05AM -0700, Alex Williamson wrote: > On Tue, 24 Jan 2017 18:25:55 +0800 > Peter Xu wrote: > > > A cleanup for vfio_iommu_map_notify(). Should have no functional change, > > just to make the function shorter and easier to understand. > > > > Signed-off-by: Peter Xu

Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-24 Thread Alex Williamson
On Tue, 24 Jan 2017 18:25:55 +0800 Peter Xu wrote: > A cleanup for vfio_iommu_map_notify(). Should have no functional change, > just to make the function shorter and easier to understand. > > Signed-off-by: Peter Xu > --- > hw/vfio/common.c | 58 > +

[Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()

2017-01-24 Thread Peter Xu
A cleanup for vfio_iommu_map_notify(). Should have no functional change, just to make the function shorter and easier to understand. Signed-off-by: Peter Xu --- hw/vfio/common.c | 58 +--- 1 file changed, 38 insertions(+), 20 deletions(-) diff