mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yan Zhao <yan.y.zhao@intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<alex.williamson@redhat.com>, <kevin.tian@intel.com>,
	<jgg@nvidia.com>
Subject: Re: [PATCH] vfio/type1: check pfn valid before converting to struct page
Date: Thu, 18 May 2023 08:52:12 +0800	[thread overview]
Message-ID: <ZGV2vF0MQwQ+LZRX@yzhao56-desk.sh.intel.com> (raw)
In-Reply-To: <ZGTwaP6peRcpl+GA@google.com>

On Wed, May 17, 2023 at 08:19:04AM -0700, Sean Christopherson wrote:
> On Tue, May 16, 2023, Yan Zhao wrote:
> > vfio_pin_page_external() can return a phys_pfn for vma with VM_PFNMAP,
> > e.g. for MMIO PFNs.
> > 
> > It's necessary to check if it's a valid pfn before calling pfn_to_page().
> > 
> > Fixes: 34a255e67615 ("vfio: Replace phys_pfn with pages for vfio_pin_pages()")
> 
> Might be worth adding a blurb to call out that this is _not_ ABI breakage.  Prior
Do you mean "_not_ ABI breakage" with
34a255e67615 ("vfio: Replace phys_pfn with pages for vfio_pin_pages()")
or with this fix commit?

> to the buggy commit, KVMGT manually checked that the pfn pinned by vfio_pin_pages()
> was pfn_valid(), and s390's driver(s) either blindly expected struct page memory,
> e.g. did
> 
>         ret = page_array_pin(&pa, vdev);
>         if (ret < 0) {
>                 page_array_unpin_free(&pa, vdev);
>                 return ret;
>         }
> 
>         l = n;
>         for (i = 0; i < pa.pa_nr; i++) {
>                 struct page *page = pfn_to_page(pa.pa_pfn[i]);
>                 void *from = kmap_local_page(page);
> 
> or in the case of its crypto driver, apparently was all kinds of confused about
> virtual vs. physical, i.e. likely couldn't have worked with anything but "normal"
> memory anyways.
> 
> AFAICT, those are the only in-tree users of vfio_pin_pages().
Though there are no in-tree users currently expect vfio_pin_pages() to cover
MMIO ranges, with the
commit 34a255e67615 ("vfio: Replace phys_pfn with pages for vfio_pin_pages()"),
the IOVA ranges supported by vfio_pin_pages() is still reduced.

Previously, it's the callers(vendor drivers)' option to decide if they want to
support MMIO GFNs or not, while now only if there are other interfaces provided
by VFIO, the vendor drivers could not allow pinning of MMIO GFNs, i.e. no guest
P2P.

  reply	other threads:[~2023-05-18  1:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16  9:30 Yan Zhao
2023-05-16 11:50 ` Jason Gunthorpe
2023-05-17 15:19 ` Sean Christopherson
2023-05-18  0:52   ` Yan Zhao [this message]
2023-05-18 18:07     ` Sean Christopherson
2023-05-19  1:25       ` Yan Zhao

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=ZGV2vF0MQwQ+LZRX@yzhao56-desk.sh.intel.com \
    --to=yan.y.zhao@intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seanjc@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®