aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/s390/crypto/zcrypt_api.c24
-rw-r--r--drivers/s390/crypto/zcrypt_api.h28
-rw-r--r--drivers/s390/crypto/zcrypt_cex2a.c3
-rw-r--r--drivers/s390/crypto/zcrypt_error.h6
-rw-r--r--drivers/s390/crypto/zcrypt_pcica.c3
-rw-r--r--drivers/s390/crypto/zcrypt_pcicc.c15
-rw-r--r--drivers/s390/crypto/zcrypt_pcixcc.c68
7 files changed, 17 insertions, 130 deletions
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index 4d36e805a234..8a4964f3584b 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -1068,10 +1068,8 @@ static int zcrypt_status_write(struct file *file, const char __user *buffer,
1068 1068
1069#define LBUFSIZE 1200UL 1069#define LBUFSIZE 1200UL
1070 lbuf = kmalloc(LBUFSIZE, GFP_KERNEL); 1070 lbuf = kmalloc(LBUFSIZE, GFP_KERNEL);
1071 if (!lbuf) { 1071 if (!lbuf)
1072 PRINTK("kmalloc failed!\n");
1073 return 0; 1072 return 0;
1074 }
1075 1073
1076 local_count = min(LBUFSIZE - 1, count); 1074 local_count = min(LBUFSIZE - 1, count);
1077 if (copy_from_user(lbuf, buffer, local_count) != 0) { 1075 if (copy_from_user(lbuf, buffer, local_count) != 0) {
@@ -1081,23 +1079,15 @@ static int zcrypt_status_write(struct file *file, const char __user *buffer,
1081 lbuf[local_count] = '\0'; 1079 lbuf[local_count] = '\0';
1082 1080
1083 ptr = strstr(lbuf, "Online devices"); 1081 ptr = strstr(lbuf, "Online devices");
1084 if (!ptr) { 1082 if (!ptr)
1085 PRINTK("Unable to parse data (missing \"Online devices\")\n");
1086 goto out; 1083 goto out;
1087 }
1088 ptr = strstr(ptr, "\n"); 1084 ptr = strstr(ptr, "\n");
1089 if (!ptr) { 1085 if (!ptr)
1090 PRINTK("Unable to parse data (missing newline "
1091 "after \"Online devices\")\n");
1092 goto out; 1086 goto out;
1093 }
1094 ptr++; 1087 ptr++;
1095 1088
1096 if (strstr(ptr, "Waiting work element counts") == NULL) { 1089 if (strstr(ptr, "Waiting work element counts") == NULL)
1097 PRINTK("Unable to parse data (missing "
1098 "\"Waiting work element counts\")\n");
1099 goto out; 1090 goto out;
1100 }
1101 1091
1102 for (j = 0; j < 64 && *ptr; ptr++) { 1092 for (j = 0; j < 64 && *ptr; ptr++) {
1103 /* 1093 /*
@@ -1197,16 +1187,12 @@ int __init zcrypt_api_init(void)
1197 1187
1198 /* Register the request sprayer. */ 1188 /* Register the request sprayer. */
1199 rc = misc_register(&zcrypt_misc_device); 1189 rc = misc_register(&zcrypt_misc_device);
1200 if (rc < 0) { 1190 if (rc < 0)
1201 PRINTKW(KERN_ERR "misc_register (minor %d) failed with %d\n",
1202 zcrypt_misc_device.minor, rc);
1203 goto out; 1191 goto out;
1204 }
1205 1192
1206 /* Set up the proc file system */ 1193 /* Set up the proc file system */
1207 zcrypt_entry = create_proc_entry("driver/z90crypt", 0644, NULL); 1194 zcrypt_entry = create_proc_entry("driver/z90crypt", 0644, NULL);
1208 if (!zcrypt_entry) { 1195 if (!zcrypt_entry) {
1209 PRINTK("Couldn't create z90crypt proc entry\n");
1210 rc = -ENOMEM; 1196 rc = -ENOMEM;
1211 goto out_misc; 1197 goto out_misc;
1212 } 1198 }
diff --git a/drivers/s390/crypto/zcrypt_api.h b/drivers/s390/crypto/zcrypt_api.h
index 5c6e222b2ac4..1d1ec74dadb2 100644
--- a/drivers/s390/crypto/zcrypt_api.h
+++ b/drivers/s390/crypto/zcrypt_api.h
@@ -30,34 +30,6 @@
30#ifndef _ZCRYPT_API_H_ 30#ifndef _ZCRYPT_API_H_
31#define _ZCRYPT_API_H_ 31#define _ZCRYPT_API_H_
32 32
33/**
34 * Macro definitions
35 *
36 * PDEBUG debugs in the form "zcrypt: function_name -> message"
37 *
38 * PRINTK is like PDEBUG, except that it is always enabled
39 * PRINTKN is like PRINTK, except that it does not include the function name
40 * PRINTKW is like PRINTK, except that it uses KERN_WARNING
41 * PRINTKC is like PRINTK, except that it uses KERN_CRIT
42 */
43#define DEV_NAME "zcrypt"
44
45#define PRINTK(fmt, args...) \
46 printk(KERN_DEBUG DEV_NAME ": %s -> " fmt, __func__ , ## args)
47#define PRINTKN(fmt, args...) \
48 printk(KERN_DEBUG DEV_NAME ": " fmt, ## args)
49#define PRINTKW(fmt, args...) \
50 printk(KERN_WARNING DEV_NAME ": %s -> " fmt, __func__ , ## args)
51#define PRINTKC(fmt, args...) \
52 printk(KERN_CRIT DEV_NAME ": %s -> " fmt, __func__ , ## args)
53
54#ifdef ZCRYPT_DEBUG
55#define PDEBUG(fmt, args...) \
56 printk(KERN_DEBUG DEV_NAME ": %s -> " fmt, __func__ , ## args)
57#else
58#define PDEBUG(fmt, args...) do {} while (0)
59#endif
60
61#include "ap_bus.h" 33#include "ap_bus.h"
62#include <asm/zcrypt.h> 34#include <asm/zcrypt.h>
63 35
diff --git a/drivers/s390/crypto/zcrypt_cex2a.c b/drivers/s390/crypto/zcrypt_cex2a.c
index 78ffba1dd613..54f4cbc3be9e 100644
--- a/drivers/s390/crypto/zcrypt_cex2a.c
+++ b/drivers/s390/crypto/zcrypt_cex2a.c
@@ -243,9 +243,6 @@ static int convert_response(struct zcrypt_device *zdev,
243 return convert_type80(zdev, reply, 243 return convert_type80(zdev, reply,
244 outputdata, outputdatalength); 244 outputdata, outputdatalength);
245 default: /* Unknown response type, this should NEVER EVER happen */ 245 default: /* Unknown response type, this should NEVER EVER happen */
246 PRINTK("Unrecognized Message Header: %08x%08x\n",
247 *(unsigned int *) reply->message,
248 *(unsigned int *) (reply->message+4));
249 zdev->online = 0; 246 zdev->online = 0;
250 return -EAGAIN; /* repeat the request on a different device. */ 247 return -EAGAIN; /* repeat the request on a different device. */
251 } 248 }
diff --git a/drivers/s390/crypto/zcrypt_error.h b/drivers/s390/crypto/zcrypt_error.h
index 3e27fe77d207..03ba27f05f92 100644
--- a/drivers/s390/crypto/zcrypt_error.h
+++ b/drivers/s390/crypto/zcrypt_error.h
@@ -92,10 +92,6 @@ static inline int convert_error(struct zcrypt_device *zdev,
92{ 92{
93 struct error_hdr *ehdr = reply->message; 93 struct error_hdr *ehdr = reply->message;
94 94
95 PRINTK("Hardware error : Type %02x Message Header: %08x%08x\n",
96 ehdr->type, *(unsigned int *) reply->message,
97 *(unsigned int *) (reply->message + 4));
98
99 switch (ehdr->reply_code) { 95 switch (ehdr->reply_code) {
100 case REP82_ERROR_OPERAND_INVALID: 96 case REP82_ERROR_OPERAND_INVALID:
101 case REP82_ERROR_OPERAND_SIZE: 97 case REP82_ERROR_OPERAND_SIZE:
@@ -123,8 +119,6 @@ static inline int convert_error(struct zcrypt_device *zdev,
123 zdev->online = 0; 119 zdev->online = 0;
124 return -EAGAIN; 120 return -EAGAIN;
125 default: 121 default:
126 PRINTKW("unknown type %02x reply code = %d\n",
127 ehdr->type, ehdr->reply_code);
128 zdev->online = 0; 122 zdev->online = 0;
129 return -EAGAIN; /* repeat the request on a different device. */ 123 return -EAGAIN; /* repeat the request on a different device. */
130 } 124 }
diff --git a/drivers/s390/crypto/zcrypt_pcica.c b/drivers/s390/crypto/zcrypt_pcica.c
index 6e93b4751782..12da4815ba8e 100644
--- a/drivers/s390/crypto/zcrypt_pcica.c
+++ b/drivers/s390/crypto/zcrypt_pcica.c
@@ -226,9 +226,6 @@ static int convert_response(struct zcrypt_device *zdev,
226 return convert_type84(zdev, reply, 226 return convert_type84(zdev, reply,
227 outputdata, outputdatalength); 227 outputdata, outputdatalength);
228 default: /* Unknown response type, this should NEVER EVER happen */ 228 default: /* Unknown response type, this should NEVER EVER happen */
229 PRINTK("Unrecognized Message Header: %08x%08x\n",
230 *(unsigned int *) reply->message,
231 *(unsigned int *) (reply->message+4));
232 zdev->online = 0; 229 zdev->online = 0;
233 return -EAGAIN; /* repeat the request on a different device. */ 230 return -EAGAIN; /* repeat the request on a different device. */
234 } 231 }
diff --git a/drivers/s390/crypto/zcrypt_pcicc.c b/drivers/s390/crypto/zcrypt_pcicc.c
index 17ea56ce1c11..779952cb19fc 100644
--- a/drivers/s390/crypto/zcrypt_pcicc.c
+++ b/drivers/s390/crypto/zcrypt_pcicc.c
@@ -361,26 +361,18 @@ static int convert_type86(struct zcrypt_device *zdev,
361 service_rc = le16_to_cpu(msg->cprb.ccp_rtcode); 361 service_rc = le16_to_cpu(msg->cprb.ccp_rtcode);
362 if (unlikely(service_rc != 0)) { 362 if (unlikely(service_rc != 0)) {
363 service_rs = le16_to_cpu(msg->cprb.ccp_rscode); 363 service_rs = le16_to_cpu(msg->cprb.ccp_rscode);
364 if (service_rc == 8 && service_rs == 66) { 364 if (service_rc == 8 && service_rs == 66)
365 PDEBUG("Bad block format on PCICC\n");
366 return -EINVAL; 365 return -EINVAL;
367 } 366 if (service_rc == 8 && service_rs == 65)
368 if (service_rc == 8 && service_rs == 65) {
369 PDEBUG("Probably an even modulus on PCICC\n");
370 return -EINVAL; 367 return -EINVAL;
371 }
372 if (service_rc == 8 && service_rs == 770) { 368 if (service_rc == 8 && service_rs == 770) {
373 PDEBUG("Invalid key length on PCICC\n");
374 zdev->max_mod_size = PCICC_MAX_MOD_SIZE_OLD; 369 zdev->max_mod_size = PCICC_MAX_MOD_SIZE_OLD;
375 return -EAGAIN; 370 return -EAGAIN;
376 } 371 }
377 if (service_rc == 8 && service_rs == 783) { 372 if (service_rc == 8 && service_rs == 783) {
378 PDEBUG("Extended bitlengths not enabled on PCICC\n");
379 zdev->max_mod_size = PCICC_MAX_MOD_SIZE_OLD; 373 zdev->max_mod_size = PCICC_MAX_MOD_SIZE_OLD;
380 return -EAGAIN; 374 return -EAGAIN;
381 } 375 }
382 PRINTK("Unknown service rc/rs (PCICC): %d/%d\n",
383 service_rc, service_rs);
384 zdev->online = 0; 376 zdev->online = 0;
385 return -EAGAIN; /* repeat the request on a different device. */ 377 return -EAGAIN; /* repeat the request on a different device. */
386 } 378 }
@@ -434,9 +426,6 @@ static int convert_response(struct zcrypt_device *zdev,
434 outputdata, outputdatalength); 426 outputdata, outputdatalength);
435 /* no break, incorrect cprb version is an unknown response */ 427 /* no break, incorrect cprb version is an unknown response */
436 default: /* Unknown response type, this should NEVER EVER happen */ 428 default: /* Unknown response type, this should NEVER EVER happen */
437 PRINTK("Unrecognized Message Header: %08x%08x\n",
438 *(unsigned int *) reply->message,
439 *(unsigned int *) (reply->message+4));
440 zdev->online = 0; 429 zdev->online = 0;
441 return -EAGAIN; /* repeat the request on a different device. */ 430 return -EAGAIN; /* repeat the request on a different device. */
442 } 431 }
diff --git a/drivers/s390/crypto/zcrypt_pcixcc.c b/drivers/s390/crypto/zcrypt_pcixcc.c
index 4040c1c981d1..d8ad36f81540 100644
--- a/drivers/s390/crypto/zcrypt_pcixcc.c
+++ b/drivers/s390/crypto/zcrypt_pcixcc.c
@@ -290,38 +290,19 @@ static int XCRB_msg_to_type6CPRB_msgX(struct zcrypt_device *zdev,
290 ap_msg->length = sizeof(struct type6_hdr) + 290 ap_msg->length = sizeof(struct type6_hdr) +
291 CEIL4(xcRB->request_control_blk_length) + 291 CEIL4(xcRB->request_control_blk_length) +
292 xcRB->request_data_length; 292 xcRB->request_data_length;
293 if (ap_msg->length > PCIXCC_MAX_XCRB_MESSAGE_SIZE) { 293 if (ap_msg->length > PCIXCC_MAX_XCRB_MESSAGE_SIZE)
294 PRINTK("Combined message is too large (%ld/%d/%d).\n",
295 sizeof(struct type6_hdr),
296 xcRB->request_control_blk_length,
297 xcRB->request_data_length);
298 return -EFAULT; 294 return -EFAULT;
299 } 295 if (CEIL4(xcRB->reply_control_blk_length) > PCIXCC_MAX_XCRB_REPLY_SIZE)
300 if (CEIL4(xcRB->reply_control_blk_length) >
301 PCIXCC_MAX_XCRB_REPLY_SIZE) {
302 PDEBUG("Reply CPRB length is too large (%d).\n",
303 xcRB->request_control_blk_length);
304 return -EFAULT; 296 return -EFAULT;
305 } 297 if (CEIL4(xcRB->reply_data_length) > PCIXCC_MAX_XCRB_DATA_SIZE)
306 if (CEIL4(xcRB->reply_data_length) > PCIXCC_MAX_XCRB_DATA_SIZE) {
307 PDEBUG("Reply data block length is too large (%d).\n",
308 xcRB->reply_data_length);
309 return -EFAULT; 298 return -EFAULT;
310 }
311 replylen = CEIL4(xcRB->reply_control_blk_length) + 299 replylen = CEIL4(xcRB->reply_control_blk_length) +
312 CEIL4(xcRB->reply_data_length) + 300 CEIL4(xcRB->reply_data_length) +
313 sizeof(struct type86_fmt2_msg); 301 sizeof(struct type86_fmt2_msg);
314 if (replylen > PCIXCC_MAX_XCRB_RESPONSE_SIZE) { 302 if (replylen > PCIXCC_MAX_XCRB_RESPONSE_SIZE) {
315 PDEBUG("Reply CPRB + data block > PCIXCC_MAX_XCRB_RESPONSE_SIZE"
316 " (%d/%d/%d).\n",
317 sizeof(struct type86_fmt2_msg),
318 xcRB->reply_control_blk_length,
319 xcRB->reply_data_length);
320 xcRB->reply_control_blk_length = PCIXCC_MAX_XCRB_RESPONSE_SIZE - 303 xcRB->reply_control_blk_length = PCIXCC_MAX_XCRB_RESPONSE_SIZE -
321 (sizeof(struct type86_fmt2_msg) + 304 (sizeof(struct type86_fmt2_msg) +
322 CEIL4(xcRB->reply_data_length)); 305 CEIL4(xcRB->reply_data_length));
323 PDEBUG("Capping Reply CPRB length at %d\n",
324 xcRB->reply_control_blk_length);
325 } 306 }
326 307
327 /* prepare type6 header */ 308 /* prepare type6 header */
@@ -340,11 +321,8 @@ static int XCRB_msg_to_type6CPRB_msgX(struct zcrypt_device *zdev,
340 xcRB->request_control_blk_length)) 321 xcRB->request_control_blk_length))
341 return -EFAULT; 322 return -EFAULT;
342 if (msg->cprbx.cprb_len + sizeof(msg->hdr.function_code) > 323 if (msg->cprbx.cprb_len + sizeof(msg->hdr.function_code) >
343 xcRB->request_control_blk_length) { 324 xcRB->request_control_blk_length)
344 PDEBUG("cprb_len too large (%d/%d)\n", msg->cprbx.cprb_len,
345 xcRB->request_control_blk_length);
346 return -EFAULT; 325 return -EFAULT;
347 }
348 function_code = ((unsigned char *)&msg->cprbx) + msg->cprbx.cprb_len; 326 function_code = ((unsigned char *)&msg->cprbx) + msg->cprbx.cprb_len;
349 memcpy(msg->hdr.function_code, function_code, sizeof(msg->hdr.function_code)); 327 memcpy(msg->hdr.function_code, function_code, sizeof(msg->hdr.function_code));
350 328
@@ -472,29 +450,18 @@ static int convert_type86_ica(struct zcrypt_device *zdev,
472 service_rc = msg->cprbx.ccp_rtcode; 450 service_rc = msg->cprbx.ccp_rtcode;
473 if (unlikely(service_rc != 0)) { 451 if (unlikely(service_rc != 0)) {
474 service_rs = msg->cprbx.ccp_rscode; 452 service_rs = msg->cprbx.ccp_rscode;
475 if (service_rc == 8 && service_rs == 66) { 453 if (service_rc == 8 && service_rs == 66)
476 PDEBUG("Bad block format on PCIXCC/CEX2C\n");
477 return -EINVAL; 454 return -EINVAL;
478 } 455 if (service_rc == 8 && service_rs == 65)
479 if (service_rc == 8 && service_rs == 65) {
480 PDEBUG("Probably an even modulus on PCIXCC/CEX2C\n");
481 return -EINVAL; 456 return -EINVAL;
482 } 457 if (service_rc == 8 && service_rs == 770)
483 if (service_rc == 8 && service_rs == 770) {
484 PDEBUG("Invalid key length on PCIXCC/CEX2C\n");
485 return -EINVAL; 458 return -EINVAL;
486 }
487 if (service_rc == 8 && service_rs == 783) { 459 if (service_rc == 8 && service_rs == 783) {
488 PDEBUG("Extended bitlengths not enabled on PCIXCC/CEX2C\n");
489 zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE_OLD; 460 zdev->min_mod_size = PCIXCC_MIN_MOD_SIZE_OLD;
490 return -EAGAIN; 461 return -EAGAIN;
491 } 462 }
492 if (service_rc == 12 && service_rs == 769) { 463 if (service_rc == 12 && service_rs == 769)
493 PDEBUG("Invalid key on PCIXCC/CEX2C\n");
494 return -EINVAL; 464 return -EINVAL;
495 }
496 PRINTK("Unknown service rc/rs (PCIXCC/CEX2C): %d/%d\n",
497 service_rc, service_rs);
498 zdev->online = 0; 465 zdev->online = 0;
499 return -EAGAIN; /* repeat the request on a different device. */ 466 return -EAGAIN; /* repeat the request on a different device. */
500 } 467 }
@@ -570,11 +537,8 @@ static int convert_type86_rng(struct zcrypt_device *zdev,
570 } __attribute__((packed)) *msg = reply->message; 537 } __attribute__((packed)) *msg = reply->message;
571 char *data = reply->message; 538 char *data = reply->message;
572 539
573 if (msg->cprbx.ccp_rtcode != 0 || msg->cprbx.ccp_rscode != 0) { 540 if (msg->cprbx.ccp_rtcode != 0 || msg->cprbx.ccp_rscode != 0)
574 PDEBUG("RNG response error on PCIXCC/CEX2C rc=%hu/rs=%hu\n",
575 rc, rs);
576 return -EINVAL; 541 return -EINVAL;
577 }
578 memcpy(buffer, data + msg->fmt2.offset2, msg->fmt2.count2); 542 memcpy(buffer, data + msg->fmt2.offset2, msg->fmt2.count2);
579 return msg->fmt2.count2; 543 return msg->fmt2.count2;
580} 544}
@@ -599,9 +563,6 @@ static int convert_response_ica(struct zcrypt_device *zdev,
599 outputdata, outputdatalength); 563 outputdata, outputdatalength);
600 /* no break, incorrect cprb version is an unknown response */ 564 /* no break, incorrect cprb version is an unknown response */
601 default: /* Unknown response type, this should NEVER EVER happen */ 565 default: /* Unknown response type, this should NEVER EVER happen */
602 PRINTK("Unrecognized Message Header: %08x%08x\n",
603 *(unsigned int *) reply->message,
604 *(unsigned int *) (reply->message+4));
605 zdev->online = 0; 566 zdev->online = 0;
606 return -EAGAIN; /* repeat the request on a different device. */ 567 return -EAGAIN; /* repeat the request on a different device. */
607 } 568 }
@@ -628,9 +589,6 @@ static int convert_response_xcrb(struct zcrypt_device *zdev,
628 return convert_type86_xcrb(zdev, reply, xcRB); 589 return convert_type86_xcrb(zdev, reply, xcRB);
629 /* no break, incorrect cprb version is an unknown response */ 590 /* no break, incorrect cprb version is an unknown response */
630 default: /* Unknown response type, this should NEVER EVER happen */ 591 default: /* Unknown response type, this should NEVER EVER happen */
631 PRINTK("Unrecognized Message Header: %08x%08x\n",
632 *(unsigned int *) reply->message,
633 *(unsigned int *) (reply->message+4));
634 xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ 592 xcRB->status = 0x0008044DL; /* HDD_InvalidParm */
635 zdev->online = 0; 593 zdev->online = 0;
636 return -EAGAIN; /* repeat the request on a different device. */ 594 return -EAGAIN; /* repeat the request on a different device. */
@@ -654,9 +612,6 @@ static int convert_response_rng(struct zcrypt_device *zdev,
654 return convert_type86_rng(zdev, reply, data); 612 return convert_type86_rng(zdev, reply, data);
655 /* no break, incorrect cprb version is an unknown response */ 613 /* no break, incorrect cprb version is an unknown response */
656 default: /* Unknown response type, this should NEVER EVER happen */ 614 default: /* Unknown response type, this should NEVER EVER happen */
657 PRINTK("Unrecognized Message Header: %08x%08x\n",
658 *(unsigned int *) reply->message,
659 *(unsigned int *) (reply->message+4));
660 zdev->online = 0; 615 zdev->online = 0;
661 return -EAGAIN; /* repeat the request on a different device. */ 616 return -EAGAIN; /* repeat the request on a different device. */
662 } 617 }
@@ -701,10 +656,7 @@ static void zcrypt_pcixcc_receive(struct ap_device *ap_dev,
701 memcpy(msg->message, reply->message, length); 656 memcpy(msg->message, reply->message, length);
702 break; 657 break;
703 default: 658 default:
704 PRINTK("Invalid internal response type: %i\n", 659 memcpy(msg->message, &error_reply, sizeof error_reply);
705 resp_type->type);
706 memcpy(msg->message, &error_reply,
707 sizeof error_reply);
708 } 660 }
709 } else 661 } else
710 memcpy(msg->message, reply->message, sizeof error_reply); 662 memcpy(msg->message, reply->message, sizeof error_reply);