.. | .. |
---|
2 | 2 | /* |
---|
3 | 3 | * include/asm-s390/zcrypt.h |
---|
4 | 4 | * |
---|
5 | | - * zcrypt 2.1.0 (user-visible header) |
---|
| 5 | + * zcrypt 2.2.1 (user-visible header) |
---|
6 | 6 | * |
---|
7 | | - * Copyright IBM Corp. 2001, 2006 |
---|
| 7 | + * Copyright IBM Corp. 2001, 2019 |
---|
8 | 8 | * Author(s): Robert Burroughs |
---|
9 | 9 | * Eric Rossman (edrossma@us.ibm.com) |
---|
10 | 10 | * |
---|
.. | .. |
---|
15 | 15 | #define __ASM_S390_ZCRYPT_H |
---|
16 | 16 | |
---|
17 | 17 | #define ZCRYPT_VERSION 2 |
---|
18 | | -#define ZCRYPT_RELEASE 1 |
---|
| 18 | +#define ZCRYPT_RELEASE 2 |
---|
19 | 19 | #define ZCRYPT_VARIANT 1 |
---|
20 | 20 | |
---|
21 | 21 | #include <linux/ioctl.h> |
---|
22 | 22 | #include <linux/compiler.h> |
---|
| 23 | +#include <linux/types.h> |
---|
| 24 | + |
---|
| 25 | +/* Name of the zcrypt device driver. */ |
---|
| 26 | +#define ZCRYPT_NAME "zcrypt" |
---|
23 | 27 | |
---|
24 | 28 | /** |
---|
25 | 29 | * struct ica_rsa_modexpo |
---|
.. | .. |
---|
32 | 36 | * - length(n_modulus) = inputdatalength |
---|
33 | 37 | */ |
---|
34 | 38 | 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; |
---|
| 39 | + __u8 __user *inputdata; |
---|
| 40 | + __u32 inputdatalength; |
---|
| 41 | + __u8 __user *outputdata; |
---|
| 42 | + __u32 outputdatalength; |
---|
| 43 | + __u8 __user *b_key; |
---|
| 44 | + __u8 __user *n_modulus; |
---|
41 | 45 | }; |
---|
42 | 46 | |
---|
43 | 47 | /** |
---|
.. | .. |
---|
55 | 59 | * - length(u_mult_inv) = inputdatalength/2 + 8 |
---|
56 | 60 | */ |
---|
57 | 61 | 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; |
---|
| 62 | + __u8 __user *inputdata; |
---|
| 63 | + __u32 inputdatalength; |
---|
| 64 | + __u8 __user *outputdata; |
---|
| 65 | + __u32 outputdatalength; |
---|
| 66 | + __u8 __user *bp_key; |
---|
| 67 | + __u8 __user *bq_key; |
---|
| 68 | + __u8 __user *np_prime; |
---|
| 69 | + __u8 __user *nq_prime; |
---|
| 70 | + __u8 __user *u_mult_inv; |
---|
67 | 71 | }; |
---|
68 | 72 | |
---|
69 | 73 | /** |
---|
.. | .. |
---|
79 | 83 | * key block |
---|
80 | 84 | */ |
---|
81 | 85 | struct CPRBX { |
---|
82 | | - unsigned short cprb_len; /* CPRB length 220 */ |
---|
83 | | - unsigned char cprb_ver_id; /* CPRB version id. 0x02 */ |
---|
84 | | - unsigned char pad_000[3]; /* Alignment pad bytes */ |
---|
85 | | - unsigned char func_id[2]; /* function id 0x5432 */ |
---|
86 | | - unsigned char cprb_flags[4]; /* Flags */ |
---|
87 | | - unsigned int req_parml; /* request parameter buffer len */ |
---|
88 | | - unsigned int req_datal; /* request data buffer */ |
---|
89 | | - unsigned int rpl_msgbl; /* reply message block length */ |
---|
90 | | - unsigned int rpld_parml; /* replied parameter block len */ |
---|
91 | | - unsigned int rpl_datal; /* reply data block len */ |
---|
92 | | - unsigned int rpld_datal; /* replied data block len */ |
---|
93 | | - unsigned int req_extbl; /* request extension block len */ |
---|
94 | | - unsigned char pad_001[4]; /* reserved */ |
---|
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'*/ |
---|
108 | | - unsigned short ccp_rtcode; /* server return code */ |
---|
109 | | - unsigned short ccp_rscode; /* server reason code */ |
---|
110 | | - unsigned int mac_data_len; /* Mac Data Length */ |
---|
111 | | - unsigned char logon_id[8]; /* Logon Identifier */ |
---|
112 | | - unsigned char mac_value[8]; /* Mac Value */ |
---|
113 | | - unsigned char mac_content_flgs;/* Mac content flag byte */ |
---|
114 | | - unsigned char pad_002; /* Alignment */ |
---|
115 | | - unsigned short domain; /* Domain */ |
---|
116 | | - unsigned char usage_domain[4];/* Usage domain */ |
---|
117 | | - unsigned char cntrl_domain[4];/* Control domain */ |
---|
118 | | - unsigned char S390enf_mask[4];/* S/390 enforcement mask */ |
---|
119 | | - unsigned char pad_004[36]; /* reserved */ |
---|
| 86 | + __u16 cprb_len; /* CPRB length 220 */ |
---|
| 87 | + __u8 cprb_ver_id; /* CPRB version id. 0x02 */ |
---|
| 88 | + __u8 pad_000[3]; /* Alignment pad bytes */ |
---|
| 89 | + __u8 func_id[2]; /* function id 0x5432 */ |
---|
| 90 | + __u8 cprb_flags[4]; /* Flags */ |
---|
| 91 | + __u32 req_parml; /* request parameter buffer len */ |
---|
| 92 | + __u32 req_datal; /* request data buffer */ |
---|
| 93 | + __u32 rpl_msgbl; /* reply message block length */ |
---|
| 94 | + __u32 rpld_parml; /* replied parameter block len */ |
---|
| 95 | + __u32 rpl_datal; /* reply data block len */ |
---|
| 96 | + __u32 rpld_datal; /* replied data block len */ |
---|
| 97 | + __u32 req_extbl; /* request extension block len */ |
---|
| 98 | + __u8 pad_001[4]; /* reserved */ |
---|
| 99 | + __u32 rpld_extbl; /* replied extension block len */ |
---|
| 100 | + __u8 padx000[16 - sizeof(__u8 *)]; |
---|
| 101 | + __u8 __user *req_parmb; /* request parm block 'address' */ |
---|
| 102 | + __u8 padx001[16 - sizeof(__u8 *)]; |
---|
| 103 | + __u8 __user *req_datab; /* request data block 'address' */ |
---|
| 104 | + __u8 padx002[16 - sizeof(__u8 *)]; |
---|
| 105 | + __u8 __user *rpl_parmb; /* reply parm block 'address' */ |
---|
| 106 | + __u8 padx003[16 - sizeof(__u8 *)]; |
---|
| 107 | + __u8 __user *rpl_datab; /* reply data block 'address' */ |
---|
| 108 | + __u8 padx004[16 - sizeof(__u8 *)]; |
---|
| 109 | + __u8 __user *req_extb; /* request extension block 'addr'*/ |
---|
| 110 | + __u8 padx005[16 - sizeof(__u8 *)]; |
---|
| 111 | + __u8 __user *rpl_extb; /* reply extension block 'address'*/ |
---|
| 112 | + __u16 ccp_rtcode; /* server return code */ |
---|
| 113 | + __u16 ccp_rscode; /* server reason code */ |
---|
| 114 | + __u32 mac_data_len; /* Mac Data Length */ |
---|
| 115 | + __u8 logon_id[8]; /* Logon Identifier */ |
---|
| 116 | + __u8 mac_value[8]; /* Mac Value */ |
---|
| 117 | + __u8 mac_content_flgs; /* Mac content flag byte */ |
---|
| 118 | + __u8 pad_002; /* Alignment */ |
---|
| 119 | + __u16 domain; /* Domain */ |
---|
| 120 | + __u8 usage_domain[4]; /* Usage domain */ |
---|
| 121 | + __u8 cntrl_domain[4]; /* Control domain */ |
---|
| 122 | + __u8 S390enf_mask[4]; /* S/390 enforcement mask */ |
---|
| 123 | + __u8 pad_004[36]; /* reserved */ |
---|
120 | 124 | } __attribute__((packed)); |
---|
121 | 125 | |
---|
122 | 126 | /** |
---|
123 | 127 | * xcRB |
---|
124 | 128 | */ |
---|
125 | 129 | struct ica_xcRB { |
---|
126 | | - unsigned short agent_ID; |
---|
127 | | - unsigned int user_defined; |
---|
128 | | - unsigned short request_ID; |
---|
129 | | - unsigned int request_control_blk_length; |
---|
130 | | - unsigned char padding1[16 - sizeof(char *)]; |
---|
131 | | - char __user *request_control_blk_addr; |
---|
132 | | - unsigned int request_data_length; |
---|
133 | | - char padding2[16 - sizeof(char *)]; |
---|
134 | | - char __user *request_data_address; |
---|
135 | | - unsigned int reply_control_blk_length; |
---|
136 | | - char padding3[16 - sizeof(char *)]; |
---|
137 | | - char __user *reply_control_blk_addr; |
---|
138 | | - unsigned int reply_data_length; |
---|
139 | | - char padding4[16 - sizeof(char *)]; |
---|
140 | | - char __user *reply_data_addr; |
---|
141 | | - unsigned short priority_window; |
---|
142 | | - unsigned int status; |
---|
| 130 | + __u16 agent_ID; |
---|
| 131 | + __u32 user_defined; |
---|
| 132 | + __u16 request_ID; |
---|
| 133 | + __u32 request_control_blk_length; |
---|
| 134 | + __u8 _padding1[16 - sizeof(__u8 *)]; |
---|
| 135 | + __u8 __user *request_control_blk_addr; |
---|
| 136 | + __u32 request_data_length; |
---|
| 137 | + __u8 _padding2[16 - sizeof(__u8 *)]; |
---|
| 138 | + __u8 __user *request_data_address; |
---|
| 139 | + __u32 reply_control_blk_length; |
---|
| 140 | + __u8 _padding3[16 - sizeof(__u8 *)]; |
---|
| 141 | + __u8 __user *reply_control_blk_addr; |
---|
| 142 | + __u32 reply_data_length; |
---|
| 143 | + __u8 __padding4[16 - sizeof(__u8 *)]; |
---|
| 144 | + __u8 __user *reply_data_addr; |
---|
| 145 | + __u16 priority_window; |
---|
| 146 | + __u32 status; |
---|
143 | 147 | } __attribute__((packed)); |
---|
144 | 148 | |
---|
145 | 149 | /** |
---|
.. | .. |
---|
157 | 161 | * @payload_len: Payload length |
---|
158 | 162 | */ |
---|
159 | 163 | struct ep11_cprb { |
---|
160 | | - uint16_t cprb_len; |
---|
161 | | - unsigned char cprb_ver_id; |
---|
162 | | - unsigned char pad_000[2]; |
---|
163 | | - unsigned char flags; |
---|
164 | | - unsigned char func_id[2]; |
---|
165 | | - uint32_t source_id; |
---|
166 | | - uint32_t target_id; |
---|
167 | | - uint32_t ret_code; |
---|
168 | | - uint32_t reserved1; |
---|
169 | | - uint32_t reserved2; |
---|
170 | | - uint32_t payload_len; |
---|
| 164 | + __u16 cprb_len; |
---|
| 165 | + __u8 cprb_ver_id; |
---|
| 166 | + __u8 pad_000[2]; |
---|
| 167 | + __u8 flags; |
---|
| 168 | + __u8 func_id[2]; |
---|
| 169 | + __u32 source_id; |
---|
| 170 | + __u32 target_id; |
---|
| 171 | + __u32 ret_code; |
---|
| 172 | + __u32 reserved1; |
---|
| 173 | + __u32 reserved2; |
---|
| 174 | + __u32 payload_len; |
---|
171 | 175 | } __attribute__((packed)); |
---|
172 | 176 | |
---|
173 | 177 | /** |
---|
.. | .. |
---|
176 | 180 | * @dom_id: Usage domain id |
---|
177 | 181 | */ |
---|
178 | 182 | struct ep11_target_dev { |
---|
179 | | - uint16_t ap_id; |
---|
180 | | - uint16_t dom_id; |
---|
| 183 | + __u16 ap_id; |
---|
| 184 | + __u16 dom_id; |
---|
181 | 185 | }; |
---|
182 | 186 | |
---|
183 | 187 | /** |
---|
.. | .. |
---|
192 | 196 | * @resp: Addr to response block |
---|
193 | 197 | */ |
---|
194 | 198 | struct ep11_urb { |
---|
195 | | - uint16_t targets_num; |
---|
196 | | - uint64_t targets; |
---|
197 | | - uint64_t weight; |
---|
198 | | - uint64_t req_no; |
---|
199 | | - uint64_t req_len; |
---|
200 | | - uint64_t req; |
---|
201 | | - uint64_t resp_len; |
---|
202 | | - uint64_t resp; |
---|
| 199 | + __u16 targets_num; |
---|
| 200 | + __u8 __user *targets; |
---|
| 201 | + __u64 weight; |
---|
| 202 | + __u64 req_no; |
---|
| 203 | + __u64 req_len; |
---|
| 204 | + __u8 __user *req; |
---|
| 205 | + __u64 resp_len; |
---|
| 206 | + __u8 __user *resp; |
---|
203 | 207 | } __attribute__((packed)); |
---|
204 | 208 | |
---|
205 | 209 | /** |
---|
.. | .. |
---|
233 | 237 | struct zcrypt_device_status_ext device[MAX_ZDEV_ENTRIES_EXT]; |
---|
234 | 238 | }; |
---|
235 | 239 | |
---|
236 | | -#define AUTOSELECT 0xFFFFFFFF |
---|
| 240 | +#define AUTOSELECT 0xFFFFFFFF |
---|
| 241 | +#define AUTOSEL_AP ((__u16) 0xFFFF) |
---|
| 242 | +#define AUTOSEL_DOM ((__u16) 0xFFFF) |
---|
237 | 243 | |
---|
238 | 244 | #define ZCRYPT_IOCTL_MAGIC 'z' |
---|
239 | 245 | |
---|
.. | .. |
---|
282 | 288 | * 0x08: CEX3A |
---|
283 | 289 | * 0x0a: CEX4 |
---|
284 | 290 | * 0x0b: CEX5 |
---|
285 | | - * 0x0c: CEX6 |
---|
| 291 | + * 0x0c: CEX6 and CEX7 |
---|
286 | 292 | * 0x0d: device is disabled |
---|
287 | 293 | * |
---|
288 | 294 | * ZCRYPT_QDEPTH_MASK |
---|
.. | .. |
---|
310 | 316 | #define ZCRYPT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x5a, int[MAX_ZDEV_CARDIDS_EXT]) |
---|
311 | 317 | |
---|
312 | 318 | /* |
---|
| 319 | + * Support for multiple zcrypt device nodes. |
---|
| 320 | + */ |
---|
| 321 | + |
---|
| 322 | +/* Nr of minor device node numbers to allocate. */ |
---|
| 323 | +#define ZCRYPT_MAX_MINOR_NODES 256 |
---|
| 324 | + |
---|
| 325 | +/* Max amount of possible ioctls */ |
---|
| 326 | +#define MAX_ZDEV_IOCTLS (1 << _IOC_NRBITS) |
---|
| 327 | + |
---|
| 328 | +/* |
---|
313 | 329 | * Only deprecated defines, structs and ioctls below this line. |
---|
314 | 330 | */ |
---|
315 | 331 | |
---|