Skip to content

Commit b9bd10c

Browse files
Tony KrowiakAlexander Gordeev
authored andcommitted
s390/vfio-ap: do not reset queue removed from host config
When a queue is unbound from the vfio_ap device driver, it is reset to ensure its crypto data is not leaked when it is bound to another device driver. If the queue is unbound due to the fact that the adapter or domain was removed from the host's AP configuration, then attempting to reset it will fail with response code 01 (APID not valid) getting returned from the reset command. Let's ensure that the queue is assigned to the host's configuration before resetting it. Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com> Reviewed-by: "Jason J. Herne" <jjherne@linux.ibm.com> Reviewed-by: Halil Pasic <pasic@linux.ibm.com> Fixes: eeb386a ("s390/vfio-ap: handle config changed and scan complete notification") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20240115185441.31526-7-akrowiak@linux.ibm.com Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent f009cfa commit b9bd10c

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

drivers/s390/crypto/vfio_ap_ops.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,10 +2215,10 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev)
22152215
q = dev_get_drvdata(&apdev->device);
22162216
get_update_locks_for_queue(q);
22172217
matrix_mdev = q->matrix_mdev;
2218+
apid = AP_QID_CARD(q->apqn);
2219+
apqi = AP_QID_QUEUE(q->apqn);
22182220

22192221
if (matrix_mdev) {
2220-
apid = AP_QID_CARD(q->apqn);
2221-
apqi = AP_QID_QUEUE(q->apqn);
22222222
/* If the queue is assigned to the guest's AP configuration */
22232223
if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) &&
22242224
test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) {
@@ -2234,8 +2234,16 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev)
22342234
}
22352235
}
22362236

2237-
vfio_ap_mdev_reset_queue(q);
2238-
flush_work(&q->reset_work);
2237+
/*
2238+
* If the queue is not in the host's AP configuration, then resetting
2239+
* it will fail with response code 01, (APQN not valid); so, let's make
2240+
* sure it is in the host's config.
2241+
*/
2242+
if (test_bit_inv(apid, (unsigned long *)matrix_dev->info.apm) &&
2243+
test_bit_inv(apqi, (unsigned long *)matrix_dev->info.aqm)) {
2244+
vfio_ap_mdev_reset_queue(q);
2245+
flush_work(&q->reset_work);
2246+
}
22392247

22402248
done:
22412249
if (matrix_mdev)

0 commit comments

Comments
 (0)