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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull s390 updates from Martin Schwidefsky:

- A couple of patches for the zcrypt driver:
+ Add two masks to determine which AP cards and queues are host
devices, this will be useful for KVM AP device passthrough
+ Add-on patch to improve the parsing of the new apmask and aqmask
+ Some code beautification

- Second try to reenable the GCC plugins, the first patch set had a
patch to do this but the merge somehow missed this

- Remove the s390 specific GCC version check and use the generic one

- Three patches for kdump, two bug fixes and one cleanup

- Three patches for the PCI layer, one bug fix and two cleanups

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
s390: remove gcc version check (4.3 or newer)
s390/zcrypt: hex string mask improvements for apmask and aqmask.
s390/zcrypt: AP bus support for alternate driver(s)
s390/zcrypt: code beautify
s390/zcrypt: switch return type to bool for ap_instructions_available()
s390/kdump: Remove kzalloc_panic
s390/kdump: Fix memleak in nt_vmcoreinfo
s390/kdump: Make elfcorehdr size calculation ABI compliant
s390/pci: remove fmb address from debug output
s390/pci: remove stale rc
s390/pci: fix out of bounds access during irq setup
s390/zcrypt: fix ap_instructions_available() returncodes
s390: reenable gcc plugins for real

+707 -301
+1 -1
arch/s390/Kconfig
··· 140 140 select HAVE_FUNCTION_GRAPH_TRACER 141 141 select HAVE_FUNCTION_TRACER 142 142 select HAVE_FUTEX_CMPXCHG if FUTEX 143 - select HAVE_GCC_PLUGINS if BROKEN 143 + select HAVE_GCC_PLUGINS 144 144 select HAVE_KERNEL_BZIP2 145 145 select HAVE_KERNEL_GZIP 146 146 select HAVE_KERNEL_LZ4
+7 -7
arch/s390/include/asm/ap.h
··· 49 49 /** 50 50 * ap_intructions_available() - Test if AP instructions are available. 51 51 * 52 - * Returns 0 if the AP instructions are installed. 52 + * Returns true if the AP instructions are installed, otherwise false. 53 53 */ 54 - static inline int ap_instructions_available(void) 54 + static inline bool ap_instructions_available(void) 55 55 { 56 56 register unsigned long reg0 asm ("0") = AP_MKQID(0, 0); 57 - register unsigned long reg1 asm ("1") = -ENODEV; 58 - register unsigned long reg2 asm ("2"); 57 + register unsigned long reg1 asm ("1") = 0; 58 + register unsigned long reg2 asm ("2") = 0; 59 59 60 60 asm volatile( 61 61 " .long 0xb2af0000\n" /* PQAP(TAPQ) */ 62 - "0: la %0,0\n" 62 + "0: la %0,1\n" 63 63 "1:\n" 64 64 EX_TABLE(0b, 1b) 65 - : "+d" (reg1), "=d" (reg2) 65 + : "+d" (reg1), "+d" (reg2) 66 66 : "d" (reg0) 67 67 : "cc"); 68 - return reg1; 68 + return reg1 != 0; 69 69 } 70 70 71 71 /**
+36 -36
arch/s390/include/uapi/asm/zcrypt.h
··· 32 32 * - length(n_modulus) = inputdatalength 33 33 */ 34 34 struct ica_rsa_modexpo { 35 - char __user * inputdata; 36 - unsigned int inputdatalength; 37 - char __user * outputdata; 38 - unsigned int outputdatalength; 39 - char __user * b_key; 40 - char __user * n_modulus; 35 + char __user *inputdata; 36 + unsigned int inputdatalength; 37 + char __user *outputdata; 38 + unsigned int outputdatalength; 39 + char __user *b_key; 40 + char __user *n_modulus; 41 41 }; 42 42 43 43 /** ··· 55 55 * - length(u_mult_inv) = inputdatalength/2 + 8 56 56 */ 57 57 struct ica_rsa_modexpo_crt { 58 - char __user * inputdata; 59 - unsigned int inputdatalength; 60 - char __user * outputdata; 61 - unsigned int outputdatalength; 62 - char __user * bp_key; 63 - char __user * bq_key; 64 - char __user * np_prime; 65 - char __user * nq_prime; 66 - char __user * u_mult_inv; 58 + char __user *inputdata; 59 + unsigned int inputdatalength; 60 + char __user *outputdata; 61 + unsigned int outputdatalength; 62 + char __user *bp_key; 63 + char __user *bq_key; 64 + char __user *np_prime; 65 + char __user *nq_prime; 66 + char __user *u_mult_inv; 67 67 }; 68 68 69 69 /** ··· 93 93 unsigned int req_extbl; /* request extension block len */ 94 94 unsigned char pad_001[4]; /* reserved */ 95 95 unsigned int rpld_extbl; /* replied extension block len */ 96 - unsigned char padx000[16 - sizeof (char *)]; 97 - unsigned char * req_parmb; /* request parm block 'address' */ 98 - unsigned char padx001[16 - sizeof (char *)]; 99 - unsigned char * req_datab; /* request data block 'address' */ 100 - unsigned char padx002[16 - sizeof (char *)]; 101 - unsigned char * rpl_parmb; /* reply parm block 'address' */ 102 - unsigned char padx003[16 - sizeof (char *)]; 103 - unsigned char * rpl_datab; /* reply data block 'address' */ 104 - unsigned char padx004[16 - sizeof (char *)]; 105 - unsigned char * req_extb; /* request extension block 'addr'*/ 106 - unsigned char padx005[16 - sizeof (char *)]; 107 - unsigned char * rpl_extb; /* reply extension block 'address'*/ 96 + unsigned char padx000[16 - sizeof(char *)]; 97 + unsigned char *req_parmb; /* request parm block 'address' */ 98 + unsigned char padx001[16 - sizeof(char *)]; 99 + unsigned char *req_datab; /* request data block 'address' */ 100 + unsigned char padx002[16 - sizeof(char *)]; 101 + unsigned char *rpl_parmb; /* reply parm block 'address' */ 102 + unsigned char padx003[16 - sizeof(char *)]; 103 + unsigned char *rpl_datab; /* reply data block 'address' */ 104 + unsigned char padx004[16 - sizeof(char *)]; 105 + unsigned char *req_extb; /* request extension block 'addr'*/ 106 + unsigned char padx005[16 - sizeof(char *)]; 107 + unsigned char *rpl_extb; /* reply extension block 'address'*/ 108 108 unsigned short ccp_rtcode; /* server return code */ 109 109 unsigned short ccp_rscode; /* server reason code */ 110 110 unsigned int mac_data_len; /* Mac Data Length */ ··· 127 127 unsigned int user_defined; 128 128 unsigned short request_ID; 129 129 unsigned int request_control_blk_length; 130 - unsigned char padding1[16 - sizeof (char *)]; 131 - char __user * request_control_blk_addr; 130 + unsigned char padding1[16 - sizeof(char *)]; 131 + char __user *request_control_blk_addr; 132 132 unsigned int request_data_length; 133 - char padding2[16 - sizeof (char *)]; 134 - char __user * request_data_address; 133 + char padding2[16 - sizeof(char *)]; 134 + char __user *request_data_address; 135 135 unsigned int reply_control_blk_length; 136 - char padding3[16 - sizeof (char *)]; 137 - char __user * reply_control_blk_addr; 136 + char padding3[16 - sizeof(char *)]; 137 + char __user *reply_control_blk_addr; 138 138 unsigned int reply_data_length; 139 - char padding4[16 - sizeof (char *)]; 140 - char __user * reply_data_addr; 139 + char padding4[16 - sizeof(char *)]; 140 + char __user *reply_data_addr; 141 141 unsigned short priority_window; 142 142 unsigned int status; 143 143 } __attribute__((packed)); ··· 233 233 struct zcrypt_device_status_ext device[MAX_ZDEV_ENTRIES_EXT]; 234 234 }; 235 235 236 - #define AUTOSELECT ((unsigned int)0xFFFFFFFF) 236 + #define AUTOSELECT 0xFFFFFFFF 237 237 238 238 #define ZCRYPT_IOCTL_MAGIC 'z' 239 239
-8
arch/s390/kernel/asm-offsets.c
··· 17 17 #include <asm/gmap.h> 18 18 #include <asm/nmi.h> 19 19 20 - /* 21 - * Make sure that the compiler is new enough. We want a compiler that 22 - * is known to work with the "Q" assembler constraint. 23 - */ 24 - #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) 25 - #error Your compiler is too old; please use version 4.3 or newer 26 - #endif 27 - 28 20 int main(void) 29 21 { 30 22 /* task struct offsets */
+35 -37
arch/s390/kernel/crash_dump.c
··· 293 293 prot); 294 294 } 295 295 296 - /* 297 - * Alloc memory and panic in case of ENOMEM 298 - */ 299 - static void *kzalloc_panic(int len) 300 - { 301 - void *rc; 302 - 303 - rc = kzalloc(len, GFP_KERNEL); 304 - if (!rc) 305 - panic("s390 kdump kzalloc (%d) failed", len); 306 - return rc; 307 - } 308 - 309 296 static const char *nt_name(Elf64_Word type) 310 297 { 311 298 const char *name = "LINUX"; ··· 438 451 if (copy_oldmem_kernel(nt_name, addr + sizeof(note), 439 452 sizeof(nt_name) - 1)) 440 453 return NULL; 441 - if (strcmp(nt_name, "VMCOREINFO") != 0) 454 + if (strcmp(nt_name, VMCOREINFO_NOTE_NAME) != 0) 442 455 return NULL; 443 - vmcoreinfo = kzalloc_panic(note.n_descsz); 444 - if (copy_oldmem_kernel(vmcoreinfo, addr + 24, note.n_descsz)) 456 + vmcoreinfo = kzalloc(note.n_descsz, GFP_KERNEL); 457 + if (!vmcoreinfo) 445 458 return NULL; 459 + if (copy_oldmem_kernel(vmcoreinfo, addr + 24, note.n_descsz)) { 460 + kfree(vmcoreinfo); 461 + return NULL; 462 + } 446 463 *size = note.n_descsz; 447 464 return vmcoreinfo; 448 465 } ··· 456 465 */ 457 466 static void *nt_vmcoreinfo(void *ptr) 458 467 { 468 + const char *name = VMCOREINFO_NOTE_NAME; 459 469 unsigned long size; 460 470 void *vmcoreinfo; 461 471 462 472 vmcoreinfo = os_info_old_entry(OS_INFO_VMCOREINFO, &size); 463 - if (!vmcoreinfo) 464 - vmcoreinfo = get_vmcoreinfo_old(&size); 473 + if (vmcoreinfo) 474 + return nt_init_name(ptr, 0, vmcoreinfo, size, name); 475 + 476 + vmcoreinfo = get_vmcoreinfo_old(&size); 465 477 if (!vmcoreinfo) 466 478 return ptr; 467 - return nt_init_name(ptr, 0, vmcoreinfo, size, "VMCOREINFO"); 479 + ptr = nt_init_name(ptr, 0, vmcoreinfo, size, name); 480 + kfree(vmcoreinfo); 481 + return ptr; 468 482 } 469 483 470 484 static size_t nt_vmcoreinfo_size(void) 471 485 { 472 - const char *name = "VMCOREINFO"; 473 - char nt_name[11]; 474 - Elf64_Nhdr note; 475 - void *addr; 486 + const char *name = VMCOREINFO_NOTE_NAME; 487 + unsigned long size; 488 + void *vmcoreinfo; 476 489 477 - if (copy_oldmem_kernel(&addr, &S390_lowcore.vmcore_info, sizeof(addr))) 490 + vmcoreinfo = os_info_old_entry(OS_INFO_VMCOREINFO, &size); 491 + if (vmcoreinfo) 492 + return nt_size_name(size, name); 493 + 494 + vmcoreinfo = get_vmcoreinfo_old(&size); 495 + if (!vmcoreinfo) 478 496 return 0; 479 497 480 - if (copy_oldmem_kernel(&note, addr, sizeof(note))) 481 - return 0; 482 - 483 - memset(nt_name, 0, sizeof(nt_name)); 484 - if (copy_oldmem_kernel(nt_name, addr + sizeof(note), 485 - sizeof(nt_name) - 1)) 486 - return 0; 487 - 488 - if (strcmp(nt_name, name) != 0) 489 - return 0; 490 - 491 - return nt_size_name(note.n_descsz, name); 498 + kfree(vmcoreinfo); 499 + return nt_size_name(size, name); 492 500 } 493 501 494 502 /* ··· 650 660 651 661 alloc_size = get_elfcorehdr_size(mem_chunk_cnt); 652 662 653 - hdr = kzalloc_panic(alloc_size); 663 + hdr = kzalloc(alloc_size, GFP_KERNEL); 664 + 665 + /* Without elfcorehdr /proc/vmcore cannot be created. Thus creating 666 + * a dump with this crash kernel will fail. Panic now to allow other 667 + * dump mechanisms to take over. 668 + */ 669 + if (!hdr) 670 + panic("s390 kdump allocating elfcorehdr failed"); 671 + 654 672 /* Init elf header */ 655 673 ptr = ehdr_init(hdr, mem_chunk_cnt); 656 674 /* Init program headers */
+2 -1
arch/s390/pci/pci.c
··· 420 420 /* Request MSI interrupts */ 421 421 hwirq = 0; 422 422 for_each_pci_msi_entry(msi, pdev) { 423 - rc = -EIO; 423 + if (hwirq >= msi_vecs) 424 + break; 424 425 irq = irq_alloc_desc(0); /* Alloc irq on node 0 */ 425 426 if (irq < 0) 426 427 return -ENOMEM;
-1
arch/s390/pci/pci_debug.c
··· 93 93 } 94 94 95 95 /* header */ 96 - seq_printf(m, "FMB @ %p\n", zdev->fmb); 97 96 seq_printf(m, "Update interval: %u ms\n", zdev->fmb_update); 98 97 seq_printf(m, "Samples: %u\n", zdev->fmb->samples); 99 98 seq_printf(m, "Last update TOD: %Lx\n", zdev->fmb->last_update);
+392 -40
drivers/s390/crypto/ap_bus.c
··· 34 34 #include <linux/crypto.h> 35 35 #include <linux/mod_devicetable.h> 36 36 #include <linux/debugfs.h> 37 + #include <linux/ctype.h> 37 38 38 39 #include "ap_bus.h" 39 40 #include "ap_debug.h" ··· 44 43 */ 45 44 int ap_domain_index = -1; /* Adjunct Processor Domain Index */ 46 45 static DEFINE_SPINLOCK(ap_domain_lock); 47 - module_param_named(domain, ap_domain_index, int, S_IRUSR|S_IRGRP); 46 + module_param_named(domain, ap_domain_index, int, 0440); 48 47 MODULE_PARM_DESC(domain, "domain index for ap devices"); 49 48 EXPORT_SYMBOL(ap_domain_index); 50 49 51 - static int ap_thread_flag = 0; 52 - module_param_named(poll_thread, ap_thread_flag, int, S_IRUSR|S_IRGRP); 50 + static int ap_thread_flag; 51 + module_param_named(poll_thread, ap_thread_flag, int, 0440); 53 52 MODULE_PARM_DESC(poll_thread, "Turn on/off poll thread, default is 0 (off)."); 53 + 54 + static char *apm_str; 55 + module_param_named(apmask, apm_str, charp, 0440); 56 + MODULE_PARM_DESC(apmask, "AP bus adapter mask."); 57 + 58 + static char *aqm_str; 59 + module_param_named(aqmask, aqm_str, charp, 0440); 60 + MODULE_PARM_DESC(aqmask, "AP bus domain mask."); 54 61 55 62 static struct device *ap_root_device; 56 63 57 64 DEFINE_SPINLOCK(ap_list_lock); 58 65 LIST_HEAD(ap_card_list); 66 + 67 + /* Default permissions (card and domain masking) */ 68 + static struct ap_perms { 69 + DECLARE_BITMAP(apm, AP_DEVICES); 70 + DECLARE_BITMAP(aqm, AP_DOMAINS); 71 + } ap_perms; 72 + static DEFINE_MUTEX(ap_perms_mutex); 59 73 60 74 static struct ap_config_info *ap_configuration; 61 75 static bool initialised; ··· 94 78 static void ap_tasklet_fn(unsigned long); 95 79 static DECLARE_TASKLET(ap_tasklet, ap_tasklet_fn, 0); 96 80 static DECLARE_WAIT_QUEUE_HEAD(ap_poll_wait); 97 - static struct task_struct *ap_poll_kthread = NULL; 81 + static struct task_struct *ap_poll_kthread; 98 82 static DEFINE_MUTEX(ap_poll_thread_mutex); 99 83 static DEFINE_SPINLOCK(ap_poll_timer_lock); 100 84 static struct hrtimer ap_poll_timer; 101 - /* In LPAR poll with 4kHz frequency. Poll every 250000 nanoseconds. 102 - * If z/VM change to 1500000 nanoseconds to adjust to z/VM polling.*/ 85 + /* 86 + * In LPAR poll with 4kHz frequency. Poll every 250000 nanoseconds. 87 + * If z/VM change to 1500000 nanoseconds to adjust to z/VM polling. 88 + */ 103 89 static unsigned long long poll_timeout = 250000; 104 90 105 91 /* Suspend flag */ 106 92 static int ap_suspend_flag; 107 93 /* Maximum domain id */ 108 94 static int ap_max_domain_id; 109 - /* Flag to check if domain was set through module parameter domain=. This is 95 + /* 96 + * Flag to check if domain was set through module parameter domain=. This is 110 97 * important when supsend and resume is done in a z/VM environment where the 111 - * domain might change. */ 112 - static int user_set_domain = 0; 98 + * domain might change. 99 + */ 100 + static int user_set_domain; 113 101 static struct bus_type ap_bus_type; 114 102 115 103 /* Adapter interrupt definitions */ ··· 551 531 * It sets up a single environment variable DEV_TYPE which contains the 552 532 * hardware device type. 553 533 */ 554 - static int ap_uevent (struct device *dev, struct kobj_uevent_env *env) 534 + static int ap_uevent(struct device *dev, struct kobj_uevent_env *env) 555 535 { 556 536 struct ap_device *ap_dev = to_ap_dev(dev); 557 537 int retval = 0; ··· 590 570 591 571 static void ap_bus_suspend(void) 592 572 { 593 - AP_DBF(DBF_DEBUG, "ap_bus_suspend running\n"); 573 + AP_DBF(DBF_DEBUG, "%s running\n", __func__); 594 574 595 575 ap_suspend_flag = 1; 596 576 /* ··· 627 607 { 628 608 int rc; 629 609 630 - AP_DBF(DBF_DEBUG, "ap_bus_resume running\n"); 610 + AP_DBF(DBF_DEBUG, "%s running\n", __func__); 631 611 632 612 /* remove all queue devices */ 633 613 bus_for_each_dev(&ap_bus_type, NULL, NULL, ··· 686 666 .pm = &ap_bus_pm_ops, 687 667 }; 688 668 669 + static int __ap_revise_reserved(struct device *dev, void *dummy) 670 + { 671 + int rc, card, queue, devres, drvres; 672 + 673 + if (is_queue_dev(dev)) { 674 + card = AP_QID_CARD(to_ap_queue(dev)->qid); 675 + queue = AP_QID_QUEUE(to_ap_queue(dev)->qid); 676 + mutex_lock(&ap_perms_mutex); 677 + devres = test_bit_inv(card, ap_perms.apm) 678 + && test_bit_inv(queue, ap_perms.aqm); 679 + mutex_unlock(&ap_perms_mutex); 680 + drvres = to_ap_drv(dev->driver)->flags 681 + & AP_DRIVER_FLAG_DEFAULT; 682 + if (!!devres != !!drvres) { 683 + AP_DBF(DBF_DEBUG, "reprobing queue=%02x.%04x\n", 684 + card, queue); 685 + rc = device_reprobe(dev); 686 + } 687 + } 688 + 689 + return 0; 690 + } 691 + 692 + static void ap_bus_revise_bindings(void) 693 + { 694 + bus_for_each_dev(&ap_bus_type, NULL, NULL, __ap_revise_reserved); 695 + } 696 + 697 + int ap_owned_by_def_drv(int card, int queue) 698 + { 699 + int rc = 0; 700 + 701 + if (card < 0 || card >= AP_DEVICES || queue < 0 || queue >= AP_DOMAINS) 702 + return -EINVAL; 703 + 704 + mutex_lock(&ap_perms_mutex); 705 + 706 + if (test_bit_inv(card, ap_perms.apm) 707 + && test_bit_inv(queue, ap_perms.aqm)) 708 + rc = 1; 709 + 710 + mutex_unlock(&ap_perms_mutex); 711 + 712 + return rc; 713 + } 714 + EXPORT_SYMBOL(ap_owned_by_def_drv); 715 + 716 + int ap_apqn_in_matrix_owned_by_def_drv(unsigned long *apm, 717 + unsigned long *aqm) 718 + { 719 + int card, queue, rc = 0; 720 + 721 + mutex_lock(&ap_perms_mutex); 722 + 723 + for (card = 0; !rc && card < AP_DEVICES; card++) 724 + if (test_bit_inv(card, apm) && 725 + test_bit_inv(card, ap_perms.apm)) 726 + for (queue = 0; !rc && queue < AP_DOMAINS; queue++) 727 + if (test_bit_inv(queue, aqm) && 728 + test_bit_inv(queue, ap_perms.aqm)) 729 + rc = 1; 730 + 731 + mutex_unlock(&ap_perms_mutex); 732 + 733 + return rc; 734 + } 735 + EXPORT_SYMBOL(ap_apqn_in_matrix_owned_by_def_drv); 736 + 689 737 static int ap_device_probe(struct device *dev) 690 738 { 691 739 struct ap_device *ap_dev = to_ap_dev(dev); 692 740 struct ap_driver *ap_drv = to_ap_drv(dev->driver); 693 - int rc; 741 + int card, queue, devres, drvres, rc; 742 + 743 + if (is_queue_dev(dev)) { 744 + /* 745 + * If the apqn is marked as reserved/used by ap bus and 746 + * default drivers, only probe with drivers with the default 747 + * flag set. If it is not marked, only probe with drivers 748 + * with the default flag not set. 749 + */ 750 + card = AP_QID_CARD(to_ap_queue(dev)->qid); 751 + queue = AP_QID_QUEUE(to_ap_queue(dev)->qid); 752 + mutex_lock(&ap_perms_mutex); 753 + devres = test_bit_inv(card, ap_perms.apm) 754 + && test_bit_inv(queue, ap_perms.aqm); 755 + mutex_unlock(&ap_perms_mutex); 756 + drvres = ap_drv->flags & AP_DRIVER_FLAG_DEFAULT; 757 + if (!!devres != !!drvres) 758 + return -ENODEV; 759 + } 694 760 695 761 /* Add queue/card to list of active queues/cards */ 696 762 spin_lock_bh(&ap_list_lock); ··· 857 751 EXPORT_SYMBOL(ap_bus_force_rescan); 858 752 859 753 /* 754 + * hex2bitmap() - parse hex mask string and set bitmap. 755 + * Valid strings are "0x012345678" with at least one valid hex number. 756 + * Rest of the bitmap to the right is padded with 0. No spaces allowed 757 + * within the string, the leading 0x may be omitted. 758 + * Returns the bitmask with exactly the bits set as given by the hex 759 + * string (both in big endian order). 760 + */ 761 + static int hex2bitmap(const char *str, unsigned long *bitmap, int bits) 762 + { 763 + int i, n, b; 764 + 765 + /* bits needs to be a multiple of 8 */ 766 + if (bits & 0x07) 767 + return -EINVAL; 768 + 769 + memset(bitmap, 0, bits / 8); 770 + 771 + if (str[0] == '0' && str[1] == 'x') 772 + str++; 773 + if (*str == 'x') 774 + str++; 775 + 776 + for (i = 0; isxdigit(*str) && i < bits; str++) { 777 + b = hex_to_bin(*str); 778 + for (n = 0; n < 4; n++) 779 + if (b & (0x08 >> n)) 780 + set_bit_inv(i + n, bitmap); 781 + i += 4; 782 + } 783 + 784 + if (*str == '\n') 785 + str++; 786 + if (*str) 787 + return -EINVAL; 788 + return 0; 789 + } 790 + 791 + /* 792 + * str2clrsetmasks() - parse bitmask argument and set the clear and 793 + * the set bitmap mask. A concatenation (done with ',') of these terms 794 + * is recognized: 795 + * +<bitnr>[-<bitnr>] or -<bitnr>[-<bitnr>] 796 + * <bitnr> may be any valid number (hex, decimal or octal) in the range 797 + * 0...bits-1; the leading + or - is required. Here are some examples: 798 + * +0-15,+32,-128,-0xFF 799 + * -0-255,+1-16,+0x128 800 + * +1,+2,+3,+4,-5,-7-10 801 + * Returns a clear and a set bitmask. Every positive value in the string 802 + * results in a bit set in the set mask and every negative value in the 803 + * string results in a bit SET in the clear mask. As a bit may be touched 804 + * more than once, the last 'operation' wins: +0-255,-128 = all but bit 805 + * 128 set in the set mask, only bit 128 set in the clear mask. 806 + */ 807 + static int str2clrsetmasks(const char *str, 808 + unsigned long *clrmap, 809 + unsigned long *setmap, 810 + int bits) 811 + { 812 + int a, i, z; 813 + char *np, sign; 814 + 815 + /* bits needs to be a multiple of 8 */ 816 + if (bits & 0x07) 817 + return -EINVAL; 818 + 819 + memset(clrmap, 0, bits / 8); 820 + memset(setmap, 0, bits / 8); 821 + 822 + while (*str) { 823 + sign = *str++; 824 + if (sign != '+' && sign != '-') 825 + return -EINVAL; 826 + a = z = simple_strtoul(str, &np, 0); 827 + if (str == np || a >= bits) 828 + return -EINVAL; 829 + str = np; 830 + if (*str == '-') { 831 + z = simple_strtoul(++str, &np, 0); 832 + if (str == np || a > z || z >= bits) 833 + return -EINVAL; 834 + str = np; 835 + } 836 + for (i = a; i <= z; i++) 837 + if (sign == '+') { 838 + set_bit_inv(i, setmap); 839 + clear_bit_inv(i, clrmap); 840 + } else { 841 + clear_bit_inv(i, setmap); 842 + set_bit_inv(i, clrmap); 843 + } 844 + while (*str == ',' || *str == '\n') 845 + str++; 846 + } 847 + 848 + return 0; 849 + } 850 + 851 + /* 852 + * process_mask_arg() - parse a bitmap string and clear/set the 853 + * bits in the bitmap accordingly. The string may be given as 854 + * absolute value, a hex string like 0x1F2E3D4C5B6A" simple over- 855 + * writing the current content of the bitmap. Or as relative string 856 + * like "+1-16,-32,-0x40,+128" where only single bits or ranges of 857 + * bits are cleared or set. Distinction is done based on the very 858 + * first character which may be '+' or '-' for the relative string 859 + * and othewise assume to be an absolute value string. If parsing fails 860 + * a negative errno value is returned. All arguments and bitmaps are 861 + * big endian order. 862 + */ 863 + static int process_mask_arg(const char *str, 864 + unsigned long *bitmap, int bits, 865 + struct mutex *lock) 866 + { 867 + int i; 868 + 869 + /* bits needs to be a multiple of 8 */ 870 + if (bits & 0x07) 871 + return -EINVAL; 872 + 873 + if (*str == '+' || *str == '-') { 874 + DECLARE_BITMAP(clrm, bits); 875 + DECLARE_BITMAP(setm, bits); 876 + 877 + i = str2clrsetmasks(str, clrm, setm, bits); 878 + if (i) 879 + return i; 880 + if (mutex_lock_interruptible(lock)) 881 + return -ERESTARTSYS; 882 + for (i = 0; i < bits; i++) { 883 + if (test_bit_inv(i, clrm)) 884 + clear_bit_inv(i, bitmap); 885 + if (test_bit_inv(i, setm)) 886 + set_bit_inv(i, bitmap); 887 + } 888 + } else { 889 + DECLARE_BITMAP(setm, bits); 890 + 891 + i = hex2bitmap(str, setm, bits); 892 + if (i) 893 + return i; 894 + if (mutex_lock_interruptible(lock)) 895 + return -ERESTARTSYS; 896 + for (i = 0; i < bits; i++) 897 + if (test_bit_inv(i, setm)) 898 + set_bit_inv(i, bitmap); 899 + else 900 + clear_bit_inv(i, bitmap); 901 + } 902 + mutex_unlock(lock); 903 + 904 + return 0; 905 + } 906 + 907 + /* 860 908 * AP bus attributes. 861 909 */ 910 + 862 911 static ssize_t ap_domain_show(struct bus_type *bus, char *buf) 863 912 { 864 913 return snprintf(buf, PAGE_SIZE, "%d\n", ap_domain_index); ··· 1025 764 int domain; 1026 765 1027 766 if (sscanf(buf, "%i\n", &domain) != 1 || 1028 - domain < 0 || domain > ap_max_domain_id) 767 + domain < 0 || domain > ap_max_domain_id || 768 + !test_bit_inv(domain, ap_perms.aqm)) 1029 769 return -EINVAL; 1030 770 spin_lock_bh(&ap_domain_lock); 1031 771 ap_domain_index = domain; ··· 1037 775 return count; 1038 776 } 1039 777 1040 - static BUS_ATTR(ap_domain, 0644, ap_domain_show, ap_domain_store); 778 + static BUS_ATTR_RW(ap_domain); 1041 779 1042 780 static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf) 1043 781 { ··· 1052 790 ap_configuration->adm[6], ap_configuration->adm[7]); 1053 791 } 1054 792 1055 - static BUS_ATTR(ap_control_domain_mask, 0444, 1056 - ap_control_domain_mask_show, NULL); 793 + static BUS_ATTR_RO(ap_control_domain_mask); 1057 794 1058 795 static ssize_t ap_usage_domain_mask_show(struct bus_type *bus, char *buf) 1059 796 { ··· 1067 806 ap_configuration->aqm[6], ap_configuration->aqm[7]); 1068 807 } 1069 808 1070 - static BUS_ATTR(ap_usage_domain_mask, 0444, 1071 - ap_usage_domain_mask_show, NULL); 1072 - 1073 - static ssize_t ap_config_time_show(struct bus_type *bus, char *buf) 1074 - { 1075 - return snprintf(buf, PAGE_SIZE, "%d\n", ap_config_time); 1076 - } 809 + static BUS_ATTR_RO(ap_usage_domain_mask); 1077 810 1078 811 static ssize_t ap_interrupts_show(struct bus_type *bus, char *buf) 1079 812 { ··· 1075 820 ap_using_interrupts() ? 1 : 0); 1076 821 } 1077 822 1078 - static BUS_ATTR(ap_interrupts, 0444, ap_interrupts_show, NULL); 823 + static BUS_ATTR_RO(ap_interrupts); 1079 824 1080 - static ssize_t ap_config_time_store(struct bus_type *bus, 1081 - const char *buf, size_t count) 825 + static ssize_t config_time_show(struct bus_type *bus, char *buf) 826 + { 827 + return snprintf(buf, PAGE_SIZE, "%d\n", ap_config_time); 828 + } 829 + 830 + static ssize_t config_time_store(struct bus_type *bus, 831 + const char *buf, size_t count) 1082 832 { 1083 833 int time; 1084 834 ··· 1094 834 return count; 1095 835 } 1096 836 1097 - static BUS_ATTR(config_time, 0644, ap_config_time_show, ap_config_time_store); 837 + static BUS_ATTR_RW(config_time); 1098 838 1099 - static ssize_t ap_poll_thread_show(struct bus_type *bus, char *buf) 839 + static ssize_t poll_thread_show(struct bus_type *bus, char *buf) 1100 840 { 1101 841 return snprintf(buf, PAGE_SIZE, "%d\n", ap_poll_kthread ? 1 : 0); 1102 842 } 1103 843 1104 - static ssize_t ap_poll_thread_store(struct bus_type *bus, 1105 - const char *buf, size_t count) 844 + static ssize_t poll_thread_store(struct bus_type *bus, 845 + const char *buf, size_t count) 1106 846 { 1107 847 int flag, rc; 1108 848 ··· 1117 857 return count; 1118 858 } 1119 859 1120 - static BUS_ATTR(poll_thread, 0644, ap_poll_thread_show, ap_poll_thread_store); 860 + static BUS_ATTR_RW(poll_thread); 1121 861 1122 862 static ssize_t poll_timeout_show(struct bus_type *bus, char *buf) 1123 863 { ··· 1146 886 return count; 1147 887 } 1148 888 1149 - static BUS_ATTR(poll_timeout, 0644, poll_timeout_show, poll_timeout_store); 889 + static BUS_ATTR_RW(poll_timeout); 1150 890 1151 891 static ssize_t ap_max_domain_id_show(struct bus_type *bus, char *buf) 1152 892 { ··· 1159 899 return snprintf(buf, PAGE_SIZE, "%d\n", max_domain_id); 1160 900 } 1161 901 1162 - static BUS_ATTR(ap_max_domain_id, 0444, ap_max_domain_id_show, NULL); 902 + static BUS_ATTR_RO(ap_max_domain_id); 903 + 904 + static ssize_t apmask_show(struct bus_type *bus, char *buf) 905 + { 906 + int rc; 907 + 908 + if (mutex_lock_interruptible(&ap_perms_mutex)) 909 + return -ERESTARTSYS; 910 + rc = snprintf(buf, PAGE_SIZE, 911 + "0x%016lx%016lx%016lx%016lx\n", 912 + ap_perms.apm[0], ap_perms.apm[1], 913 + ap_perms.apm[2], ap_perms.apm[3]); 914 + mutex_unlock(&ap_perms_mutex); 915 + 916 + return rc; 917 + } 918 + 919 + static ssize_t apmask_store(struct bus_type *bus, const char *buf, 920 + size_t count) 921 + { 922 + int rc; 923 + 924 + rc = process_mask_arg(buf, ap_perms.apm, AP_DEVICES, &ap_perms_mutex); 925 + if (rc) 926 + return rc; 927 + 928 + ap_bus_revise_bindings(); 929 + 930 + return count; 931 + } 932 + 933 + static BUS_ATTR_RW(apmask); 934 + 935 + static ssize_t aqmask_show(struct bus_type *bus, char *buf) 936 + { 937 + int rc; 938 + 939 + if (mutex_lock_interruptible(&ap_perms_mutex)) 940 + return -ERESTARTSYS; 941 + rc = snprintf(buf, PAGE_SIZE, 942 + "0x%016lx%016lx%016lx%016lx\n", 943 + ap_perms.aqm[0], ap_perms.aqm[1], 944 + ap_perms.aqm[2], ap_perms.aqm[3]); 945 + mutex_unlock(&ap_perms_mutex); 946 + 947 + return rc; 948 + } 949 + 950 + static ssize_t aqmask_store(struct bus_type *bus, const char *buf, 951 + size_t count) 952 + { 953 + int rc; 954 + 955 + rc = process_mask_arg(buf, ap_perms.aqm, AP_DOMAINS, &ap_perms_mutex); 956 + if (rc) 957 + return rc; 958 + 959 + ap_bus_revise_bindings(); 960 + 961 + return count; 962 + } 963 + 964 + static BUS_ATTR_RW(aqmask); 1163 965 1164 966 static struct bus_attribute *const ap_bus_attrs[] = { 1165 967 &bus_attr_ap_domain, ··· 1232 910 &bus_attr_ap_interrupts, 1233 911 &bus_attr_poll_timeout, 1234 912 &bus_attr_ap_max_domain_id, 913 + &bus_attr_apmask, 914 + &bus_attr_aqmask, 1235 915 NULL, 1236 916 }; 1237 917 ··· 1262 938 best_domain = -1; 1263 939 max_count = 0; 1264 940 for (i = 0; i < AP_DOMAINS; i++) { 1265 - if (!ap_test_config_domain(i)) 941 + if (!ap_test_config_domain(i) || 942 + !test_bit_inv(i, ap_perms.aqm)) 1266 943 continue; 1267 944 count = 0; 1268 945 for (j = 0; j < AP_DEVICES; j++) { ··· 1281 956 best_domain = i; 1282 957 } 1283 958 } 1284 - if (best_domain >= 0){ 959 + if (best_domain >= 0) { 1285 960 ap_domain_index = best_domain; 1286 961 AP_DBF(DBF_DEBUG, "new ap_domain_index=%d\n", ap_domain_index); 1287 962 spin_unlock_bh(&ap_domain_lock); ··· 1363 1038 unsigned int func = 0; 1364 1039 int rc, id, dom, borked, domains, defdomdevs = 0; 1365 1040 1366 - AP_DBF(DBF_DEBUG, "ap_scan_bus running\n"); 1041 + AP_DBF(DBF_DEBUG, "%s running\n", __func__); 1367 1042 1368 1043 ap_query_configuration(ap_configuration); 1369 1044 if (ap_select_domain() != 0) ··· 1488 1163 } /* end device loop */ 1489 1164 1490 1165 if (defdomdevs < 1) 1491 - AP_DBF(DBF_INFO, "no queue device with default domain %d available\n", 1166 + AP_DBF(DBF_INFO, 1167 + "no queue device with default domain %d available\n", 1492 1168 ap_domain_index); 1493 1169 1494 1170 out: ··· 1513 1187 return 0; 1514 1188 } 1515 1189 1190 + static void __init ap_perms_init(void) 1191 + { 1192 + /* all resources useable if no kernel parameter string given */ 1193 + memset(&ap_perms.apm, 0xFF, sizeof(ap_perms.apm)); 1194 + memset(&ap_perms.aqm, 0xFF, sizeof(ap_perms.aqm)); 1195 + 1196 + /* apm kernel parameter string */ 1197 + if (apm_str) { 1198 + memset(&ap_perms.apm, 0, sizeof(ap_perms.apm)); 1199 + process_mask_arg(apm_str, ap_perms.apm, AP_DEVICES, 1200 + &ap_perms_mutex); 1201 + } 1202 + 1203 + /* aqm kernel parameter string */ 1204 + if (aqm_str) { 1205 + memset(&ap_perms.aqm, 0, sizeof(ap_perms.aqm)); 1206 + process_mask_arg(aqm_str, ap_perms.aqm, AP_DOMAINS, 1207 + &ap_perms_mutex); 1208 + } 1209 + } 1210 + 1516 1211 /** 1517 1212 * ap_module_init(): The module initialization code. 1518 1213 * ··· 1548 1201 if (rc) 1549 1202 return rc; 1550 1203 1551 - if (ap_instructions_available() != 0) { 1204 + if (!ap_instructions_available()) { 1552 1205 pr_warn("The hardware system does not support AP instructions\n"); 1553 1206 return -ENODEV; 1554 1207 } 1208 + 1209 + /* set up the AP permissions (ap and aq masks) */ 1210 + ap_perms_init(); 1555 1211 1556 1212 /* Get AP configuration data if available */ 1557 1213 ap_init_configuration(); ··· 1564 1214 ap_max_domain_id ? ap_max_domain_id : AP_DOMAINS - 1; 1565 1215 else 1566 1216 max_domain_id = 15; 1567 - if (ap_domain_index < -1 || ap_domain_index > max_domain_id) { 1217 + if (ap_domain_index < -1 || ap_domain_index > max_domain_id || 1218 + (ap_domain_index >= 0 && 1219 + !test_bit_inv(ap_domain_index, ap_perms.aqm))) { 1568 1220 pr_warn("%d is not a valid cryptographic domain\n", 1569 1221 ap_domain_index); 1570 1222 ap_domain_index = -1;
+34 -2
drivers/s390/crypto/ap_bus.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * Copyright IBM Corp. 2006, 2012 4 4 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> ··· 117 117 struct ap_device; 118 118 struct ap_message; 119 119 120 + /* 121 + * The ap driver struct includes a flags field which holds some info for 122 + * the ap bus about the driver. Currently only one flag is supported and 123 + * used: The DEFAULT flag marks an ap driver as a default driver which is 124 + * used together with the apmask and aqmask whitelisting of the ap bus. 125 + */ 126 + #define AP_DRIVER_FLAG_DEFAULT 0x0001 127 + 120 128 struct ap_driver { 121 129 struct device_driver driver; 122 130 struct ap_device_id *ids; 131 + unsigned int flags; 123 132 124 133 int (*probe)(struct ap_device *); 125 134 void (*remove)(struct ap_device *); ··· 176 167 int pendingq_count; /* # requests on pendingq list. */ 177 168 int requestq_count; /* # requests on requestq list. */ 178 169 int total_request_count; /* # requests ever for this AP device.*/ 179 - int request_timeout; /* Request timout in jiffies. */ 170 + int request_timeout; /* Request timeout in jiffies. */ 180 171 struct timer_list timeout; /* Timer for request timeouts. */ 181 172 struct list_head pendingq; /* List of message sent to AP queue. */ 182 173 struct list_head requestq; /* List of message yet to be sent. */ ··· 256 247 257 248 struct ap_card *ap_card_create(int id, int queue_depth, int raw_device_type, 258 249 int comp_device_type, unsigned int functions); 250 + 251 + /* 252 + * check APQN for owned/reserved by ap bus and default driver(s). 253 + * Checks if this APQN is or will be in use by the ap bus 254 + * and the default set of drivers. 255 + * If yes, returns 1, if not returns 0. On error a negative 256 + * errno value is returned. 257 + */ 258 + int ap_owned_by_def_drv(int card, int queue); 259 + 260 + /* 261 + * check 'matrix' of APQNs for owned/reserved by ap bus and 262 + * default driver(s). 263 + * Checks if there is at least one APQN in the given 'matrix' 264 + * marked as owned/reserved by the ap bus and default driver(s). 265 + * If such an APQN is found the return value is 1, otherwise 266 + * 0 is returned. On error a negative errno value is returned. 267 + * The parameter apm is a bitmask which should be declared 268 + * as DECLARE_BITMAP(apm, AP_DEVICES), the aqm parameter is 269 + * similar, should be declared as DECLARE_BITMAP(aqm, AP_DOMAINS). 270 + */ 271 + int ap_apqn_in_matrix_owned_by_def_drv(unsigned long *apm, 272 + unsigned long *aqm); 259 273 260 274 #endif /* _AP_BUS_H_ */
+25 -25
drivers/s390/crypto/ap_card.c
··· 18 18 /* 19 19 * AP card related attributes. 20 20 */ 21 - static ssize_t ap_hwtype_show(struct device *dev, 22 - struct device_attribute *attr, char *buf) 21 + static ssize_t hwtype_show(struct device *dev, 22 + struct device_attribute *attr, char *buf) 23 23 { 24 24 struct ap_card *ac = to_ap_card(dev); 25 25 26 26 return snprintf(buf, PAGE_SIZE, "%d\n", ac->ap_dev.device_type); 27 27 } 28 28 29 - static DEVICE_ATTR(hwtype, 0444, ap_hwtype_show, NULL); 29 + static DEVICE_ATTR_RO(hwtype); 30 30 31 - static ssize_t ap_raw_hwtype_show(struct device *dev, 32 - struct device_attribute *attr, char *buf) 31 + static ssize_t raw_hwtype_show(struct device *dev, 32 + struct device_attribute *attr, char *buf) 33 33 { 34 34 struct ap_card *ac = to_ap_card(dev); 35 35 36 36 return snprintf(buf, PAGE_SIZE, "%d\n", ac->raw_hwtype); 37 37 } 38 38 39 - static DEVICE_ATTR(raw_hwtype, 0444, ap_raw_hwtype_show, NULL); 39 + static DEVICE_ATTR_RO(raw_hwtype); 40 40 41 - static ssize_t ap_depth_show(struct device *dev, struct device_attribute *attr, 42 - char *buf) 41 + static ssize_t depth_show(struct device *dev, struct device_attribute *attr, 42 + char *buf) 43 43 { 44 44 struct ap_card *ac = to_ap_card(dev); 45 45 46 46 return snprintf(buf, PAGE_SIZE, "%d\n", ac->queue_depth); 47 47 } 48 48 49 - static DEVICE_ATTR(depth, 0444, ap_depth_show, NULL); 49 + static DEVICE_ATTR_RO(depth); 50 50 51 51 static ssize_t ap_functions_show(struct device *dev, 52 52 struct device_attribute *attr, char *buf) ··· 58 58 59 59 static DEVICE_ATTR_RO(ap_functions); 60 60 61 - static ssize_t ap_req_count_show(struct device *dev, 62 - struct device_attribute *attr, 63 - char *buf) 61 + static ssize_t request_count_show(struct device *dev, 62 + struct device_attribute *attr, 63 + char *buf) 64 64 { 65 65 struct ap_card *ac = to_ap_card(dev); 66 66 unsigned int req_cnt; ··· 72 72 return snprintf(buf, PAGE_SIZE, "%d\n", req_cnt); 73 73 } 74 74 75 - static ssize_t ap_req_count_store(struct device *dev, 76 - struct device_attribute *attr, 77 - const char *buf, size_t count) 75 + static ssize_t request_count_store(struct device *dev, 76 + struct device_attribute *attr, 77 + const char *buf, size_t count) 78 78 { 79 79 struct ap_card *ac = to_ap_card(dev); 80 80 struct ap_queue *aq; ··· 88 88 return count; 89 89 } 90 90 91 - static DEVICE_ATTR(request_count, 0644, ap_req_count_show, ap_req_count_store); 91 + static DEVICE_ATTR_RW(request_count); 92 92 93 - static ssize_t ap_requestq_count_show(struct device *dev, 94 - struct device_attribute *attr, char *buf) 93 + static ssize_t requestq_count_show(struct device *dev, 94 + struct device_attribute *attr, char *buf) 95 95 { 96 96 struct ap_card *ac = to_ap_card(dev); 97 97 struct ap_queue *aq; ··· 105 105 return snprintf(buf, PAGE_SIZE, "%d\n", reqq_cnt); 106 106 } 107 107 108 - static DEVICE_ATTR(requestq_count, 0444, ap_requestq_count_show, NULL); 108 + static DEVICE_ATTR_RO(requestq_count); 109 109 110 - static ssize_t ap_pendingq_count_show(struct device *dev, 111 - struct device_attribute *attr, char *buf) 110 + static ssize_t pendingq_count_show(struct device *dev, 111 + struct device_attribute *attr, char *buf) 112 112 { 113 113 struct ap_card *ac = to_ap_card(dev); 114 114 struct ap_queue *aq; ··· 122 122 return snprintf(buf, PAGE_SIZE, "%d\n", penq_cnt); 123 123 } 124 124 125 - static DEVICE_ATTR(pendingq_count, 0444, ap_pendingq_count_show, NULL); 125 + static DEVICE_ATTR_RO(pendingq_count); 126 126 127 - static ssize_t ap_modalias_show(struct device *dev, 128 - struct device_attribute *attr, char *buf) 127 + static ssize_t modalias_show(struct device *dev, 128 + struct device_attribute *attr, char *buf) 129 129 { 130 130 return sprintf(buf, "ap:t%02X\n", to_ap_dev(dev)->device_type); 131 131 } 132 132 133 - static DEVICE_ATTR(modalias, 0444, ap_modalias_show, NULL); 133 + static DEVICE_ATTR_RO(modalias); 134 134 135 135 static struct attribute *ap_card_dev_attrs[] = { 136 136 &dev_attr_hwtype.attr,
+19 -19
drivers/s390/crypto/ap_queue.c
··· 462 462 /* 463 463 * AP queue related attributes. 464 464 */ 465 - static ssize_t ap_req_count_show(struct device *dev, 466 - struct device_attribute *attr, 467 - char *buf) 465 + static ssize_t request_count_show(struct device *dev, 466 + struct device_attribute *attr, 467 + char *buf) 468 468 { 469 469 struct ap_queue *aq = to_ap_queue(dev); 470 470 unsigned int req_cnt; ··· 475 475 return snprintf(buf, PAGE_SIZE, "%d\n", req_cnt); 476 476 } 477 477 478 - static ssize_t ap_req_count_store(struct device *dev, 479 - struct device_attribute *attr, 480 - const char *buf, size_t count) 478 + static ssize_t request_count_store(struct device *dev, 479 + struct device_attribute *attr, 480 + const char *buf, size_t count) 481 481 { 482 482 struct ap_queue *aq = to_ap_queue(dev); 483 483 ··· 488 488 return count; 489 489 } 490 490 491 - static DEVICE_ATTR(request_count, 0644, ap_req_count_show, ap_req_count_store); 491 + static DEVICE_ATTR_RW(request_count); 492 492 493 - static ssize_t ap_requestq_count_show(struct device *dev, 494 - struct device_attribute *attr, char *buf) 493 + static ssize_t requestq_count_show(struct device *dev, 494 + struct device_attribute *attr, char *buf) 495 495 { 496 496 struct ap_queue *aq = to_ap_queue(dev); 497 497 unsigned int reqq_cnt = 0; ··· 502 502 return snprintf(buf, PAGE_SIZE, "%d\n", reqq_cnt); 503 503 } 504 504 505 - static DEVICE_ATTR(requestq_count, 0444, ap_requestq_count_show, NULL); 505 + static DEVICE_ATTR_RO(requestq_count); 506 506 507 - static ssize_t ap_pendingq_count_show(struct device *dev, 508 - struct device_attribute *attr, char *buf) 507 + static ssize_t pendingq_count_show(struct device *dev, 508 + struct device_attribute *attr, char *buf) 509 509 { 510 510 struct ap_queue *aq = to_ap_queue(dev); 511 511 unsigned int penq_cnt = 0; ··· 516 516 return snprintf(buf, PAGE_SIZE, "%d\n", penq_cnt); 517 517 } 518 518 519 - static DEVICE_ATTR(pendingq_count, 0444, ap_pendingq_count_show, NULL); 519 + static DEVICE_ATTR_RO(pendingq_count); 520 520 521 - static ssize_t ap_reset_show(struct device *dev, 522 - struct device_attribute *attr, char *buf) 521 + static ssize_t reset_show(struct device *dev, 522 + struct device_attribute *attr, char *buf) 523 523 { 524 524 struct ap_queue *aq = to_ap_queue(dev); 525 525 int rc = 0; ··· 541 541 return rc; 542 542 } 543 543 544 - static DEVICE_ATTR(reset, 0444, ap_reset_show, NULL); 544 + static DEVICE_ATTR_RO(reset); 545 545 546 - static ssize_t ap_interrupt_show(struct device *dev, 547 - struct device_attribute *attr, char *buf) 546 + static ssize_t interrupt_show(struct device *dev, 547 + struct device_attribute *attr, char *buf) 548 548 { 549 549 struct ap_queue *aq = to_ap_queue(dev); 550 550 int rc = 0; ··· 560 560 return rc; 561 561 } 562 562 563 - static DEVICE_ATTR(interrupt, 0444, ap_interrupt_show, NULL); 563 + static DEVICE_ATTR_RO(interrupt); 564 564 565 565 static struct attribute *ap_queue_dev_attrs[] = { 566 566 &dev_attr_request_count.attr,
+48 -43
drivers/s390/crypto/pkey_api.c
··· 82 82 83 83 if (t->type != 0x01) { 84 84 DEBUG_ERR( 85 - "check_secaeskeytoken secure token check failed, type mismatch 0x%02x != 0x01\n", 86 - (int) t->type); 85 + "%s secure token check failed, type mismatch 0x%02x != 0x01\n", 86 + __func__, (int) t->type); 87 87 return -EINVAL; 88 88 } 89 89 if (t->version != 0x04) { 90 90 DEBUG_ERR( 91 - "check_secaeskeytoken secure token check failed, version mismatch 0x%02x != 0x04\n", 92 - (int) t->version); 91 + "%s secure token check failed, version mismatch 0x%02x != 0x04\n", 92 + __func__, (int) t->version); 93 93 return -EINVAL; 94 94 } 95 95 if (keybitsize > 0 && t->bitsize != keybitsize) { 96 96 DEBUG_ERR( 97 - "check_secaeskeytoken secure token check failed, bitsize mismatch %d != %d\n", 98 - (int) t->bitsize, keybitsize); 97 + "%s secure token check failed, bitsize mismatch %d != %d\n", 98 + __func__, (int) t->bitsize, keybitsize); 99 99 return -EINVAL; 100 100 } 101 101 ··· 270 270 break; 271 271 default: 272 272 DEBUG_ERR( 273 - "pkey_genseckey unknown/unsupported keytype %d\n", 274 - keytype); 273 + "%s unknown/unsupported keytype %d\n", 274 + __func__, keytype); 275 275 rc = -EINVAL; 276 276 goto out; 277 277 } ··· 290 290 rc = _zcrypt_send_cprb(&xcrb); 291 291 if (rc) { 292 292 DEBUG_ERR( 293 - "pkey_genseckey zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", 294 - (int) cardnr, (int) domain, rc); 293 + "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", 294 + __func__, (int) cardnr, (int) domain, rc); 295 295 goto out; 296 296 } 297 297 298 298 /* check response returncode and reasoncode */ 299 299 if (prepcblk->ccp_rtcode != 0) { 300 300 DEBUG_ERR( 301 - "pkey_genseckey secure key generate failure, card response %d/%d\n", 301 + "%s secure key generate failure, card response %d/%d\n", 302 + __func__, 302 303 (int) prepcblk->ccp_rtcode, 303 304 (int) prepcblk->ccp_rscode); 304 305 rc = -EIO; ··· 316 315 - sizeof(prepparm->lv3.keyblock.tokattr); 317 316 if (seckeysize != SECKEYBLOBSIZE) { 318 317 DEBUG_ERR( 319 - "pkey_genseckey secure token size mismatch %d != %d bytes\n", 320 - seckeysize, SECKEYBLOBSIZE); 318 + "%s secure token size mismatch %d != %d bytes\n", 319 + __func__, seckeysize, SECKEYBLOBSIZE); 321 320 rc = -EIO; 322 321 goto out; 323 322 } ··· 408 407 break; 409 408 default: 410 409 DEBUG_ERR( 411 - "pkey_clr2seckey unknown/unsupported keytype %d\n", 412 - keytype); 410 + "%s unknown/unsupported keytype %d\n", 411 + __func__, keytype); 413 412 rc = -EINVAL; 414 413 goto out; 415 414 } ··· 428 427 rc = _zcrypt_send_cprb(&xcrb); 429 428 if (rc) { 430 429 DEBUG_ERR( 431 - "pkey_clr2seckey zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", 432 - (int) cardnr, (int) domain, rc); 430 + "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", 431 + __func__, (int) cardnr, (int) domain, rc); 433 432 goto out; 434 433 } 435 434 436 435 /* check response returncode and reasoncode */ 437 436 if (prepcblk->ccp_rtcode != 0) { 438 437 DEBUG_ERR( 439 - "pkey_clr2seckey clear key import failure, card response %d/%d\n", 438 + "%s clear key import failure, card response %d/%d\n", 439 + __func__, 440 440 (int) prepcblk->ccp_rtcode, 441 441 (int) prepcblk->ccp_rscode); 442 442 rc = -EIO; ··· 454 452 - sizeof(prepparm->lv3.keyblock.tokattr); 455 453 if (seckeysize != SECKEYBLOBSIZE) { 456 454 DEBUG_ERR( 457 - "pkey_clr2seckey secure token size mismatch %d != %d bytes\n", 458 - seckeysize, SECKEYBLOBSIZE); 455 + "%s secure token size mismatch %d != %d bytes\n", 456 + __func__, seckeysize, SECKEYBLOBSIZE); 459 457 rc = -EIO; 460 458 goto out; 461 459 } ··· 555 553 rc = _zcrypt_send_cprb(&xcrb); 556 554 if (rc) { 557 555 DEBUG_ERR( 558 - "pkey_sec2protkey zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", 559 - (int) cardnr, (int) domain, rc); 556 + "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", 557 + __func__, (int) cardnr, (int) domain, rc); 560 558 goto out; 561 559 } 562 560 563 561 /* check response returncode and reasoncode */ 564 562 if (prepcblk->ccp_rtcode != 0) { 565 563 DEBUG_ERR( 566 - "pkey_sec2protkey unwrap secure key failure, card response %d/%d\n", 564 + "%s unwrap secure key failure, card response %d/%d\n", 565 + __func__, 567 566 (int) prepcblk->ccp_rtcode, 568 567 (int) prepcblk->ccp_rscode); 569 568 rc = -EIO; ··· 572 569 } 573 570 if (prepcblk->ccp_rscode != 0) { 574 571 DEBUG_WARN( 575 - "pkey_sec2protkey unwrap secure key warning, card response %d/%d\n", 572 + "%s unwrap secure key warning, card response %d/%d\n", 573 + __func__, 576 574 (int) prepcblk->ccp_rtcode, 577 575 (int) prepcblk->ccp_rscode); 578 576 } ··· 585 581 /* check the returned keyblock */ 586 582 if (prepparm->lv3.keyblock.version != 0x01) { 587 583 DEBUG_ERR( 588 - "pkey_sec2protkey reply param keyblock version mismatch 0x%02x != 0x01\n", 589 - (int) prepparm->lv3.keyblock.version); 584 + "%s reply param keyblock version mismatch 0x%02x != 0x01\n", 585 + __func__, (int) prepparm->lv3.keyblock.version); 590 586 rc = -EIO; 591 587 goto out; 592 588 } ··· 603 599 protkey->type = PKEY_KEYTYPE_AES_256; 604 600 break; 605 601 default: 606 - DEBUG_ERR("pkey_sec2protkey unknown/unsupported keytype %d\n", 607 - prepparm->lv3.keyblock.keylen); 602 + DEBUG_ERR("%s unknown/unsupported keytype %d\n", 603 + __func__, prepparm->lv3.keyblock.keylen); 608 604 rc = -EIO; 609 605 goto out; 610 606 } ··· 642 638 fc = CPACF_PCKMO_ENC_AES_256_KEY; 643 639 break; 644 640 default: 645 - DEBUG_ERR("pkey_clr2protkey unknown/unsupported keytype %d\n", 646 - keytype); 641 + DEBUG_ERR("%s unknown/unsupported keytype %d\n", 642 + __func__, keytype); 647 643 return -EINVAL; 648 644 } 649 645 ··· 717 713 rc = _zcrypt_send_cprb(&xcrb); 718 714 if (rc) { 719 715 DEBUG_ERR( 720 - "query_crypto_facility zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", 721 - (int) cardnr, (int) domain, rc); 716 + "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", 717 + __func__, (int) cardnr, (int) domain, rc); 722 718 goto out; 723 719 } 724 720 725 721 /* check response returncode and reasoncode */ 726 722 if (prepcblk->ccp_rtcode != 0) { 727 723 DEBUG_ERR( 728 - "query_crypto_facility unwrap secure key failure, card response %d/%d\n", 724 + "%s unwrap secure key failure, card response %d/%d\n", 725 + __func__, 729 726 (int) prepcblk->ccp_rtcode, 730 727 (int) prepcblk->ccp_rscode); 731 728 rc = -EIO; ··· 998 993 } 999 994 1000 995 if (rc) 1001 - DEBUG_DBG("pkey_skey2pkey failed rc=%d\n", rc); 996 + DEBUG_DBG("%s failed rc=%d\n", __func__, rc); 1002 997 1003 998 return rc; 1004 999 } ··· 1035 1030 if (rc) 1036 1031 goto out; 1037 1032 if (t->mkvp == mkvp[1]) { 1038 - DEBUG_DBG("pkey_verifykey secure key has old mkvp\n"); 1033 + DEBUG_DBG("%s secure key has old mkvp\n", __func__); 1039 1034 if (pattributes) 1040 1035 *pattributes |= PKEY_VERIFY_ATTR_OLD_MKVP; 1041 1036 } ··· 1046 1041 *pdomain = domain; 1047 1042 1048 1043 out: 1049 - DEBUG_DBG("pkey_verifykey rc=%d\n", rc); 1044 + DEBUG_DBG("%s rc=%d\n", __func__, rc); 1050 1045 return rc; 1051 1046 } 1052 1047 EXPORT_SYMBOL(pkey_verifykey); ··· 1069 1064 return -EFAULT; 1070 1065 rc = pkey_genseckey(kgs.cardnr, kgs.domain, 1071 1066 kgs.keytype, &kgs.seckey); 1072 - DEBUG_DBG("pkey_ioctl pkey_genseckey()=%d\n", rc); 1067 + DEBUG_DBG("%s pkey_genseckey()=%d\n", __func__, rc); 1073 1068 if (rc) 1074 1069 break; 1075 1070 if (copy_to_user(ugs, &kgs, sizeof(kgs))) ··· 1084 1079 return -EFAULT; 1085 1080 rc = pkey_clr2seckey(kcs.cardnr, kcs.domain, kcs.keytype, 1086 1081 &kcs.clrkey, &kcs.seckey); 1087 - DEBUG_DBG("pkey_ioctl pkey_clr2seckey()=%d\n", rc); 1082 + DEBUG_DBG("%s pkey_clr2seckey()=%d\n", __func__, rc); 1088 1083 if (rc) 1089 1084 break; 1090 1085 if (copy_to_user(ucs, &kcs, sizeof(kcs))) ··· 1100 1095 return -EFAULT; 1101 1096 rc = pkey_sec2protkey(ksp.cardnr, ksp.domain, 1102 1097 &ksp.seckey, &ksp.protkey); 1103 - DEBUG_DBG("pkey_ioctl pkey_sec2protkey()=%d\n", rc); 1098 + DEBUG_DBG("%s pkey_sec2protkey()=%d\n", __func__, rc); 1104 1099 if (rc) 1105 1100 break; 1106 1101 if (copy_to_user(usp, &ksp, sizeof(ksp))) ··· 1115 1110 return -EFAULT; 1116 1111 rc = pkey_clr2protkey(kcp.keytype, 1117 1112 &kcp.clrkey, &kcp.protkey); 1118 - DEBUG_DBG("pkey_ioctl pkey_clr2protkey()=%d\n", rc); 1113 + DEBUG_DBG("%s pkey_clr2protkey()=%d\n", __func__, rc); 1119 1114 if (rc) 1120 1115 break; 1121 1116 if (copy_to_user(ucp, &kcp, sizeof(kcp))) ··· 1131 1126 return -EFAULT; 1132 1127 rc = pkey_findcard(&kfc.seckey, 1133 1128 &kfc.cardnr, &kfc.domain, 1); 1134 - DEBUG_DBG("pkey_ioctl pkey_findcard()=%d\n", rc); 1129 + DEBUG_DBG("%s pkey_findcard()=%d\n", __func__, rc); 1135 1130 if (rc) 1136 1131 break; 1137 1132 if (copy_to_user(ufc, &kfc, sizeof(kfc))) ··· 1145 1140 if (copy_from_user(&ksp, usp, sizeof(ksp))) 1146 1141 return -EFAULT; 1147 1142 rc = pkey_skey2pkey(&ksp.seckey, &ksp.protkey); 1148 - DEBUG_DBG("pkey_ioctl pkey_skey2pkey()=%d\n", rc); 1143 + DEBUG_DBG("%s pkey_skey2pkey()=%d\n", __func__, rc); 1149 1144 if (rc) 1150 1145 break; 1151 1146 if (copy_to_user(usp, &ksp, sizeof(ksp))) ··· 1160 1155 return -EFAULT; 1161 1156 rc = pkey_verifykey(&kvk.seckey, &kvk.cardnr, &kvk.domain, 1162 1157 &kvk.keysize, &kvk.attributes); 1163 - DEBUG_DBG("pkey_ioctl pkey_verifykey()=%d\n", rc); 1158 + DEBUG_DBG("%s pkey_verifykey()=%d\n", __func__, rc); 1164 1159 if (rc) 1165 1160 break; 1166 1161 if (copy_to_user(uvk, &kvk, sizeof(kvk)))
+18 -12
drivers/s390/crypto/zcrypt_api.c
··· 50 50 EXPORT_TRACEPOINT_SYMBOL(s390_zcrypt_rep); 51 51 52 52 static int zcrypt_hwrng_seed = 1; 53 - module_param_named(hwrng_seed, zcrypt_hwrng_seed, int, S_IRUSR|S_IRGRP); 53 + module_param_named(hwrng_seed, zcrypt_hwrng_seed, int, 0440); 54 54 MODULE_PARM_DESC(hwrng_seed, "Turn on/off hwrng auto seed, default is 1 (on)."); 55 55 56 56 DEFINE_SPINLOCK(zcrypt_list_lock); ··· 182 182 183 183 static inline bool zcrypt_card_compare(struct zcrypt_card *zc, 184 184 struct zcrypt_card *pref_zc, 185 - unsigned weight, unsigned pref_weight) 185 + unsigned int weight, 186 + unsigned int pref_weight) 186 187 { 187 188 if (!pref_zc) 188 189 return false; ··· 197 196 198 197 static inline bool zcrypt_queue_compare(struct zcrypt_queue *zq, 199 198 struct zcrypt_queue *pref_zq, 200 - unsigned weight, unsigned pref_weight) 199 + unsigned int weight, 200 + unsigned int pref_weight) 201 201 { 202 202 if (!pref_zq) 203 203 return false; ··· 794 792 case ICARSAMODEXPO: { 795 793 struct ica_rsa_modexpo __user *umex = (void __user *) arg; 796 794 struct ica_rsa_modexpo mex; 795 + 797 796 if (copy_from_user(&mex, umex, sizeof(mex))) 798 797 return -EFAULT; 799 798 do { ··· 814 811 case ICARSACRT: { 815 812 struct ica_rsa_modexpo_crt __user *ucrt = (void __user *) arg; 816 813 struct ica_rsa_modexpo_crt crt; 814 + 817 815 if (copy_from_user(&crt, ucrt, sizeof(crt))) 818 816 return -EFAULT; 819 817 do { ··· 834 830 case ZSECSENDCPRB: { 835 831 struct ica_xcRB __user *uxcRB = (void __user *) arg; 836 832 struct ica_xcRB xcRB; 833 + 837 834 if (copy_from_user(&xcRB, uxcRB, sizeof(xcRB))) 838 835 return -EFAULT; 839 836 do { ··· 854 849 case ZSENDEP11CPRB: { 855 850 struct ep11_urb __user *uxcrb = (void __user *)arg; 856 851 struct ep11_urb xcrb; 852 + 857 853 if (copy_from_user(&xcrb, uxcrb, sizeof(xcrb))) 858 854 return -EFAULT; 859 855 do { ··· 1043 1037 return -EFAULT; 1044 1038 crt64.inputdata = compat_ptr(crt32.inputdata); 1045 1039 crt64.inputdatalength = crt32.inputdatalength; 1046 - crt64.outputdata= compat_ptr(crt32.outputdata); 1040 + crt64.outputdata = compat_ptr(crt32.outputdata); 1047 1041 crt64.outputdatalength = crt32.outputdatalength; 1048 1042 crt64.bp_key = compat_ptr(crt32.bp_key); 1049 1043 crt64.bq_key = compat_ptr(crt32.bq_key); ··· 1069 1063 unsigned int user_defined; 1070 1064 unsigned short request_ID; 1071 1065 unsigned int request_control_blk_length; 1072 - unsigned char padding1[16 - sizeof (compat_uptr_t)]; 1066 + unsigned char padding1[16 - sizeof(compat_uptr_t)]; 1073 1067 compat_uptr_t request_control_blk_addr; 1074 1068 unsigned int request_data_length; 1075 - char padding2[16 - sizeof (compat_uptr_t)]; 1069 + char padding2[16 - sizeof(compat_uptr_t)]; 1076 1070 compat_uptr_t request_data_address; 1077 1071 unsigned int reply_control_blk_length; 1078 - char padding3[16 - sizeof (compat_uptr_t)]; 1072 + char padding3[16 - sizeof(compat_uptr_t)]; 1079 1073 compat_uptr_t reply_control_blk_addr; 1080 1074 unsigned int reply_data_length; 1081 - char padding4[16 - sizeof (compat_uptr_t)]; 1075 + char padding4[16 - sizeof(compat_uptr_t)]; 1082 1076 compat_uptr_t reply_data_addr; 1083 1077 unsigned short priority_window; 1084 1078 unsigned int status; 1085 - } __attribute__((packed)); 1079 + } __packed; 1086 1080 1087 1081 static long trans_xcRB32(struct file *filp, unsigned int cmd, 1088 1082 unsigned long arg) ··· 1126 1120 xcRB32.reply_data_length = xcRB64.reply_data_length; 1127 1121 xcRB32.status = xcRB64.status; 1128 1122 if (copy_to_user(uxcRB32, &xcRB32, sizeof(xcRB32))) 1129 - return -EFAULT; 1123 + return -EFAULT; 1130 1124 return rc; 1131 1125 } 1132 1126 ··· 1188 1182 rc = zcrypt_rng((char *) zcrypt_rng_buffer); 1189 1183 if (rc < 0) 1190 1184 return -EIO; 1191 - zcrypt_rng_buffer_index = rc / sizeof *data; 1185 + zcrypt_rng_buffer_index = rc / sizeof(*data); 1192 1186 } 1193 1187 *data = zcrypt_rng_buffer[--zcrypt_rng_buffer_index]; 1194 - return sizeof *data; 1188 + return sizeof(*data); 1195 1189 } 1196 1190 1197 1191 static struct hwrng zcrypt_rng_dev = {
+1 -1
drivers/s390/crypto/zcrypt_api.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * zcrypt 2.1.0 4 4 *
+14 -15
drivers/s390/crypto/zcrypt_card.c
··· 38 38 * Device attributes common for all crypto card devices. 39 39 */ 40 40 41 - static ssize_t zcrypt_card_type_show(struct device *dev, 42 - struct device_attribute *attr, char *buf) 41 + static ssize_t type_show(struct device *dev, 42 + struct device_attribute *attr, char *buf) 43 43 { 44 44 struct zcrypt_card *zc = to_ap_card(dev)->private; 45 45 46 46 return snprintf(buf, PAGE_SIZE, "%s\n", zc->type_string); 47 47 } 48 48 49 - static DEVICE_ATTR(type, 0444, zcrypt_card_type_show, NULL); 49 + static DEVICE_ATTR_RO(type); 50 50 51 - static ssize_t zcrypt_card_online_show(struct device *dev, 52 - struct device_attribute *attr, 53 - char *buf) 51 + static ssize_t online_show(struct device *dev, 52 + struct device_attribute *attr, 53 + char *buf) 54 54 { 55 55 struct zcrypt_card *zc = to_ap_card(dev)->private; 56 56 57 57 return snprintf(buf, PAGE_SIZE, "%d\n", zc->online); 58 58 } 59 59 60 - static ssize_t zcrypt_card_online_store(struct device *dev, 61 - struct device_attribute *attr, 62 - const char *buf, size_t count) 60 + static ssize_t online_store(struct device *dev, 61 + struct device_attribute *attr, 62 + const char *buf, size_t count) 63 63 { 64 64 struct zcrypt_card *zc = to_ap_card(dev)->private; 65 65 struct zcrypt_queue *zq; ··· 80 80 return count; 81 81 } 82 82 83 - static DEVICE_ATTR(online, 0644, zcrypt_card_online_show, 84 - zcrypt_card_online_store); 83 + static DEVICE_ATTR_RW(online); 85 84 86 - static ssize_t zcrypt_card_load_show(struct device *dev, 87 - struct device_attribute *attr, 88 - char *buf) 85 + static ssize_t load_show(struct device *dev, 86 + struct device_attribute *attr, 87 + char *buf) 89 88 { 90 89 struct zcrypt_card *zc = to_ap_card(dev)->private; 91 90 92 91 return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&zc->load)); 93 92 } 94 93 95 - static DEVICE_ATTR(load, 0444, zcrypt_card_load_show, NULL); 94 + static DEVICE_ATTR_RO(load); 96 95 97 96 static struct attribute *zcrypt_card_attrs[] = { 98 97 &dev_attr_type.attr,
+6 -6
drivers/s390/crypto/zcrypt_cca_key.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * zcrypt 2.1.0 4 4 * ··· 31 31 unsigned char version; 32 32 unsigned short token_length; 33 33 unsigned char reserved[4]; 34 - } __attribute__((packed)); 34 + } __packed; 35 35 36 36 #define CCA_TKN_HDR_ID_EXT 0x1E 37 37 ··· 51 51 unsigned short exponent_len; 52 52 unsigned short modulus_bit_len; 53 53 unsigned short modulus_byte_len; /* In a private key, this is 0 */ 54 - } __attribute__((packed)); 54 + } __packed; 55 55 56 56 /** 57 57 * mapping for the cca private CRT key 'token' ··· 85 85 unsigned short pad_len; 86 86 unsigned char reserved4[52]; 87 87 unsigned char confounder[8]; 88 - } __attribute__((packed)); 88 + } __packed; 89 89 90 90 #define CCA_PVT_EXT_CRT_SEC_ID_PVT 0x08 91 91 #define CCA_PVT_EXT_CRT_SEC_FMT_CL 0x40 ··· 114 114 struct cca_token_hdr pubHdr; 115 115 struct cca_public_sec pubSec; 116 116 char exponent[0]; 117 - } __attribute__((packed)) *key = p; 117 + } __packed *key = p; 118 118 unsigned char *temp; 119 119 int i; 120 120 ··· 183 183 struct cca_token_hdr token; 184 184 struct cca_pvt_ext_CRT_sec pvt; 185 185 char key_parts[0]; 186 - } __attribute__((packed)) *key = p; 186 + } __packed *key = p; 187 187 struct cca_public_sec *pub; 188 188 int short_len, long_len, pad_len, key_len, size; 189 189
+2
drivers/s390/crypto/zcrypt_cex2a.c
··· 145 145 .probe = zcrypt_cex2a_card_probe, 146 146 .remove = zcrypt_cex2a_card_remove, 147 147 .ids = zcrypt_cex2a_card_ids, 148 + .flags = AP_DRIVER_FLAG_DEFAULT, 148 149 }; 149 150 150 151 /** ··· 209 208 .suspend = ap_queue_suspend, 210 209 .resume = ap_queue_resume, 211 210 .ids = zcrypt_cex2a_queue_ids, 211 + .flags = AP_DRIVER_FLAG_DEFAULT, 212 212 }; 213 213 214 214 int __init zcrypt_cex2a_init(void)
+9 -9
drivers/s390/crypto/zcrypt_cex2a.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * zcrypt 2.1.0 4 4 * ··· 30 30 unsigned char reserved2; 31 31 unsigned char ignored; 32 32 unsigned short reserved3; 33 - } __attribute__((packed)); 33 + } __packed; 34 34 35 35 #define TYPE50_TYPE_CODE 0x50 36 36 ··· 49 49 unsigned char exponent[128]; 50 50 unsigned char modulus[128]; 51 51 unsigned char message[128]; 52 - } __attribute__((packed)); 52 + } __packed; 53 53 54 54 /* Mod-Exp, with a large modulus */ 55 55 struct type50_meb2_msg { ··· 59 59 unsigned char exponent[256]; 60 60 unsigned char modulus[256]; 61 61 unsigned char message[256]; 62 - } __attribute__((packed)); 62 + } __packed; 63 63 64 64 /* Mod-Exp, with a larger modulus */ 65 65 struct type50_meb3_msg { ··· 69 69 unsigned char exponent[512]; 70 70 unsigned char modulus[512]; 71 71 unsigned char message[512]; 72 - } __attribute__((packed)); 72 + } __packed; 73 73 74 74 /* CRT, with a small modulus */ 75 75 struct type50_crb1_msg { ··· 82 82 unsigned char dq[64]; 83 83 unsigned char u[64]; 84 84 unsigned char message[128]; 85 - } __attribute__((packed)); 85 + } __packed; 86 86 87 87 /* CRT, with a large modulus */ 88 88 struct type50_crb2_msg { ··· 95 95 unsigned char dq[128]; 96 96 unsigned char u[128]; 97 97 unsigned char message[256]; 98 - } __attribute__((packed)); 98 + } __packed; 99 99 100 100 /* CRT, with a larger modulus */ 101 101 struct type50_crb3_msg { ··· 108 108 unsigned char dq[256]; 109 109 unsigned char u[256]; 110 110 unsigned char message[512]; 111 - } __attribute__((packed)); 111 + } __packed; 112 112 113 113 /** 114 114 * The type 80 response family is associated with a CEX2A card. ··· 128 128 unsigned char code; /* 0x00 */ 129 129 unsigned char reserved2[3]; 130 130 unsigned char reserved3[8]; 131 - } __attribute__((packed)); 131 + } __packed; 132 132 133 133 int zcrypt_cex2a_init(void); 134 134 void zcrypt_cex2a_exit(void);
+2
drivers/s390/crypto/zcrypt_cex4.c
··· 214 214 .probe = zcrypt_cex4_card_probe, 215 215 .remove = zcrypt_cex4_card_remove, 216 216 .ids = zcrypt_cex4_card_ids, 217 + .flags = AP_DRIVER_FLAG_DEFAULT, 217 218 }; 218 219 219 220 /** ··· 284 283 .suspend = ap_queue_suspend, 285 284 .resume = ap_queue_resume, 286 285 .ids = zcrypt_cex4_queue_ids, 286 + .flags = AP_DRIVER_FLAG_DEFAULT, 287 287 }; 288 288 289 289 int __init zcrypt_cex4_init(void)
+1 -1
drivers/s390/crypto/zcrypt_error.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * zcrypt 2.1.0 4 4 *
+12 -5
drivers/s390/crypto/zcrypt_msgtype50.c
··· 27 27 #include "zcrypt_error.h" 28 28 #include "zcrypt_msgtype50.h" 29 29 30 - #define CEX3A_MAX_MOD_SIZE 512 /* 4096 bits */ 30 + /* 4096 bits */ 31 + #define CEX3A_MAX_MOD_SIZE 512 31 32 32 - #define CEX2A_MAX_RESPONSE_SIZE 0x110 /* max outputdatalength + type80_hdr */ 33 + /* max outputdatalength + type80_hdr */ 34 + #define CEX2A_MAX_RESPONSE_SIZE 0x110 33 35 34 - #define CEX3A_MAX_RESPONSE_SIZE 0x210 /* 512 bit modulus 35 - * (max outputdatalength) + 36 - * type80_hdr*/ 36 + /* 512 bit modulus, (max outputdatalength) + type80_hdr */ 37 + #define CEX3A_MAX_RESPONSE_SIZE 0x210 37 38 38 39 MODULE_AUTHOR("IBM Corporation"); 39 40 MODULE_DESCRIPTION("Cryptographic Accelerator (message type 50), " \ ··· 210 209 211 210 if (mod_len <= 128) { 212 211 struct type50_meb1_msg *meb1 = ap_msg->message; 212 + 213 213 memset(meb1, 0, sizeof(*meb1)); 214 214 ap_msg->length = sizeof(*meb1); 215 215 meb1->header.msg_type_code = TYPE50_TYPE_CODE; ··· 221 219 inp = meb1->message + sizeof(meb1->message) - mod_len; 222 220 } else if (mod_len <= 256) { 223 221 struct type50_meb2_msg *meb2 = ap_msg->message; 222 + 224 223 memset(meb2, 0, sizeof(*meb2)); 225 224 ap_msg->length = sizeof(*meb2); 226 225 meb2->header.msg_type_code = TYPE50_TYPE_CODE; ··· 232 229 inp = meb2->message + sizeof(meb2->message) - mod_len; 233 230 } else if (mod_len <= 512) { 234 231 struct type50_meb3_msg *meb3 = ap_msg->message; 232 + 235 233 memset(meb3, 0, sizeof(*meb3)); 236 234 ap_msg->length = sizeof(*meb3); 237 235 meb3->header.msg_type_code = TYPE50_TYPE_CODE; ··· 278 274 */ 279 275 if (mod_len <= 128) { /* up to 1024 bit key size */ 280 276 struct type50_crb1_msg *crb1 = ap_msg->message; 277 + 281 278 memset(crb1, 0, sizeof(*crb1)); 282 279 ap_msg->length = sizeof(*crb1); 283 280 crb1->header.msg_type_code = TYPE50_TYPE_CODE; ··· 292 287 inp = crb1->message + sizeof(crb1->message) - mod_len; 293 288 } else if (mod_len <= 256) { /* up to 2048 bit key size */ 294 289 struct type50_crb2_msg *crb2 = ap_msg->message; 290 + 295 291 memset(crb2, 0, sizeof(*crb2)); 296 292 ap_msg->length = sizeof(*crb2); 297 293 crb2->header.msg_type_code = TYPE50_TYPE_CODE; ··· 307 301 } else if ((mod_len <= 512) && /* up to 4096 bit key size */ 308 302 (zq->zcard->max_mod_size == CEX3A_MAX_MOD_SIZE)) { 309 303 struct type50_crb3_msg *crb3 = ap_msg->message; 304 + 310 305 memset(crb3, 0, sizeof(*crb3)); 311 306 ap_msg->length = sizeof(*crb3); 312 307 crb3->header.msg_type_code = TYPE50_TYPE_CODE;
+4 -4
drivers/s390/crypto/zcrypt_msgtype50.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * zcrypt 2.1.0 4 4 * ··· 17 17 #define MSGTYPE50_NAME "zcrypt_msgtype50" 18 18 #define MSGTYPE50_VARIANT_DEFAULT 0 19 19 20 - #define MSGTYPE50_CRB2_MAX_MSG_SIZE 0x390 /*sizeof(struct type50_crb2_msg)*/ 21 - #define MSGTYPE50_CRB3_MAX_MSG_SIZE 0x710 /*sizeof(struct type50_crb3_msg)*/ 20 + #define MSGTYPE50_CRB2_MAX_MSG_SIZE 0x390 /* sizeof(struct type50_crb2_msg) */ 21 + #define MSGTYPE50_CRB3_MAX_MSG_SIZE 0x710 /* sizeof(struct type50_crb3_msg) */ 22 22 23 - #define MSGTYPE_ADJUSTMENT 0x08 /*type04 extension (not needed in type50)*/ 23 + #define MSGTYPE_ADJUSTMENT 0x08 /* type04 extension (not needed in type50) */ 24 24 25 25 unsigned int get_rsa_modex_fc(struct ica_rsa_modexpo *, int *); 26 26 unsigned int get_rsa_crt_fc(struct ica_rsa_modexpo_crt *, int *);
+22 -12
drivers/s390/crypto/zcrypt_msgtype6.c
··· 421 421 if (ap_msg->length > MSGTYPE06_MAX_MSG_SIZE) 422 422 return -EINVAL; 423 423 424 - /* Overflow check 425 - sum must be greater (or equal) than the largest operand */ 424 + /* 425 + * Overflow check 426 + * sum must be greater (or equal) than the largest operand 427 + */ 426 428 req_sumlen = CEIL4(xcRB->request_control_blk_length) + 427 429 xcRB->request_data_length; 428 430 if ((CEIL4(xcRB->request_control_blk_length) <= ··· 444 442 if (replylen > MSGTYPE06_MAX_MSG_SIZE) 445 443 return -EINVAL; 446 444 447 - /* Overflow check 448 - sum must be greater (or equal) than the largest operand */ 445 + /* 446 + * Overflow check 447 + * sum must be greater (or equal) than the largest operand 448 + */ 449 449 resp_sumlen = CEIL4(xcRB->reply_control_blk_length) + 450 450 xcRB->reply_data_length; 451 451 if ((CEIL4(xcRB->reply_control_blk_length) <= xcRB->reply_data_length) ? ··· 458 454 459 455 /* prepare type6 header */ 460 456 msg->hdr = static_type6_hdrX; 461 - memcpy(msg->hdr.agent_id , &(xcRB->agent_ID), sizeof(xcRB->agent_ID)); 457 + memcpy(msg->hdr.agent_id, &(xcRB->agent_ID), sizeof(xcRB->agent_ID)); 462 458 msg->hdr.ToCardLen1 = xcRB->request_control_blk_length; 463 459 if (xcRB->request_data_length) { 464 460 msg->hdr.offset2 = msg->hdr.offset1 + rcblen; ··· 810 806 if (msg->cprbx.cprb_ver_id == 0x02) 811 807 return convert_type86_ica(zq, reply, 812 808 outputdata, outputdatalength); 813 - /* Fall through, no break, incorrect cprb version is an unknown 814 - * response */ 809 + /* 810 + * Fall through, no break, incorrect cprb version is an unknown 811 + * response 812 + */ 815 813 default: /* Unknown response type, this should NEVER EVER happen */ 816 814 zq->online = 0; 817 815 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", ··· 846 840 } 847 841 if (msg->cprbx.cprb_ver_id == 0x02) 848 842 return convert_type86_xcrb(zq, reply, xcRB); 849 - /* Fall through, no break, incorrect cprb version is an unknown 850 - * response */ 843 + /* 844 + * Fall through, no break, incorrect cprb version is an unknown 845 + * response 846 + */ 851 847 default: /* Unknown response type, this should NEVER EVER happen */ 852 848 xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ 853 849 zq->online = 0; ··· 909 901 return -EINVAL; 910 902 if (msg->cprbx.cprb_ver_id == 0x02) 911 903 return convert_type86_rng(zq, reply, data); 912 - /* Fall through, no break, incorrect cprb version is an unknown 913 - * response */ 904 + /* 905 + * Fall through, no break, incorrect cprb version is an unknown 906 + * response 907 + */ 914 908 default: /* Unknown response type, this should NEVER EVER happen */ 915 909 zq->online = 0; 916 910 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", ··· 1014 1004 } 1015 1005 } else { 1016 1006 memcpy(msg->message, reply->message, sizeof(error_reply)); 1017 - } 1007 + } 1018 1008 out: 1019 1009 complete(&(resp_type->work)); 1020 1010 }
+1 -1
drivers/s390/crypto/zcrypt_msgtype6.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * zcrypt 2.1.0 4 4 *
+4 -2
drivers/s390/crypto/zcrypt_pcixcc.c
··· 95 95 struct type86_hdr hdr; 96 96 struct type86_fmt2_ext fmt2; 97 97 struct CPRBX cprbx; 98 - } __attribute__((packed)) *reply; 98 + } __packed *reply; 99 99 struct { 100 100 struct type6_hdr hdr; 101 101 struct CPRBX cprbx; ··· 104 104 char rule[8]; 105 105 short int verb_length; 106 106 short int key_length; 107 - } __packed * msg; 107 + } __packed *msg; 108 108 int rc, i; 109 109 110 110 ap_init_message(&ap_msg); ··· 223 223 .probe = zcrypt_pcixcc_card_probe, 224 224 .remove = zcrypt_pcixcc_card_remove, 225 225 .ids = zcrypt_pcixcc_card_ids, 226 + .flags = AP_DRIVER_FLAG_DEFAULT, 226 227 }; 227 228 228 229 /** ··· 287 286 .suspend = ap_queue_suspend, 288 287 .resume = ap_queue_resume, 289 288 .ids = zcrypt_pcixcc_queue_ids, 289 + .flags = AP_DRIVER_FLAG_DEFAULT, 290 290 }; 291 291 292 292 int __init zcrypt_pcixcc_init(void)
+1 -1
drivers/s390/crypto/zcrypt_pcixcc.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * zcrypt 2.1.0 4 4 *
+11 -12
drivers/s390/crypto/zcrypt_queue.c
··· 38 38 * Device attributes common for all crypto queue devices. 39 39 */ 40 40 41 - static ssize_t zcrypt_queue_online_show(struct device *dev, 42 - struct device_attribute *attr, 43 - char *buf) 41 + static ssize_t online_show(struct device *dev, 42 + struct device_attribute *attr, 43 + char *buf) 44 44 { 45 45 struct zcrypt_queue *zq = to_ap_queue(dev)->private; 46 46 47 47 return snprintf(buf, PAGE_SIZE, "%d\n", zq->online); 48 48 } 49 49 50 - static ssize_t zcrypt_queue_online_store(struct device *dev, 51 - struct device_attribute *attr, 52 - const char *buf, size_t count) 50 + static ssize_t online_store(struct device *dev, 51 + struct device_attribute *attr, 52 + const char *buf, size_t count) 53 53 { 54 54 struct zcrypt_queue *zq = to_ap_queue(dev)->private; 55 55 struct zcrypt_card *zc = zq->zcard; ··· 72 72 return count; 73 73 } 74 74 75 - static DEVICE_ATTR(online, 0644, zcrypt_queue_online_show, 76 - zcrypt_queue_online_store); 75 + static DEVICE_ATTR_RW(online); 77 76 78 - static ssize_t zcrypt_queue_load_show(struct device *dev, 79 - struct device_attribute *attr, 80 - char *buf) 77 + static ssize_t load_show(struct device *dev, 78 + struct device_attribute *attr, 79 + char *buf) 81 80 { 82 81 struct zcrypt_queue *zq = to_ap_queue(dev)->private; 83 82 84 83 return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&zq->load)); 85 84 } 86 85 87 - static DEVICE_ATTR(load, 0444, zcrypt_queue_load_show, NULL); 86 + static DEVICE_ATTR_RO(load); 88 87 89 88 static struct attribute *zcrypt_queue_attrs[] = { 90 89 &dev_attr_online.attr,