Skip to content

Commit c0e983b

Browse files
hfreudeAlexander Gordeev
authored andcommitted
s390/zcrypt: Handle ep11 cprb return code
An EP11 reply cprb contains a field ret_code which may hold an error code different than the error code stored in the payload of the cprb. As of now all the EP11 misc functions do not evaluate this field but focus on the error code in the payload. Before checking the payload error, first the cprb error field should be evaluated which is introduced with this patch. If the return code value 0x000c0003 is seen, this indicates a busy situation which is reflected by -EBUSY in the zcrpyt_ep11misc.c low level function. A higher level caller should consider to retry after waiting a dedicated duration (say 1 second). Fixes: ed6776c ("s390/crypto: remove retry loop with sleep from PAES pkey invocation") Signed-off-by: Harald Freudenberger <[email protected]> Reviewed-by: Ingo Franzki <[email protected]> Reviewed-by: Holger Dengler <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent a449999 commit c0e983b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

drivers/s390/crypto/zcrypt_ep11misc.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,22 @@ static int check_reply_pl(const u8 *pl, const char *func)
563563
return 0;
564564
}
565565

566+
/* Check ep11 reply cprb, return 0 or suggested errno value. */
567+
static int check_reply_cprb(const struct ep11_cprb *rep, const char *func)
568+
{
569+
/* check ep11 reply return code field */
570+
if (rep->ret_code) {
571+
ZCRYPT_DBF_ERR("%s ep11 reply ret_code=0x%08x\n", __func__,
572+
rep->ret_code);
573+
if (rep->ret_code == 0x000c0003)
574+
return -EBUSY;
575+
else
576+
return -EIO;
577+
}
578+
579+
return 0;
580+
}
581+
566582
/*
567583
* Helper function which does an ep11 query with given query type.
568584
*/
@@ -627,6 +643,12 @@ static int ep11_query_info(u16 cardnr, u16 domain, u32 query_type,
627643
goto out;
628644
}
629645

646+
/* check ep11 reply cprb */
647+
rc = check_reply_cprb(rep, __func__);
648+
if (rc)
649+
goto out;
650+
651+
/* check payload */
630652
rc = check_reply_pl((u8 *)rep_pl, __func__);
631653
if (rc)
632654
goto out;
@@ -877,6 +899,12 @@ static int _ep11_genaeskey(u16 card, u16 domain,
877899
goto out;
878900
}
879901

902+
/* check ep11 reply cprb */
903+
rc = check_reply_cprb(rep, __func__);
904+
if (rc)
905+
goto out;
906+
907+
/* check payload */
880908
rc = check_reply_pl((u8 *)rep_pl, __func__);
881909
if (rc)
882910
goto out;
@@ -1028,6 +1056,12 @@ static int ep11_cryptsingle(u16 card, u16 domain,
10281056
goto out;
10291057
}
10301058

1059+
/* check ep11 reply cprb */
1060+
rc = check_reply_cprb(rep, __func__);
1061+
if (rc)
1062+
goto out;
1063+
1064+
/* check payload */
10311065
rc = check_reply_pl((u8 *)rep_pl, __func__);
10321066
if (rc)
10331067
goto out;
@@ -1185,6 +1219,12 @@ static int _ep11_unwrapkey(u16 card, u16 domain,
11851219
goto out;
11861220
}
11871221

1222+
/* check ep11 reply cprb */
1223+
rc = check_reply_cprb(rep, __func__);
1224+
if (rc)
1225+
goto out;
1226+
1227+
/* check payload */
11881228
rc = check_reply_pl((u8 *)rep_pl, __func__);
11891229
if (rc)
11901230
goto out;
@@ -1339,6 +1379,12 @@ static int _ep11_wrapkey(u16 card, u16 domain,
13391379
goto out;
13401380
}
13411381

1382+
/* check ep11 reply cprb */
1383+
rc = check_reply_cprb(rep, __func__);
1384+
if (rc)
1385+
goto out;
1386+
1387+
/* check payload */
13421388
rc = check_reply_pl((u8 *)rep_pl, __func__);
13431389
if (rc)
13441390
goto out;

0 commit comments

Comments
 (0)