]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/ap: Use all-bits-one apmask/aqmask for vfio in_use() checks
authorHarald Freudenberger <freude@linux.ibm.com>
Wed, 19 Nov 2025 15:27:35 +0000 (16:27 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 24 Nov 2025 10:43:05 +0000 (11:43 +0100)
For the in_use() check of an updated apmask the host's aqmask
was provided to the vfio function. Similar on an update of the
aqmask the host's apmask was provided to the vfio in_use()
function. This led to false results on the check for apmask or
aqmask updates. For example with only one APQN when exactly
this card is tried to be re-assigned back to the host, the
in_use() check did not complain.

The correct behavior is achieved with providing a full mask
for aqmask when an adapter is to be checked and similar a full
mask for aqmask when a domain is to be checked for usage.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
drivers/s390/crypto/ap_bus.c

index 82f4ac97fe976108ef69c89c32dcc3cd9e1ebea3..cea7399456c657bc278ed09934483be4bb2c7df4 100644 (file)
@@ -1452,6 +1452,7 @@ static int __verify_card_reservations(struct device_driver *drv, void *data)
        int rc = 0;
        struct ap_driver *ap_drv = to_ap_drv(drv);
        unsigned long *newapm = (unsigned long *)data;
+       unsigned long aqm_any[BITS_TO_LONGS(AP_DOMAINS)];
 
        /*
         * increase the driver's module refcounter to be sure it is not
@@ -1461,7 +1462,8 @@ static int __verify_card_reservations(struct device_driver *drv, void *data)
                return 0;
 
        if (ap_drv->in_use) {
-               rc = ap_drv->in_use(newapm, ap_perms.aqm);
+               bitmap_fill(aqm_any, AP_DOMAINS);
+               rc = ap_drv->in_use(newapm, aqm_any);
                if (rc)
                        rc = -EBUSY;
        }
@@ -1544,6 +1546,7 @@ static int __verify_queue_reservations(struct device_driver *drv, void *data)
        int rc = 0;
        struct ap_driver *ap_drv = to_ap_drv(drv);
        unsigned long *newaqm = (unsigned long *)data;
+       unsigned long apm_any[BITS_TO_LONGS(AP_DEVICES)];
 
        /*
         * increase the driver's module refcounter to be sure it is not
@@ -1553,7 +1556,8 @@ static int __verify_queue_reservations(struct device_driver *drv, void *data)
                return 0;
 
        if (ap_drv->in_use) {
-               rc = ap_drv->in_use(ap_perms.apm, newaqm);
+               bitmap_fill(apm_any, AP_DEVICES);
+               rc = ap_drv->in_use(apm_any, newaqm);
                if (rc)
                        rc = -EBUSY;
        }