Skip to content

Commit 5cf1a56

Browse files
hfreudeVasily Gorbik
authored andcommitted
s390/ap: fix vanishing crypto cards in SE environment
A secure execution (SE, also known as confidential computing) guest may see asynchronous errors on a crypto firmware queue. The current implementation to gather information about cards and queues in ap_queue_info() simple returns if an asynchronous error is hanging on the firmware queue. If such a situation happened and it was the only queue visible for a crypto card within an SE guest, then the card vanished from sysfs as the AP bus scan function refuses to hold a card without any type information. As lszcrypt evaluates the sysfs such a card vanished from the lszcrypt card listing and the user is baffled and has no way to reset and thus clear the pending asynchronous error. This patch improves the named function to also evaluate GR2 of the TAPQ in case of asynchronous error pending. If there is a not-null value stored in, the info is processed now. In the end, a queue with pending asynchronous error does not lead to a vanishing card any more. Reviewed-by: Holger Dengler <dengler@linux.ibm.com> Signed-off-by: Harald Freudenberger <freude@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent cfaef65 commit 5cf1a56

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

drivers/s390/crypto/ap_bus.c

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ EXPORT_SYMBOL(ap_test_config_ctrl_domain);
352352
/*
353353
* ap_queue_info(): Check and get AP queue info.
354354
* Returns: 1 if APQN exists and info is filled,
355-
* 0 if APQN seems to exit but there is no info
355+
* 0 if APQN seems to exist but there is no info
356356
* available (eg. caused by an asynch pending error)
357357
* -1 invalid APQN, TAPQ error or AP queue status which
358358
* indicates there is no APQN.
@@ -373,36 +373,33 @@ static int ap_queue_info(ap_qid_t qid, int *q_type, unsigned int *q_fac,
373373
/* call TAPQ on this APQN */
374374
status = ap_test_queue(qid, ap_apft_available(), &tapq_info);
375375

376-
/* handle pending async error with return 'no info available' */
377-
if (status.async)
378-
return 0;
379-
380376
switch (status.response_code) {
381377
case AP_RESPONSE_NORMAL:
382378
case AP_RESPONSE_RESET_IN_PROGRESS:
383379
case AP_RESPONSE_DECONFIGURED:
384380
case AP_RESPONSE_CHECKSTOPPED:
385381
case AP_RESPONSE_BUSY:
386-
/*
387-
* According to the architecture in all these cases the
388-
* info should be filled. All bits 0 is not possible as
389-
* there is at least one of the mode bits set.
390-
*/
391-
if (WARN_ON_ONCE(!tapq_info.value))
392-
return 0;
393-
*q_type = tapq_info.at;
394-
*q_fac = tapq_info.fac;
395-
*q_depth = tapq_info.qd;
396-
*q_ml = tapq_info.ml;
397-
*q_decfg = status.response_code == AP_RESPONSE_DECONFIGURED;
398-
*q_cstop = status.response_code == AP_RESPONSE_CHECKSTOPPED;
399-
return 1;
382+
/* For all these RCs the tapq info should be available */
383+
break;
400384
default:
401-
/*
402-
* A response code which indicates, there is no info available.
403-
*/
404-
return -1;
385+
/* On a pending async error the info should be available */
386+
if (!status.async)
387+
return -1;
388+
break;
405389
}
390+
391+
/* There should be at least one of the mode bits set */
392+
if (WARN_ON_ONCE(!tapq_info.value))
393+
return 0;
394+
395+
*q_type = tapq_info.at;
396+
*q_fac = tapq_info.fac;
397+
*q_depth = tapq_info.qd;
398+
*q_ml = tapq_info.ml;
399+
*q_decfg = status.response_code == AP_RESPONSE_DECONFIGURED;
400+
*q_cstop = status.response_code == AP_RESPONSE_CHECKSTOPPED;
401+
402+
return 1;
406403
}
407404

408405
void ap_wait(enum ap_sm_wait wait)

0 commit comments

Comments
 (0)