Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/zcrypt: Support up to 256 crypto adapters.

There was an artificial restriction on the card/adapter id
to only 6 bits but all the AP commands do support adapter
ids with 8 bit. This patch removes this restriction to 64
adapters and now up to 256 adapter can get addressed.

Some of the ioctl calls work on the max number of cards
possible (which was 64). These ioctls are now deprecated
but still supported. All the defines, structs and ioctl
interface declarations have been kept for compabibility.
There are now new ioctls (and defines for these) with an
additional '2' appended which provide the extended versions
with 256 cards supported.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Harald Freudenberger and committed by
Martin Schwidefsky
af4a7227 71cbbff8

+237 -120
+3 -3
arch/s390/include/asm/ap.h
··· 20 20 */ 21 21 typedef unsigned int ap_qid_t; 22 22 23 - #define AP_MKQID(_card, _queue) (((_card) & 63) << 8 | ((_queue) & 255)) 24 - #define AP_QID_CARD(_qid) (((_qid) >> 8) & 63) 25 - #define AP_QID_QUEUE(_qid) ((_qid) & 255) 23 + #define AP_MKQID(_card, _queue) (((_card) & 0xff) << 8 | ((_queue) & 0xff)) 24 + #define AP_QID_CARD(_qid) (((_qid) >> 8) & 0xff) 25 + #define AP_QID_QUEUE(_qid) ((_qid) & 0xff) 26 26 27 27 /** 28 28 * struct ap_queue_status - Holds the AP queue status.
+78 -46
arch/s390/include/uapi/asm/zcrypt.h
··· 203 203 } __attribute__((packed)); 204 204 205 205 /** 206 - * struct zcrypt_device_status 206 + * struct zcrypt_device_status_ext 207 207 * @hwtype: raw hardware type 208 - * @qid: 6 bit device index, 8 bit domain 208 + * @qid: 8 bit device index, 8 bit domain 209 209 * @functions: AP device function bit field 'abcdef' 210 210 * a, b, c = reserved 211 211 * d = CCA coprocessor ··· 214 214 * @online online status 215 215 * @reserved reserved 216 216 */ 217 - struct zcrypt_device_status { 217 + struct zcrypt_device_status_ext { 218 218 unsigned int hwtype:8; 219 - unsigned int qid:14; 219 + unsigned int qid:16; 220 220 unsigned int online:1; 221 221 unsigned int functions:6; 222 - unsigned int reserved:3; 222 + unsigned int reserved:1; 223 223 }; 224 224 225 - #define MAX_ZDEV_CARDIDS 64 226 - #define MAX_ZDEV_DOMAINS 256 225 + #define MAX_ZDEV_CARDIDS_EXT 256 226 + #define MAX_ZDEV_DOMAINS_EXT 256 227 227 228 - /** 229 - * Maximum number of zcrypt devices 230 - */ 231 - #define MAX_ZDEV_ENTRIES (MAX_ZDEV_CARDIDS * MAX_ZDEV_DOMAINS) 228 + /* Maximum number of zcrypt devices */ 229 + #define MAX_ZDEV_ENTRIES_EXT (MAX_ZDEV_CARDIDS_EXT * MAX_ZDEV_DOMAINS_EXT) 232 230 233 - /** 234 - * zcrypt_device_matrix 235 - * Device matrix of all zcrypt devices 236 - */ 237 - struct zcrypt_device_matrix { 238 - struct zcrypt_device_status device[MAX_ZDEV_ENTRIES]; 231 + /* Device matrix of all zcrypt devices */ 232 + struct zcrypt_device_matrix_ext { 233 + struct zcrypt_device_status_ext device[MAX_ZDEV_ENTRIES_EXT]; 239 234 }; 240 235 241 236 #define AUTOSELECT ((unsigned int)0xFFFFFFFF) ··· 265 270 * ZSENDEP11CPRB 266 271 * Send an arbitrary EP11 CPRB to an EP11 coprocessor crypto card. 267 272 * 268 - * Z90STAT_STATUS_MASK 269 - * Return an 64 element array of unsigned chars for the status of 270 - * all devices. 273 + * ZCRYPT_DEVICE_STATUS 274 + * The given struct zcrypt_device_matrix_ext is updated with 275 + * status information for each currently known apqn. 276 + * 277 + * ZCRYPT_STATUS_MASK 278 + * Return an MAX_ZDEV_CARDIDS_EXT element array of unsigned chars for the 279 + * status of all devices. 271 280 * 0x01: PCICA 272 281 * 0x02: PCICC 273 282 * 0x03: PCIXCC_MCL2 274 283 * 0x04: PCIXCC_MCL3 275 284 * 0x05: CEX2C 276 285 * 0x06: CEX2A 277 - * 0x0d: device is disabled via the proc filesystem 286 + * 0x07: CEX3C 287 + * 0x08: CEX3A 288 + * 0x0a: CEX4 289 + * 0x0b: CEX5 290 + * 0x0c: CEX6 291 + * 0x0d: device is disabled 278 292 * 279 - * Z90STAT_QDEPTH_MASK 280 - * Return an 64 element array of unsigned chars for the queue 281 - * depth of all devices. 293 + * ZCRYPT_QDEPTH_MASK 294 + * Return an MAX_ZDEV_CARDIDS_EXT element array of unsigned chars for the 295 + * queue depth of all devices. 282 296 * 283 - * Z90STAT_PERDEV_REQCNT 284 - * Return an 64 element array of unsigned integers for the number 285 - * of successfully completed requests per device since the device 286 - * was detected and made available. 297 + * ZCRYPT_PERDEV_REQCNT 298 + * Return an MAX_ZDEV_CARDIDS_EXT element array of unsigned integers for 299 + * the number of successfully completed requests per device since the 300 + * device was detected and made available. 287 301 * 288 - * Z90STAT_REQUESTQ_COUNT 289 - * Return an integer count of the number of entries waiting to be 290 - * sent to a device. 291 - * 292 - * Z90STAT_PENDINGQ_COUNT 293 - * Return an integer count of the number of entries sent to all 294 - * devices awaiting the reply. 295 - * 296 - * Z90STAT_TOTALOPEN_COUNT 297 - * Return an integer count of the number of open file handles. 298 - * 299 - * Z90STAT_DOMAIN_INDEX 300 - * Return the integer value of the Cryptographic Domain. 301 302 */ 302 303 303 304 /** ··· 303 312 #define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0) 304 313 #define ZSECSENDCPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x81, 0) 305 314 #define ZSENDEP11CPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x04, 0) 306 - #define ZDEVICESTATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x4f, 0) 307 315 308 - /* Status ioctl calls */ 316 + #define ZCRYPT_DEVICE_STATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x5f, 0) 317 + #define ZCRYPT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x58, char[MAX_ZDEV_CARDIDS_EXT]) 318 + #define ZCRYPT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x59, char[MAX_ZDEV_CARDIDS_EXT]) 319 + #define ZCRYPT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x5a, int[MAX_ZDEV_CARDIDS_EXT]) 320 + 321 + /* 322 + * Only deprecated defines, structs and ioctls below this line. 323 + */ 324 + 325 + /* Deprecated: use MAX_ZDEV_CARDIDS_EXT */ 326 + #define MAX_ZDEV_CARDIDS 64 327 + /* Deprecated: use MAX_ZDEV_DOMAINS_EXT */ 328 + #define MAX_ZDEV_DOMAINS 256 329 + 330 + /* Deprecated: use MAX_ZDEV_ENTRIES_EXT */ 331 + #define MAX_ZDEV_ENTRIES (MAX_ZDEV_CARDIDS * MAX_ZDEV_DOMAINS) 332 + 333 + /* Deprecated: use struct zcrypt_device_status_ext */ 334 + struct zcrypt_device_status { 335 + unsigned int hwtype:8; 336 + unsigned int qid:14; 337 + unsigned int online:1; 338 + unsigned int functions:6; 339 + unsigned int reserved:3; 340 + }; 341 + 342 + /* Deprecated: use struct zcrypt_device_matrix_ext */ 343 + struct zcrypt_device_matrix { 344 + struct zcrypt_device_status device[MAX_ZDEV_ENTRIES]; 345 + }; 346 + 347 + /* Deprecated: use ZCRYPT_DEVICE_STATUS */ 348 + #define ZDEVICESTATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x4f, 0) 349 + /* Deprecated: use ZCRYPT_STATUS_MASK */ 350 + #define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64]) 351 + /* Deprecated: use ZCRYPT_QDEPTH_MASK */ 352 + #define Z90STAT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x49, char[64]) 353 + /* Deprecated: use ZCRYPT_PERDEV_REQCNT */ 354 + #define Z90STAT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4a, int[64]) 355 + 356 + /* Deprecated: use sysfs to query these values */ 309 357 #define Z90STAT_REQUESTQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x44, int) 310 358 #define Z90STAT_PENDINGQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x45, int) 311 359 #define Z90STAT_TOTALOPEN_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x46, int) 312 360 #define Z90STAT_DOMAIN_INDEX _IOR(ZCRYPT_IOCTL_MAGIC, 0x47, int) 313 - #define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64]) 314 - #define Z90STAT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x49, char[64]) 315 - #define Z90STAT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4a, int[64]) 361 + 362 + /* 363 + * The ioctl number ranges 0x40 - 0x42 and 0x4b - 0x4e had been used in the 364 + * past, don't assign new ioctls for these. 365 + */ 316 366 317 367 #endif /* __ASM_S390_ZCRYPT_H */
+1 -1
drivers/s390/crypto/ap_bus.h
··· 17 17 #include <linux/types.h> 18 18 #include <asm/ap.h> 19 19 20 - #define AP_DEVICES 64 /* Number of AP devices. */ 20 + #define AP_DEVICES 256 /* Number of AP devices. */ 21 21 #define AP_DOMAINS 256 /* Number of AP domains. */ 22 22 #define AP_RESET_TIMEOUT (HZ*0.7) /* Time in ticks for reset timeouts. */ 23 23 #define AP_CONFIG_TIME 30 /* Time in seconds between AP bus rescans. */
+21 -20
drivers/s390/crypto/pkey_api.c
··· 889 889 u16 *pcardnr, u16 *pdomain, int verify) 890 890 { 891 891 struct secaeskeytoken *t = (struct secaeskeytoken *) seckey; 892 - struct zcrypt_device_matrix *device_matrix; 892 + struct zcrypt_device_status_ext *device_status; 893 893 u16 card, dom; 894 894 u64 mkvp[2]; 895 895 int i, rc, oi = -1; ··· 899 899 return -EINVAL; 900 900 901 901 /* fetch status of all crypto cards */ 902 - device_matrix = kmalloc(sizeof(struct zcrypt_device_matrix), 902 + device_status = kmalloc(MAX_ZDEV_ENTRIES_EXT 903 + * sizeof(struct zcrypt_device_status_ext), 903 904 GFP_KERNEL); 904 - if (!device_matrix) 905 + if (!device_status) 905 906 return -ENOMEM; 906 - zcrypt_device_status_mask(device_matrix); 907 + zcrypt_device_status_mask_ext(device_status); 907 908 908 909 /* walk through all crypto cards */ 909 - for (i = 0; i < MAX_ZDEV_ENTRIES; i++) { 910 - card = AP_QID_CARD(device_matrix->device[i].qid); 911 - dom = AP_QID_QUEUE(device_matrix->device[i].qid); 912 - if (device_matrix->device[i].online && 913 - device_matrix->device[i].functions & 0x04) { 910 + for (i = 0; i < MAX_ZDEV_ENTRIES_EXT; i++) { 911 + card = AP_QID_CARD(device_status[i].qid); 912 + dom = AP_QID_QUEUE(device_status[i].qid); 913 + if (device_status[i].online && 914 + device_status[i].functions & 0x04) { 914 915 /* an enabled CCA Coprocessor card */ 915 916 /* try cached mkvp */ 916 917 if (mkvp_cache_fetch(card, dom, mkvp) == 0 && ··· 931 930 mkvp_cache_scrub(card, dom); 932 931 } 933 932 } 934 - if (i >= MAX_ZDEV_ENTRIES) { 933 + if (i >= MAX_ZDEV_ENTRIES_EXT) { 935 934 /* nothing found, so this time without cache */ 936 - for (i = 0; i < MAX_ZDEV_ENTRIES; i++) { 937 - if (!(device_matrix->device[i].online && 938 - device_matrix->device[i].functions & 0x04)) 935 + for (i = 0; i < MAX_ZDEV_ENTRIES_EXT; i++) { 936 + if (!(device_status[i].online && 937 + device_status[i].functions & 0x04)) 939 938 continue; 940 - card = AP_QID_CARD(device_matrix->device[i].qid); 941 - dom = AP_QID_QUEUE(device_matrix->device[i].qid); 939 + card = AP_QID_CARD(device_status[i].qid); 940 + dom = AP_QID_QUEUE(device_status[i].qid); 942 941 /* fresh fetch mkvp from adapter */ 943 942 if (fetch_mkvp(card, dom, mkvp) == 0) { 944 943 mkvp_cache_update(card, dom, mkvp); ··· 948 947 oi = i; 949 948 } 950 949 } 951 - if (i >= MAX_ZDEV_ENTRIES && oi >= 0) { 950 + if (i >= MAX_ZDEV_ENTRIES_EXT && oi >= 0) { 952 951 /* old mkvp matched, use this card then */ 953 - card = AP_QID_CARD(device_matrix->device[oi].qid); 954 - dom = AP_QID_QUEUE(device_matrix->device[oi].qid); 952 + card = AP_QID_CARD(device_status[oi].qid); 953 + dom = AP_QID_QUEUE(device_status[oi].qid); 955 954 } 956 955 } 957 - if (i < MAX_ZDEV_ENTRIES || oi >= 0) { 956 + if (i < MAX_ZDEV_ENTRIES_EXT || oi >= 0) { 958 957 if (pcardnr) 959 958 *pcardnr = card; 960 959 if (pdomain) ··· 963 962 } else 964 963 rc = -ENODEV; 965 964 966 - kfree(device_matrix); 965 + kfree(device_status); 967 966 return rc; 968 967 } 969 968 EXPORT_SYMBOL(pkey_findcard);
+133 -49
drivers/s390/crypto/zcrypt_api.c
··· 605 605 return rc; 606 606 } 607 607 608 - void zcrypt_device_status_mask(struct zcrypt_device_matrix *matrix) 608 + static void zcrypt_device_status_mask(struct zcrypt_device_status *devstatus) 609 609 { 610 610 struct zcrypt_card *zc; 611 611 struct zcrypt_queue *zq; 612 612 struct zcrypt_device_status *stat; 613 + int card, queue; 613 614 614 - memset(matrix, 0, sizeof(*matrix)); 615 + memset(devstatus, 0, MAX_ZDEV_ENTRIES 616 + * sizeof(struct zcrypt_device_status)); 617 + 615 618 spin_lock(&zcrypt_list_lock); 616 619 for_each_zcrypt_card(zc) { 617 620 for_each_zcrypt_queue(zq, zc) { 618 - stat = matrix->device; 619 - stat += AP_QID_CARD(zq->queue->qid) * MAX_ZDEV_DOMAINS; 620 - stat += AP_QID_QUEUE(zq->queue->qid); 621 + card = AP_QID_CARD(zq->queue->qid); 622 + if (card >= MAX_ZDEV_CARDIDS) 623 + continue; 624 + queue = AP_QID_QUEUE(zq->queue->qid); 625 + stat = &devstatus[card * AP_DOMAINS + queue]; 621 626 stat->hwtype = zc->card->ap_dev.device_type; 622 627 stat->functions = zc->card->functions >> 26; 623 628 stat->qid = zq->queue->qid; ··· 631 626 } 632 627 spin_unlock(&zcrypt_list_lock); 633 628 } 634 - EXPORT_SYMBOL(zcrypt_device_status_mask); 635 629 636 - static void zcrypt_status_mask(char status[AP_DEVICES]) 630 + void zcrypt_device_status_mask_ext(struct zcrypt_device_status_ext *devstatus) 637 631 { 638 632 struct zcrypt_card *zc; 639 633 struct zcrypt_queue *zq; 634 + struct zcrypt_device_status_ext *stat; 635 + int card, queue; 640 636 641 - memset(status, 0, sizeof(char) * AP_DEVICES); 637 + memset(devstatus, 0, MAX_ZDEV_ENTRIES_EXT 638 + * sizeof(struct zcrypt_device_status_ext)); 639 + 642 640 spin_lock(&zcrypt_list_lock); 643 641 for_each_zcrypt_card(zc) { 644 642 for_each_zcrypt_queue(zq, zc) { 645 - if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index) 643 + card = AP_QID_CARD(zq->queue->qid); 644 + queue = AP_QID_QUEUE(zq->queue->qid); 645 + stat = &devstatus[card * AP_DOMAINS + queue]; 646 + stat->hwtype = zc->card->ap_dev.device_type; 647 + stat->functions = zc->card->functions >> 26; 648 + stat->qid = zq->queue->qid; 649 + stat->online = zq->online ? 0x01 : 0x00; 650 + } 651 + } 652 + spin_unlock(&zcrypt_list_lock); 653 + } 654 + EXPORT_SYMBOL(zcrypt_device_status_mask_ext); 655 + 656 + static void zcrypt_status_mask(char status[], size_t max_adapters) 657 + { 658 + struct zcrypt_card *zc; 659 + struct zcrypt_queue *zq; 660 + int card; 661 + 662 + memset(status, 0, max_adapters); 663 + spin_lock(&zcrypt_list_lock); 664 + for_each_zcrypt_card(zc) { 665 + for_each_zcrypt_queue(zq, zc) { 666 + card = AP_QID_CARD(zq->queue->qid); 667 + if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index 668 + || card >= max_adapters) 646 669 continue; 647 - status[AP_QID_CARD(zq->queue->qid)] = 648 - zc->online ? zc->user_space_type : 0x0d; 670 + status[card] = zc->online ? zc->user_space_type : 0x0d; 649 671 } 650 672 } 651 673 spin_unlock(&zcrypt_list_lock); 652 674 } 653 675 654 - static void zcrypt_qdepth_mask(char qdepth[AP_DEVICES]) 676 + static void zcrypt_qdepth_mask(char qdepth[], size_t max_adapters) 655 677 { 656 678 struct zcrypt_card *zc; 657 679 struct zcrypt_queue *zq; 680 + int card; 658 681 659 - memset(qdepth, 0, sizeof(char) * AP_DEVICES); 682 + memset(qdepth, 0, max_adapters); 660 683 spin_lock(&zcrypt_list_lock); 661 684 local_bh_disable(); 662 685 for_each_zcrypt_card(zc) { 663 686 for_each_zcrypt_queue(zq, zc) { 664 - if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index) 687 + card = AP_QID_CARD(zq->queue->qid); 688 + if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index 689 + || card >= max_adapters) 665 690 continue; 666 691 spin_lock(&zq->queue->lock); 667 - qdepth[AP_QID_CARD(zq->queue->qid)] = 692 + qdepth[card] = 668 693 zq->queue->pendingq_count + 669 694 zq->queue->requestq_count; 670 695 spin_unlock(&zq->queue->lock); ··· 704 669 spin_unlock(&zcrypt_list_lock); 705 670 } 706 671 707 - static void zcrypt_perdev_reqcnt(int reqcnt[AP_DEVICES]) 672 + static void zcrypt_perdev_reqcnt(int reqcnt[], size_t max_adapters) 708 673 { 709 674 struct zcrypt_card *zc; 710 675 struct zcrypt_queue *zq; 676 + int card; 711 677 712 - memset(reqcnt, 0, sizeof(int) * AP_DEVICES); 678 + memset(reqcnt, 0, sizeof(int) * max_adapters); 713 679 spin_lock(&zcrypt_list_lock); 714 680 local_bh_disable(); 715 681 for_each_zcrypt_card(zc) { 716 682 for_each_zcrypt_queue(zq, zc) { 717 - if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index) 683 + card = AP_QID_CARD(zq->queue->qid); 684 + if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index 685 + || card >= max_adapters) 718 686 continue; 719 687 spin_lock(&zq->queue->lock); 720 - reqcnt[AP_QID_CARD(zq->queue->qid)] = 721 - zq->queue->total_request_count; 688 + reqcnt[card] = zq->queue->total_request_count; 722 689 spin_unlock(&zq->queue->lock); 723 690 } 724 691 } ··· 777 740 static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, 778 741 unsigned long arg) 779 742 { 780 - int rc; 743 + int rc = 0; 781 744 782 745 switch (cmd) { 783 746 case ICARSAMODEXPO: { ··· 856 819 return -EFAULT; 857 820 return rc; 858 821 } 859 - case ZDEVICESTATUS: { 860 - struct zcrypt_device_matrix *device_status; 822 + case ZCRYPT_DEVICE_STATUS: { 823 + struct zcrypt_device_status_ext *device_status; 824 + size_t total_size = MAX_ZDEV_ENTRIES_EXT 825 + * sizeof(struct zcrypt_device_status_ext); 861 826 862 - device_status = kzalloc(sizeof(struct zcrypt_device_matrix), 863 - GFP_KERNEL); 827 + device_status = kzalloc(total_size, GFP_KERNEL); 864 828 if (!device_status) 865 829 return -ENOMEM; 866 - 867 - zcrypt_device_status_mask(device_status); 868 - 830 + zcrypt_device_status_mask_ext(device_status); 869 831 if (copy_to_user((char __user *) arg, device_status, 870 - sizeof(struct zcrypt_device_matrix))) { 871 - kfree(device_status); 872 - return -EFAULT; 873 - } 874 - 832 + total_size)) 833 + rc = -EFAULT; 875 834 kfree(device_status); 876 - return 0; 835 + return rc; 877 836 } 878 - case Z90STAT_STATUS_MASK: { 837 + case ZCRYPT_STATUS_MASK: { 879 838 char status[AP_DEVICES]; 880 - zcrypt_status_mask(status); 881 - if (copy_to_user((char __user *) arg, status, 882 - sizeof(char) * AP_DEVICES)) 839 + 840 + zcrypt_status_mask(status, AP_DEVICES); 841 + if (copy_to_user((char __user *) arg, status, sizeof(status))) 883 842 return -EFAULT; 884 843 return 0; 885 844 } 886 - case Z90STAT_QDEPTH_MASK: { 845 + case ZCRYPT_QDEPTH_MASK: { 887 846 char qdepth[AP_DEVICES]; 888 - zcrypt_qdepth_mask(qdepth); 889 - if (copy_to_user((char __user *) arg, qdepth, 890 - sizeof(char) * AP_DEVICES)) 847 + 848 + zcrypt_qdepth_mask(qdepth, AP_DEVICES); 849 + if (copy_to_user((char __user *) arg, qdepth, sizeof(qdepth))) 891 850 return -EFAULT; 892 851 return 0; 893 852 } 894 - case Z90STAT_PERDEV_REQCNT: { 895 - int reqcnt[AP_DEVICES]; 896 - zcrypt_perdev_reqcnt(reqcnt); 897 - if (copy_to_user((int __user *) arg, reqcnt, 898 - sizeof(int) * AP_DEVICES)) 899 - return -EFAULT; 900 - return 0; 853 + case ZCRYPT_PERDEV_REQCNT: { 854 + int *reqcnt; 855 + 856 + reqcnt = kcalloc(AP_DEVICES, sizeof(int), GFP_KERNEL); 857 + if (!reqcnt) 858 + return -ENOMEM; 859 + zcrypt_perdev_reqcnt(reqcnt, AP_DEVICES); 860 + if (copy_to_user((int __user *) arg, reqcnt, sizeof(reqcnt))) 861 + rc = -EFAULT; 862 + kfree(reqcnt); 863 + return rc; 901 864 } 902 865 case Z90STAT_REQUESTQ_COUNT: 903 866 return put_user(zcrypt_requestq_count(), (int __user *) arg); ··· 908 871 (int __user *) arg); 909 872 case Z90STAT_DOMAIN_INDEX: 910 873 return put_user(ap_domain_index, (int __user *) arg); 874 + /* 875 + * Deprecated ioctls 876 + */ 877 + case ZDEVICESTATUS: { 878 + /* the old ioctl supports only 64 adapters */ 879 + struct zcrypt_device_status *device_status; 880 + size_t total_size = MAX_ZDEV_ENTRIES 881 + * sizeof(struct zcrypt_device_status); 882 + 883 + device_status = kzalloc(total_size, GFP_KERNEL); 884 + if (!device_status) 885 + return -ENOMEM; 886 + zcrypt_device_status_mask(device_status); 887 + if (copy_to_user((char __user *) arg, device_status, 888 + total_size)) 889 + rc = -EFAULT; 890 + kfree(device_status); 891 + return rc; 892 + } 893 + case Z90STAT_STATUS_MASK: { 894 + /* the old ioctl supports only 64 adapters */ 895 + char status[MAX_ZDEV_CARDIDS]; 896 + 897 + zcrypt_status_mask(status, MAX_ZDEV_CARDIDS); 898 + if (copy_to_user((char __user *) arg, status, sizeof(status))) 899 + return -EFAULT; 900 + return 0; 901 + } 902 + case Z90STAT_QDEPTH_MASK: { 903 + /* the old ioctl supports only 64 adapters */ 904 + char qdepth[MAX_ZDEV_CARDIDS]; 905 + 906 + zcrypt_qdepth_mask(qdepth, MAX_ZDEV_CARDIDS); 907 + if (copy_to_user((char __user *) arg, qdepth, sizeof(qdepth))) 908 + return -EFAULT; 909 + return 0; 910 + } 911 + case Z90STAT_PERDEV_REQCNT: { 912 + /* the old ioctl supports only 64 adapters */ 913 + int reqcnt[MAX_ZDEV_CARDIDS]; 914 + 915 + zcrypt_perdev_reqcnt(reqcnt, MAX_ZDEV_CARDIDS); 916 + if (copy_to_user((int __user *) arg, reqcnt, sizeof(reqcnt))) 917 + return -EFAULT; 918 + return 0; 919 + } 911 920 /* unknown ioctl number */ 912 921 default: 922 + ZCRYPT_DBF(DBF_DEBUG, "unknown ioctl 0x%08x\n", cmd); 913 923 return -ENOIOCTLCMD; 914 924 } 915 925 }
+1 -1
drivers/s390/crypto/zcrypt_api.h
··· 155 155 int zcrypt_api_init(void); 156 156 void zcrypt_api_exit(void); 157 157 long zcrypt_send_cprb(struct ica_xcRB *xcRB); 158 - void zcrypt_device_status_mask(struct zcrypt_device_matrix *devstatus); 158 + void zcrypt_device_status_mask_ext(struct zcrypt_device_status_ext *devstatus); 159 159 160 160 #endif /* _ZCRYPT_API_H_ */