Skip to content

Commit 4c2c4dc

Browse files
ifranzkijschmidb
authored andcommitted
CCA adapters are not usable in an Secure Execution guest
Trying to use CCA adapters in an Secure Execution guest fails, because CCA adapters are not usable there. Nevertheless they show up as online, so special checking needs to be added to detect this situation. Don't set the 'ecc_via_online_card' flag in such case, so that the EC mechanisms are reported to not be available with dynamic hardware when running in an Secure Execution guest, and attempts to use curves that would require a CCA adapter fail with ENODEV. This can then be handled by the calling applications appropriately. Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
1 parent ff35d02 commit 4c2c4dc

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/s390_crypto.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,11 @@ unsigned int search_for_cards()
403403
char buf[250];
404404
struct dirent *direntp;
405405
char type[6];
406-
int rc;
406+
int rc, in_se_guest = 0;
407+
408+
rc = file_fgets("/sys/firmware/uv/prot_virt_guest", buf, sizeof(buf));
409+
if (rc == 0 && strcmp(buf, "1") == 0)
410+
in_se_guest = 1;
407411

408412
if ((sysDir = opendir(dev)) == NULL)
409413
return 0;
@@ -440,10 +444,10 @@ unsigned int search_for_cards()
440444
if (type[4] == 'A')
441445
ret |= CARD_AVAILABLE | CEXnA_AVAILABLE;
442446

443-
if (type[4] == 'C')
447+
if (type[4] == 'C' && !in_se_guest)
444448
ret |= CARD_AVAILABLE | CEXnC_AVAILABLE;
445449

446-
if (type[3] >= '4' && type[4] == 'C')
450+
if (type[3] >= '4' && type[4] == 'C' && !in_se_guest)
447451
ret |= CARD_AVAILABLE | CEX4C_AVAILABLE;
448452
}
449453

0 commit comments

Comments
 (0)