[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr()
From: |
Peter Xu |
Subject: |
Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr() |
Date: |
Thu, 26 Jan 2017 15:12:44 +0800 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
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 efforts allow this to race?
>
> You need to keep a reference to the MemoryRegion if you do
> rcu_read_unlock. But it's simpler to call vfio_get_vaddr within
> rcu_read_lock, and keep the lock/unlock in vfio_iommu_map_notify.
>
> 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).
How about this one?
/*
* 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 vaddr
* is valid along the way we build up the IO page table (via
* vfio_dma_map()). Then, as long as the mapping is set up, we can
* unlock since those pages will be pinned in kernel (which makes
* sure that the RAM backend of vaddr will always be there, even
* if the memory object is destroyed and RAM released).
*
* For unmapping case, we don't really need the protection since
* the pages are in all cases locked in kernel, so we'll probably
* be safe even without the lock. However, it won't hurt we have
* the lock as well here.
*/
Thanks,
-- peterx
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(), (continued)
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(), Paolo Bonzini, 2017/01/25
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(), Alex Williamson, 2017/01/25
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(), Paolo Bonzini, 2017/01/25
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(), Alex Williamson, 2017/01/25
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(), Paolo Bonzini, 2017/01/25
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(), Alex Williamson, 2017/01/25
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(), Peter Xu, 2017/01/26
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(),
Peter Xu <=
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(), Paolo Bonzini, 2017/01/26
- Re: [Qemu-devel] [PATCH v5 02/18] vfio: introduce vfio_get_vaddr(), Peter Xu, 2017/01/26
[Qemu-devel] [PATCH v5 03/18] vfio: allow to notify unmap for very large region, Peter Xu, 2017/01/24
[Qemu-devel] [PATCH v5 04/18] intel_iommu: add "caching-mode" option, Peter Xu, 2017/01/24
[Qemu-devel] [PATCH v5 05/18] intel_iommu: simplify irq region translation, Peter Xu, 2017/01/24
[Qemu-devel] [PATCH v5 06/18] intel_iommu: renaming gpa to iova where proper, Peter Xu, 2017/01/24
[Qemu-devel] [PATCH v5 07/18] intel_iommu: fix trace for inv desc handling, Peter Xu, 2017/01/24
[Qemu-devel] [PATCH v5 09/18] intel_iommu: vtd_slpt_level_shift check level, Peter Xu, 2017/01/24