Commit e1dbc5a4 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 40c431a5 4ec84835
...@@ -140,7 +140,7 @@ config S390 ...@@ -140,7 +140,7 @@ config S390
select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_TRACER
select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_GCC_PLUGINS if BROKEN select HAVE_GCC_PLUGINS
select HAVE_KERNEL_BZIP2 select HAVE_KERNEL_BZIP2
select HAVE_KERNEL_GZIP select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZ4 select HAVE_KERNEL_LZ4
......
...@@ -49,23 +49,23 @@ struct ap_queue_status { ...@@ -49,23 +49,23 @@ struct ap_queue_status {
/** /**
* ap_intructions_available() - Test if AP instructions are available. * ap_intructions_available() - Test if AP instructions are available.
* *
* Returns 0 if the AP instructions are installed. * Returns true if the AP instructions are installed, otherwise false.
*/ */
static inline int ap_instructions_available(void) static inline bool ap_instructions_available(void)
{ {
register unsigned long reg0 asm ("0") = AP_MKQID(0, 0); register unsigned long reg0 asm ("0") = AP_MKQID(0, 0);
register unsigned long reg1 asm ("1") = -ENODEV; register unsigned long reg1 asm ("1") = 0;
register unsigned long reg2 asm ("2"); register unsigned long reg2 asm ("2") = 0;
asm volatile( asm volatile(
" .long 0xb2af0000\n" /* PQAP(TAPQ) */ " .long 0xb2af0000\n" /* PQAP(TAPQ) */
"0: la %0,0\n" "0: la %0,1\n"
"1:\n" "1:\n"
EX_TABLE(0b, 1b) EX_TABLE(0b, 1b)
: "+d" (reg1), "=d" (reg2) : "+d" (reg1), "+d" (reg2)
: "d" (reg0) : "d" (reg0)
: "cc"); : "cc");
return reg1; return reg1 != 0;
} }
/** /**
......
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
* - length(n_modulus) = inputdatalength * - length(n_modulus) = inputdatalength
*/ */
struct ica_rsa_modexpo { struct ica_rsa_modexpo {
char __user * inputdata; char __user *inputdata;
unsigned int inputdatalength; unsigned int inputdatalength;
char __user * outputdata; char __user *outputdata;
unsigned int outputdatalength; unsigned int outputdatalength;
char __user * b_key; char __user *b_key;
char __user * n_modulus; char __user *n_modulus;
}; };
/** /**
...@@ -55,15 +55,15 @@ struct ica_rsa_modexpo { ...@@ -55,15 +55,15 @@ struct ica_rsa_modexpo {
* - length(u_mult_inv) = inputdatalength/2 + 8 * - length(u_mult_inv) = inputdatalength/2 + 8
*/ */
struct ica_rsa_modexpo_crt { struct ica_rsa_modexpo_crt {
char __user * inputdata; char __user *inputdata;
unsigned int inputdatalength; unsigned int inputdatalength;
char __user * outputdata; char __user *outputdata;
unsigned int outputdatalength; unsigned int outputdatalength;
char __user * bp_key; char __user *bp_key;
char __user * bq_key; char __user *bq_key;
char __user * np_prime; char __user *np_prime;
char __user * nq_prime; char __user *nq_prime;
char __user * u_mult_inv; char __user *u_mult_inv;
}; };
/** /**
...@@ -93,18 +93,18 @@ struct CPRBX { ...@@ -93,18 +93,18 @@ struct CPRBX {
unsigned int req_extbl; /* request extension block len */ unsigned int req_extbl; /* request extension block len */
unsigned char pad_001[4]; /* reserved */ unsigned char pad_001[4]; /* reserved */
unsigned int rpld_extbl; /* replied extension block len */ unsigned int rpld_extbl; /* replied extension block len */
unsigned char padx000[16 - sizeof (char *)]; unsigned char padx000[16 - sizeof(char *)];
unsigned char * req_parmb; /* request parm block 'address' */ unsigned char *req_parmb; /* request parm block 'address' */
unsigned char padx001[16 - sizeof (char *)]; unsigned char padx001[16 - sizeof(char *)];
unsigned char * req_datab; /* request data block 'address' */ unsigned char *req_datab; /* request data block 'address' */
unsigned char padx002[16 - sizeof (char *)]; unsigned char padx002[16 - sizeof(char *)];
unsigned char * rpl_parmb; /* reply parm block 'address' */ unsigned char *rpl_parmb; /* reply parm block 'address' */
unsigned char padx003[16 - sizeof (char *)]; unsigned char padx003[16 - sizeof(char *)];
unsigned char * rpl_datab; /* reply data block 'address' */ unsigned char *rpl_datab; /* reply data block 'address' */
unsigned char padx004[16 - sizeof (char *)]; unsigned char padx004[16 - sizeof(char *)];
unsigned char * req_extb; /* request extension block 'addr'*/ unsigned char *req_extb; /* request extension block 'addr'*/
unsigned char padx005[16 - sizeof (char *)]; unsigned char padx005[16 - sizeof(char *)];
unsigned char * rpl_extb; /* reply extension block 'address'*/ unsigned char *rpl_extb; /* reply extension block 'address'*/
unsigned short ccp_rtcode; /* server return code */ unsigned short ccp_rtcode; /* server return code */
unsigned short ccp_rscode; /* server reason code */ unsigned short ccp_rscode; /* server reason code */
unsigned int mac_data_len; /* Mac Data Length */ unsigned int mac_data_len; /* Mac Data Length */
...@@ -127,17 +127,17 @@ struct ica_xcRB { ...@@ -127,17 +127,17 @@ struct ica_xcRB {
unsigned int user_defined; unsigned int user_defined;
unsigned short request_ID; unsigned short request_ID;
unsigned int request_control_blk_length; unsigned int request_control_blk_length;
unsigned char padding1[16 - sizeof (char *)]; unsigned char padding1[16 - sizeof(char *)];
char __user * request_control_blk_addr; char __user *request_control_blk_addr;
unsigned int request_data_length; unsigned int request_data_length;
char padding2[16 - sizeof (char *)]; char padding2[16 - sizeof(char *)];
char __user * request_data_address; char __user *request_data_address;
unsigned int reply_control_blk_length; unsigned int reply_control_blk_length;
char padding3[16 - sizeof (char *)]; char padding3[16 - sizeof(char *)];
char __user * reply_control_blk_addr; char __user *reply_control_blk_addr;
unsigned int reply_data_length; unsigned int reply_data_length;
char padding4[16 - sizeof (char *)]; char padding4[16 - sizeof(char *)];
char __user * reply_data_addr; char __user *reply_data_addr;
unsigned short priority_window; unsigned short priority_window;
unsigned int status; unsigned int status;
} __attribute__((packed)); } __attribute__((packed));
...@@ -233,7 +233,7 @@ struct zcrypt_device_matrix_ext { ...@@ -233,7 +233,7 @@ struct zcrypt_device_matrix_ext {
struct zcrypt_device_status_ext device[MAX_ZDEV_ENTRIES_EXT]; struct zcrypt_device_status_ext device[MAX_ZDEV_ENTRIES_EXT];
}; };
#define AUTOSELECT ((unsigned int)0xFFFFFFFF) #define AUTOSELECT 0xFFFFFFFF
#define ZCRYPT_IOCTL_MAGIC 'z' #define ZCRYPT_IOCTL_MAGIC 'z'
......
...@@ -17,14 +17,6 @@ ...@@ -17,14 +17,6 @@
#include <asm/gmap.h> #include <asm/gmap.h>
#include <asm/nmi.h> #include <asm/nmi.h>
/*
* Make sure that the compiler is new enough. We want a compiler that
* is known to work with the "Q" assembler constraint.
*/
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
#error Your compiler is too old; please use version 4.3 or newer
#endif
int main(void) int main(void)
{ {
/* task struct offsets */ /* task struct offsets */
......
...@@ -293,19 +293,6 @@ int remap_oldmem_pfn_range(struct vm_area_struct *vma, unsigned long from, ...@@ -293,19 +293,6 @@ int remap_oldmem_pfn_range(struct vm_area_struct *vma, unsigned long from,
prot); prot);
} }
/*
* Alloc memory and panic in case of ENOMEM
*/
static void *kzalloc_panic(int len)
{
void *rc;
rc = kzalloc(len, GFP_KERNEL);
if (!rc)
panic("s390 kdump kzalloc (%d) failed", len);
return rc;
}
static const char *nt_name(Elf64_Word type) static const char *nt_name(Elf64_Word type)
{ {
const char *name = "LINUX"; const char *name = "LINUX";
...@@ -451,11 +438,15 @@ static void *get_vmcoreinfo_old(unsigned long *size) ...@@ -451,11 +438,15 @@ static void *get_vmcoreinfo_old(unsigned long *size)
if (copy_oldmem_kernel(nt_name, addr + sizeof(note), if (copy_oldmem_kernel(nt_name, addr + sizeof(note),
sizeof(nt_name) - 1)) sizeof(nt_name) - 1))
return NULL; return NULL;
if (strcmp(nt_name, "VMCOREINFO") != 0) if (strcmp(nt_name, VMCOREINFO_NOTE_NAME) != 0)
return NULL;
vmcoreinfo = kzalloc(note.n_descsz, GFP_KERNEL);
if (!vmcoreinfo)
return NULL; return NULL;
vmcoreinfo = kzalloc_panic(note.n_descsz); if (copy_oldmem_kernel(vmcoreinfo, addr + 24, note.n_descsz)) {
if (copy_oldmem_kernel(vmcoreinfo, addr + 24, note.n_descsz)) kfree(vmcoreinfo);
return NULL; return NULL;
}
*size = note.n_descsz; *size = note.n_descsz;
return vmcoreinfo; return vmcoreinfo;
} }
...@@ -465,39 +456,38 @@ static void *get_vmcoreinfo_old(unsigned long *size) ...@@ -465,39 +456,38 @@ static void *get_vmcoreinfo_old(unsigned long *size)
*/ */
static void *nt_vmcoreinfo(void *ptr) static void *nt_vmcoreinfo(void *ptr)
{ {
const char *name = VMCOREINFO_NOTE_NAME;
unsigned long size; unsigned long size;
void *vmcoreinfo; void *vmcoreinfo;
vmcoreinfo = os_info_old_entry(OS_INFO_VMCOREINFO, &size); vmcoreinfo = os_info_old_entry(OS_INFO_VMCOREINFO, &size);
if (!vmcoreinfo) if (vmcoreinfo)
return nt_init_name(ptr, 0, vmcoreinfo, size, name);
vmcoreinfo = get_vmcoreinfo_old(&size); vmcoreinfo = get_vmcoreinfo_old(&size);
if (!vmcoreinfo) if (!vmcoreinfo)
return ptr; return ptr;
return nt_init_name(ptr, 0, vmcoreinfo, size, "VMCOREINFO"); ptr = nt_init_name(ptr, 0, vmcoreinfo, size, name);
kfree(vmcoreinfo);
return ptr;
} }
static size_t nt_vmcoreinfo_size(void) static size_t nt_vmcoreinfo_size(void)
{ {
const char *name = "VMCOREINFO"; const char *name = VMCOREINFO_NOTE_NAME;
char nt_name[11]; unsigned long size;
Elf64_Nhdr note; void *vmcoreinfo;
void *addr;
if (copy_oldmem_kernel(&addr, &S390_lowcore.vmcore_info, sizeof(addr)))
return 0;
if (copy_oldmem_kernel(&note, addr, sizeof(note)))
return 0;
memset(nt_name, 0, sizeof(nt_name)); vmcoreinfo = os_info_old_entry(OS_INFO_VMCOREINFO, &size);
if (copy_oldmem_kernel(nt_name, addr + sizeof(note), if (vmcoreinfo)
sizeof(nt_name) - 1)) return nt_size_name(size, name);
return 0;
if (strcmp(nt_name, name) != 0) vmcoreinfo = get_vmcoreinfo_old(&size);
if (!vmcoreinfo)
return 0; return 0;
return nt_size_name(note.n_descsz, name); kfree(vmcoreinfo);
return nt_size_name(size, name);
} }
/* /*
...@@ -660,7 +650,15 @@ int elfcorehdr_alloc(unsigned long long *addr, unsigned long long *size) ...@@ -660,7 +650,15 @@ int elfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)
alloc_size = get_elfcorehdr_size(mem_chunk_cnt); alloc_size = get_elfcorehdr_size(mem_chunk_cnt);
hdr = kzalloc_panic(alloc_size); hdr = kzalloc(alloc_size, GFP_KERNEL);
/* Without elfcorehdr /proc/vmcore cannot be created. Thus creating
* a dump with this crash kernel will fail. Panic now to allow other
* dump mechanisms to take over.
*/
if (!hdr)
panic("s390 kdump allocating elfcorehdr failed");
/* Init elf header */ /* Init elf header */
ptr = ehdr_init(hdr, mem_chunk_cnt); ptr = ehdr_init(hdr, mem_chunk_cnt);
/* Init program headers */ /* Init program headers */
......
...@@ -420,7 +420,8 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) ...@@ -420,7 +420,8 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
/* Request MSI interrupts */ /* Request MSI interrupts */
hwirq = 0; hwirq = 0;
for_each_pci_msi_entry(msi, pdev) { for_each_pci_msi_entry(msi, pdev) {
rc = -EIO; if (hwirq >= msi_vecs)
break;
irq = irq_alloc_desc(0); /* Alloc irq on node 0 */ irq = irq_alloc_desc(0); /* Alloc irq on node 0 */
if (irq < 0) if (irq < 0)
return -ENOMEM; return -ENOMEM;
......
...@@ -93,7 +93,6 @@ static int pci_perf_show(struct seq_file *m, void *v) ...@@ -93,7 +93,6 @@ static int pci_perf_show(struct seq_file *m, void *v)
} }
/* header */ /* header */
seq_printf(m, "FMB @ %p\n", zdev->fmb);
seq_printf(m, "Update interval: %u ms\n", zdev->fmb_update); seq_printf(m, "Update interval: %u ms\n", zdev->fmb_update);
seq_printf(m, "Samples: %u\n", zdev->fmb->samples); seq_printf(m, "Samples: %u\n", zdev->fmb->samples);
seq_printf(m, "Last update TOD: %Lx\n", zdev->fmb->last_update); seq_printf(m, "Last update TOD: %Lx\n", zdev->fmb->last_update);
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0+ /* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* Copyright IBM Corp. 2006, 2012 * Copyright IBM Corp. 2006, 2012
* Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
...@@ -117,9 +117,18 @@ enum ap_wait { ...@@ -117,9 +117,18 @@ enum ap_wait {
struct ap_device; struct ap_device;
struct ap_message; struct ap_message;
/*
* The ap driver struct includes a flags field which holds some info for
* the ap bus about the driver. Currently only one flag is supported and
* used: The DEFAULT flag marks an ap driver as a default driver which is
* used together with the apmask and aqmask whitelisting of the ap bus.
*/
#define AP_DRIVER_FLAG_DEFAULT 0x0001
struct ap_driver { struct ap_driver {
struct device_driver driver; struct device_driver driver;
struct ap_device_id *ids; struct ap_device_id *ids;
unsigned int flags;
int (*probe)(struct ap_device *); int (*probe)(struct ap_device *);
void (*remove)(struct ap_device *); void (*remove)(struct ap_device *);
...@@ -167,7 +176,7 @@ struct ap_queue { ...@@ -167,7 +176,7 @@ struct ap_queue {
int pendingq_count; /* # requests on pendingq list. */ int pendingq_count; /* # requests on pendingq list. */
int requestq_count; /* # requests on requestq list. */ int requestq_count; /* # requests on requestq list. */
int total_request_count; /* # requests ever for this AP device.*/ int total_request_count; /* # requests ever for this AP device.*/
int request_timeout; /* Request timout in jiffies. */ int request_timeout; /* Request timeout in jiffies. */
struct timer_list timeout; /* Timer for request timeouts. */ struct timer_list timeout; /* Timer for request timeouts. */
struct list_head pendingq; /* List of message sent to AP queue. */ struct list_head pendingq; /* List of message sent to AP queue. */
struct list_head requestq; /* List of message yet to be sent. */ struct list_head requestq; /* List of message yet to be sent. */
...@@ -248,4 +257,27 @@ void ap_queue_resume(struct ap_device *ap_dev); ...@@ -248,4 +257,27 @@ void ap_queue_resume(struct ap_device *ap_dev);
struct ap_card *ap_card_create(int id, int queue_depth, int raw_device_type, struct ap_card *ap_card_create(int id, int queue_depth, int raw_device_type,
int comp_device_type, unsigned int functions); int comp_device_type, unsigned int functions);
/*
* check APQN for owned/reserved by ap bus and default driver(s).
* Checks if this APQN is or will be in use by the ap bus
* and the default set of drivers.
* If yes, returns 1, if not returns 0. On error a negative
* errno value is returned.
*/
int ap_owned_by_def_drv(int card, int queue);
/*
* check 'matrix' of APQNs for owned/reserved by ap bus and
* default driver(s).
* Checks if there is at least one APQN in the given 'matrix'
* marked as owned/reserved by the ap bus and default driver(s).
* If such an APQN is found the return value is 1, otherwise
* 0 is returned. On error a negative errno value is returned.
* The parameter apm is a bitmask which should be declared
* as DECLARE_BITMAP(apm, AP_DEVICES), the aqm parameter is
* similar, should be declared as DECLARE_BITMAP(aqm, AP_DOMAINS).
*/
int ap_apqn_in_matrix_owned_by_def_drv(unsigned long *apm,
unsigned long *aqm);
#endif /* _AP_BUS_H_ */ #endif /* _AP_BUS_H_ */
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
/* /*
* AP card related attributes. * AP card related attributes.
*/ */
static ssize_t ap_hwtype_show(struct device *dev, static ssize_t hwtype_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct ap_card *ac = to_ap_card(dev); struct ap_card *ac = to_ap_card(dev);
...@@ -26,9 +26,9 @@ static ssize_t ap_hwtype_show(struct device *dev, ...@@ -26,9 +26,9 @@ static ssize_t ap_hwtype_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", ac->ap_dev.device_type); return snprintf(buf, PAGE_SIZE, "%d\n", ac->ap_dev.device_type);
} }
static DEVICE_ATTR(hwtype, 0444, ap_hwtype_show, NULL); static DEVICE_ATTR_RO(hwtype);
static ssize_t ap_raw_hwtype_show(struct device *dev, static ssize_t raw_hwtype_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct ap_card *ac = to_ap_card(dev); struct ap_card *ac = to_ap_card(dev);
...@@ -36,9 +36,9 @@ static ssize_t ap_raw_hwtype_show(struct device *dev, ...@@ -36,9 +36,9 @@ static ssize_t ap_raw_hwtype_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", ac->raw_hwtype); return snprintf(buf, PAGE_SIZE, "%d\n", ac->raw_hwtype);
} }
static DEVICE_ATTR(raw_hwtype, 0444, ap_raw_hwtype_show, NULL); static DEVICE_ATTR_RO(raw_hwtype);
static ssize_t ap_depth_show(struct device *dev, struct device_attribute *attr, static ssize_t depth_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct ap_card *ac = to_ap_card(dev); struct ap_card *ac = to_ap_card(dev);
...@@ -46,7 +46,7 @@ static ssize_t ap_depth_show(struct device *dev, struct device_attribute *attr, ...@@ -46,7 +46,7 @@ static ssize_t ap_depth_show(struct device *dev, struct device_attribute *attr,
return snprintf(buf, PAGE_SIZE, "%d\n", ac->queue_depth); return snprintf(buf, PAGE_SIZE, "%d\n", ac->queue_depth);
} }
static DEVICE_ATTR(depth, 0444, ap_depth_show, NULL); static DEVICE_ATTR_RO(depth);
static ssize_t ap_functions_show(struct device *dev, static ssize_t ap_functions_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
...@@ -58,7 +58,7 @@ static ssize_t ap_functions_show(struct device *dev, ...@@ -58,7 +58,7 @@ static ssize_t ap_functions_show(struct device *dev,
static DEVICE_ATTR_RO(ap_functions); static DEVICE_ATTR_RO(ap_functions);
static ssize_t ap_req_count_show(struct device *dev, static ssize_t request_count_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
...@@ -72,7 +72,7 @@ static ssize_t ap_req_count_show(struct device *dev, ...@@ -72,7 +72,7 @@ static ssize_t ap_req_count_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", req_cnt); return snprintf(buf, PAGE_SIZE, "%d\n", req_cnt);
} }
static ssize_t ap_req_count_store(struct device *dev, static ssize_t request_count_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
...@@ -88,9 +88,9 @@ static ssize_t ap_req_count_store(struct device *dev, ...@@ -88,9 +88,9 @@ static ssize_t ap_req_count_store(struct device *dev,
return count; return count;
} }
static DEVICE_ATTR(request_count, 0644, ap_req_count_show, ap_req_count_store); static DEVICE_ATTR_RW(request_count);
static ssize_t ap_requestq_count_show(struct device *dev, static ssize_t requestq_count_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct ap_card *ac = to_ap_card(dev); struct ap_card *ac = to_ap_card(dev);
...@@ -105,9 +105,9 @@ static ssize_t ap_requestq_count_show(struct device *dev, ...@@ -105,9 +105,9 @@ static ssize_t ap_requestq_count_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", reqq_cnt); return snprintf(buf, PAGE_SIZE, "%d\n", reqq_cnt);
} }
static DEVICE_ATTR(requestq_count, 0444, ap_requestq_count_show, NULL); static DEVICE_ATTR_RO(requestq_count);
static ssize_t ap_pendingq_count_show(struct device *dev, static ssize_t pendingq_count_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct ap_card *ac = to_ap_card(dev); struct ap_card *ac = to_ap_card(dev);
...@@ -122,15 +122,15 @@ static ssize_t ap_pendingq_count_show(struct device *dev, ...@@ -122,15 +122,15 @@ static ssize_t ap_pendingq_count_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", penq_cnt); return snprintf(buf, PAGE_SIZE, "%d\n", penq_cnt);
} }
static DEVICE_ATTR(pendingq_count, 0444, ap_pendingq_count_show, NULL); static DEVICE_ATTR_RO(pendingq_count);
static ssize_t ap_modalias_show(struct device *dev, static ssize_t modalias_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
return sprintf(buf, "ap:t%02X\n", to_ap_dev(dev)->device_type); return sprintf(buf, "ap:t%02X\n", to_ap_dev(dev)->device_type);
} }
static DEVICE_ATTR(modalias, 0444, ap_modalias_show, NULL); static DEVICE_ATTR_RO(modalias);
static struct attribute *ap_card_dev_attrs[] = { static struct attribute *ap_card_dev_attrs[] = {
&dev_attr_hwtype.attr, &dev_attr_hwtype.attr,
......
...@@ -462,7 +462,7 @@ EXPORT_SYMBOL(ap_queue_resume); ...@@ -462,7 +462,7 @@ EXPORT_SYMBOL(ap_queue_resume);
/* /*
* AP queue related attributes. * AP queue related attributes.
*/ */
static ssize_t ap_req_count_show(struct device *dev, static ssize_t request_count_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
...@@ -475,7 +475,7 @@ static ssize_t ap_req_count_show(struct device *dev, ...@@ -475,7 +475,7 @@ static ssize_t ap_req_count_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", req_cnt); return snprintf(buf, PAGE_SIZE, "%d\n", req_cnt);
} }
static ssize_t ap_req_count_store(struct device *dev, static ssize_t request_count_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
...@@ -488,9 +488,9 @@ static ssize_t ap_req_count_store(struct device *dev, ...@@ -488,9 +488,9 @@ static ssize_t ap_req_count_store(struct device *dev,
return count; return count;
} }
static DEVICE_ATTR(request_count, 0644, ap_req_count_show, ap_req_count_store); static DEVICE_ATTR_RW(request_count);
static ssize_t ap_requestq_count_show(struct device *dev, static ssize_t requestq_count_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct ap_queue *aq = to_ap_queue(dev); struct ap_queue *aq = to_ap_queue(dev);
...@@ -502,9 +502,9 @@ static ssize_t ap_requestq_count_show(struct device *dev, ...@@ -502,9 +502,9 @@ static ssize_t ap_requestq_count_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", reqq_cnt); return snprintf(buf, PAGE_SIZE, "%d\n", reqq_cnt);
} }
static DEVICE_ATTR(requestq_count, 0444, ap_requestq_count_show, NULL); static DEVICE_ATTR_RO(requestq_count);
static ssize_t ap_pendingq_count_show(struct device *dev, static ssize_t pendingq_count_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct ap_queue *aq = to_ap_queue(dev); struct ap_queue *aq = to_ap_queue(dev);
...@@ -516,9 +516,9 @@ static ssize_t ap_pendingq_count_show(struct device *dev, ...@@ -516,9 +516,9 @@ static ssize_t ap_pendingq_count_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", penq_cnt); return snprintf(buf, PAGE_SIZE, "%d\n", penq_cnt);
} }
static DEVICE_ATTR(pendingq_count, 0444, ap_pendingq_count_show, NULL); static DEVICE_ATTR_RO(pendingq_count);
static ssize_t ap_reset_show(struct device *dev, static ssize_t reset_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct ap_queue *aq = to_ap_queue(dev); struct ap_queue *aq = to_ap_queue(dev);
...@@ -541,9 +541,9 @@ static ssize_t ap_reset_show(struct device *dev, ...@@ -541,9 +541,9 @@ static ssize_t ap_reset_show(struct device *dev,
return rc; return rc;
} }
static DEVICE_ATTR(reset, 0444, ap_reset_show, NULL); static DEVICE_ATTR_RO(reset);
static ssize_t ap_interrupt_show(struct device *dev, static ssize_t interrupt_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct ap_queue *aq = to_ap_queue(dev); struct ap_queue *aq = to_ap_queue(dev);
...@@ -560,7 +560,7 @@ static ssize_t ap_interrupt_show(struct device *dev, ...@@ -560,7 +560,7 @@ static ssize_t ap_interrupt_show(struct device *dev,
return rc; return rc;
} }
static DEVICE_ATTR(interrupt, 0444, ap_interrupt_show, NULL); static DEVICE_ATTR_RO(interrupt);
static struct attribute *ap_queue_dev_attrs[] = { static struct attribute *ap_queue_dev_attrs[] = {
&dev_attr_request_count.attr, &dev_attr_request_count.attr,
......
...@@ -82,20 +82,20 @@ static int check_secaeskeytoken(const u8 *token, int keybitsize) ...@@ -82,20 +82,20 @@ static int check_secaeskeytoken(const u8 *token, int keybitsize)
if (t->type != 0x01) { if (t->type != 0x01) {
DEBUG_ERR( DEBUG_ERR(
"check_secaeskeytoken secure token check failed, type mismatch 0x%02x != 0x01\n", "%s secure token check failed, type mismatch 0x%02x != 0x01\n",
(int) t->type); __func__, (int) t->type);
return -EINVAL; return -EINVAL;
} }
if (t->version != 0x04) { if (t->version != 0x04) {
DEBUG_ERR( DEBUG_ERR(
"check_secaeskeytoken secure token check failed, version mismatch 0x%02x != 0x04\n", "%s secure token check failed, version mismatch 0x%02x != 0x04\n",
(int) t->version); __func__, (int) t->version);
return -EINVAL; return -EINVAL;
} }
if (keybitsize > 0 && t->bitsize != keybitsize) { if (keybitsize > 0 && t->bitsize != keybitsize) {
DEBUG_ERR( DEBUG_ERR(
"check_secaeskeytoken secure token check failed, bitsize mismatch %d != %d\n", "%s secure token check failed, bitsize mismatch %d != %d\n",
(int) t->bitsize, keybitsize); __func__, (int) t->bitsize, keybitsize);
return -EINVAL; return -EINVAL;
} }
...@@ -270,8 +270,8 @@ int pkey_genseckey(u16 cardnr, u16 domain, ...@@ -270,8 +270,8 @@ int pkey_genseckey(u16 cardnr, u16 domain,
break; break;
default: default:
DEBUG_ERR( DEBUG_ERR(
"pkey_genseckey unknown/unsupported keytype %d\n", "%s unknown/unsupported keytype %d\n",
keytype); __func__, keytype);
rc = -EINVAL; rc = -EINVAL;
goto out; goto out;
} }
...@@ -290,15 +290,16 @@ int pkey_genseckey(u16 cardnr, u16 domain, ...@@ -290,15 +290,16 @@ int pkey_genseckey(u16 cardnr, u16 domain,
rc = _zcrypt_send_cprb(&xcrb); rc = _zcrypt_send_cprb(&xcrb);
if (rc) { if (rc) {
DEBUG_ERR( DEBUG_ERR(
"pkey_genseckey zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n",
(int) cardnr, (int) domain, rc); __func__, (int) cardnr, (int) domain, rc);
goto out; goto out;
} }
/* check response returncode and reasoncode */ /* check response returncode and reasoncode */
if (prepcblk->ccp_rtcode != 0) { if (prepcblk->ccp_rtcode != 0) {
DEBUG_ERR( DEBUG_ERR(
"pkey_genseckey secure key generate failure, card response %d/%d\n", "%s secure key generate failure, card response %d/%d\n",
__func__,
(int) prepcblk->ccp_rtcode, (int) prepcblk->ccp_rtcode,
(int) prepcblk->ccp_rscode); (int) prepcblk->ccp_rscode);
rc = -EIO; rc = -EIO;
...@@ -315,8 +316,8 @@ int pkey_genseckey(u16 cardnr, u16 domain, ...@@ -315,8 +316,8 @@ int pkey_genseckey(u16 cardnr, u16 domain,
- sizeof(prepparm->lv3.keyblock.tokattr); - sizeof(prepparm->lv3.keyblock.tokattr);
if (seckeysize != SECKEYBLOBSIZE) { if (seckeysize != SECKEYBLOBSIZE) {
DEBUG_ERR( DEBUG_ERR(
"pkey_genseckey secure token size mismatch %d != %d bytes\n", "%s secure token size mismatch %d != %d bytes\n",
seckeysize, SECKEYBLOBSIZE); __func__, seckeysize, SECKEYBLOBSIZE);
rc = -EIO; rc = -EIO;
goto out; goto out;
} }
...@@ -407,8 +408,8 @@ int pkey_clr2seckey(u16 cardnr, u16 domain, u32 keytype, ...@@ -407,8 +408,8 @@ int pkey_clr2seckey(u16 cardnr, u16 domain, u32 keytype,
break; break;
default: default:
DEBUG_ERR( DEBUG_ERR(
"pkey_clr2seckey unknown/unsupported keytype %d\n", "%s unknown/unsupported keytype %d\n",
keytype); __func__, keytype);
rc = -EINVAL; rc = -EINVAL;
goto out; goto out;
} }
...@@ -427,15 +428,16 @@ int pkey_clr2seckey(u16 cardnr, u16 domain, u32 keytype, ...@@ -427,15 +428,16 @@ int pkey_clr2seckey(u16 cardnr, u16 domain, u32 keytype,
rc = _zcrypt_send_cprb(&xcrb); rc = _zcrypt_send_cprb(&xcrb);
if (rc) { if (rc) {
DEBUG_ERR( DEBUG_ERR(
"pkey_clr2seckey zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n",
(int) cardnr, (int) domain, rc); __func__, (int) cardnr, (int) domain, rc);
goto out; goto out;
} }
/* check response returncode and reasoncode */ /* check response returncode and reasoncode */
if (prepcblk->ccp_rtcode != 0) { if (prepcblk->ccp_rtcode != 0) {
DEBUG_ERR( DEBUG_ERR(
"pkey_clr2seckey clear key import failure, card response %d/%d\n", "%s clear key import failure, card response %d/%d\n",
__func__,
(int) prepcblk->ccp_rtcode, (int) prepcblk->ccp_rtcode,
(int) prepcblk->ccp_rscode); (int) prepcblk->ccp_rscode);
rc = -EIO; rc = -EIO;
...@@ -452,8 +454,8 @@ int pkey_clr2seckey(u16 cardnr, u16 domain, u32 keytype, ...@@ -452,8 +454,8 @@ int pkey_clr2seckey(u16 cardnr, u16 domain, u32 keytype,
- sizeof(prepparm->lv3.keyblock.tokattr); - sizeof(prepparm->lv3.keyblock.tokattr);
if (seckeysize != SECKEYBLOBSIZE) { if (seckeysize != SECKEYBLOBSIZE) {
DEBUG_ERR( DEBUG_ERR(
"pkey_clr2seckey secure token size mismatch %d != %d bytes\n", "%s secure token size mismatch %d != %d bytes\n",
seckeysize, SECKEYBLOBSIZE); __func__, seckeysize, SECKEYBLOBSIZE);
rc = -EIO; rc = -EIO;
goto out; goto out;
} }
...@@ -553,15 +555,16 @@ int pkey_sec2protkey(u16 cardnr, u16 domain, ...@@ -553,15 +555,16 @@ int pkey_sec2protkey(u16 cardnr, u16 domain,
rc = _zcrypt_send_cprb(&xcrb); rc = _zcrypt_send_cprb(&xcrb);
if (rc) { if (rc) {
DEBUG_ERR( DEBUG_ERR(
"pkey_sec2protkey zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n",
(int) cardnr, (int) domain, rc); __func__, (int) cardnr, (int) domain, rc);
goto out; goto out;
} }
/* check response returncode and reasoncode */ /* check response returncode and reasoncode */
if (prepcblk->ccp_rtcode != 0) { if (prepcblk->ccp_rtcode != 0) {
DEBUG_ERR( DEBUG_ERR(
"pkey_sec2protkey unwrap secure key failure, card response %d/%d\n", "%s unwrap secure key failure, card response %d/%d\n",
__func__,
(int) prepcblk->ccp_rtcode, (int) prepcblk->ccp_rtcode,
(int) prepcblk->ccp_rscode); (int) prepcblk->ccp_rscode);
rc = -EIO; rc = -EIO;
...@@ -569,7 +572,8 @@ int pkey_sec2protkey(u16 cardnr, u16 domain, ...@@ -569,7 +572,8 @@ int pkey_sec2protkey(u16 cardnr, u16 domain,
} }
if (prepcblk->ccp_rscode != 0) { if (prepcblk->ccp_rscode != 0) {
DEBUG_WARN( DEBUG_WARN(
"pkey_sec2protkey unwrap secure key warning, card response %d/%d\n", "%s unwrap secure key warning, card response %d/%d\n",
__func__,
(int) prepcblk->ccp_rtcode, (int) prepcblk->ccp_rtcode,
(int) prepcblk->ccp_rscode); (int) prepcblk->ccp_rscode);
} }
...@@ -581,8 +585,8 @@ int pkey_sec2protkey(u16 cardnr, u16 domain, ...@@ -581,8 +585,8 @@ int pkey_sec2protkey(u16 cardnr, u16 domain,
/* check the returned keyblock */ /* check the returned keyblock */
if (prepparm->lv3.keyblock.version != 0x01) { if (prepparm->lv3.keyblock.version != 0x01) {
DEBUG_ERR( DEBUG_ERR(
"pkey_sec2protkey reply param keyblock version mismatch 0x%02x != 0x01\n", "%s reply param keyblock version mismatch 0x%02x != 0x01\n",
(int) prepparm->lv3.keyblock.version); __func__, (int) prepparm->lv3.keyblock.version);
rc = -EIO; rc = -EIO;
goto out; goto out;
} }
...@@ -599,8 +603,8 @@ int pkey_sec2protkey(u16 cardnr, u16 domain, ...@@ -599,8 +603,8 @@ int pkey_sec2protkey(u16 cardnr, u16 domain,
protkey->type = PKEY_KEYTYPE_AES_256; protkey->type = PKEY_KEYTYPE_AES_256;
break; break;
default: default:
DEBUG_ERR("pkey_sec2protkey unknown/unsupported keytype %d\n", DEBUG_ERR("%s unknown/unsupported keytype %d\n",
prepparm->lv3.keyblock.keylen); __func__, prepparm->lv3.keyblock.keylen);
rc = -EIO; rc = -EIO;
goto out; goto out;
} }
...@@ -638,8 +642,8 @@ int pkey_clr2protkey(u32 keytype, ...@@ -638,8 +642,8 @@ int pkey_clr2protkey(u32 keytype,
fc = CPACF_PCKMO_ENC_AES_256_KEY; fc = CPACF_PCKMO_ENC_AES_256_KEY;
break; break;
default: default:
DEBUG_ERR("pkey_clr2protkey unknown/unsupported keytype %d\n", DEBUG_ERR("%s unknown/unsupported keytype %d\n",
keytype); __func__, keytype);
return -EINVAL; return -EINVAL;
} }
...@@ -713,15 +717,16 @@ static int query_crypto_facility(u16 cardnr, u16 domain, ...@@ -713,15 +717,16 @@ static int query_crypto_facility(u16 cardnr, u16 domain,
rc = _zcrypt_send_cprb(&xcrb); rc = _zcrypt_send_cprb(&xcrb);
if (rc) { if (rc) {
DEBUG_ERR( DEBUG_ERR(
"query_crypto_facility zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n", "%s zcrypt_send_cprb (cardnr=%d domain=%d) failed with errno %d\n",
(int) cardnr, (int) domain, rc); __func__, (int) cardnr, (int) domain, rc);
goto out; goto out;
} }
/* check response returncode and reasoncode */ /* check response returncode and reasoncode */
if (prepcblk->ccp_rtcode != 0) { if (prepcblk->ccp_rtcode != 0) {
DEBUG_ERR( DEBUG_ERR(
"query_crypto_facility unwrap secure key failure, card response %d/%d\n", "%s unwrap secure key failure, card response %d/%d\n",
__func__,
(int) prepcblk->ccp_rtcode, (int) prepcblk->ccp_rtcode,
(int) prepcblk->ccp_rscode); (int) prepcblk->ccp_rscode);
rc = -EIO; rc = -EIO;
...@@ -993,7 +998,7 @@ int pkey_skey2pkey(const struct pkey_seckey *seckey, ...@@ -993,7 +998,7 @@ int pkey_skey2pkey(const struct pkey_seckey *seckey,
} }
if (rc) if (rc)
DEBUG_DBG("pkey_skey2pkey failed rc=%d\n", rc); DEBUG_DBG("%s failed rc=%d\n", __func__, rc);
return rc; return rc;
} }
...@@ -1030,7 +1035,7 @@ int pkey_verifykey(const struct pkey_seckey *seckey, ...@@ -1030,7 +1035,7 @@ int pkey_verifykey(const struct pkey_seckey *seckey,
if (rc) if (rc)
goto out; goto out;
if (t->mkvp == mkvp[1]) { if (t->mkvp == mkvp[1]) {
DEBUG_DBG("pkey_verifykey secure key has old mkvp\n"); DEBUG_DBG("%s secure key has old mkvp\n", __func__);
if (pattributes) if (pattributes)
*pattributes |= PKEY_VERIFY_ATTR_OLD_MKVP; *pattributes |= PKEY_VERIFY_ATTR_OLD_MKVP;
} }
...@@ -1041,7 +1046,7 @@ int pkey_verifykey(const struct pkey_seckey *seckey, ...@@ -1041,7 +1046,7 @@ int pkey_verifykey(const struct pkey_seckey *seckey,
*pdomain = domain; *pdomain = domain;
out: out:
DEBUG_DBG("pkey_verifykey rc=%d\n", rc); DEBUG_DBG("%s rc=%d\n", __func__, rc);
return rc; return rc;
} }
EXPORT_SYMBOL(pkey_verifykey); EXPORT_SYMBOL(pkey_verifykey);
...@@ -1064,7 +1069,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -1064,7 +1069,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
return -EFAULT; return -EFAULT;
rc = pkey_genseckey(kgs.cardnr, kgs.domain, rc = pkey_genseckey(kgs.cardnr, kgs.domain,
kgs.keytype, &kgs.seckey); kgs.keytype, &kgs.seckey);
DEBUG_DBG("pkey_ioctl pkey_genseckey()=%d\n", rc); DEBUG_DBG("%s pkey_genseckey()=%d\n", __func__, rc);
if (rc) if (rc)
break; break;
if (copy_to_user(ugs, &kgs, sizeof(kgs))) if (copy_to_user(ugs, &kgs, sizeof(kgs)))
...@@ -1079,7 +1084,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -1079,7 +1084,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
return -EFAULT; return -EFAULT;
rc = pkey_clr2seckey(kcs.cardnr, kcs.domain, kcs.keytype, rc = pkey_clr2seckey(kcs.cardnr, kcs.domain, kcs.keytype,
&kcs.clrkey, &kcs.seckey); &kcs.clrkey, &kcs.seckey);
DEBUG_DBG("pkey_ioctl pkey_clr2seckey()=%d\n", rc); DEBUG_DBG("%s pkey_clr2seckey()=%d\n", __func__, rc);
if (rc) if (rc)
break; break;
if (copy_to_user(ucs, &kcs, sizeof(kcs))) if (copy_to_user(ucs, &kcs, sizeof(kcs)))
...@@ -1095,7 +1100,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -1095,7 +1100,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
return -EFAULT; return -EFAULT;
rc = pkey_sec2protkey(ksp.cardnr, ksp.domain, rc = pkey_sec2protkey(ksp.cardnr, ksp.domain,
&ksp.seckey, &ksp.protkey); &ksp.seckey, &ksp.protkey);
DEBUG_DBG("pkey_ioctl pkey_sec2protkey()=%d\n", rc); DEBUG_DBG("%s pkey_sec2protkey()=%d\n", __func__, rc);
if (rc) if (rc)
break; break;
if (copy_to_user(usp, &ksp, sizeof(ksp))) if (copy_to_user(usp, &ksp, sizeof(ksp)))
...@@ -1110,7 +1115,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -1110,7 +1115,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
return -EFAULT; return -EFAULT;
rc = pkey_clr2protkey(kcp.keytype, rc = pkey_clr2protkey(kcp.keytype,
&kcp.clrkey, &kcp.protkey); &kcp.clrkey, &kcp.protkey);
DEBUG_DBG("pkey_ioctl pkey_clr2protkey()=%d\n", rc); DEBUG_DBG("%s pkey_clr2protkey()=%d\n", __func__, rc);
if (rc) if (rc)
break; break;
if (copy_to_user(ucp, &kcp, sizeof(kcp))) if (copy_to_user(ucp, &kcp, sizeof(kcp)))
...@@ -1126,7 +1131,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -1126,7 +1131,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
return -EFAULT; return -EFAULT;
rc = pkey_findcard(&kfc.seckey, rc = pkey_findcard(&kfc.seckey,
&kfc.cardnr, &kfc.domain, 1); &kfc.cardnr, &kfc.domain, 1);
DEBUG_DBG("pkey_ioctl pkey_findcard()=%d\n", rc); DEBUG_DBG("%s pkey_findcard()=%d\n", __func__, rc);
if (rc) if (rc)
break; break;
if (copy_to_user(ufc, &kfc, sizeof(kfc))) if (copy_to_user(ufc, &kfc, sizeof(kfc)))
...@@ -1140,7 +1145,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -1140,7 +1145,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
if (copy_from_user(&ksp, usp, sizeof(ksp))) if (copy_from_user(&ksp, usp, sizeof(ksp)))
return -EFAULT; return -EFAULT;
rc = pkey_skey2pkey(&ksp.seckey, &ksp.protkey); rc = pkey_skey2pkey(&ksp.seckey, &ksp.protkey);
DEBUG_DBG("pkey_ioctl pkey_skey2pkey()=%d\n", rc); DEBUG_DBG("%s pkey_skey2pkey()=%d\n", __func__, rc);
if (rc) if (rc)
break; break;
if (copy_to_user(usp, &ksp, sizeof(ksp))) if (copy_to_user(usp, &ksp, sizeof(ksp)))
...@@ -1155,7 +1160,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -1155,7 +1160,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
return -EFAULT; return -EFAULT;
rc = pkey_verifykey(&kvk.seckey, &kvk.cardnr, &kvk.domain, rc = pkey_verifykey(&kvk.seckey, &kvk.cardnr, &kvk.domain,
&kvk.keysize, &kvk.attributes); &kvk.keysize, &kvk.attributes);
DEBUG_DBG("pkey_ioctl pkey_verifykey()=%d\n", rc); DEBUG_DBG("%s pkey_verifykey()=%d\n", __func__, rc);
if (rc) if (rc)
break; break;
if (copy_to_user(uvk, &kvk, sizeof(kvk))) if (copy_to_user(uvk, &kvk, sizeof(kvk)))
......
...@@ -50,7 +50,7 @@ EXPORT_TRACEPOINT_SYMBOL(s390_zcrypt_req); ...@@ -50,7 +50,7 @@ EXPORT_TRACEPOINT_SYMBOL(s390_zcrypt_req);
EXPORT_TRACEPOINT_SYMBOL(s390_zcrypt_rep); EXPORT_TRACEPOINT_SYMBOL(s390_zcrypt_rep);
static int zcrypt_hwrng_seed = 1; static int zcrypt_hwrng_seed = 1;
module_param_named(hwrng_seed, zcrypt_hwrng_seed, int, S_IRUSR|S_IRGRP); module_param_named(hwrng_seed, zcrypt_hwrng_seed, int, 0440);
MODULE_PARM_DESC(hwrng_seed, "Turn on/off hwrng auto seed, default is 1 (on)."); MODULE_PARM_DESC(hwrng_seed, "Turn on/off hwrng auto seed, default is 1 (on).");
DEFINE_SPINLOCK(zcrypt_list_lock); DEFINE_SPINLOCK(zcrypt_list_lock);
...@@ -182,7 +182,8 @@ static inline void zcrypt_drop_queue(struct zcrypt_card *zc, ...@@ -182,7 +182,8 @@ static inline void zcrypt_drop_queue(struct zcrypt_card *zc,
static inline bool zcrypt_card_compare(struct zcrypt_card *zc, static inline bool zcrypt_card_compare(struct zcrypt_card *zc,
struct zcrypt_card *pref_zc, struct zcrypt_card *pref_zc,
unsigned weight, unsigned pref_weight) unsigned int weight,
unsigned int pref_weight)
{ {
if (!pref_zc) if (!pref_zc)
return false; return false;
...@@ -196,7 +197,8 @@ static inline bool zcrypt_card_compare(struct zcrypt_card *zc, ...@@ -196,7 +197,8 @@ static inline bool zcrypt_card_compare(struct zcrypt_card *zc,
static inline bool zcrypt_queue_compare(struct zcrypt_queue *zq, static inline bool zcrypt_queue_compare(struct zcrypt_queue *zq,
struct zcrypt_queue *pref_zq, struct zcrypt_queue *pref_zq,
unsigned weight, unsigned pref_weight) unsigned int weight,
unsigned int pref_weight)
{ {
if (!pref_zq) if (!pref_zq)
return false; return false;
...@@ -792,6 +794,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -792,6 +794,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
case ICARSAMODEXPO: { case ICARSAMODEXPO: {
struct ica_rsa_modexpo __user *umex = (void __user *) arg; struct ica_rsa_modexpo __user *umex = (void __user *) arg;
struct ica_rsa_modexpo mex; struct ica_rsa_modexpo mex;
if (copy_from_user(&mex, umex, sizeof(mex))) if (copy_from_user(&mex, umex, sizeof(mex)))
return -EFAULT; return -EFAULT;
do { do {
...@@ -811,6 +814,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -811,6 +814,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
case ICARSACRT: { case ICARSACRT: {
struct ica_rsa_modexpo_crt __user *ucrt = (void __user *) arg; struct ica_rsa_modexpo_crt __user *ucrt = (void __user *) arg;
struct ica_rsa_modexpo_crt crt; struct ica_rsa_modexpo_crt crt;
if (copy_from_user(&crt, ucrt, sizeof(crt))) if (copy_from_user(&crt, ucrt, sizeof(crt)))
return -EFAULT; return -EFAULT;
do { do {
...@@ -830,6 +834,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -830,6 +834,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
case ZSECSENDCPRB: { case ZSECSENDCPRB: {
struct ica_xcRB __user *uxcRB = (void __user *) arg; struct ica_xcRB __user *uxcRB = (void __user *) arg;
struct ica_xcRB xcRB; struct ica_xcRB xcRB;
if (copy_from_user(&xcRB, uxcRB, sizeof(xcRB))) if (copy_from_user(&xcRB, uxcRB, sizeof(xcRB)))
return -EFAULT; return -EFAULT;
do { do {
...@@ -849,6 +854,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -849,6 +854,7 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
case ZSENDEP11CPRB: { case ZSENDEP11CPRB: {
struct ep11_urb __user *uxcrb = (void __user *)arg; struct ep11_urb __user *uxcrb = (void __user *)arg;
struct ep11_urb xcrb; struct ep11_urb xcrb;
if (copy_from_user(&xcrb, uxcrb, sizeof(xcrb))) if (copy_from_user(&xcrb, uxcrb, sizeof(xcrb)))
return -EFAULT; return -EFAULT;
do { do {
...@@ -1037,7 +1043,7 @@ static long trans_modexpo_crt32(struct file *filp, unsigned int cmd, ...@@ -1037,7 +1043,7 @@ static long trans_modexpo_crt32(struct file *filp, unsigned int cmd,
return -EFAULT; return -EFAULT;
crt64.inputdata = compat_ptr(crt32.inputdata); crt64.inputdata = compat_ptr(crt32.inputdata);
crt64.inputdatalength = crt32.inputdatalength; crt64.inputdatalength = crt32.inputdatalength;
crt64.outputdata= compat_ptr(crt32.outputdata); crt64.outputdata = compat_ptr(crt32.outputdata);
crt64.outputdatalength = crt32.outputdatalength; crt64.outputdatalength = crt32.outputdatalength;
crt64.bp_key = compat_ptr(crt32.bp_key); crt64.bp_key = compat_ptr(crt32.bp_key);
crt64.bq_key = compat_ptr(crt32.bq_key); crt64.bq_key = compat_ptr(crt32.bq_key);
...@@ -1063,20 +1069,20 @@ struct compat_ica_xcRB { ...@@ -1063,20 +1069,20 @@ struct compat_ica_xcRB {
unsigned int user_defined; unsigned int user_defined;
unsigned short request_ID; unsigned short request_ID;
unsigned int request_control_blk_length; unsigned int request_control_blk_length;
unsigned char padding1[16 - sizeof (compat_uptr_t)]; unsigned char padding1[16 - sizeof(compat_uptr_t)];
compat_uptr_t request_control_blk_addr; compat_uptr_t request_control_blk_addr;
unsigned int request_data_length; unsigned int request_data_length;
char padding2[16 - sizeof (compat_uptr_t)]; char padding2[16 - sizeof(compat_uptr_t)];
compat_uptr_t request_data_address; compat_uptr_t request_data_address;
unsigned int reply_control_blk_length; unsigned int reply_control_blk_length;
char padding3[16 - sizeof (compat_uptr_t)]; char padding3[16 - sizeof(compat_uptr_t)];
compat_uptr_t reply_control_blk_addr; compat_uptr_t reply_control_blk_addr;
unsigned int reply_data_length; unsigned int reply_data_length;
char padding4[16 - sizeof (compat_uptr_t)]; char padding4[16 - sizeof(compat_uptr_t)];
compat_uptr_t reply_data_addr; compat_uptr_t reply_data_addr;
unsigned short priority_window; unsigned short priority_window;
unsigned int status; unsigned int status;
} __attribute__((packed)); } __packed;
static long trans_xcRB32(struct file *filp, unsigned int cmd, static long trans_xcRB32(struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
...@@ -1182,10 +1188,10 @@ static int zcrypt_rng_data_read(struct hwrng *rng, u32 *data) ...@@ -1182,10 +1188,10 @@ static int zcrypt_rng_data_read(struct hwrng *rng, u32 *data)
rc = zcrypt_rng((char *) zcrypt_rng_buffer); rc = zcrypt_rng((char *) zcrypt_rng_buffer);
if (rc < 0) if (rc < 0)
return -EIO; return -EIO;
zcrypt_rng_buffer_index = rc / sizeof *data; zcrypt_rng_buffer_index = rc / sizeof(*data);
} }
*data = zcrypt_rng_buffer[--zcrypt_rng_buffer_index]; *data = zcrypt_rng_buffer[--zcrypt_rng_buffer_index];
return sizeof *data; return sizeof(*data);
} }
static struct hwrng zcrypt_rng_dev = { static struct hwrng zcrypt_rng_dev = {
......
// SPDX-License-Identifier: GPL-2.0+ /* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* zcrypt 2.1.0 * zcrypt 2.1.0
* *
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* Device attributes common for all crypto card devices. * Device attributes common for all crypto card devices.
*/ */
static ssize_t zcrypt_card_type_show(struct device *dev, static ssize_t type_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct zcrypt_card *zc = to_ap_card(dev)->private; struct zcrypt_card *zc = to_ap_card(dev)->private;
...@@ -46,9 +46,9 @@ static ssize_t zcrypt_card_type_show(struct device *dev, ...@@ -46,9 +46,9 @@ static ssize_t zcrypt_card_type_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%s\n", zc->type_string); return snprintf(buf, PAGE_SIZE, "%s\n", zc->type_string);
} }
static DEVICE_ATTR(type, 0444, zcrypt_card_type_show, NULL); static DEVICE_ATTR_RO(type);
static ssize_t zcrypt_card_online_show(struct device *dev, static ssize_t online_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
...@@ -57,7 +57,7 @@ static ssize_t zcrypt_card_online_show(struct device *dev, ...@@ -57,7 +57,7 @@ static ssize_t zcrypt_card_online_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", zc->online); return snprintf(buf, PAGE_SIZE, "%d\n", zc->online);
} }
static ssize_t zcrypt_card_online_store(struct device *dev, static ssize_t online_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
...@@ -80,10 +80,9 @@ static ssize_t zcrypt_card_online_store(struct device *dev, ...@@ -80,10 +80,9 @@ static ssize_t zcrypt_card_online_store(struct device *dev,
return count; return count;
} }
static DEVICE_ATTR(online, 0644, zcrypt_card_online_show, static DEVICE_ATTR_RW(online);
zcrypt_card_online_store);
static ssize_t zcrypt_card_load_show(struct device *dev, static ssize_t load_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
...@@ -92,7 +91,7 @@ static ssize_t zcrypt_card_load_show(struct device *dev, ...@@ -92,7 +91,7 @@ static ssize_t zcrypt_card_load_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&zc->load)); return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&zc->load));
} }
static DEVICE_ATTR(load, 0444, zcrypt_card_load_show, NULL); static DEVICE_ATTR_RO(load);
static struct attribute *zcrypt_card_attrs[] = { static struct attribute *zcrypt_card_attrs[] = {
&dev_attr_type.attr, &dev_attr_type.attr,
......
// SPDX-License-Identifier: GPL-2.0+ /* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* zcrypt 2.1.0 * zcrypt 2.1.0
* *
...@@ -31,7 +31,7 @@ struct cca_token_hdr { ...@@ -31,7 +31,7 @@ struct cca_token_hdr {
unsigned char version; unsigned char version;
unsigned short token_length; unsigned short token_length;
unsigned char reserved[4]; unsigned char reserved[4];
} __attribute__((packed)); } __packed;
#define CCA_TKN_HDR_ID_EXT 0x1E #define CCA_TKN_HDR_ID_EXT 0x1E
...@@ -51,7 +51,7 @@ struct cca_public_sec { ...@@ -51,7 +51,7 @@ struct cca_public_sec {
unsigned short exponent_len; unsigned short exponent_len;
unsigned short modulus_bit_len; unsigned short modulus_bit_len;
unsigned short modulus_byte_len; /* In a private key, this is 0 */ unsigned short modulus_byte_len; /* In a private key, this is 0 */
} __attribute__((packed)); } __packed;
/** /**
* mapping for the cca private CRT key 'token' * mapping for the cca private CRT key 'token'
...@@ -85,7 +85,7 @@ struct cca_pvt_ext_CRT_sec { ...@@ -85,7 +85,7 @@ struct cca_pvt_ext_CRT_sec {
unsigned short pad_len; unsigned short pad_len;
unsigned char reserved4[52]; unsigned char reserved4[52];
unsigned char confounder[8]; unsigned char confounder[8];
} __attribute__((packed)); } __packed;
#define CCA_PVT_EXT_CRT_SEC_ID_PVT 0x08 #define CCA_PVT_EXT_CRT_SEC_ID_PVT 0x08
#define CCA_PVT_EXT_CRT_SEC_FMT_CL 0x40 #define CCA_PVT_EXT_CRT_SEC_FMT_CL 0x40
...@@ -114,7 +114,7 @@ static inline int zcrypt_type6_mex_key_en(struct ica_rsa_modexpo *mex, void *p) ...@@ -114,7 +114,7 @@ static inline int zcrypt_type6_mex_key_en(struct ica_rsa_modexpo *mex, void *p)
struct cca_token_hdr pubHdr; struct cca_token_hdr pubHdr;
struct cca_public_sec pubSec; struct cca_public_sec pubSec;
char exponent[0]; char exponent[0];
} __attribute__((packed)) *key = p; } __packed *key = p;
unsigned char *temp; unsigned char *temp;
int i; int i;
...@@ -183,7 +183,7 @@ static inline int zcrypt_type6_crt_key(struct ica_rsa_modexpo_crt *crt, void *p) ...@@ -183,7 +183,7 @@ static inline int zcrypt_type6_crt_key(struct ica_rsa_modexpo_crt *crt, void *p)
struct cca_token_hdr token; struct cca_token_hdr token;
struct cca_pvt_ext_CRT_sec pvt; struct cca_pvt_ext_CRT_sec pvt;
char key_parts[0]; char key_parts[0];
} __attribute__((packed)) *key = p; } __packed *key = p;
struct cca_public_sec *pub; struct cca_public_sec *pub;
int short_len, long_len, pad_len, key_len, size; int short_len, long_len, pad_len, key_len, size;
......
...@@ -145,6 +145,7 @@ static struct ap_driver zcrypt_cex2a_card_driver = { ...@@ -145,6 +145,7 @@ static struct ap_driver zcrypt_cex2a_card_driver = {
.probe = zcrypt_cex2a_card_probe, .probe = zcrypt_cex2a_card_probe,
.remove = zcrypt_cex2a_card_remove, .remove = zcrypt_cex2a_card_remove,
.ids = zcrypt_cex2a_card_ids, .ids = zcrypt_cex2a_card_ids,
.flags = AP_DRIVER_FLAG_DEFAULT,
}; };
/** /**
...@@ -208,6 +209,7 @@ static struct ap_driver zcrypt_cex2a_queue_driver = { ...@@ -208,6 +209,7 @@ static struct ap_driver zcrypt_cex2a_queue_driver = {
.suspend = ap_queue_suspend, .suspend = ap_queue_suspend,
.resume = ap_queue_resume, .resume = ap_queue_resume,
.ids = zcrypt_cex2a_queue_ids, .ids = zcrypt_cex2a_queue_ids,
.flags = AP_DRIVER_FLAG_DEFAULT,
}; };
int __init zcrypt_cex2a_init(void) int __init zcrypt_cex2a_init(void)
......
// SPDX-License-Identifier: GPL-2.0+ /* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* zcrypt 2.1.0 * zcrypt 2.1.0
* *
...@@ -30,7 +30,7 @@ struct type50_hdr { ...@@ -30,7 +30,7 @@ struct type50_hdr {
unsigned char reserved2; unsigned char reserved2;
unsigned char ignored; unsigned char ignored;
unsigned short reserved3; unsigned short reserved3;
} __attribute__((packed)); } __packed;
#define TYPE50_TYPE_CODE 0x50 #define TYPE50_TYPE_CODE 0x50
...@@ -49,7 +49,7 @@ struct type50_meb1_msg { ...@@ -49,7 +49,7 @@ struct type50_meb1_msg {
unsigned char exponent[128]; unsigned char exponent[128];
unsigned char modulus[128]; unsigned char modulus[128];
unsigned char message[128]; unsigned char message[128];
} __attribute__((packed)); } __packed;
/* Mod-Exp, with a large modulus */ /* Mod-Exp, with a large modulus */
struct type50_meb2_msg { struct type50_meb2_msg {
...@@ -59,7 +59,7 @@ struct type50_meb2_msg { ...@@ -59,7 +59,7 @@ struct type50_meb2_msg {
unsigned char exponent[256]; unsigned char exponent[256];
unsigned char modulus[256]; unsigned char modulus[256];
unsigned char message[256]; unsigned char message[256];
} __attribute__((packed)); } __packed;
/* Mod-Exp, with a larger modulus */ /* Mod-Exp, with a larger modulus */
struct type50_meb3_msg { struct type50_meb3_msg {
...@@ -69,7 +69,7 @@ struct type50_meb3_msg { ...@@ -69,7 +69,7 @@ struct type50_meb3_msg {
unsigned char exponent[512]; unsigned char exponent[512];
unsigned char modulus[512]; unsigned char modulus[512];
unsigned char message[512]; unsigned char message[512];
} __attribute__((packed)); } __packed;
/* CRT, with a small modulus */ /* CRT, with a small modulus */
struct type50_crb1_msg { struct type50_crb1_msg {
...@@ -82,7 +82,7 @@ struct type50_crb1_msg { ...@@ -82,7 +82,7 @@ struct type50_crb1_msg {
unsigned char dq[64]; unsigned char dq[64];
unsigned char u[64]; unsigned char u[64];
unsigned char message[128]; unsigned char message[128];
} __attribute__((packed)); } __packed;
/* CRT, with a large modulus */ /* CRT, with a large modulus */
struct type50_crb2_msg { struct type50_crb2_msg {
...@@ -95,7 +95,7 @@ struct type50_crb2_msg { ...@@ -95,7 +95,7 @@ struct type50_crb2_msg {
unsigned char dq[128]; unsigned char dq[128];
unsigned char u[128]; unsigned char u[128];
unsigned char message[256]; unsigned char message[256];
} __attribute__((packed)); } __packed;
/* CRT, with a larger modulus */ /* CRT, with a larger modulus */
struct type50_crb3_msg { struct type50_crb3_msg {
...@@ -108,7 +108,7 @@ struct type50_crb3_msg { ...@@ -108,7 +108,7 @@ struct type50_crb3_msg {
unsigned char dq[256]; unsigned char dq[256];
unsigned char u[256]; unsigned char u[256];
unsigned char message[512]; unsigned char message[512];
} __attribute__((packed)); } __packed;
/** /**
* The type 80 response family is associated with a CEX2A card. * The type 80 response family is associated with a CEX2A card.
...@@ -128,7 +128,7 @@ struct type80_hdr { ...@@ -128,7 +128,7 @@ struct type80_hdr {
unsigned char code; /* 0x00 */ unsigned char code; /* 0x00 */
unsigned char reserved2[3]; unsigned char reserved2[3];
unsigned char reserved3[8]; unsigned char reserved3[8];
} __attribute__((packed)); } __packed;
int zcrypt_cex2a_init(void); int zcrypt_cex2a_init(void);
void zcrypt_cex2a_exit(void); void zcrypt_cex2a_exit(void);
......
...@@ -214,6 +214,7 @@ static struct ap_driver zcrypt_cex4_card_driver = { ...@@ -214,6 +214,7 @@ static struct ap_driver zcrypt_cex4_card_driver = {
.probe = zcrypt_cex4_card_probe, .probe = zcrypt_cex4_card_probe,
.remove = zcrypt_cex4_card_remove, .remove = zcrypt_cex4_card_remove,
.ids = zcrypt_cex4_card_ids, .ids = zcrypt_cex4_card_ids,
.flags = AP_DRIVER_FLAG_DEFAULT,
}; };
/** /**
...@@ -283,6 +284,7 @@ static struct ap_driver zcrypt_cex4_queue_driver = { ...@@ -283,6 +284,7 @@ static struct ap_driver zcrypt_cex4_queue_driver = {
.suspend = ap_queue_suspend, .suspend = ap_queue_suspend,
.resume = ap_queue_resume, .resume = ap_queue_resume,
.ids = zcrypt_cex4_queue_ids, .ids = zcrypt_cex4_queue_ids,
.flags = AP_DRIVER_FLAG_DEFAULT,
}; };
int __init zcrypt_cex4_init(void) int __init zcrypt_cex4_init(void)
......
// SPDX-License-Identifier: GPL-2.0+ /* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* zcrypt 2.1.0 * zcrypt 2.1.0
* *
......
...@@ -27,13 +27,14 @@ ...@@ -27,13 +27,14 @@
#include "zcrypt_error.h" #include "zcrypt_error.h"
#include "zcrypt_msgtype50.h" #include "zcrypt_msgtype50.h"
#define CEX3A_MAX_MOD_SIZE 512 /* 4096 bits */ /* 4096 bits */
#define CEX3A_MAX_MOD_SIZE 512
#define CEX2A_MAX_RESPONSE_SIZE 0x110 /* max outputdatalength + type80_hdr */ /* max outputdatalength + type80_hdr */
#define CEX2A_MAX_RESPONSE_SIZE 0x110
#define CEX3A_MAX_RESPONSE_SIZE 0x210 /* 512 bit modulus /* 512 bit modulus, (max outputdatalength) + type80_hdr */
* (max outputdatalength) + #define CEX3A_MAX_RESPONSE_SIZE 0x210
* type80_hdr*/
MODULE_AUTHOR("IBM Corporation"); MODULE_AUTHOR("IBM Corporation");
MODULE_DESCRIPTION("Cryptographic Accelerator (message type 50), " \ MODULE_DESCRIPTION("Cryptographic Accelerator (message type 50), " \
...@@ -209,6 +210,7 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq, ...@@ -209,6 +210,7 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq,
if (mod_len <= 128) { if (mod_len <= 128) {
struct type50_meb1_msg *meb1 = ap_msg->message; struct type50_meb1_msg *meb1 = ap_msg->message;
memset(meb1, 0, sizeof(*meb1)); memset(meb1, 0, sizeof(*meb1));
ap_msg->length = sizeof(*meb1); ap_msg->length = sizeof(*meb1);
meb1->header.msg_type_code = TYPE50_TYPE_CODE; meb1->header.msg_type_code = TYPE50_TYPE_CODE;
...@@ -219,6 +221,7 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq, ...@@ -219,6 +221,7 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq,
inp = meb1->message + sizeof(meb1->message) - mod_len; inp = meb1->message + sizeof(meb1->message) - mod_len;
} else if (mod_len <= 256) { } else if (mod_len <= 256) {
struct type50_meb2_msg *meb2 = ap_msg->message; struct type50_meb2_msg *meb2 = ap_msg->message;
memset(meb2, 0, sizeof(*meb2)); memset(meb2, 0, sizeof(*meb2));
ap_msg->length = sizeof(*meb2); ap_msg->length = sizeof(*meb2);
meb2->header.msg_type_code = TYPE50_TYPE_CODE; meb2->header.msg_type_code = TYPE50_TYPE_CODE;
...@@ -229,6 +232,7 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq, ...@@ -229,6 +232,7 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq,
inp = meb2->message + sizeof(meb2->message) - mod_len; inp = meb2->message + sizeof(meb2->message) - mod_len;
} else if (mod_len <= 512) { } else if (mod_len <= 512) {
struct type50_meb3_msg *meb3 = ap_msg->message; struct type50_meb3_msg *meb3 = ap_msg->message;
memset(meb3, 0, sizeof(*meb3)); memset(meb3, 0, sizeof(*meb3));
ap_msg->length = sizeof(*meb3); ap_msg->length = sizeof(*meb3);
meb3->header.msg_type_code = TYPE50_TYPE_CODE; meb3->header.msg_type_code = TYPE50_TYPE_CODE;
...@@ -274,6 +278,7 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq, ...@@ -274,6 +278,7 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq,
*/ */
if (mod_len <= 128) { /* up to 1024 bit key size */ if (mod_len <= 128) { /* up to 1024 bit key size */
struct type50_crb1_msg *crb1 = ap_msg->message; struct type50_crb1_msg *crb1 = ap_msg->message;
memset(crb1, 0, sizeof(*crb1)); memset(crb1, 0, sizeof(*crb1));
ap_msg->length = sizeof(*crb1); ap_msg->length = sizeof(*crb1);
crb1->header.msg_type_code = TYPE50_TYPE_CODE; crb1->header.msg_type_code = TYPE50_TYPE_CODE;
...@@ -287,6 +292,7 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq, ...@@ -287,6 +292,7 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq,
inp = crb1->message + sizeof(crb1->message) - mod_len; inp = crb1->message + sizeof(crb1->message) - mod_len;
} else if (mod_len <= 256) { /* up to 2048 bit key size */ } else if (mod_len <= 256) { /* up to 2048 bit key size */
struct type50_crb2_msg *crb2 = ap_msg->message; struct type50_crb2_msg *crb2 = ap_msg->message;
memset(crb2, 0, sizeof(*crb2)); memset(crb2, 0, sizeof(*crb2));
ap_msg->length = sizeof(*crb2); ap_msg->length = sizeof(*crb2);
crb2->header.msg_type_code = TYPE50_TYPE_CODE; crb2->header.msg_type_code = TYPE50_TYPE_CODE;
...@@ -301,6 +307,7 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq, ...@@ -301,6 +307,7 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq,
} else if ((mod_len <= 512) && /* up to 4096 bit key size */ } else if ((mod_len <= 512) && /* up to 4096 bit key size */
(zq->zcard->max_mod_size == CEX3A_MAX_MOD_SIZE)) { (zq->zcard->max_mod_size == CEX3A_MAX_MOD_SIZE)) {
struct type50_crb3_msg *crb3 = ap_msg->message; struct type50_crb3_msg *crb3 = ap_msg->message;
memset(crb3, 0, sizeof(*crb3)); memset(crb3, 0, sizeof(*crb3));
ap_msg->length = sizeof(*crb3); ap_msg->length = sizeof(*crb3);
crb3->header.msg_type_code = TYPE50_TYPE_CODE; crb3->header.msg_type_code = TYPE50_TYPE_CODE;
......
// SPDX-License-Identifier: GPL-2.0+ /* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* zcrypt 2.1.0 * zcrypt 2.1.0
* *
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
#define MSGTYPE50_NAME "zcrypt_msgtype50" #define MSGTYPE50_NAME "zcrypt_msgtype50"
#define MSGTYPE50_VARIANT_DEFAULT 0 #define MSGTYPE50_VARIANT_DEFAULT 0
#define MSGTYPE50_CRB2_MAX_MSG_SIZE 0x390 /*sizeof(struct type50_crb2_msg)*/ #define MSGTYPE50_CRB2_MAX_MSG_SIZE 0x390 /* sizeof(struct type50_crb2_msg) */
#define MSGTYPE50_CRB3_MAX_MSG_SIZE 0x710 /*sizeof(struct type50_crb3_msg)*/ #define MSGTYPE50_CRB3_MAX_MSG_SIZE 0x710 /* sizeof(struct type50_crb3_msg) */
#define MSGTYPE_ADJUSTMENT 0x08 /*type04 extension (not needed in type50)*/ #define MSGTYPE_ADJUSTMENT 0x08 /* type04 extension (not needed in type50) */
unsigned int get_rsa_modex_fc(struct ica_rsa_modexpo *, int *); unsigned int get_rsa_modex_fc(struct ica_rsa_modexpo *, int *);
unsigned int get_rsa_crt_fc(struct ica_rsa_modexpo_crt *, int *); unsigned int get_rsa_crt_fc(struct ica_rsa_modexpo_crt *, int *);
......
...@@ -421,8 +421,10 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg, ...@@ -421,8 +421,10 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg,
if (ap_msg->length > MSGTYPE06_MAX_MSG_SIZE) if (ap_msg->length > MSGTYPE06_MAX_MSG_SIZE)
return -EINVAL; return -EINVAL;
/* Overflow check /*
sum must be greater (or equal) than the largest operand */ * Overflow check
* sum must be greater (or equal) than the largest operand
*/
req_sumlen = CEIL4(xcRB->request_control_blk_length) + req_sumlen = CEIL4(xcRB->request_control_blk_length) +
xcRB->request_data_length; xcRB->request_data_length;
if ((CEIL4(xcRB->request_control_blk_length) <= if ((CEIL4(xcRB->request_control_blk_length) <=
...@@ -442,8 +444,10 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg, ...@@ -442,8 +444,10 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg,
if (replylen > MSGTYPE06_MAX_MSG_SIZE) if (replylen > MSGTYPE06_MAX_MSG_SIZE)
return -EINVAL; return -EINVAL;
/* Overflow check /*
sum must be greater (or equal) than the largest operand */ * Overflow check
* sum must be greater (or equal) than the largest operand
*/
resp_sumlen = CEIL4(xcRB->reply_control_blk_length) + resp_sumlen = CEIL4(xcRB->reply_control_blk_length) +
xcRB->reply_data_length; xcRB->reply_data_length;
if ((CEIL4(xcRB->reply_control_blk_length) <= xcRB->reply_data_length) ? if ((CEIL4(xcRB->reply_control_blk_length) <= xcRB->reply_data_length) ?
...@@ -454,7 +458,7 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg, ...@@ -454,7 +458,7 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg,
/* prepare type6 header */ /* prepare type6 header */
msg->hdr = static_type6_hdrX; msg->hdr = static_type6_hdrX;
memcpy(msg->hdr.agent_id , &(xcRB->agent_ID), sizeof(xcRB->agent_ID)); memcpy(msg->hdr.agent_id, &(xcRB->agent_ID), sizeof(xcRB->agent_ID));
msg->hdr.ToCardLen1 = xcRB->request_control_blk_length; msg->hdr.ToCardLen1 = xcRB->request_control_blk_length;
if (xcRB->request_data_length) { if (xcRB->request_data_length) {
msg->hdr.offset2 = msg->hdr.offset1 + rcblen; msg->hdr.offset2 = msg->hdr.offset1 + rcblen;
...@@ -806,8 +810,10 @@ static int convert_response_ica(struct zcrypt_queue *zq, ...@@ -806,8 +810,10 @@ static int convert_response_ica(struct zcrypt_queue *zq,
if (msg->cprbx.cprb_ver_id == 0x02) if (msg->cprbx.cprb_ver_id == 0x02)
return convert_type86_ica(zq, reply, return convert_type86_ica(zq, reply,
outputdata, outputdatalength); outputdata, outputdatalength);
/* Fall through, no break, incorrect cprb version is an unknown /*
* response */ * Fall through, no break, incorrect cprb version is an unknown
* response
*/
default: /* Unknown response type, this should NEVER EVER happen */ default: /* Unknown response type, this should NEVER EVER happen */
zq->online = 0; zq->online = 0;
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
...@@ -840,8 +846,10 @@ static int convert_response_xcrb(struct zcrypt_queue *zq, ...@@ -840,8 +846,10 @@ static int convert_response_xcrb(struct zcrypt_queue *zq,
} }
if (msg->cprbx.cprb_ver_id == 0x02) if (msg->cprbx.cprb_ver_id == 0x02)
return convert_type86_xcrb(zq, reply, xcRB); return convert_type86_xcrb(zq, reply, xcRB);
/* Fall through, no break, incorrect cprb version is an unknown /*
* response */ * Fall through, no break, incorrect cprb version is an unknown
* response
*/
default: /* Unknown response type, this should NEVER EVER happen */ default: /* Unknown response type, this should NEVER EVER happen */
xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ xcRB->status = 0x0008044DL; /* HDD_InvalidParm */
zq->online = 0; zq->online = 0;
...@@ -901,8 +909,10 @@ static int convert_response_rng(struct zcrypt_queue *zq, ...@@ -901,8 +909,10 @@ static int convert_response_rng(struct zcrypt_queue *zq,
return -EINVAL; return -EINVAL;
if (msg->cprbx.cprb_ver_id == 0x02) if (msg->cprbx.cprb_ver_id == 0x02)
return convert_type86_rng(zq, reply, data); return convert_type86_rng(zq, reply, data);
/* Fall through, no break, incorrect cprb version is an unknown /*
* response */ * Fall through, no break, incorrect cprb version is an unknown
* response
*/
default: /* Unknown response type, this should NEVER EVER happen */ default: /* Unknown response type, this should NEVER EVER happen */
zq->online = 0; zq->online = 0;
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
......
// SPDX-License-Identifier: GPL-2.0+ /* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* zcrypt 2.1.0 * zcrypt 2.1.0
* *
......
...@@ -95,7 +95,7 @@ static int zcrypt_pcixcc_rng_supported(struct ap_queue *aq) ...@@ -95,7 +95,7 @@ static int zcrypt_pcixcc_rng_supported(struct ap_queue *aq)
struct type86_hdr hdr; struct type86_hdr hdr;
struct type86_fmt2_ext fmt2; struct type86_fmt2_ext fmt2;
struct CPRBX cprbx; struct CPRBX cprbx;
} __attribute__((packed)) *reply; } __packed *reply;
struct { struct {
struct type6_hdr hdr; struct type6_hdr hdr;
struct CPRBX cprbx; struct CPRBX cprbx;
...@@ -104,7 +104,7 @@ static int zcrypt_pcixcc_rng_supported(struct ap_queue *aq) ...@@ -104,7 +104,7 @@ static int zcrypt_pcixcc_rng_supported(struct ap_queue *aq)
char rule[8]; char rule[8];
short int verb_length; short int verb_length;
short int key_length; short int key_length;
} __packed * msg; } __packed *msg;
int rc, i; int rc, i;
ap_init_message(&ap_msg); ap_init_message(&ap_msg);
...@@ -223,6 +223,7 @@ static struct ap_driver zcrypt_pcixcc_card_driver = { ...@@ -223,6 +223,7 @@ static struct ap_driver zcrypt_pcixcc_card_driver = {
.probe = zcrypt_pcixcc_card_probe, .probe = zcrypt_pcixcc_card_probe,
.remove = zcrypt_pcixcc_card_remove, .remove = zcrypt_pcixcc_card_remove,
.ids = zcrypt_pcixcc_card_ids, .ids = zcrypt_pcixcc_card_ids,
.flags = AP_DRIVER_FLAG_DEFAULT,
}; };
/** /**
...@@ -286,6 +287,7 @@ static struct ap_driver zcrypt_pcixcc_queue_driver = { ...@@ -286,6 +287,7 @@ static struct ap_driver zcrypt_pcixcc_queue_driver = {
.suspend = ap_queue_suspend, .suspend = ap_queue_suspend,
.resume = ap_queue_resume, .resume = ap_queue_resume,
.ids = zcrypt_pcixcc_queue_ids, .ids = zcrypt_pcixcc_queue_ids,
.flags = AP_DRIVER_FLAG_DEFAULT,
}; };
int __init zcrypt_pcixcc_init(void) int __init zcrypt_pcixcc_init(void)
......
// SPDX-License-Identifier: GPL-2.0+ /* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* zcrypt 2.1.0 * zcrypt 2.1.0
* *
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* Device attributes common for all crypto queue devices. * Device attributes common for all crypto queue devices.
*/ */
static ssize_t zcrypt_queue_online_show(struct device *dev, static ssize_t online_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
...@@ -47,7 +47,7 @@ static ssize_t zcrypt_queue_online_show(struct device *dev, ...@@ -47,7 +47,7 @@ static ssize_t zcrypt_queue_online_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", zq->online); return snprintf(buf, PAGE_SIZE, "%d\n", zq->online);
} }
static ssize_t zcrypt_queue_online_store(struct device *dev, static ssize_t online_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
...@@ -72,10 +72,9 @@ static ssize_t zcrypt_queue_online_store(struct device *dev, ...@@ -72,10 +72,9 @@ static ssize_t zcrypt_queue_online_store(struct device *dev,
return count; return count;
} }
static DEVICE_ATTR(online, 0644, zcrypt_queue_online_show, static DEVICE_ATTR_RW(online);
zcrypt_queue_online_store);
static ssize_t zcrypt_queue_load_show(struct device *dev, static ssize_t load_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
...@@ -84,7 +83,7 @@ static ssize_t zcrypt_queue_load_show(struct device *dev, ...@@ -84,7 +83,7 @@ static ssize_t zcrypt_queue_load_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&zq->load)); return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&zq->load));
} }
static DEVICE_ATTR(load, 0444, zcrypt_queue_load_show, NULL); static DEVICE_ATTR_RO(load);
static struct attribute *zcrypt_queue_attrs[] = { static struct attribute *zcrypt_queue_attrs[] = {
&dev_attr_online.attr, &dev_attr_online.attr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment