@@ -112,7 +112,7 @@ static void vfio_ap_wait_for_irqclear(int apqn)
112112 *
113113 * Unregisters the ISC in the GIB when the saved ISC not invalid.
114114 * Unpins the guest's page holding the NIB when it exists.
115- * Resets the saved_pfn and saved_isc to invalid values.
115+ * Resets the saved_iova and saved_isc to invalid values.
116116 */
117117static void vfio_ap_free_aqic_resources (struct vfio_ap_queue * q )
118118{
@@ -123,9 +123,9 @@ static void vfio_ap_free_aqic_resources(struct vfio_ap_queue *q)
123123 kvm_s390_gisc_unregister (q -> matrix_mdev -> kvm , q -> saved_isc );
124124 q -> saved_isc = VFIO_AP_ISC_INVALID ;
125125 }
126- if (q -> saved_pfn && !WARN_ON (!q -> matrix_mdev )) {
127- vfio_unpin_pages (& q -> matrix_mdev -> vdev , q -> saved_pfn << PAGE_SHIFT , 1 );
128- q -> saved_pfn = 0 ;
126+ if (q -> saved_iova && !WARN_ON (!q -> matrix_mdev )) {
127+ vfio_unpin_pages (& q -> matrix_mdev -> vdev , q -> saved_iova , 1 );
128+ q -> saved_iova = 0 ;
129129 }
130130}
131131
@@ -189,27 +189,19 @@ static struct ap_queue_status vfio_ap_irq_disable(struct vfio_ap_queue *q)
189189 *
190190 * @vcpu: the object representing the vcpu executing the PQAP(AQIC) instruction.
191191 * @nib: the location for storing the nib address.
192- * @g_pfn: the location for storing the page frame number of the page containing
193- * the nib.
194192 *
195193 * When the PQAP(AQIC) instruction is executed, general register 2 contains the
196194 * address of the notification indicator byte (nib) used for IRQ notification.
197- * This function parses the nib from gr2 and calculates the page frame
198- * number for the guest of the page containing the nib. The values are
199- * stored in @nib and @g_pfn respectively.
200- *
201- * The g_pfn of the nib is then validated to ensure the nib address is valid.
195+ * This function parses and validates the nib from gr2.
202196 *
203197 * Return: returns zero if the nib address is a valid; otherwise, returns
204198 * -EINVAL.
205199 */
206- static int vfio_ap_validate_nib (struct kvm_vcpu * vcpu , unsigned long * nib ,
207- unsigned long * g_pfn )
200+ static int vfio_ap_validate_nib (struct kvm_vcpu * vcpu , dma_addr_t * nib )
208201{
209202 * nib = vcpu -> run -> s .regs .gprs [2 ];
210- * g_pfn = * nib >> PAGE_SHIFT ;
211203
212- if (kvm_is_error_hva (gfn_to_hva (vcpu -> kvm , * g_pfn )))
204+ if (kvm_is_error_hva (gfn_to_hva (vcpu -> kvm , * nib >> PAGE_SHIFT )))
213205 return - EINVAL ;
214206
215207 return 0 ;
@@ -239,34 +231,34 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
239231 int isc ,
240232 struct kvm_vcpu * vcpu )
241233{
242- unsigned long nib ;
243234 struct ap_qirq_ctrl aqic_gisa = {};
244235 struct ap_queue_status status = {};
245236 struct kvm_s390_gisa * gisa ;
246237 int nisc ;
247238 struct kvm * kvm ;
248- unsigned long g_pfn , h_pfn ;
239+ unsigned long h_pfn ;
249240 phys_addr_t h_nib ;
241+ dma_addr_t nib ;
250242 int ret ;
251243
252244 /* Verify that the notification indicator byte address is valid */
253- if (vfio_ap_validate_nib (vcpu , & nib , & g_pfn )) {
254- VFIO_AP_DBF_WARN ("%s: invalid NIB address: nib=%#lx, g_pfn=%#lx , apqn=%#04x\n" ,
255- __func__ , nib , g_pfn , q -> apqn );
245+ if (vfio_ap_validate_nib (vcpu , & nib )) {
246+ VFIO_AP_DBF_WARN ("%s: invalid NIB address: nib=%pad , apqn=%#04x\n" ,
247+ __func__ , & nib , q -> apqn );
256248
257249 status .response_code = AP_RESPONSE_INVALID_ADDRESS ;
258250 return status ;
259251 }
260252
261- ret = vfio_pin_pages (& q -> matrix_mdev -> vdev , g_pfn << PAGE_SHIFT , 1 ,
253+ ret = vfio_pin_pages (& q -> matrix_mdev -> vdev , nib , 1 ,
262254 IOMMU_READ | IOMMU_WRITE , & h_pfn );
263255 switch (ret ) {
264256 case 1 :
265257 break ;
266258 default :
267259 VFIO_AP_DBF_WARN ("%s: vfio_pin_pages failed: rc=%d,"
268- "nib=%#lx, g_pfn=%#lx , apqn=%#04x\n" ,
269- __func__ , ret , nib , g_pfn , q -> apqn );
260+ "nib=%pad , apqn=%#04x\n" ,
261+ __func__ , ret , & nib , q -> apqn );
270262
271263 status .response_code = AP_RESPONSE_INVALID_ADDRESS ;
272264 return status ;
@@ -296,12 +288,12 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
296288 case AP_RESPONSE_NORMAL :
297289 /* See if we did clear older IRQ configuration */
298290 vfio_ap_free_aqic_resources (q );
299- q -> saved_pfn = g_pfn ;
291+ q -> saved_iova = nib ;
300292 q -> saved_isc = isc ;
301293 break ;
302294 case AP_RESPONSE_OTHERWISE_CHANGED :
303295 /* We could not modify IRQ setings: clear new configuration */
304- vfio_unpin_pages (& q -> matrix_mdev -> vdev , g_pfn << PAGE_SHIFT , 1 );
296+ vfio_unpin_pages (& q -> matrix_mdev -> vdev , nib , 1 );
305297 kvm_s390_gisc_unregister (kvm , isc );
306298 break ;
307299 default :
0 commit comments