All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vipin Sharma <vipinsh@google.com>
To: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org, alex@shazbot.org, dmatlack@google.com,
	 jgg@nvidia.com
Subject: Re: [PATCH 1/3] vfio/type1: Skip reserved PFNs in vpfn_pages()
Date: Tue, 1 Dec 2026 15:42:35 -0800	[thread overview]
Message-ID: <20261130214104.GA2554154.vipinsh@google.com> (raw)
In-Reply-To: <20261119185659.889654-2-aaronlewis@google.com>

On Thu, Nov 19, 2026 at 06:56:57PM +0000, Aaron Lewis wrote:
> vpfn_pages() is used by vfio_pin_pages_remote() and
> vfio_unpin_pages_remote() to count how many pages in an IOVA range are
> already accounted in dma->locked_vm via external page pinning.
> 
> However, while vfio_pin_page_external() and
> vfio_iommu_unmap_unpin_reaccount() skip invalid and reserved PFNs when
> accounting dma->locked_vm, vpfn_pages() counts every entry in
> dma->pfn_list indiscriminately. If a reserved PFN is externally pinned,
> vpfn_pages() reports it as accounted in dma->locked_vm even though it
> never was.
> 
> As a result, vfio_unpin_pages_remote() inflates locked_vm when it
> unwinds a failed vfio_iommu_replay(). vfio_pin_pages_remote() would
> under-account for the same reason, but today it only consults
> vpfn_pages() for runs that start with a non-reserved PFN. A subsequent
> patch removes that restriction and relies on vpfn_pages() being exact.
> 
> Check is_invalid_reserved_pfn() in vpfn_pages() so it only counts
> externally pinned PFNs that were actually accounted.
> 
> Fixes: f6c84a52cc41 ("vfio/type1: optimize vfio_pin_pages_remote()")
> Fixes: d10872050ffe ("vfio/type1: batch vfio_find_vpfn() in function vfio_unpin_pages_remote()")
> Signed-off-by: Aaron Lewis <aaronlewis@google.com>

Reviewed-by: Vipin Sharma <vipinsh@google.com>


  reply	other threads:[~2026-12-01 23:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 18:56 [PATCH 0/3] vfio/type1: Fix pin leaks for reserved GUP-pinned pages Aaron Lewis
2026-11-19 18:56 ` [PATCH 1/3] vfio/type1: Skip reserved PFNs in vpfn_pages() Aaron Lewis
2026-12-01 23:42   ` Vipin Sharma [this message]
2026-11-19 18:56 ` [PATCH 2/3] vfio/type1: Track GUP vs PFNMAP in DMA map/unmap Aaron Lewis
2026-11-19 19:12   ` sashiko-bot
2026-12-02  0:07   ` Vipin Sharma
2026-11-19 18:56 ` [PATCH 3/3] vfio/type1: Track GUP vs PFNMAP in external page pinning Aaron Lewis
2026-11-19 20:27 ` [PATCH 0/3] vfio/type1: Fix pin leaks for reserved GUP-pinned pages Jason Gunthorpe
2026-11-20 16:59   ` Aaron Lewis
2026-11-25 19:34     ` Alex Williamson
2026-11-30 14:40       ` Aaron Lewis
2026-11-30 23:52         ` Alex Williamson
2026-12-02  0:25           ` Vipin Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130214104.GA2554154.vipinsh@google.com \
    --to=vipinsh@google.com \
    --cc=aaronlewis@google.com \
    --cc=alex@shazbot.org \
    --cc=dmatlack@google.com \
    --cc=jgg@nvidia.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.