@@ -984,6 +984,11 @@ static ssize_t assign_adapter_store(struct device *dev,
984
984
goto done ;
985
985
}
986
986
987
+ if (test_bit_inv (apid , matrix_mdev -> matrix .apm )) {
988
+ ret = count ;
989
+ goto done ;
990
+ }
991
+
987
992
set_bit_inv (apid , matrix_mdev -> matrix .apm );
988
993
989
994
ret = vfio_ap_mdev_validate_masks (matrix_mdev );
@@ -1109,6 +1114,11 @@ static ssize_t unassign_adapter_store(struct device *dev,
1109
1114
goto done ;
1110
1115
}
1111
1116
1117
+ if (!test_bit_inv (apid , matrix_mdev -> matrix .apm )) {
1118
+ ret = count ;
1119
+ goto done ;
1120
+ }
1121
+
1112
1122
clear_bit_inv ((unsigned long )apid , matrix_mdev -> matrix .apm );
1113
1123
vfio_ap_mdev_hot_unplug_adapter (matrix_mdev , apid );
1114
1124
ret = count ;
@@ -1183,6 +1193,11 @@ static ssize_t assign_domain_store(struct device *dev,
1183
1193
goto done ;
1184
1194
}
1185
1195
1196
+ if (test_bit_inv (apqi , matrix_mdev -> matrix .aqm )) {
1197
+ ret = count ;
1198
+ goto done ;
1199
+ }
1200
+
1186
1201
set_bit_inv (apqi , matrix_mdev -> matrix .aqm );
1187
1202
1188
1203
ret = vfio_ap_mdev_validate_masks (matrix_mdev );
@@ -1286,6 +1301,11 @@ static ssize_t unassign_domain_store(struct device *dev,
1286
1301
goto done ;
1287
1302
}
1288
1303
1304
+ if (!test_bit_inv (apqi , matrix_mdev -> matrix .aqm )) {
1305
+ ret = count ;
1306
+ goto done ;
1307
+ }
1308
+
1289
1309
clear_bit_inv ((unsigned long )apqi , matrix_mdev -> matrix .aqm );
1290
1310
vfio_ap_mdev_hot_unplug_domain (matrix_mdev , apqi );
1291
1311
ret = count ;
@@ -1329,6 +1349,11 @@ static ssize_t assign_control_domain_store(struct device *dev,
1329
1349
goto done ;
1330
1350
}
1331
1351
1352
+ if (test_bit_inv (id , matrix_mdev -> matrix .adm )) {
1353
+ ret = count ;
1354
+ goto done ;
1355
+ }
1356
+
1332
1357
/* Set the bit in the ADM (bitmask) corresponding to the AP control
1333
1358
* domain number (id). The bits in the mask, from most significant to
1334
1359
* least significant, correspond to IDs 0 up to the one less than the
@@ -1378,6 +1403,11 @@ static ssize_t unassign_control_domain_store(struct device *dev,
1378
1403
goto done ;
1379
1404
}
1380
1405
1406
+ if (!test_bit_inv (domid , matrix_mdev -> matrix .adm )) {
1407
+ ret = count ;
1408
+ goto done ;
1409
+ }
1410
+
1381
1411
clear_bit_inv (domid , matrix_mdev -> matrix .adm );
1382
1412
1383
1413
if (test_bit_inv (domid , matrix_mdev -> shadow_apcb .adm )) {
0 commit comments