s390/zcrypt: don't report online if card or queue is in check-stop state
authorIngo Franzki <ifranzki@linux.ibm.com>
Thu, 26 Oct 2023 09:24:03 +0000 (11:24 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Sun, 5 Nov 2023 21:34:57 +0000 (22:34 +0100)
If a card or a queue is in check-stop state, it can't be used by
applications to perform crypto operations. Applications check the 'online'
sysfs attribute to check if a card or queue is usable.

Report a card or queue as offline in case it is in check-stop state.
Furthermore, don't allow to set a card or queue online, if it is in
check-stop state.

This is similar to when the card or the queue is in deconfigured state,
there it is also reported as being offline, and it can't be set online.

Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/crypto/zcrypt_card.c
drivers/s390/crypto/zcrypt_queue.c

index c815722d0ac87ea1eebdb50b52db00b7fb26980c..050462d952224455860f4274b8d3e12ba602cba6 100644 (file)
@@ -52,7 +52,7 @@ static ssize_t online_show(struct device *dev,
 {
        struct zcrypt_card *zc = dev_get_drvdata(dev);
        struct ap_card *ac = to_ap_card(dev);
-       int online = ac->config && zc->online ? 1 : 0;
+       int online = ac->config && !ac->chkstop && zc->online ? 1 : 0;
 
        return sysfs_emit(buf, "%d\n", online);
 }
@@ -70,7 +70,7 @@ static ssize_t online_store(struct device *dev,
        if (sscanf(buf, "%d\n", &online) != 1 || online < 0 || online > 1)
                return -EINVAL;
 
-       if (online && !ac->config)
+       if (online && (!ac->config || ac->chkstop))
                return -ENODEV;
 
        zc->online = online;
index 112a80e8e6c2c394ae88f300a5fde6364b5390bd..67d8e0ae0eec5e867b6c7261634df5af993fb7b9 100644 (file)
@@ -42,7 +42,7 @@ static ssize_t online_show(struct device *dev,
 {
        struct zcrypt_queue *zq = dev_get_drvdata(dev);
        struct ap_queue *aq = to_ap_queue(dev);
-       int online = aq->config && zq->online ? 1 : 0;
+       int online = aq->config && !aq->chkstop && zq->online ? 1 : 0;
 
        return sysfs_emit(buf, "%d\n", online);
 }
@@ -59,7 +59,8 @@ static ssize_t online_store(struct device *dev,
        if (sscanf(buf, "%d\n", &online) != 1 || online < 0 || online > 1)
                return -EINVAL;
 
-       if (online && (!aq->config || !aq->card->config))
+       if (online && (!aq->config || !aq->card->config ||
+                      aq->chkstop || aq->card->chkstop))
                return -ENODEV;
        if (online && !zc->online)
                return -EINVAL;