diff options
author | Ingo Tuchscherer <ingo.tuchscherer@de.ibm.com> | 2013-11-20 04:47:13 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2013-12-18 11:37:15 -0500 |
commit | 91f3e3eaba4413e76ce8e12e3ef10525a889142f (patch) | |
tree | e4cef25c9b51388a462776c6a8e642571fa2f19b /drivers/s390 | |
parent | 9efe4f2992025c3a4027c60bf36ae9d710ca3781 (diff) |
s390/zcrypt: add support for EP11 coprocessor cards
This feature extends the generic cryptographic device driver (zcrypt)
with a new capability to service EP11 requests for the Crypto Express4S
card in EP11 (Enterprise PKCS#11 mode) coprocessor mode.
Signed-off-by: Ingo Tuchscherer <ingo.tuchscherer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/crypto/ap_bus.c | 31 | ||||
-rw-r--r-- | drivers/s390/crypto/ap_bus.h | 4 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_api.c | 109 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_api.h | 2 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_cex4.c | 20 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_error.h | 18 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_msgtype50.c | 12 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_msgtype6.c | 260 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_msgtype6.h | 2 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_pcica.c | 11 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_pcicc.c | 12 |
11 files changed, 467 insertions, 14 deletions
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index 02300dcfac91..ab3baa7f9508 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
@@ -591,7 +591,13 @@ static int ap_init_queue(ap_qid_t qid) | |||
591 | if (rc != -ENODEV && rc != -EBUSY) | 591 | if (rc != -ENODEV && rc != -EBUSY) |
592 | break; | 592 | break; |
593 | if (i < AP_MAX_RESET - 1) { | 593 | if (i < AP_MAX_RESET - 1) { |
594 | udelay(5); | 594 | /* Time we are waiting until we give up (0.7sec * 90). |
595 | * Since the actual request (in progress) will not | ||
596 | * interrupted immediately for the reset command, | ||
597 | * we have to be patient. In worst case we have to | ||
598 | * wait 60sec + reset time (some msec). | ||
599 | */ | ||
600 | schedule_timeout(AP_RESET_TIMEOUT); | ||
595 | status = ap_test_queue(qid, &dummy, &dummy); | 601 | status = ap_test_queue(qid, &dummy, &dummy); |
596 | } | 602 | } |
597 | } | 603 | } |
@@ -992,6 +998,28 @@ static ssize_t ap_domain_show(struct bus_type *bus, char *buf) | |||
992 | 998 | ||
993 | static BUS_ATTR(ap_domain, 0444, ap_domain_show, NULL); | 999 | static BUS_ATTR(ap_domain, 0444, ap_domain_show, NULL); |
994 | 1000 | ||
1001 | static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf) | ||
1002 | { | ||
1003 | if (ap_configuration != NULL) { /* QCI not supported */ | ||
1004 | if (test_facility(76)) { /* format 1 - 256 bit domain field */ | ||
1005 | return snprintf(buf, PAGE_SIZE, | ||
1006 | "0x%08x%08x%08x%08x%08x%08x%08x%08x\n", | ||
1007 | ap_configuration->adm[0], ap_configuration->adm[1], | ||
1008 | ap_configuration->adm[2], ap_configuration->adm[3], | ||
1009 | ap_configuration->adm[4], ap_configuration->adm[5], | ||
1010 | ap_configuration->adm[6], ap_configuration->adm[7]); | ||
1011 | } else { /* format 0 - 16 bit domain field */ | ||
1012 | return snprintf(buf, PAGE_SIZE, "%08x%08x\n", | ||
1013 | ap_configuration->adm[0], ap_configuration->adm[1]); | ||
1014 | } | ||
1015 | } else { | ||
1016 | return snprintf(buf, PAGE_SIZE, "not supported\n"); | ||
1017 | } | ||
1018 | } | ||
1019 | |||
1020 | static BUS_ATTR(ap_control_domain_mask, 0444, | ||
1021 | ap_control_domain_mask_show, NULL); | ||
1022 | |||
995 | static ssize_t ap_config_time_show(struct bus_type *bus, char *buf) | 1023 | static ssize_t ap_config_time_show(struct bus_type *bus, char *buf) |
996 | { | 1024 | { |
997 | return snprintf(buf, PAGE_SIZE, "%d\n", ap_config_time); | 1025 | return snprintf(buf, PAGE_SIZE, "%d\n", ap_config_time); |
@@ -1077,6 +1105,7 @@ static BUS_ATTR(poll_timeout, 0644, poll_timeout_show, poll_timeout_store); | |||
1077 | 1105 | ||
1078 | static struct bus_attribute *const ap_bus_attrs[] = { | 1106 | static struct bus_attribute *const ap_bus_attrs[] = { |
1079 | &bus_attr_ap_domain, | 1107 | &bus_attr_ap_domain, |
1108 | &bus_attr_ap_control_domain_mask, | ||
1080 | &bus_attr_config_time, | 1109 | &bus_attr_config_time, |
1081 | &bus_attr_poll_thread, | 1110 | &bus_attr_poll_thread, |
1082 | &bus_attr_ap_interrupts, | 1111 | &bus_attr_ap_interrupts, |
diff --git a/drivers/s390/crypto/ap_bus.h b/drivers/s390/crypto/ap_bus.h index 685f6cc022f9..6405ae24a7a6 100644 --- a/drivers/s390/crypto/ap_bus.h +++ b/drivers/s390/crypto/ap_bus.h | |||
@@ -33,7 +33,7 @@ | |||
33 | #define AP_DEVICES 64 /* Number of AP devices. */ | 33 | #define AP_DEVICES 64 /* Number of AP devices. */ |
34 | #define AP_DOMAINS 16 /* Number of AP domains. */ | 34 | #define AP_DOMAINS 16 /* Number of AP domains. */ |
35 | #define AP_MAX_RESET 90 /* Maximum number of resets. */ | 35 | #define AP_MAX_RESET 90 /* Maximum number of resets. */ |
36 | #define AP_RESET_TIMEOUT (HZ/2) /* Time in ticks for reset timeouts. */ | 36 | #define AP_RESET_TIMEOUT (HZ*0.7) /* Time in ticks for reset timeouts. */ |
37 | #define AP_CONFIG_TIME 30 /* Time in seconds between AP bus rescans. */ | 37 | #define AP_CONFIG_TIME 30 /* Time in seconds between AP bus rescans. */ |
38 | #define AP_POLL_TIME 1 /* Time in ticks between receive polls. */ | 38 | #define AP_POLL_TIME 1 /* Time in ticks between receive polls. */ |
39 | 39 | ||
@@ -125,6 +125,8 @@ static inline int ap_test_bit(unsigned int *ptr, unsigned int nr) | |||
125 | #define AP_FUNC_CRT4K 2 | 125 | #define AP_FUNC_CRT4K 2 |
126 | #define AP_FUNC_COPRO 3 | 126 | #define AP_FUNC_COPRO 3 |
127 | #define AP_FUNC_ACCEL 4 | 127 | #define AP_FUNC_ACCEL 4 |
128 | #define AP_FUNC_EP11 5 | ||
129 | #define AP_FUNC_APXA 6 | ||
128 | 130 | ||
129 | /* | 131 | /* |
130 | * AP reset flag states | 132 | * AP reset flag states |
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index 31cfaa556072..4b824b15194f 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c | |||
@@ -44,6 +44,8 @@ | |||
44 | #include "zcrypt_debug.h" | 44 | #include "zcrypt_debug.h" |
45 | #include "zcrypt_api.h" | 45 | #include "zcrypt_api.h" |
46 | 46 | ||
47 | #include "zcrypt_msgtype6.h" | ||
48 | |||
47 | /* | 49 | /* |
48 | * Module description. | 50 | * Module description. |
49 | */ | 51 | */ |
@@ -554,9 +556,9 @@ static long zcrypt_send_cprb(struct ica_xcRB *xcRB) | |||
554 | spin_lock_bh(&zcrypt_device_lock); | 556 | spin_lock_bh(&zcrypt_device_lock); |
555 | list_for_each_entry(zdev, &zcrypt_device_list, list) { | 557 | list_for_each_entry(zdev, &zcrypt_device_list, list) { |
556 | if (!zdev->online || !zdev->ops->send_cprb || | 558 | if (!zdev->online || !zdev->ops->send_cprb || |
557 | (xcRB->user_defined != AUTOSELECT && | 559 | (zdev->ops->variant == MSGTYPE06_VARIANT_EP11) || |
558 | AP_QID_DEVICE(zdev->ap_dev->qid) != xcRB->user_defined) | 560 | (xcRB->user_defined != AUTOSELECT && |
559 | ) | 561 | AP_QID_DEVICE(zdev->ap_dev->qid) != xcRB->user_defined)) |
560 | continue; | 562 | continue; |
561 | zcrypt_device_get(zdev); | 563 | zcrypt_device_get(zdev); |
562 | get_device(&zdev->ap_dev->device); | 564 | get_device(&zdev->ap_dev->device); |
@@ -581,6 +583,90 @@ static long zcrypt_send_cprb(struct ica_xcRB *xcRB) | |||
581 | return -ENODEV; | 583 | return -ENODEV; |
582 | } | 584 | } |
583 | 585 | ||
586 | struct ep11_target_dev_list { | ||
587 | unsigned short targets_num; | ||
588 | struct ep11_target_dev *targets; | ||
589 | }; | ||
590 | |||
591 | static bool is_desired_ep11dev(unsigned int dev_qid, | ||
592 | struct ep11_target_dev_list dev_list) | ||
593 | { | ||
594 | int n; | ||
595 | |||
596 | for (n = 0; n < dev_list.targets_num; n++, dev_list.targets++) { | ||
597 | if ((AP_QID_DEVICE(dev_qid) == dev_list.targets->ap_id) && | ||
598 | (AP_QID_QUEUE(dev_qid) == dev_list.targets->dom_id)) { | ||
599 | return true; | ||
600 | } | ||
601 | } | ||
602 | return false; | ||
603 | } | ||
604 | |||
605 | static long zcrypt_send_ep11_cprb(struct ep11_urb *xcrb) | ||
606 | { | ||
607 | struct zcrypt_device *zdev; | ||
608 | bool autoselect = false; | ||
609 | int rc; | ||
610 | struct ep11_target_dev_list ep11_dev_list = { | ||
611 | .targets_num = 0x00, | ||
612 | .targets = NULL, | ||
613 | }; | ||
614 | |||
615 | ep11_dev_list.targets_num = (unsigned short) xcrb->targets_num; | ||
616 | |||
617 | /* empty list indicates autoselect (all available targets) */ | ||
618 | if (ep11_dev_list.targets_num == 0) | ||
619 | autoselect = true; | ||
620 | else { | ||
621 | ep11_dev_list.targets = kcalloc((unsigned short) | ||
622 | xcrb->targets_num, | ||
623 | sizeof(struct ep11_target_dev), | ||
624 | GFP_KERNEL); | ||
625 | if (!ep11_dev_list.targets) | ||
626 | return -ENOMEM; | ||
627 | |||
628 | if (copy_from_user(ep11_dev_list.targets, | ||
629 | (struct ep11_target_dev *)xcrb->targets, | ||
630 | xcrb->targets_num * | ||
631 | sizeof(struct ep11_target_dev))) | ||
632 | return -EFAULT; | ||
633 | } | ||
634 | |||
635 | spin_lock_bh(&zcrypt_device_lock); | ||
636 | list_for_each_entry(zdev, &zcrypt_device_list, list) { | ||
637 | /* check if device is eligible */ | ||
638 | if (!zdev->online || | ||
639 | zdev->ops->variant != MSGTYPE06_VARIANT_EP11) | ||
640 | continue; | ||
641 | |||
642 | /* check if device is selected as valid target */ | ||
643 | if (!is_desired_ep11dev(zdev->ap_dev->qid, ep11_dev_list) && | ||
644 | !autoselect) | ||
645 | continue; | ||
646 | |||
647 | zcrypt_device_get(zdev); | ||
648 | get_device(&zdev->ap_dev->device); | ||
649 | zdev->request_count++; | ||
650 | __zcrypt_decrease_preference(zdev); | ||
651 | if (try_module_get(zdev->ap_dev->drv->driver.owner)) { | ||
652 | spin_unlock_bh(&zcrypt_device_lock); | ||
653 | rc = zdev->ops->send_ep11_cprb(zdev, xcrb); | ||
654 | spin_lock_bh(&zcrypt_device_lock); | ||
655 | module_put(zdev->ap_dev->drv->driver.owner); | ||
656 | } else { | ||
657 | rc = -EAGAIN; | ||
658 | } | ||
659 | zdev->request_count--; | ||
660 | __zcrypt_increase_preference(zdev); | ||
661 | put_device(&zdev->ap_dev->device); | ||
662 | zcrypt_device_put(zdev); | ||
663 | spin_unlock_bh(&zcrypt_device_lock); | ||
664 | return rc; | ||
665 | } | ||
666 | spin_unlock_bh(&zcrypt_device_lock); | ||
667 | return -ENODEV; | ||
668 | } | ||
669 | |||
584 | static long zcrypt_rng(char *buffer) | 670 | static long zcrypt_rng(char *buffer) |
585 | { | 671 | { |
586 | struct zcrypt_device *zdev; | 672 | struct zcrypt_device *zdev; |
@@ -784,6 +870,23 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, | |||
784 | return -EFAULT; | 870 | return -EFAULT; |
785 | return rc; | 871 | return rc; |
786 | } | 872 | } |
873 | case ZSENDEP11CPRB: { | ||
874 | struct ep11_urb __user *uxcrb = (void __user *)arg; | ||
875 | struct ep11_urb xcrb; | ||
876 | if (copy_from_user(&xcrb, uxcrb, sizeof(xcrb))) | ||
877 | return -EFAULT; | ||
878 | do { | ||
879 | rc = zcrypt_send_ep11_cprb(&xcrb); | ||
880 | } while (rc == -EAGAIN); | ||
881 | /* on failure: retry once again after a requested rescan */ | ||
882 | if ((rc == -ENODEV) && (zcrypt_process_rescan())) | ||
883 | do { | ||
884 | rc = zcrypt_send_ep11_cprb(&xcrb); | ||
885 | } while (rc == -EAGAIN); | ||
886 | if (copy_to_user(uxcrb, &xcrb, sizeof(xcrb))) | ||
887 | return -EFAULT; | ||
888 | return rc; | ||
889 | } | ||
787 | case Z90STAT_STATUS_MASK: { | 890 | case Z90STAT_STATUS_MASK: { |
788 | char status[AP_DEVICES]; | 891 | char status[AP_DEVICES]; |
789 | zcrypt_status_mask(status); | 892 | zcrypt_status_mask(status); |
diff --git a/drivers/s390/crypto/zcrypt_api.h b/drivers/s390/crypto/zcrypt_api.h index 89632919c993..b3d496bfaa7e 100644 --- a/drivers/s390/crypto/zcrypt_api.h +++ b/drivers/s390/crypto/zcrypt_api.h | |||
@@ -74,6 +74,7 @@ struct ica_z90_status { | |||
74 | #define ZCRYPT_CEX2A 6 | 74 | #define ZCRYPT_CEX2A 6 |
75 | #define ZCRYPT_CEX3C 7 | 75 | #define ZCRYPT_CEX3C 7 |
76 | #define ZCRYPT_CEX3A 8 | 76 | #define ZCRYPT_CEX3A 8 |
77 | #define ZCRYPT_CEX4 10 | ||
77 | 78 | ||
78 | /** | 79 | /** |
79 | * Large random numbers are pulled in 4096 byte chunks from the crypto cards | 80 | * Large random numbers are pulled in 4096 byte chunks from the crypto cards |
@@ -89,6 +90,7 @@ struct zcrypt_ops { | |||
89 | long (*rsa_modexpo_crt)(struct zcrypt_device *, | 90 | long (*rsa_modexpo_crt)(struct zcrypt_device *, |
90 | struct ica_rsa_modexpo_crt *); | 91 | struct ica_rsa_modexpo_crt *); |
91 | long (*send_cprb)(struct zcrypt_device *, struct ica_xcRB *); | 92 | long (*send_cprb)(struct zcrypt_device *, struct ica_xcRB *); |
93 | long (*send_ep11_cprb)(struct zcrypt_device *, struct ep11_urb *); | ||
92 | long (*rng)(struct zcrypt_device *, char *); | 94 | long (*rng)(struct zcrypt_device *, char *); |
93 | struct list_head list; /* zcrypt ops list. */ | 95 | struct list_head list; /* zcrypt ops list. */ |
94 | struct module *owner; | 96 | struct module *owner; |
diff --git a/drivers/s390/crypto/zcrypt_cex4.c b/drivers/s390/crypto/zcrypt_cex4.c index ce1226398ac9..569f8b1d86c0 100644 --- a/drivers/s390/crypto/zcrypt_cex4.c +++ b/drivers/s390/crypto/zcrypt_cex4.c | |||
@@ -30,7 +30,12 @@ | |||
30 | #define CEX4A_MAX_MESSAGE_SIZE MSGTYPE50_CRB3_MAX_MSG_SIZE | 30 | #define CEX4A_MAX_MESSAGE_SIZE MSGTYPE50_CRB3_MAX_MSG_SIZE |
31 | #define CEX4C_MAX_MESSAGE_SIZE MSGTYPE06_MAX_MSG_SIZE | 31 | #define CEX4C_MAX_MESSAGE_SIZE MSGTYPE06_MAX_MSG_SIZE |
32 | 32 | ||
33 | #define CEX4_CLEANUP_TIME (15*HZ) | 33 | /* Waiting time for requests to be processed. |
34 | * Currently there are some types of request which are not deterministic. | ||
35 | * But the maximum time limit managed by the stomper code is set to 60sec. | ||
36 | * Hence we have to wait at least that time period. | ||
37 | */ | ||
38 | #define CEX4_CLEANUP_TIME (61*HZ) | ||
34 | 39 | ||
35 | static struct ap_device_id zcrypt_cex4_ids[] = { | 40 | static struct ap_device_id zcrypt_cex4_ids[] = { |
36 | { AP_DEVICE(AP_DEVICE_TYPE_CEX4) }, | 41 | { AP_DEVICE(AP_DEVICE_TYPE_CEX4) }, |
@@ -101,6 +106,19 @@ static int zcrypt_cex4_probe(struct ap_device *ap_dev) | |||
101 | zdev->speed_rating = CEX4C_SPEED_RATING; | 106 | zdev->speed_rating = CEX4C_SPEED_RATING; |
102 | zdev->ops = zcrypt_msgtype_request(MSGTYPE06_NAME, | 107 | zdev->ops = zcrypt_msgtype_request(MSGTYPE06_NAME, |
103 | MSGTYPE06_VARIANT_DEFAULT); | 108 | MSGTYPE06_VARIANT_DEFAULT); |
109 | } else if (ap_test_bit(&ap_dev->functions, AP_FUNC_EP11)) { | ||
110 | zdev = zcrypt_device_alloc(CEX4C_MAX_MESSAGE_SIZE); | ||
111 | if (!zdev) | ||
112 | return -ENOMEM; | ||
113 | zdev->type_string = "CEX4P"; | ||
114 | zdev->user_space_type = ZCRYPT_CEX4; | ||
115 | zdev->min_mod_size = CEX4C_MIN_MOD_SIZE; | ||
116 | zdev->max_mod_size = CEX4C_MAX_MOD_SIZE; | ||
117 | zdev->max_exp_bit_length = CEX4C_MAX_MOD_SIZE; | ||
118 | zdev->short_crt = 0; | ||
119 | zdev->speed_rating = CEX4C_SPEED_RATING; | ||
120 | zdev->ops = zcrypt_msgtype_request(MSGTYPE06_NAME, | ||
121 | MSGTYPE06_VARIANT_EP11); | ||
104 | } | 122 | } |
105 | break; | 123 | break; |
106 | } | 124 | } |
diff --git a/drivers/s390/crypto/zcrypt_error.h b/drivers/s390/crypto/zcrypt_error.h index 0079b6617211..7b23f43c7b08 100644 --- a/drivers/s390/crypto/zcrypt_error.h +++ b/drivers/s390/crypto/zcrypt_error.h | |||
@@ -106,15 +106,15 @@ static inline int convert_error(struct zcrypt_device *zdev, | |||
106 | // REP88_ERROR_MESSAGE_TYPE // '20' CEX2A | 106 | // REP88_ERROR_MESSAGE_TYPE // '20' CEX2A |
107 | /* | 107 | /* |
108 | * To sent a message of the wrong type is a bug in the | 108 | * To sent a message of the wrong type is a bug in the |
109 | * device driver. Warn about it, disable the device | 109 | * device driver. Send error msg, disable the device |
110 | * and then repeat the request. | 110 | * and then repeat the request. |
111 | */ | 111 | */ |
112 | WARN_ON(1); | ||
113 | atomic_set(&zcrypt_rescan_req, 1); | 112 | atomic_set(&zcrypt_rescan_req, 1); |
114 | zdev->online = 0; | 113 | zdev->online = 0; |
114 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
115 | zdev->ap_dev->qid); | ||
115 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | 116 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", |
116 | zdev->ap_dev->qid, | 117 | zdev->ap_dev->qid, zdev->online, ehdr->reply_code); |
117 | zdev->online, ehdr->reply_code); | ||
118 | return -EAGAIN; | 118 | return -EAGAIN; |
119 | case REP82_ERROR_TRANSPORT_FAIL: | 119 | case REP82_ERROR_TRANSPORT_FAIL: |
120 | case REP82_ERROR_MACHINE_FAILURE: | 120 | case REP82_ERROR_MACHINE_FAILURE: |
@@ -122,15 +122,17 @@ static inline int convert_error(struct zcrypt_device *zdev, | |||
122 | /* If a card fails disable it and repeat the request. */ | 122 | /* If a card fails disable it and repeat the request. */ |
123 | atomic_set(&zcrypt_rescan_req, 1); | 123 | atomic_set(&zcrypt_rescan_req, 1); |
124 | zdev->online = 0; | 124 | zdev->online = 0; |
125 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
126 | zdev->ap_dev->qid); | ||
125 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | 127 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", |
126 | zdev->ap_dev->qid, | 128 | zdev->ap_dev->qid, zdev->online, ehdr->reply_code); |
127 | zdev->online, ehdr->reply_code); | ||
128 | return -EAGAIN; | 129 | return -EAGAIN; |
129 | default: | 130 | default: |
130 | zdev->online = 0; | 131 | zdev->online = 0; |
132 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
133 | zdev->ap_dev->qid); | ||
131 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | 134 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", |
132 | zdev->ap_dev->qid, | 135 | zdev->ap_dev->qid, zdev->online, ehdr->reply_code); |
133 | zdev->online, ehdr->reply_code); | ||
134 | return -EAGAIN; /* repeat the request on a different device. */ | 136 | return -EAGAIN; /* repeat the request on a different device. */ |
135 | } | 137 | } |
136 | } | 138 | } |
diff --git a/drivers/s390/crypto/zcrypt_msgtype50.c b/drivers/s390/crypto/zcrypt_msgtype50.c index 7c522f338bda..334e282f255b 100644 --- a/drivers/s390/crypto/zcrypt_msgtype50.c +++ b/drivers/s390/crypto/zcrypt_msgtype50.c | |||
@@ -25,6 +25,9 @@ | |||
25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #define KMSG_COMPONENT "zcrypt" | ||
29 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | ||
30 | |||
28 | #include <linux/module.h> | 31 | #include <linux/module.h> |
29 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
30 | #include <linux/init.h> | 33 | #include <linux/init.h> |
@@ -332,6 +335,11 @@ static int convert_type80(struct zcrypt_device *zdev, | |||
332 | if (t80h->len < sizeof(*t80h) + outputdatalength) { | 335 | if (t80h->len < sizeof(*t80h) + outputdatalength) { |
333 | /* The result is too short, the CEX2A card may not do that.. */ | 336 | /* The result is too short, the CEX2A card may not do that.. */ |
334 | zdev->online = 0; | 337 | zdev->online = 0; |
338 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
339 | zdev->ap_dev->qid); | ||
340 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | ||
341 | zdev->ap_dev->qid, zdev->online, t80h->code); | ||
342 | |||
335 | return -EAGAIN; /* repeat the request on a different device. */ | 343 | return -EAGAIN; /* repeat the request on a different device. */ |
336 | } | 344 | } |
337 | if (zdev->user_space_type == ZCRYPT_CEX2A) | 345 | if (zdev->user_space_type == ZCRYPT_CEX2A) |
@@ -359,6 +367,10 @@ static int convert_response(struct zcrypt_device *zdev, | |||
359 | outputdata, outputdatalength); | 367 | outputdata, outputdatalength); |
360 | default: /* Unknown response type, this should NEVER EVER happen */ | 368 | default: /* Unknown response type, this should NEVER EVER happen */ |
361 | zdev->online = 0; | 369 | zdev->online = 0; |
370 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
371 | zdev->ap_dev->qid); | ||
372 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | ||
373 | zdev->ap_dev->qid, zdev->online); | ||
362 | return -EAGAIN; /* repeat the request on a different device. */ | 374 | return -EAGAIN; /* repeat the request on a different device. */ |
363 | } | 375 | } |
364 | } | 376 | } |
diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c b/drivers/s390/crypto/zcrypt_msgtype6.c index 7d97fa5a26d0..57bfda1bd71a 100644 --- a/drivers/s390/crypto/zcrypt_msgtype6.c +++ b/drivers/s390/crypto/zcrypt_msgtype6.c | |||
@@ -25,6 +25,9 @@ | |||
25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #define KMSG_COMPONENT "zcrypt" | ||
29 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | ||
30 | |||
28 | #include <linux/module.h> | 31 | #include <linux/module.h> |
29 | #include <linux/init.h> | 32 | #include <linux/init.h> |
30 | #include <linux/err.h> | 33 | #include <linux/err.h> |
@@ -50,6 +53,7 @@ struct response_type { | |||
50 | }; | 53 | }; |
51 | #define PCIXCC_RESPONSE_TYPE_ICA 0 | 54 | #define PCIXCC_RESPONSE_TYPE_ICA 0 |
52 | #define PCIXCC_RESPONSE_TYPE_XCRB 1 | 55 | #define PCIXCC_RESPONSE_TYPE_XCRB 1 |
56 | #define PCIXCC_RESPONSE_TYPE_EP11 2 | ||
53 | 57 | ||
54 | MODULE_AUTHOR("IBM Corporation"); | 58 | MODULE_AUTHOR("IBM Corporation"); |
55 | MODULE_DESCRIPTION("Cryptographic Coprocessor (message type 6), " \ | 59 | MODULE_DESCRIPTION("Cryptographic Coprocessor (message type 6), " \ |
@@ -358,6 +362,91 @@ static int XCRB_msg_to_type6CPRB_msgX(struct zcrypt_device *zdev, | |||
358 | return 0; | 362 | return 0; |
359 | } | 363 | } |
360 | 364 | ||
365 | static int xcrb_msg_to_type6_ep11cprb_msgx(struct zcrypt_device *zdev, | ||
366 | struct ap_message *ap_msg, | ||
367 | struct ep11_urb *xcRB) | ||
368 | { | ||
369 | unsigned int lfmt; | ||
370 | |||
371 | static struct type6_hdr static_type6_ep11_hdr = { | ||
372 | .type = 0x06, | ||
373 | .rqid = {0x00, 0x01}, | ||
374 | .function_code = {0x00, 0x00}, | ||
375 | .agent_id[0] = 0x58, /* {'X'} */ | ||
376 | .agent_id[1] = 0x43, /* {'C'} */ | ||
377 | .offset1 = 0x00000058, | ||
378 | }; | ||
379 | |||
380 | struct { | ||
381 | struct type6_hdr hdr; | ||
382 | struct ep11_cprb cprbx; | ||
383 | unsigned char pld_tag; /* fixed value 0x30 */ | ||
384 | unsigned char pld_lenfmt; /* payload length format */ | ||
385 | } __packed * msg = ap_msg->message; | ||
386 | |||
387 | struct pld_hdr { | ||
388 | unsigned char func_tag; /* fixed value 0x4 */ | ||
389 | unsigned char func_len; /* fixed value 0x4 */ | ||
390 | unsigned int func_val; /* function ID */ | ||
391 | unsigned char dom_tag; /* fixed value 0x4 */ | ||
392 | unsigned char dom_len; /* fixed value 0x4 */ | ||
393 | unsigned int dom_val; /* domain id */ | ||
394 | } __packed * payload_hdr; | ||
395 | |||
396 | /* length checks */ | ||
397 | ap_msg->length = sizeof(struct type6_hdr) + xcRB->req_len; | ||
398 | if (CEIL4(xcRB->req_len) > MSGTYPE06_MAX_MSG_SIZE - | ||
399 | (sizeof(struct type6_hdr))) | ||
400 | return -EINVAL; | ||
401 | |||
402 | if (CEIL4(xcRB->resp_len) > MSGTYPE06_MAX_MSG_SIZE - | ||
403 | (sizeof(struct type86_fmt2_msg))) | ||
404 | return -EINVAL; | ||
405 | |||
406 | /* prepare type6 header */ | ||
407 | msg->hdr = static_type6_ep11_hdr; | ||
408 | msg->hdr.ToCardLen1 = xcRB->req_len; | ||
409 | msg->hdr.FromCardLen1 = xcRB->resp_len; | ||
410 | |||
411 | /* Import CPRB data from the ioctl input parameter */ | ||
412 | if (copy_from_user(&(msg->cprbx.cprb_len), | ||
413 | (char *)xcRB->req, xcRB->req_len)) { | ||
414 | return -EFAULT; | ||
415 | } | ||
416 | |||
417 | /* | ||
418 | The target domain field within the cprb body/payload block will be | ||
419 | replaced by the usage domain for non-management commands only. | ||
420 | Therefore we check the first bit of the 'flags' parameter for | ||
421 | management command indication. | ||
422 | 0 - non managment command | ||
423 | 1 - management command | ||
424 | */ | ||
425 | if (!((msg->cprbx.flags & 0x80) == 0x80)) { | ||
426 | msg->cprbx.target_id = (unsigned int) | ||
427 | AP_QID_QUEUE(zdev->ap_dev->qid); | ||
428 | |||
429 | if ((msg->pld_lenfmt & 0x80) == 0x80) { /*ext.len.fmt 2 or 3*/ | ||
430 | switch (msg->pld_lenfmt & 0x03) { | ||
431 | case 1: | ||
432 | lfmt = 2; | ||
433 | break; | ||
434 | case 2: | ||
435 | lfmt = 3; | ||
436 | break; | ||
437 | default: | ||
438 | return -EINVAL; | ||
439 | } | ||
440 | } else { | ||
441 | lfmt = 1; /* length format #1 */ | ||
442 | } | ||
443 | payload_hdr = (struct pld_hdr *)((&(msg->pld_lenfmt))+lfmt); | ||
444 | payload_hdr->dom_val = (unsigned int) | ||
445 | AP_QID_QUEUE(zdev->ap_dev->qid); | ||
446 | } | ||
447 | return 0; | ||
448 | } | ||
449 | |||
361 | /** | 450 | /** |
362 | * Copy results from a type 86 ICA reply message back to user space. | 451 | * Copy results from a type 86 ICA reply message back to user space. |
363 | * | 452 | * |
@@ -377,6 +466,12 @@ struct type86x_reply { | |||
377 | char text[0]; | 466 | char text[0]; |
378 | } __packed; | 467 | } __packed; |
379 | 468 | ||
469 | struct type86_ep11_reply { | ||
470 | struct type86_hdr hdr; | ||
471 | struct type86_fmt2_ext fmt2; | ||
472 | struct ep11_cprb cprbx; | ||
473 | } __packed; | ||
474 | |||
380 | static int convert_type86_ica(struct zcrypt_device *zdev, | 475 | static int convert_type86_ica(struct zcrypt_device *zdev, |
381 | struct ap_message *reply, | 476 | struct ap_message *reply, |
382 | char __user *outputdata, | 477 | char __user *outputdata, |
@@ -440,6 +535,11 @@ static int convert_type86_ica(struct zcrypt_device *zdev, | |||
440 | if (service_rc == 8 && service_rs == 72) | 535 | if (service_rc == 8 && service_rs == 72) |
441 | return -EINVAL; | 536 | return -EINVAL; |
442 | zdev->online = 0; | 537 | zdev->online = 0; |
538 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
539 | zdev->ap_dev->qid); | ||
540 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | ||
541 | zdev->ap_dev->qid, zdev->online, | ||
542 | msg->hdr.reply_code); | ||
443 | return -EAGAIN; /* repeat the request on a different device. */ | 543 | return -EAGAIN; /* repeat the request on a different device. */ |
444 | } | 544 | } |
445 | data = msg->text; | 545 | data = msg->text; |
@@ -503,6 +603,33 @@ static int convert_type86_xcrb(struct zcrypt_device *zdev, | |||
503 | return 0; | 603 | return 0; |
504 | } | 604 | } |
505 | 605 | ||
606 | /** | ||
607 | * Copy results from a type 86 EP11 XCRB reply message back to user space. | ||
608 | * | ||
609 | * @zdev: crypto device pointer | ||
610 | * @reply: reply AP message. | ||
611 | * @xcRB: pointer to EP11 user request block | ||
612 | * | ||
613 | * Returns 0 on success or -EINVAL, -EFAULT, -EAGAIN in case of an error. | ||
614 | */ | ||
615 | static int convert_type86_ep11_xcrb(struct zcrypt_device *zdev, | ||
616 | struct ap_message *reply, | ||
617 | struct ep11_urb *xcRB) | ||
618 | { | ||
619 | struct type86_fmt2_msg *msg = reply->message; | ||
620 | char *data = reply->message; | ||
621 | |||
622 | if (xcRB->resp_len < msg->fmt2.count1) | ||
623 | return -EINVAL; | ||
624 | |||
625 | /* Copy response CPRB to user */ | ||
626 | if (copy_to_user((char *)xcRB->resp, | ||
627 | data + msg->fmt2.offset1, msg->fmt2.count1)) | ||
628 | return -EFAULT; | ||
629 | xcRB->resp_len = msg->fmt2.count1; | ||
630 | return 0; | ||
631 | } | ||
632 | |||
506 | static int convert_type86_rng(struct zcrypt_device *zdev, | 633 | static int convert_type86_rng(struct zcrypt_device *zdev, |
507 | struct ap_message *reply, | 634 | struct ap_message *reply, |
508 | char *buffer) | 635 | char *buffer) |
@@ -551,6 +678,10 @@ static int convert_response_ica(struct zcrypt_device *zdev, | |||
551 | * response */ | 678 | * response */ |
552 | default: /* Unknown response type, this should NEVER EVER happen */ | 679 | default: /* Unknown response type, this should NEVER EVER happen */ |
553 | zdev->online = 0; | 680 | zdev->online = 0; |
681 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
682 | zdev->ap_dev->qid); | ||
683 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | ||
684 | zdev->ap_dev->qid, zdev->online); | ||
554 | return -EAGAIN; /* repeat the request on a different device. */ | 685 | return -EAGAIN; /* repeat the request on a different device. */ |
555 | } | 686 | } |
556 | } | 687 | } |
@@ -579,10 +710,40 @@ static int convert_response_xcrb(struct zcrypt_device *zdev, | |||
579 | default: /* Unknown response type, this should NEVER EVER happen */ | 710 | default: /* Unknown response type, this should NEVER EVER happen */ |
580 | xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ | 711 | xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ |
581 | zdev->online = 0; | 712 | zdev->online = 0; |
713 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
714 | zdev->ap_dev->qid); | ||
715 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | ||
716 | zdev->ap_dev->qid, zdev->online); | ||
582 | return -EAGAIN; /* repeat the request on a different device. */ | 717 | return -EAGAIN; /* repeat the request on a different device. */ |
583 | } | 718 | } |
584 | } | 719 | } |
585 | 720 | ||
721 | static int convert_response_ep11_xcrb(struct zcrypt_device *zdev, | ||
722 | struct ap_message *reply, struct ep11_urb *xcRB) | ||
723 | { | ||
724 | struct type86_ep11_reply *msg = reply->message; | ||
725 | |||
726 | /* Response type byte is the second byte in the response. */ | ||
727 | switch (((unsigned char *)reply->message)[1]) { | ||
728 | case TYPE82_RSP_CODE: | ||
729 | case TYPE87_RSP_CODE: | ||
730 | return convert_error(zdev, reply); | ||
731 | case TYPE86_RSP_CODE: | ||
732 | if (msg->hdr.reply_code) | ||
733 | return convert_error(zdev, reply); | ||
734 | if (msg->cprbx.cprb_ver_id == 0x04) | ||
735 | return convert_type86_ep11_xcrb(zdev, reply, xcRB); | ||
736 | /* Fall through, no break, incorrect cprb version is an unknown resp.*/ | ||
737 | default: /* Unknown response type, this should NEVER EVER happen */ | ||
738 | zdev->online = 0; | ||
739 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
740 | zdev->ap_dev->qid); | ||
741 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | ||
742 | zdev->ap_dev->qid, zdev->online); | ||
743 | return -EAGAIN; /* repeat the request on a different device. */ | ||
744 | } | ||
745 | } | ||
746 | |||
586 | static int convert_response_rng(struct zcrypt_device *zdev, | 747 | static int convert_response_rng(struct zcrypt_device *zdev, |
587 | struct ap_message *reply, | 748 | struct ap_message *reply, |
588 | char *data) | 749 | char *data) |
@@ -602,6 +763,10 @@ static int convert_response_rng(struct zcrypt_device *zdev, | |||
602 | * response */ | 763 | * response */ |
603 | default: /* Unknown response type, this should NEVER EVER happen */ | 764 | default: /* Unknown response type, this should NEVER EVER happen */ |
604 | zdev->online = 0; | 765 | zdev->online = 0; |
766 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
767 | zdev->ap_dev->qid); | ||
768 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | ||
769 | zdev->ap_dev->qid, zdev->online); | ||
605 | return -EAGAIN; /* repeat the request on a different device. */ | 770 | return -EAGAIN; /* repeat the request on a different device. */ |
606 | } | 771 | } |
607 | } | 772 | } |
@@ -657,6 +822,51 @@ out: | |||
657 | complete(&(resp_type->work)); | 822 | complete(&(resp_type->work)); |
658 | } | 823 | } |
659 | 824 | ||
825 | /** | ||
826 | * This function is called from the AP bus code after a crypto request | ||
827 | * "msg" has finished with the reply message "reply". | ||
828 | * It is called from tasklet context. | ||
829 | * @ap_dev: pointer to the AP device | ||
830 | * @msg: pointer to the AP message | ||
831 | * @reply: pointer to the AP reply message | ||
832 | */ | ||
833 | static void zcrypt_msgtype6_receive_ep11(struct ap_device *ap_dev, | ||
834 | struct ap_message *msg, | ||
835 | struct ap_message *reply) | ||
836 | { | ||
837 | static struct error_hdr error_reply = { | ||
838 | .type = TYPE82_RSP_CODE, | ||
839 | .reply_code = REP82_ERROR_MACHINE_FAILURE, | ||
840 | }; | ||
841 | struct response_type *resp_type = | ||
842 | (struct response_type *)msg->private; | ||
843 | struct type86_ep11_reply *t86r; | ||
844 | int length; | ||
845 | |||
846 | /* Copy the reply message to the request message buffer. */ | ||
847 | if (IS_ERR(reply)) { | ||
848 | memcpy(msg->message, &error_reply, sizeof(error_reply)); | ||
849 | goto out; | ||
850 | } | ||
851 | t86r = reply->message; | ||
852 | if (t86r->hdr.type == TYPE86_RSP_CODE && | ||
853 | t86r->cprbx.cprb_ver_id == 0x04) { | ||
854 | switch (resp_type->type) { | ||
855 | case PCIXCC_RESPONSE_TYPE_EP11: | ||
856 | length = t86r->fmt2.offset1 + t86r->fmt2.count1; | ||
857 | length = min(MSGTYPE06_MAX_MSG_SIZE, length); | ||
858 | memcpy(msg->message, reply->message, length); | ||
859 | break; | ||
860 | default: | ||
861 | memcpy(msg->message, &error_reply, sizeof(error_reply)); | ||
862 | } | ||
863 | } else { | ||
864 | memcpy(msg->message, reply->message, sizeof(error_reply)); | ||
865 | } | ||
866 | out: | ||
867 | complete(&(resp_type->work)); | ||
868 | } | ||
869 | |||
660 | static atomic_t zcrypt_step = ATOMIC_INIT(0); | 870 | static atomic_t zcrypt_step = ATOMIC_INIT(0); |
661 | 871 | ||
662 | /** | 872 | /** |
@@ -782,6 +992,46 @@ out_free: | |||
782 | } | 992 | } |
783 | 993 | ||
784 | /** | 994 | /** |
995 | * The request distributor calls this function if it picked the CEX4P | ||
996 | * device to handle a send_ep11_cprb request. | ||
997 | * @zdev: pointer to zcrypt_device structure that identifies the | ||
998 | * CEX4P device to the request distributor | ||
999 | * @xcRB: pointer to the ep11 user request block | ||
1000 | */ | ||
1001 | static long zcrypt_msgtype6_send_ep11_cprb(struct zcrypt_device *zdev, | ||
1002 | struct ep11_urb *xcrb) | ||
1003 | { | ||
1004 | struct ap_message ap_msg; | ||
1005 | struct response_type resp_type = { | ||
1006 | .type = PCIXCC_RESPONSE_TYPE_EP11, | ||
1007 | }; | ||
1008 | int rc; | ||
1009 | |||
1010 | ap_init_message(&ap_msg); | ||
1011 | ap_msg.message = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL); | ||
1012 | if (!ap_msg.message) | ||
1013 | return -ENOMEM; | ||
1014 | ap_msg.receive = zcrypt_msgtype6_receive_ep11; | ||
1015 | ap_msg.psmid = (((unsigned long long) current->pid) << 32) + | ||
1016 | atomic_inc_return(&zcrypt_step); | ||
1017 | ap_msg.private = &resp_type; | ||
1018 | rc = xcrb_msg_to_type6_ep11cprb_msgx(zdev, &ap_msg, xcrb); | ||
1019 | if (rc) | ||
1020 | goto out_free; | ||
1021 | init_completion(&resp_type.work); | ||
1022 | ap_queue_message(zdev->ap_dev, &ap_msg); | ||
1023 | rc = wait_for_completion_interruptible(&resp_type.work); | ||
1024 | if (rc == 0) | ||
1025 | rc = convert_response_ep11_xcrb(zdev, &ap_msg, xcrb); | ||
1026 | else /* Signal pending. */ | ||
1027 | ap_cancel_message(zdev->ap_dev, &ap_msg); | ||
1028 | |||
1029 | out_free: | ||
1030 | kzfree(ap_msg.message); | ||
1031 | return rc; | ||
1032 | } | ||
1033 | |||
1034 | /** | ||
785 | * The request distributor calls this function if it picked the PCIXCC/CEX2C | 1035 | * The request distributor calls this function if it picked the PCIXCC/CEX2C |
786 | * device to generate random data. | 1036 | * device to generate random data. |
787 | * @zdev: pointer to zcrypt_device structure that identifies the | 1037 | * @zdev: pointer to zcrypt_device structure that identifies the |
@@ -839,10 +1089,19 @@ static struct zcrypt_ops zcrypt_msgtype6_ops = { | |||
839 | .rng = zcrypt_msgtype6_rng, | 1089 | .rng = zcrypt_msgtype6_rng, |
840 | }; | 1090 | }; |
841 | 1091 | ||
1092 | static struct zcrypt_ops zcrypt_msgtype6_ep11_ops = { | ||
1093 | .owner = THIS_MODULE, | ||
1094 | .variant = MSGTYPE06_VARIANT_EP11, | ||
1095 | .rsa_modexpo = NULL, | ||
1096 | .rsa_modexpo_crt = NULL, | ||
1097 | .send_ep11_cprb = zcrypt_msgtype6_send_ep11_cprb, | ||
1098 | }; | ||
1099 | |||
842 | int __init zcrypt_msgtype6_init(void) | 1100 | int __init zcrypt_msgtype6_init(void) |
843 | { | 1101 | { |
844 | zcrypt_msgtype_register(&zcrypt_msgtype6_norng_ops); | 1102 | zcrypt_msgtype_register(&zcrypt_msgtype6_norng_ops); |
845 | zcrypt_msgtype_register(&zcrypt_msgtype6_ops); | 1103 | zcrypt_msgtype_register(&zcrypt_msgtype6_ops); |
1104 | zcrypt_msgtype_register(&zcrypt_msgtype6_ep11_ops); | ||
846 | return 0; | 1105 | return 0; |
847 | } | 1106 | } |
848 | 1107 | ||
@@ -850,6 +1109,7 @@ void __exit zcrypt_msgtype6_exit(void) | |||
850 | { | 1109 | { |
851 | zcrypt_msgtype_unregister(&zcrypt_msgtype6_norng_ops); | 1110 | zcrypt_msgtype_unregister(&zcrypt_msgtype6_norng_ops); |
852 | zcrypt_msgtype_unregister(&zcrypt_msgtype6_ops); | 1111 | zcrypt_msgtype_unregister(&zcrypt_msgtype6_ops); |
1112 | zcrypt_msgtype_unregister(&zcrypt_msgtype6_ep11_ops); | ||
853 | } | 1113 | } |
854 | 1114 | ||
855 | module_init(zcrypt_msgtype6_init); | 1115 | module_init(zcrypt_msgtype6_init); |
diff --git a/drivers/s390/crypto/zcrypt_msgtype6.h b/drivers/s390/crypto/zcrypt_msgtype6.h index 1e500d3c0735..207247570623 100644 --- a/drivers/s390/crypto/zcrypt_msgtype6.h +++ b/drivers/s390/crypto/zcrypt_msgtype6.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #define MSGTYPE06_NAME "zcrypt_msgtype6" | 32 | #define MSGTYPE06_NAME "zcrypt_msgtype6" |
33 | #define MSGTYPE06_VARIANT_DEFAULT 0 | 33 | #define MSGTYPE06_VARIANT_DEFAULT 0 |
34 | #define MSGTYPE06_VARIANT_NORNG 1 | 34 | #define MSGTYPE06_VARIANT_NORNG 1 |
35 | #define MSGTYPE06_VARIANT_EP11 2 | ||
35 | 36 | ||
36 | #define MSGTYPE06_MAX_MSG_SIZE (12*1024) | 37 | #define MSGTYPE06_MAX_MSG_SIZE (12*1024) |
37 | 38 | ||
@@ -99,6 +100,7 @@ struct type86_hdr { | |||
99 | } __packed; | 100 | } __packed; |
100 | 101 | ||
101 | #define TYPE86_RSP_CODE 0x86 | 102 | #define TYPE86_RSP_CODE 0x86 |
103 | #define TYPE87_RSP_CODE 0x87 | ||
102 | #define TYPE86_FMT2 0x02 | 104 | #define TYPE86_FMT2 0x02 |
103 | 105 | ||
104 | struct type86_fmt2_ext { | 106 | struct type86_fmt2_ext { |
diff --git a/drivers/s390/crypto/zcrypt_pcica.c b/drivers/s390/crypto/zcrypt_pcica.c index f2b71d8df01f..7a743f4c646c 100644 --- a/drivers/s390/crypto/zcrypt_pcica.c +++ b/drivers/s390/crypto/zcrypt_pcica.c | |||
@@ -24,6 +24,9 @@ | |||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #define KMSG_COMPONENT "zcrypt" | ||
28 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | ||
29 | |||
27 | #include <linux/module.h> | 30 | #include <linux/module.h> |
28 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
29 | #include <linux/init.h> | 32 | #include <linux/init.h> |
@@ -199,6 +202,10 @@ static int convert_type84(struct zcrypt_device *zdev, | |||
199 | if (t84h->len < sizeof(*t84h) + outputdatalength) { | 202 | if (t84h->len < sizeof(*t84h) + outputdatalength) { |
200 | /* The result is too short, the PCICA card may not do that.. */ | 203 | /* The result is too short, the PCICA card may not do that.. */ |
201 | zdev->online = 0; | 204 | zdev->online = 0; |
205 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
206 | zdev->ap_dev->qid); | ||
207 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | ||
208 | zdev->ap_dev->qid, zdev->online, t84h->code); | ||
202 | return -EAGAIN; /* repeat the request on a different device. */ | 209 | return -EAGAIN; /* repeat the request on a different device. */ |
203 | } | 210 | } |
204 | BUG_ON(t84h->len > PCICA_MAX_RESPONSE_SIZE); | 211 | BUG_ON(t84h->len > PCICA_MAX_RESPONSE_SIZE); |
@@ -223,6 +230,10 @@ static int convert_response(struct zcrypt_device *zdev, | |||
223 | outputdata, outputdatalength); | 230 | outputdata, outputdatalength); |
224 | default: /* Unknown response type, this should NEVER EVER happen */ | 231 | default: /* Unknown response type, this should NEVER EVER happen */ |
225 | zdev->online = 0; | 232 | zdev->online = 0; |
233 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
234 | zdev->ap_dev->qid); | ||
235 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | ||
236 | zdev->ap_dev->qid, zdev->online); | ||
226 | return -EAGAIN; /* repeat the request on a different device. */ | 237 | return -EAGAIN; /* repeat the request on a different device. */ |
227 | } | 238 | } |
228 | } | 239 | } |
diff --git a/drivers/s390/crypto/zcrypt_pcicc.c b/drivers/s390/crypto/zcrypt_pcicc.c index 0d90a4334055..4d14c04b746e 100644 --- a/drivers/s390/crypto/zcrypt_pcicc.c +++ b/drivers/s390/crypto/zcrypt_pcicc.c | |||
@@ -24,6 +24,9 @@ | |||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #define KMSG_COMPONENT "zcrypt" | ||
28 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | ||
29 | |||
27 | #include <linux/module.h> | 30 | #include <linux/module.h> |
28 | #include <linux/init.h> | 31 | #include <linux/init.h> |
29 | #include <linux/gfp.h> | 32 | #include <linux/gfp.h> |
@@ -372,6 +375,11 @@ static int convert_type86(struct zcrypt_device *zdev, | |||
372 | if (service_rc == 8 && service_rs == 72) | 375 | if (service_rc == 8 && service_rs == 72) |
373 | return -EINVAL; | 376 | return -EINVAL; |
374 | zdev->online = 0; | 377 | zdev->online = 0; |
378 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
379 | zdev->ap_dev->qid); | ||
380 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | ||
381 | zdev->ap_dev->qid, zdev->online, | ||
382 | msg->hdr.reply_code); | ||
375 | return -EAGAIN; /* repeat the request on a different device. */ | 383 | return -EAGAIN; /* repeat the request on a different device. */ |
376 | } | 384 | } |
377 | data = msg->text; | 385 | data = msg->text; |
@@ -425,6 +433,10 @@ static int convert_response(struct zcrypt_device *zdev, | |||
425 | /* no break, incorrect cprb version is an unknown response */ | 433 | /* no break, incorrect cprb version is an unknown response */ |
426 | default: /* Unknown response type, this should NEVER EVER happen */ | 434 | default: /* Unknown response type, this should NEVER EVER happen */ |
427 | zdev->online = 0; | 435 | zdev->online = 0; |
436 | pr_err("Cryptographic device %x failed and was set offline\n", | ||
437 | zdev->ap_dev->qid); | ||
438 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | ||
439 | zdev->ap_dev->qid, zdev->online); | ||
428 | return -EAGAIN; /* repeat the request on a different device. */ | 440 | return -EAGAIN; /* repeat the request on a different device. */ |
429 | } | 441 | } |
430 | } | 442 | } |