[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 20:01:22 +0800 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
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.
> > *
> > * 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.
> > */
>
> Even simpler, just before the definition of vfio_get_vaddr:
>
> /* Called with rcu_read_lock held. */
>
> and just before the vfio_dma_map call:
>
> /* vaddr is only valid until rcu_read_unlock(). But after
> * vfio_dma_map has set up the mapping the pages will be pinned
> * by the kernel. This makes sure that the RAM backend of vaddr
> * will always be there, even if the memory object is destroyed
> * and its backing memory munmap-ed.
> */
>
> I'm not sure that you can get rid of the lock for the unmapping case.
> Better remove that part of the comment.
Sure. Let me take yours. 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(), Peter Xu, 2017/01/26
- 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, 2017/01/26
- 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 <=
[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
[Qemu-devel] [PATCH v5 08/18] intel_iommu: fix trace for addr translation, Peter Xu, 2017/01/24
[Qemu-devel] [PATCH v5 10/18] memory: add section range info for IOMMU notifier, Peter Xu, 2017/01/24