From: Jason Gunthorpe <jgg@nvidia.com>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: mjrosato@linux.ibm.com, linux-doc@vger.kernel.org,
airlied@linux.ie, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, kwankhede@nvidia.com,
vneethv@linux.ibm.com, agordeev@linux.ibm.com, hch@infradead.org,
kvm@vger.kernel.org, corbet@lwn.net, pasic@linux.ibm.com,
borntraeger@linux.ibm.com, intel-gfx@lists.freedesktop.org,
jjherne@linux.ibm.com, farman@linux.ibm.com,
jchrist@linux.ibm.com, gor@linux.ibm.com,
linux-s390@vger.kernel.org, hca@linux.ibm.com,
freude@linux.ibm.com, rodrigo.vivi@intel.com,
intel-gvt-dev@lists.freedesktop.org, akrowiak@linux.ibm.com,
cohuck@redhat.com, oberpar@linux.ibm.com, svens@linux.ibm.com
Subject: Re: [Intel-gfx] [RFT][PATCH v2 5/9] vfio/ap: Remove redundant pfn
Date: Wed, 6 Jul 2022 14:55:19 -0300 [thread overview]
Message-ID: <20220706175519.GM693670@nvidia.com> (raw)
In-Reply-To: <20220706062759.24946-6-nicolinc@nvidia.com>
On Tue, Jul 05, 2022 at 11:27:55PM -0700, Nicolin Chen wrote:
> The vfio_ap_ops code maintains both nib address and its PFN, which
> is redundant, merely because vfio_pin/unpin_pages API wanted pfn.
> Since vfio_pin/unpin_pages() now accept "iova", remove duplicated
> pfn code in their callers too.
I would describe this as renaming saved_pfn to saved_iova
> *
> * @vcpu: the object representing the vcpu executing the PQAP(AQIC) instruction.
> * @nib: the location for storing the nib address.
> - * @g_pfn: the location for storing the page frame number of the page containing
> - * the nib.
> *
> * When the PQAP(AQIC) instruction is executed, general register 2 contains the
> * address of the notification indicator byte (nib) used for IRQ notification.
> - * This function parses the nib from gr2 and calculates the page frame
> - * number for the guest of the page containing the nib. The values are
> - * stored in @nib and @g_pfn respectively.
> - *
> - * The g_pfn of the nib is then validated to ensure the nib address is valid.
> + * This function parses and validate the nib from gr2.
> *
> * Return: returns zero if the nib address is a valid; otherwise, returns
> * -EINVAL.
> */
> -static int vfio_ap_validate_nib(struct kvm_vcpu *vcpu, unsigned long *nib,
> - unsigned long *g_pfn)
> +static int vfio_ap_validate_nib(struct kvm_vcpu *vcpu, dma_addr_t *nib)
> {
> *nib = vcpu->run->s.regs.gprs[2];
> - *g_pfn = *nib >> PAGE_SHIFT;
>
> - if (kvm_is_error_hva(gfn_to_hva(vcpu->kvm, *g_pfn)))
> + if (kvm_is_error_hva(gfn_to_hva(vcpu->kvm, *nib >> PAGE_SHIFT)))
> return -EINVAL;
This existing code is fishy. nib is either an IOVA passed to
vfio_pin_pages() or a GFN passed to gfn_to_hva(). These are not the
same thing and are not interchangable - writing code like this assumes
that the guest is running with iommu=pt or no iommu.
Someone should look at it..
Otherwise it looks OK
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
next prev parent reply other threads:[~2022-07-06 17:55 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220706062759.24946-1-nicolinc@nvidia.com>
[not found] ` <20220706062759.24946-2-nicolinc@nvidia.com>
2022-07-06 6:54 ` [Intel-gfx] [RFT][PATCH v2 1/9] vfio: Make vfio_unpin_pages() return void Christoph Hellwig
2022-07-06 16:45 ` Jason Gunthorpe
2022-07-06 17:38 ` Kirti Wankhede
2022-07-07 8:42 ` Tian, Kevin
[not found] ` <YscUCe+2sXdDiQWq@Asurada-Nvidia>
2022-07-07 19:22 ` Jason Gunthorpe
[not found] ` <20220706062759.24946-10-nicolinc@nvidia.com>
2022-07-06 6:57 ` [Intel-gfx] [RFT][PATCH v2 9/9] vfio: Replace phys_pfn with pages for vfio_pin_pages() Christoph Hellwig
2022-07-06 17:39 ` Kirti Wankhede
2022-07-06 18:18 ` Jason Gunthorpe
2022-07-07 8:49 ` Tian, Kevin
[not found] ` <20220706062759.24946-3-nicolinc@nvidia.com>
2022-07-06 16:48 ` [Intel-gfx] [RFT][PATCH v2 2/9] vfio/ap: Pass in physical address of ind to ap_aqic() Jason Gunthorpe
[not found] ` <20220706062759.24946-4-nicolinc@nvidia.com>
2022-07-06 17:05 ` [Intel-gfx] [RFT][PATCH v2 3/9] vfio/ccw: Only pass in contiguous pages Jason Gunthorpe
[not found] ` <20220706062759.24946-6-nicolinc@nvidia.com>
2022-07-06 17:55 ` Jason Gunthorpe [this message]
[not found] ` <20220706062759.24946-7-nicolinc@nvidia.com>
2022-07-06 17:59 ` [Intel-gfx] [RFT][PATCH v2 6/9] vfio/ccw: Change pa_pfn list to pa_iova list Jason Gunthorpe
[not found] ` <20220706062759.24946-8-nicolinc@nvidia.com>
2022-07-06 6:57 ` [Intel-gfx] [RFT][PATCH v2 7/9] vfio: Rename user_iova of vfio_dma_rw() Christoph Hellwig
2022-07-06 18:15 ` Jason Gunthorpe
2022-07-07 8:47 ` Tian, Kevin
[not found] ` <20220706062759.24946-9-nicolinc@nvidia.com>
2022-07-06 18:17 ` [Intel-gfx] [RFT][PATCH v2 8/9] vfio/ccw: Add kmap_local_page() for memcpy Jason Gunthorpe
2022-07-07 6:08 ` [Intel-gfx] [RFT][PATCH v2 0/9] Update vfio_pin/unpin_pages API Tian, Kevin
[not found] ` <YsZ6h/XGX1RpXQQL@Asurada-Nvidia>
2022-07-08 7:24 ` Xu, Terrence
[not found] ` <20220706062759.24946-5-nicolinc@nvidia.com>
2022-07-06 6:56 ` [Intel-gfx] [RFT][PATCH v2 4/9] vfio: Pass in starting IOVA to " Christoph Hellwig
2022-07-06 17:38 ` Kirti Wankhede
2022-07-06 17:49 ` Jason Gunthorpe
2022-07-07 8:46 ` Tian, Kevin
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=20220706175519.GM693670@nvidia.com \
--to=jgg@nvidia.com \
--cc=agordeev@linux.ibm.com \
--cc=airlied@linux.ie \
--cc=akrowiak@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=corbet@lwn.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=farman@linux.ibm.com \
--cc=freude@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hch@infradead.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jchrist@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=nicolinc@nvidia.com \
--cc=oberpar@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=rodrigo.vivi@intel.com \
--cc=svens@linux.ibm.com \
--cc=vneethv@linux.ibm.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