Skip to content

Commit cfaef65

Browse files
ifranzkiVasily Gorbik
authored andcommitted
s390/zcrypt: don't report online if card or queue is in check-stop state
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>
1 parent aa44433 commit cfaef65

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/s390/crypto/zcrypt_card.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static ssize_t online_show(struct device *dev,
5252
{
5353
struct zcrypt_card *zc = dev_get_drvdata(dev);
5454
struct ap_card *ac = to_ap_card(dev);
55-
int online = ac->config && zc->online ? 1 : 0;
55+
int online = ac->config && !ac->chkstop && zc->online ? 1 : 0;
5656

5757
return sysfs_emit(buf, "%d\n", online);
5858
}
@@ -70,7 +70,7 @@ static ssize_t online_store(struct device *dev,
7070
if (sscanf(buf, "%d\n", &online) != 1 || online < 0 || online > 1)
7171
return -EINVAL;
7272

73-
if (online && !ac->config)
73+
if (online && (!ac->config || ac->chkstop))
7474
return -ENODEV;
7575

7676
zc->online = online;

drivers/s390/crypto/zcrypt_queue.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static ssize_t online_show(struct device *dev,
4242
{
4343
struct zcrypt_queue *zq = dev_get_drvdata(dev);
4444
struct ap_queue *aq = to_ap_queue(dev);
45-
int online = aq->config && zq->online ? 1 : 0;
45+
int online = aq->config && !aq->chkstop && zq->online ? 1 : 0;
4646

4747
return sysfs_emit(buf, "%d\n", online);
4848
}
@@ -59,7 +59,8 @@ static ssize_t online_store(struct device *dev,
5959
if (sscanf(buf, "%d\n", &online) != 1 || online < 0 || online > 1)
6060
return -EINVAL;
6161

62-
if (online && (!aq->config || !aq->card->config))
62+
if (online && (!aq->config || !aq->card->config ||
63+
aq->chkstop || aq->card->chkstop))
6364
return -ENODEV;
6465
if (online && !zc->online)
6566
return -EINVAL;

0 commit comments

Comments
 (0)