From: Anthony Krowiak <akrowiak@linux.ibm.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
kwankhede@nvidia.com, corbet@lwn.net, hca@linux.ibm.com,
gor@linux.ibm.com, agordeev@linux.ibm.com,
borntraeger@linux.ibm.com, svens@linux.ibm.com,
zhenyuw@linux.intel.com, zhi.a.wang@intel.com,
jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com,
airlied@linux.ie, daniel@ffwll.ch, farman@linux.ibm.com,
mjrosato@linux.ibm.com, pasic@linux.ibm.com,
vneethv@linux.ibm.com, oberpar@linux.ibm.com,
freude@linux.ibm.com, jjherne@linux.ibm.com,
alex.williamson@redhat.com, cohuck@redhat.com, jgg@nvidia.com,
kevin.tian@intel.com, hch@infradead.org
Cc: linux-s390@vger.kernel.org, kvm@vger.kernel.org,
linux-doc@vger.kernel.org, intel-gfx@lists.freedesktop.org,
jchrist@linux.ibm.com, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, terrence.xu@intel.com,
intel-gvt-dev@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v3 06/10] vfio/ap: Change saved_pfn to saved_iova
Date: Tue, 12 Jul 2022 10:28:48 -0400 [thread overview]
Message-ID: <c1662fda-c87c-e204-dddd-e6159c8aa104@linux.ibm.com> (raw)
In-Reply-To: <20220708224427.1245-7-nicolinc@nvidia.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com>
On 7/8/22 6:44 PM, 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", change "saved_pfn"
> to "saved_iova" and remove pfn in the vfio_ap_validate_nib().
>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> Tested-by: Eric Farman <farman@linux.ibm.com>
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
> drivers/s390/crypto/vfio_ap_ops.c | 42 +++++++++++----------------
> drivers/s390/crypto/vfio_ap_private.h | 4 +--
> 2 files changed, 19 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 8a2018ab3cf0..e8856a7e151c 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -112,7 +112,7 @@ static void vfio_ap_wait_for_irqclear(int apqn)
> *
> * Unregisters the ISC in the GIB when the saved ISC not invalid.
> * Unpins the guest's page holding the NIB when it exists.
> - * Resets the saved_pfn and saved_isc to invalid values.
> + * Resets the saved_iova and saved_isc to invalid values.
> */
> static void vfio_ap_free_aqic_resources(struct vfio_ap_queue *q)
> {
> @@ -123,9 +123,9 @@ static void vfio_ap_free_aqic_resources(struct vfio_ap_queue *q)
> kvm_s390_gisc_unregister(q->matrix_mdev->kvm, q->saved_isc);
> q->saved_isc = VFIO_AP_ISC_INVALID;
> }
> - if (q->saved_pfn && !WARN_ON(!q->matrix_mdev)) {
> - vfio_unpin_pages(&q->matrix_mdev->vdev, q->saved_pfn << PAGE_SHIFT, 1);
> - q->saved_pfn = 0;
> + if (q->saved_iova && !WARN_ON(!q->matrix_mdev)) {
> + vfio_unpin_pages(&q->matrix_mdev->vdev, q->saved_iova, 1);
> + q->saved_iova = 0;
> }
> }
>
> @@ -189,27 +189,19 @@ static struct ap_queue_status vfio_ap_irq_disable(struct vfio_ap_queue *q)
> *
> * @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 validates 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;
>
> return 0;
> @@ -239,34 +231,34 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
> int isc,
> struct kvm_vcpu *vcpu)
> {
> - unsigned long nib;
> struct ap_qirq_ctrl aqic_gisa = {};
> struct ap_queue_status status = {};
> struct kvm_s390_gisa *gisa;
> int nisc;
> struct kvm *kvm;
> - unsigned long g_pfn, h_pfn;
> + unsigned long h_pfn;
> phys_addr_t h_nib;
> + dma_addr_t nib;
> int ret;
>
> /* Verify that the notification indicator byte address is valid */
> - if (vfio_ap_validate_nib(vcpu, &nib, &g_pfn)) {
> - VFIO_AP_DBF_WARN("%s: invalid NIB address: nib=%#lx, g_pfn=%#lx, apqn=%#04x\n",
> - __func__, nib, g_pfn, q->apqn);
> + if (vfio_ap_validate_nib(vcpu, &nib)) {
> + VFIO_AP_DBF_WARN("%s: invalid NIB address: nib=%pad, apqn=%#04x\n",
> + __func__, &nib, q->apqn);
>
> status.response_code = AP_RESPONSE_INVALID_ADDRESS;
> return status;
> }
>
> - ret = vfio_pin_pages(&q->matrix_mdev->vdev, g_pfn << PAGE_SHIFT, 1,
> + ret = vfio_pin_pages(&q->matrix_mdev->vdev, nib, 1,
> IOMMU_READ | IOMMU_WRITE, &h_pfn);
> switch (ret) {
> case 1:
> break;
> default:
> VFIO_AP_DBF_WARN("%s: vfio_pin_pages failed: rc=%d,"
> - "nib=%#lx, g_pfn=%#lx, apqn=%#04x\n",
> - __func__, ret, nib, g_pfn, q->apqn);
> + "nib=%pad, apqn=%#04x\n",
> + __func__, ret, &nib, q->apqn);
>
> status.response_code = AP_RESPONSE_INVALID_ADDRESS;
> return status;
> @@ -296,12 +288,12 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
> case AP_RESPONSE_NORMAL:
> /* See if we did clear older IRQ configuration */
> vfio_ap_free_aqic_resources(q);
> - q->saved_pfn = g_pfn;
> + q->saved_iova = nib;
> q->saved_isc = isc;
> break;
> case AP_RESPONSE_OTHERWISE_CHANGED:
> /* We could not modify IRQ setings: clear new configuration */
> - vfio_unpin_pages(&q->matrix_mdev->vdev, g_pfn << PAGE_SHIFT, 1);
> + vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1);
> kvm_s390_gisc_unregister(kvm, isc);
> break;
> default:
> diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h
> index a26efd804d0d..479b205179bd 100644
> --- a/drivers/s390/crypto/vfio_ap_private.h
> +++ b/drivers/s390/crypto/vfio_ap_private.h
> @@ -102,13 +102,13 @@ struct ap_matrix_mdev {
> * struct vfio_ap_queue - contains the data associated with a queue bound to the
> * vfio_ap device driver
> * @matrix_mdev: the matrix mediated device
> - * @saved_pfn: the guest PFN pinned for the guest
> + * @saved_iova: the notification indicator byte (nib) address
> * @apqn: the APQN of the AP queue device
> * @saved_isc: the guest ISC registered with the GIB interface
> */
> struct vfio_ap_queue {
> struct ap_matrix_mdev *matrix_mdev;
> - unsigned long saved_pfn;
> + dma_addr_t saved_iova;
> int apqn;
> #define VFIO_AP_ISC_INVALID 0xff
> unsigned char saved_isc;
WARNING: multiple messages have this Message-ID (diff)
From: Anthony Krowiak <akrowiak@linux.ibm.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
kwankhede@nvidia.com, corbet@lwn.net, hca@linux.ibm.com,
gor@linux.ibm.com, agordeev@linux.ibm.com,
borntraeger@linux.ibm.com, svens@linux.ibm.com,
zhenyuw@linux.intel.com, zhi.a.wang@intel.com,
jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com,
airlied@linux.ie, daniel@ffwll.ch, farman@linux.ibm.com,
mjrosato@linux.ibm.com, pasic@linux.ibm.com,
vneethv@linux.ibm.com, oberpar@linux.ibm.com,
freude@linux.ibm.com, jjherne@linux.ibm.com,
alex.williamson@redhat.com, cohuck@redhat.com, jgg@nvidia.com,
kevin.tian@intel.com, hch@infradead.org
Cc: jchrist@linux.ibm.com, kvm@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-s390@vger.kernel.org, intel-gvt-dev@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
terrence.xu@intel.com
Subject: Re: [PATCH v3 06/10] vfio/ap: Change saved_pfn to saved_iova
Date: Tue, 12 Jul 2022 10:28:48 -0400 [thread overview]
Message-ID: <c1662fda-c87c-e204-dddd-e6159c8aa104@linux.ibm.com> (raw)
In-Reply-To: <20220708224427.1245-7-nicolinc@nvidia.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com>
On 7/8/22 6:44 PM, 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", change "saved_pfn"
> to "saved_iova" and remove pfn in the vfio_ap_validate_nib().
>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> Tested-by: Eric Farman <farman@linux.ibm.com>
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
> drivers/s390/crypto/vfio_ap_ops.c | 42 +++++++++++----------------
> drivers/s390/crypto/vfio_ap_private.h | 4 +--
> 2 files changed, 19 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 8a2018ab3cf0..e8856a7e151c 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -112,7 +112,7 @@ static void vfio_ap_wait_for_irqclear(int apqn)
> *
> * Unregisters the ISC in the GIB when the saved ISC not invalid.
> * Unpins the guest's page holding the NIB when it exists.
> - * Resets the saved_pfn and saved_isc to invalid values.
> + * Resets the saved_iova and saved_isc to invalid values.
> */
> static void vfio_ap_free_aqic_resources(struct vfio_ap_queue *q)
> {
> @@ -123,9 +123,9 @@ static void vfio_ap_free_aqic_resources(struct vfio_ap_queue *q)
> kvm_s390_gisc_unregister(q->matrix_mdev->kvm, q->saved_isc);
> q->saved_isc = VFIO_AP_ISC_INVALID;
> }
> - if (q->saved_pfn && !WARN_ON(!q->matrix_mdev)) {
> - vfio_unpin_pages(&q->matrix_mdev->vdev, q->saved_pfn << PAGE_SHIFT, 1);
> - q->saved_pfn = 0;
> + if (q->saved_iova && !WARN_ON(!q->matrix_mdev)) {
> + vfio_unpin_pages(&q->matrix_mdev->vdev, q->saved_iova, 1);
> + q->saved_iova = 0;
> }
> }
>
> @@ -189,27 +189,19 @@ static struct ap_queue_status vfio_ap_irq_disable(struct vfio_ap_queue *q)
> *
> * @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 validates 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;
>
> return 0;
> @@ -239,34 +231,34 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
> int isc,
> struct kvm_vcpu *vcpu)
> {
> - unsigned long nib;
> struct ap_qirq_ctrl aqic_gisa = {};
> struct ap_queue_status status = {};
> struct kvm_s390_gisa *gisa;
> int nisc;
> struct kvm *kvm;
> - unsigned long g_pfn, h_pfn;
> + unsigned long h_pfn;
> phys_addr_t h_nib;
> + dma_addr_t nib;
> int ret;
>
> /* Verify that the notification indicator byte address is valid */
> - if (vfio_ap_validate_nib(vcpu, &nib, &g_pfn)) {
> - VFIO_AP_DBF_WARN("%s: invalid NIB address: nib=%#lx, g_pfn=%#lx, apqn=%#04x\n",
> - __func__, nib, g_pfn, q->apqn);
> + if (vfio_ap_validate_nib(vcpu, &nib)) {
> + VFIO_AP_DBF_WARN("%s: invalid NIB address: nib=%pad, apqn=%#04x\n",
> + __func__, &nib, q->apqn);
>
> status.response_code = AP_RESPONSE_INVALID_ADDRESS;
> return status;
> }
>
> - ret = vfio_pin_pages(&q->matrix_mdev->vdev, g_pfn << PAGE_SHIFT, 1,
> + ret = vfio_pin_pages(&q->matrix_mdev->vdev, nib, 1,
> IOMMU_READ | IOMMU_WRITE, &h_pfn);
> switch (ret) {
> case 1:
> break;
> default:
> VFIO_AP_DBF_WARN("%s: vfio_pin_pages failed: rc=%d,"
> - "nib=%#lx, g_pfn=%#lx, apqn=%#04x\n",
> - __func__, ret, nib, g_pfn, q->apqn);
> + "nib=%pad, apqn=%#04x\n",
> + __func__, ret, &nib, q->apqn);
>
> status.response_code = AP_RESPONSE_INVALID_ADDRESS;
> return status;
> @@ -296,12 +288,12 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
> case AP_RESPONSE_NORMAL:
> /* See if we did clear older IRQ configuration */
> vfio_ap_free_aqic_resources(q);
> - q->saved_pfn = g_pfn;
> + q->saved_iova = nib;
> q->saved_isc = isc;
> break;
> case AP_RESPONSE_OTHERWISE_CHANGED:
> /* We could not modify IRQ setings: clear new configuration */
> - vfio_unpin_pages(&q->matrix_mdev->vdev, g_pfn << PAGE_SHIFT, 1);
> + vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1);
> kvm_s390_gisc_unregister(kvm, isc);
> break;
> default:
> diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h
> index a26efd804d0d..479b205179bd 100644
> --- a/drivers/s390/crypto/vfio_ap_private.h
> +++ b/drivers/s390/crypto/vfio_ap_private.h
> @@ -102,13 +102,13 @@ struct ap_matrix_mdev {
> * struct vfio_ap_queue - contains the data associated with a queue bound to the
> * vfio_ap device driver
> * @matrix_mdev: the matrix mediated device
> - * @saved_pfn: the guest PFN pinned for the guest
> + * @saved_iova: the notification indicator byte (nib) address
> * @apqn: the APQN of the AP queue device
> * @saved_isc: the guest ISC registered with the GIB interface
> */
> struct vfio_ap_queue {
> struct ap_matrix_mdev *matrix_mdev;
> - unsigned long saved_pfn;
> + dma_addr_t saved_iova;
> int apqn;
> #define VFIO_AP_ISC_INVALID 0xff
> unsigned char saved_isc;
WARNING: multiple messages have this Message-ID (diff)
From: Anthony Krowiak <akrowiak@linux.ibm.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
kwankhede@nvidia.com, corbet@lwn.net, hca@linux.ibm.com,
gor@linux.ibm.com, agordeev@linux.ibm.com,
borntraeger@linux.ibm.com, svens@linux.ibm.com,
zhenyuw@linux.intel.com, zhi.a.wang@intel.com,
jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com,
airlied@linux.ie, daniel@ffwll.ch, farman@linux.ibm.com,
mjrosato@linux.ibm.com, pasic@linux.ibm.com,
vneethv@linux.ibm.com, oberpar@linux.ibm.com,
freude@linux.ibm.com, jjherne@linux.ibm.com,
alex.williamson@redhat.com, cohuck@redhat.com, jgg@nvidia.com,
kevin.tian@intel.com, hch@infradead.org
Cc: linux-s390@vger.kernel.org, kvm@vger.kernel.org,
linux-doc@vger.kernel.org, intel-gfx@lists.freedesktop.org,
jchrist@linux.ibm.com, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org,
intel-gvt-dev@lists.freedesktop.org
Subject: Re: [PATCH v3 06/10] vfio/ap: Change saved_pfn to saved_iova
Date: Tue, 12 Jul 2022 10:28:48 -0400 [thread overview]
Message-ID: <c1662fda-c87c-e204-dddd-e6159c8aa104@linux.ibm.com> (raw)
In-Reply-To: <20220708224427.1245-7-nicolinc@nvidia.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com>
On 7/8/22 6:44 PM, 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", change "saved_pfn"
> to "saved_iova" and remove pfn in the vfio_ap_validate_nib().
>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> Tested-by: Eric Farman <farman@linux.ibm.com>
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
> drivers/s390/crypto/vfio_ap_ops.c | 42 +++++++++++----------------
> drivers/s390/crypto/vfio_ap_private.h | 4 +--
> 2 files changed, 19 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 8a2018ab3cf0..e8856a7e151c 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -112,7 +112,7 @@ static void vfio_ap_wait_for_irqclear(int apqn)
> *
> * Unregisters the ISC in the GIB when the saved ISC not invalid.
> * Unpins the guest's page holding the NIB when it exists.
> - * Resets the saved_pfn and saved_isc to invalid values.
> + * Resets the saved_iova and saved_isc to invalid values.
> */
> static void vfio_ap_free_aqic_resources(struct vfio_ap_queue *q)
> {
> @@ -123,9 +123,9 @@ static void vfio_ap_free_aqic_resources(struct vfio_ap_queue *q)
> kvm_s390_gisc_unregister(q->matrix_mdev->kvm, q->saved_isc);
> q->saved_isc = VFIO_AP_ISC_INVALID;
> }
> - if (q->saved_pfn && !WARN_ON(!q->matrix_mdev)) {
> - vfio_unpin_pages(&q->matrix_mdev->vdev, q->saved_pfn << PAGE_SHIFT, 1);
> - q->saved_pfn = 0;
> + if (q->saved_iova && !WARN_ON(!q->matrix_mdev)) {
> + vfio_unpin_pages(&q->matrix_mdev->vdev, q->saved_iova, 1);
> + q->saved_iova = 0;
> }
> }
>
> @@ -189,27 +189,19 @@ static struct ap_queue_status vfio_ap_irq_disable(struct vfio_ap_queue *q)
> *
> * @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 validates 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;
>
> return 0;
> @@ -239,34 +231,34 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
> int isc,
> struct kvm_vcpu *vcpu)
> {
> - unsigned long nib;
> struct ap_qirq_ctrl aqic_gisa = {};
> struct ap_queue_status status = {};
> struct kvm_s390_gisa *gisa;
> int nisc;
> struct kvm *kvm;
> - unsigned long g_pfn, h_pfn;
> + unsigned long h_pfn;
> phys_addr_t h_nib;
> + dma_addr_t nib;
> int ret;
>
> /* Verify that the notification indicator byte address is valid */
> - if (vfio_ap_validate_nib(vcpu, &nib, &g_pfn)) {
> - VFIO_AP_DBF_WARN("%s: invalid NIB address: nib=%#lx, g_pfn=%#lx, apqn=%#04x\n",
> - __func__, nib, g_pfn, q->apqn);
> + if (vfio_ap_validate_nib(vcpu, &nib)) {
> + VFIO_AP_DBF_WARN("%s: invalid NIB address: nib=%pad, apqn=%#04x\n",
> + __func__, &nib, q->apqn);
>
> status.response_code = AP_RESPONSE_INVALID_ADDRESS;
> return status;
> }
>
> - ret = vfio_pin_pages(&q->matrix_mdev->vdev, g_pfn << PAGE_SHIFT, 1,
> + ret = vfio_pin_pages(&q->matrix_mdev->vdev, nib, 1,
> IOMMU_READ | IOMMU_WRITE, &h_pfn);
> switch (ret) {
> case 1:
> break;
> default:
> VFIO_AP_DBF_WARN("%s: vfio_pin_pages failed: rc=%d,"
> - "nib=%#lx, g_pfn=%#lx, apqn=%#04x\n",
> - __func__, ret, nib, g_pfn, q->apqn);
> + "nib=%pad, apqn=%#04x\n",
> + __func__, ret, &nib, q->apqn);
>
> status.response_code = AP_RESPONSE_INVALID_ADDRESS;
> return status;
> @@ -296,12 +288,12 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
> case AP_RESPONSE_NORMAL:
> /* See if we did clear older IRQ configuration */
> vfio_ap_free_aqic_resources(q);
> - q->saved_pfn = g_pfn;
> + q->saved_iova = nib;
> q->saved_isc = isc;
> break;
> case AP_RESPONSE_OTHERWISE_CHANGED:
> /* We could not modify IRQ setings: clear new configuration */
> - vfio_unpin_pages(&q->matrix_mdev->vdev, g_pfn << PAGE_SHIFT, 1);
> + vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1);
> kvm_s390_gisc_unregister(kvm, isc);
> break;
> default:
> diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h
> index a26efd804d0d..479b205179bd 100644
> --- a/drivers/s390/crypto/vfio_ap_private.h
> +++ b/drivers/s390/crypto/vfio_ap_private.h
> @@ -102,13 +102,13 @@ struct ap_matrix_mdev {
> * struct vfio_ap_queue - contains the data associated with a queue bound to the
> * vfio_ap device driver
> * @matrix_mdev: the matrix mediated device
> - * @saved_pfn: the guest PFN pinned for the guest
> + * @saved_iova: the notification indicator byte (nib) address
> * @apqn: the APQN of the AP queue device
> * @saved_isc: the guest ISC registered with the GIB interface
> */
> struct vfio_ap_queue {
> struct ap_matrix_mdev *matrix_mdev;
> - unsigned long saved_pfn;
> + dma_addr_t saved_iova;
> int apqn;
> #define VFIO_AP_ISC_INVALID 0xff
> unsigned char saved_isc;
next prev parent reply other threads:[~2022-07-20 14:07 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 22:44 [PATCH v3 00/10] Update vfio_pin/unpin_pages API Nicolin Chen
2022-07-08 22:44 ` Nicolin Chen
2022-07-08 22:44 ` [PATCH v3 01/10] vfio: Make vfio_unpin_pages() return void Nicolin Chen
2022-07-08 22:44 ` Nicolin Chen
2022-07-12 14:21 ` [Intel-gfx] " Anthony Krowiak
2022-07-12 14:21 ` Anthony Krowiak
2022-07-12 14:21 ` Anthony Krowiak
2022-07-12 18:18 ` Nicolin Chen
2022-07-12 18:18 ` Nicolin Chen
2022-07-08 22:44 ` [PATCH v3 02/10] drm/i915/gvt: Replace roundup with DIV_ROUND_UP Nicolin Chen
2022-07-08 22:44 ` Nicolin Chen
2022-07-08 22:44 ` [PATCH v3 03/10] vfio/ap: Pass in physical address of ind to ap_aqic() Nicolin Chen
2022-07-08 22:44 ` Nicolin Chen
2022-07-08 22:44 ` [PATCH v3 04/10] vfio/ccw: Only pass in contiguous pages Nicolin Chen
2022-07-08 22:44 ` Nicolin Chen
2022-07-08 22:44 ` [PATCH v3 05/10] vfio: Pass in starting IOVA to vfio_pin/unpin_pages API Nicolin Chen
2022-07-08 22:44 ` Nicolin Chen
2022-07-12 14:25 ` [Intel-gfx] " Anthony Krowiak
2022-07-12 14:25 ` Anthony Krowiak
2022-07-12 14:25 ` Anthony Krowiak
2022-07-08 22:44 ` [PATCH v3 06/10] vfio/ap: Change saved_pfn to saved_iova Nicolin Chen
2022-07-08 22:44 ` Nicolin Chen
2022-07-12 14:28 ` Anthony Krowiak [this message]
2022-07-12 14:28 ` Anthony Krowiak
2022-07-12 14:28 ` Anthony Krowiak
2022-07-08 22:44 ` [PATCH v3 07/10] vfio/ccw: Change pa_pfn list to pa_iova list Nicolin Chen
2022-07-08 22:44 ` Nicolin Chen
2022-07-08 22:44 ` [PATCH v3 08/10] vfio: Rename user_iova of vfio_dma_rw() Nicolin Chen
2022-07-08 22:44 ` Nicolin Chen
2022-07-08 22:44 ` [PATCH v3 09/10] vfio/ccw: Add kmap_local_page() for memcpy Nicolin Chen
2022-07-08 22:44 ` Nicolin Chen
2022-07-22 22:11 ` [Intel-gfx] [PATCH v3 00/10] Update vfio_pin/unpin_pages API Alex Williamson
2022-07-22 22:11 ` Alex Williamson
2022-07-22 22:11 ` Alex Williamson
2022-07-22 23:12 ` [Intel-gfx] " Nicolin Chen
2022-07-22 23:12 ` Nicolin Chen
2022-07-22 23:12 ` Nicolin Chen
2022-07-23 0:18 ` [Intel-gfx] " Alex Williamson
2022-07-23 0:18 ` Alex Williamson
2022-07-23 0:18 ` Alex Williamson
2022-07-23 0:38 ` [Intel-gfx] " Nicolin Chen
2022-07-23 0:38 ` Nicolin Chen
2022-07-23 0:38 ` Nicolin Chen
2022-07-23 1:09 ` [Intel-gfx] " Alex Williamson
2022-07-23 1:09 ` Alex Williamson
2022-07-23 1:09 ` Alex Williamson
2022-07-23 2:10 ` [Intel-gfx] " Nicolin Chen
2022-07-23 2:10 ` Nicolin Chen
2022-07-23 2:10 ` Nicolin Chen
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=c1662fda-c87c-e204-dddd-e6159c8aa104@linux.ibm.com \
--to=akrowiak@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=airlied@linux.ie \
--cc=alex.williamson@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=corbet@lwn.net \
--cc=daniel@ffwll.ch \
--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=jani.nikula@linux.intel.com \
--cc=jchrist@linux.ibm.com \
--cc=jgg@nvidia.com \
--cc=jjherne@linux.ibm.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kevin.tian@intel.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=terrence.xu@intel.com \
--cc=tvrtko.ursulin@linux.intel.com \
--cc=vneethv@linux.ibm.com \
--cc=zhenyuw@linux.intel.com \
--cc=zhi.a.wang@intel.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 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.