@@ -112,7 +112,7 @@ static void vfio_ap_wait_for_irqclear(int apqn)
112
112
*
113
113
* Unregisters the ISC in the GIB when the saved ISC not invalid.
114
114
* 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.
116
116
*/
117
117
static void vfio_ap_free_aqic_resources (struct vfio_ap_queue * q )
118
118
{
@@ -123,9 +123,9 @@ static void vfio_ap_free_aqic_resources(struct vfio_ap_queue *q)
123
123
kvm_s390_gisc_unregister (q -> matrix_mdev -> kvm , q -> saved_isc );
124
124
q -> saved_isc = VFIO_AP_ISC_INVALID ;
125
125
}
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 ;
129
129
}
130
130
}
131
131
@@ -189,27 +189,19 @@ static struct ap_queue_status vfio_ap_irq_disable(struct vfio_ap_queue *q)
189
189
*
190
190
* @vcpu: the object representing the vcpu executing the PQAP(AQIC) instruction.
191
191
* @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.
194
192
*
195
193
* When the PQAP(AQIC) instruction is executed, general register 2 contains the
196
194
* 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.
202
196
*
203
197
* Return: returns zero if the nib address is a valid; otherwise, returns
204
198
* -EINVAL.
205
199
*/
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 )
208
201
{
209
202
* nib = vcpu -> run -> s .regs .gprs [2 ];
210
- * g_pfn = * nib >> PAGE_SHIFT ;
211
203
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 )))
213
205
return - EINVAL ;
214
206
215
207
return 0 ;
@@ -239,34 +231,34 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
239
231
int isc ,
240
232
struct kvm_vcpu * vcpu )
241
233
{
242
- unsigned long nib ;
243
234
struct ap_qirq_ctrl aqic_gisa = {};
244
235
struct ap_queue_status status = {};
245
236
struct kvm_s390_gisa * gisa ;
246
237
int nisc ;
247
238
struct kvm * kvm ;
248
- unsigned long g_pfn , h_pfn ;
239
+ unsigned long h_pfn ;
249
240
phys_addr_t h_nib ;
241
+ dma_addr_t nib ;
250
242
int ret ;
251
243
252
244
/* 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 );
256
248
257
249
status .response_code = AP_RESPONSE_INVALID_ADDRESS ;
258
250
return status ;
259
251
}
260
252
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 ,
262
254
IOMMU_READ | IOMMU_WRITE , & h_pfn );
263
255
switch (ret ) {
264
256
case 1 :
265
257
break ;
266
258
default :
267
259
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 );
270
262
271
263
status .response_code = AP_RESPONSE_INVALID_ADDRESS ;
272
264
return status ;
@@ -296,12 +288,12 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
296
288
case AP_RESPONSE_NORMAL :
297
289
/* See if we did clear older IRQ configuration */
298
290
vfio_ap_free_aqic_resources (q );
299
- q -> saved_pfn = g_pfn ;
291
+ q -> saved_iova = nib ;
300
292
q -> saved_isc = isc ;
301
293
break ;
302
294
case AP_RESPONSE_OTHERWISE_CHANGED :
303
295
/* 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 );
305
297
kvm_s390_gisc_unregister (kvm , isc );
306
298
break ;
307
299
default :
0 commit comments