diff options
author | Felix Beck <felix.beck@de.ibm.com> | 2011-01-05 06:47:47 -0500 |
---|---|---|
committer | Martin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com> | 2011-01-05 06:47:27 -0500 |
commit | c2567f8ffa2704f6f2f81013e9a590deca5a865f (patch) | |
tree | 83c71b7139d21b51166f085f08bcefcaaa808b93 /drivers/s390/crypto | |
parent | 2ade1fab026b4a103f0105ec4b47654fc2f729c7 (diff) |
[S390] zcrypt: cope with cca restriction of cex3
The cca on the crypto adapter has a restriction in the size of the
exponent if a key with a modulus bigger than 2048 bit is used. Thus
in that case we have to avoid that the crypto device driver thinks
the adapter is defect and sets it offline. Therfore a new member for
the zcrypt_device struct called max_exp_bit_length is introduced. This
will be set the first time the cca returns the error code function
not implemented. If this is done with an adapter twice it will return
-EINVAL.
Signed-off-by: Felix Beck <felix.beck@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/crypto')
-rw-r--r-- | drivers/s390/crypto/zcrypt_api.h | 1 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_cex2a.c | 6 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_pcica.c | 1 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_pcicc.c | 1 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_pcixcc.c | 13 |
5 files changed, 21 insertions, 1 deletions
diff --git a/drivers/s390/crypto/zcrypt_api.h b/drivers/s390/crypto/zcrypt_api.h index 8e7ffbf2466c..88ebd114735b 100644 --- a/drivers/s390/crypto/zcrypt_api.h +++ b/drivers/s390/crypto/zcrypt_api.h | |||
@@ -109,6 +109,7 @@ struct zcrypt_device { | |||
109 | int request_count; /* # current requests. */ | 109 | int request_count; /* # current requests. */ |
110 | 110 | ||
111 | struct ap_message reply; /* Per-device reply structure. */ | 111 | struct ap_message reply; /* Per-device reply structure. */ |
112 | int max_exp_bit_length; | ||
112 | }; | 113 | }; |
113 | 114 | ||
114 | struct zcrypt_device *zcrypt_device_alloc(size_t); | 115 | struct zcrypt_device *zcrypt_device_alloc(size_t); |
diff --git a/drivers/s390/crypto/zcrypt_cex2a.c b/drivers/s390/crypto/zcrypt_cex2a.c index def0901767de..2176d00b395e 100644 --- a/drivers/s390/crypto/zcrypt_cex2a.c +++ b/drivers/s390/crypto/zcrypt_cex2a.c | |||
@@ -441,6 +441,7 @@ static int zcrypt_cex2a_probe(struct ap_device *ap_dev) | |||
441 | zdev->max_mod_size = CEX2A_MAX_MOD_SIZE; | 441 | zdev->max_mod_size = CEX2A_MAX_MOD_SIZE; |
442 | zdev->short_crt = 1; | 442 | zdev->short_crt = 1; |
443 | zdev->speed_rating = CEX2A_SPEED_RATING; | 443 | zdev->speed_rating = CEX2A_SPEED_RATING; |
444 | zdev->max_exp_bit_length = CEX2A_MAX_MOD_SIZE; | ||
444 | break; | 445 | break; |
445 | case AP_DEVICE_TYPE_CEX3A: | 446 | case AP_DEVICE_TYPE_CEX3A: |
446 | zdev = zcrypt_device_alloc(CEX3A_MAX_RESPONSE_SIZE); | 447 | zdev = zcrypt_device_alloc(CEX3A_MAX_RESPONSE_SIZE); |
@@ -450,8 +451,11 @@ static int zcrypt_cex2a_probe(struct ap_device *ap_dev) | |||
450 | zdev->type_string = "CEX3A"; | 451 | zdev->type_string = "CEX3A"; |
451 | zdev->min_mod_size = CEX2A_MIN_MOD_SIZE; | 452 | zdev->min_mod_size = CEX2A_MIN_MOD_SIZE; |
452 | zdev->max_mod_size = CEX2A_MAX_MOD_SIZE; | 453 | zdev->max_mod_size = CEX2A_MAX_MOD_SIZE; |
453 | if (ap_4096_commands_available(ap_dev->qid)) | 454 | zdev->max_exp_bit_length = CEX2A_MAX_MOD_SIZE; |
455 | if (ap_4096_commands_available(ap_dev->qid)) { | ||
454 | zdev->max_mod_size = CEX3A_MAX_MOD_SIZE; | 456 | zdev->max_mod_size = CEX3A_MAX_MOD_SIZE; |
457 | zdev->max_exp_bit_length = CEX3A_MAX_MOD_SIZE; | ||
458 | } | ||
455 | zdev->short_crt = 1; | 459 | zdev->short_crt = 1; |
456 | zdev->speed_rating = CEX3A_SPEED_RATING; | 460 | zdev->speed_rating = CEX3A_SPEED_RATING; |
457 | break; | 461 | break; |
diff --git a/drivers/s390/crypto/zcrypt_pcica.c b/drivers/s390/crypto/zcrypt_pcica.c index 09e934b295a0..1afb69c75fea 100644 --- a/drivers/s390/crypto/zcrypt_pcica.c +++ b/drivers/s390/crypto/zcrypt_pcica.c | |||
@@ -373,6 +373,7 @@ static int zcrypt_pcica_probe(struct ap_device *ap_dev) | |||
373 | zdev->min_mod_size = PCICA_MIN_MOD_SIZE; | 373 | zdev->min_mod_size = PCICA_MIN_MOD_SIZE; |
374 | zdev->max_mod_size = PCICA_MAX_MOD_SIZE; | 374 | zdev->max_mod_size = PCICA_MAX_MOD_SIZE; |
375 | zdev->speed_rating = PCICA_SPEED_RATING; | 375 | zdev->speed_rating = PCICA_SPEED_RATING; |
376 | zdev->max_exp_bit_length = PCICA_MAX_MOD_SIZE; | ||
376 | ap_dev->reply = &zdev->reply; | 377 | ap_dev->reply = &zdev->reply; |
377 | ap_dev->private = zdev; | 378 | ap_dev->private = zdev; |
378 | rc = zcrypt_device_register(zdev); | 379 | rc = zcrypt_device_register(zdev); |
diff --git a/drivers/s390/crypto/zcrypt_pcicc.c b/drivers/s390/crypto/zcrypt_pcicc.c index 9dec5c77cff4..aa4c050a5694 100644 --- a/drivers/s390/crypto/zcrypt_pcicc.c +++ b/drivers/s390/crypto/zcrypt_pcicc.c | |||
@@ -579,6 +579,7 @@ static int zcrypt_pcicc_probe(struct ap_device *ap_dev) | |||
579 | zdev->min_mod_size = PCICC_MIN_MOD_SIZE; | 579 | zdev->min_mod_size = PCICC_MIN_MOD_SIZE; |
580 | zdev->max_mod_size = PCICC_MAX_MOD_SIZE; | 580 | zdev->max_mod_size = PCICC_MAX_MOD_SIZE; |
581 | zdev->speed_rating = PCICC_SPEED_RATING; | 581 | zdev->speed_rating = PCICC_SPEED_RATING; |
582 | zdev->max_exp_bit_length = PCICC_MAX_MOD_SIZE; | ||
582 | ap_dev->reply = &zdev->reply; | 583 | ap_dev->reply = &zdev->reply; |
583 | ap_dev->private = zdev; | 584 | ap_dev->private = zdev; |
584 | rc = zcrypt_device_register(zdev); | 585 | rc = zcrypt_device_register(zdev); |
diff --git a/drivers/s390/crypto/zcrypt_pcixcc.c b/drivers/s390/crypto/zcrypt_pcixcc.c index fc8eb9dce841..4f85eb725f4f 100644 --- a/drivers/s390/crypto/zcrypt_pcixcc.c +++ b/drivers/s390/crypto/zcrypt_pcixcc.c | |||
@@ -567,6 +567,15 @@ static int convert_response_ica(struct zcrypt_device *zdev, | |||
567 | case TYPE88_RSP_CODE: | 567 | case TYPE88_RSP_CODE: |
568 | return convert_error(zdev, reply); | 568 | return convert_error(zdev, reply); |
569 | case TYPE86_RSP_CODE: | 569 | case TYPE86_RSP_CODE: |
570 | if (msg->cprbx.ccp_rtcode && | ||
571 | (msg->cprbx.ccp_rscode == 0x14f) && | ||
572 | (outputdatalength > 256)) { | ||
573 | if (zdev->max_exp_bit_length <= 17) { | ||
574 | zdev->max_exp_bit_length = 17; | ||
575 | return -EAGAIN; | ||
576 | } else | ||
577 | return -EINVAL; | ||
578 | } | ||
570 | if (msg->hdr.reply_code) | 579 | if (msg->hdr.reply_code) |
571 | return convert_error(zdev, reply); | 580 | return convert_error(zdev, reply); |
572 | if (msg->cprbx.cprb_ver_id == 0x02) | 581 | if (msg->cprbx.cprb_ver_id == 0x02) |
@@ -1052,11 +1061,13 @@ static int zcrypt_pcixcc_probe(struct ap_device *ap_dev) | |||
1052 | zdev->speed_rating = PCIXCC_MCL2_SPEED_RATING; | 1061 | zdev->speed_rating = PCIXCC_MCL2_SPEED_RATING; |
1053 | zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE_OLD; | 1062 | zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE_OLD; |
1054 | zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE; | 1063 | zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE; |
1064 | zdev->max_exp_bit_length = PCIXCC_MAX_MOD_SIZE; | ||
1055 | } else { | 1065 | } else { |
1056 | zdev->type_string = "PCIXCC_MCL3"; | 1066 | zdev->type_string = "PCIXCC_MCL3"; |
1057 | zdev->speed_rating = PCIXCC_MCL3_SPEED_RATING; | 1067 | zdev->speed_rating = PCIXCC_MCL3_SPEED_RATING; |
1058 | zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE; | 1068 | zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE; |
1059 | zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE; | 1069 | zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE; |
1070 | zdev->max_exp_bit_length = PCIXCC_MAX_MOD_SIZE; | ||
1060 | } | 1071 | } |
1061 | break; | 1072 | break; |
1062 | case AP_DEVICE_TYPE_CEX2C: | 1073 | case AP_DEVICE_TYPE_CEX2C: |
@@ -1065,6 +1076,7 @@ static int zcrypt_pcixcc_probe(struct ap_device *ap_dev) | |||
1065 | zdev->speed_rating = CEX2C_SPEED_RATING; | 1076 | zdev->speed_rating = CEX2C_SPEED_RATING; |
1066 | zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE; | 1077 | zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE; |
1067 | zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE; | 1078 | zdev->max_mod_size = PCIXCC_MAX_MOD_SIZE; |
1079 | zdev->max_exp_bit_length = PCIXCC_MAX_MOD_SIZE; | ||
1068 | break; | 1080 | break; |
1069 | case AP_DEVICE_TYPE_CEX3C: | 1081 | case AP_DEVICE_TYPE_CEX3C: |
1070 | zdev->user_space_type = ZCRYPT_CEX3C; | 1082 | zdev->user_space_type = ZCRYPT_CEX3C; |
@@ -1072,6 +1084,7 @@ static int zcrypt_pcixcc_probe(struct ap_device *ap_dev) | |||
1072 | zdev->speed_rating = CEX3C_SPEED_RATING; | 1084 | zdev->speed_rating = CEX3C_SPEED_RATING; |
1073 | zdev->min_mod_size = CEX3C_MIN_MOD_SIZE; | 1085 | zdev->min_mod_size = CEX3C_MIN_MOD_SIZE; |
1074 | zdev->max_mod_size = CEX3C_MAX_MOD_SIZE; | 1086 | zdev->max_mod_size = CEX3C_MAX_MOD_SIZE; |
1087 | zdev->max_exp_bit_length = CEX3C_MAX_MOD_SIZE; | ||
1075 | break; | 1088 | break; |
1076 | default: | 1089 | default: |
1077 | goto out_free; | 1090 | goto out_free; |