Skip to content

Commit

Permalink
Merge tag 's390-6.0-5' of git://git.kernel.org/pub/scm/linux/kernel/g…
Browse files Browse the repository at this point in the history
…it/s390/linux

Pull s390 fix from Vasily Gorbik:

 - Fix potential hangs in VFIO AP driver

* tag 's390-6.0-5' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
  s390/vfio-ap: bypass unnecessary processing of AP resources
  • Loading branch information
Linus Torvalds committed Sep 25, 2022
2 parents 42f9508 + 1918f2b commit 23b9923
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions drivers/s390/crypto/vfio_ap_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,11 @@ static ssize_t assign_adapter_store(struct device *dev,
goto done;
}

if (test_bit_inv(apid, matrix_mdev->matrix.apm)) {
ret = count;
goto done;
}

set_bit_inv(apid, matrix_mdev->matrix.apm);

ret = vfio_ap_mdev_validate_masks(matrix_mdev);
Expand Down Expand Up @@ -1109,6 +1114,11 @@ static ssize_t unassign_adapter_store(struct device *dev,
goto done;
}

if (!test_bit_inv(apid, matrix_mdev->matrix.apm)) {
ret = count;
goto done;
}

clear_bit_inv((unsigned long)apid, matrix_mdev->matrix.apm);
vfio_ap_mdev_hot_unplug_adapter(matrix_mdev, apid);
ret = count;
Expand Down Expand Up @@ -1183,6 +1193,11 @@ static ssize_t assign_domain_store(struct device *dev,
goto done;
}

if (test_bit_inv(apqi, matrix_mdev->matrix.aqm)) {
ret = count;
goto done;
}

set_bit_inv(apqi, matrix_mdev->matrix.aqm);

ret = vfio_ap_mdev_validate_masks(matrix_mdev);
Expand Down Expand Up @@ -1286,6 +1301,11 @@ static ssize_t unassign_domain_store(struct device *dev,
goto done;
}

if (!test_bit_inv(apqi, matrix_mdev->matrix.aqm)) {
ret = count;
goto done;
}

clear_bit_inv((unsigned long)apqi, matrix_mdev->matrix.aqm);
vfio_ap_mdev_hot_unplug_domain(matrix_mdev, apqi);
ret = count;
Expand Down Expand Up @@ -1329,6 +1349,11 @@ static ssize_t assign_control_domain_store(struct device *dev,
goto done;
}

if (test_bit_inv(id, matrix_mdev->matrix.adm)) {
ret = count;
goto done;
}

/* Set the bit in the ADM (bitmask) corresponding to the AP control
* domain number (id). The bits in the mask, from most significant to
* least significant, correspond to IDs 0 up to the one less than the
Expand Down Expand Up @@ -1378,6 +1403,11 @@ static ssize_t unassign_control_domain_store(struct device *dev,
goto done;
}

if (!test_bit_inv(domid, matrix_mdev->matrix.adm)) {
ret = count;
goto done;
}

clear_bit_inv(domid, matrix_mdev->matrix.adm);

if (test_bit_inv(domid, matrix_mdev->shadow_apcb.adm)) {
Expand Down

0 comments on commit 23b9923

Please sign in to comment.