]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (C) 2004 IBM Corporation | |
3 | * | |
4 | * Authors: | |
5 | * Leendert van Doorn <[email protected]> | |
6 | * Dave Safford <[email protected]> | |
7 | * Reiner Sailer <[email protected]> | |
8 | * Kylene Hall <[email protected]> | |
9 | * | |
8e81cc13 | 10 | * Maintained by: <[email protected]> |
1da177e4 LT |
11 | * |
12 | * Device driver for TCG/TCPA TPM (trusted platform module). | |
13 | * Specifications at www.trustedcomputinggroup.org | |
14 | * | |
15 | * This program is free software; you can redistribute it and/or | |
16 | * modify it under the terms of the GNU General Public License as | |
17 | * published by the Free Software Foundation, version 2 of the | |
18 | * License. | |
19 | * | |
20 | * Note, the TPM chip is not interrupt driven (only polling) | |
21 | * and can have very long timeouts (minutes!). Hence the unusual | |
700d8bdc | 22 | * calls to msleep. |
1da177e4 LT |
23 | * |
24 | */ | |
25 | ||
1da177e4 | 26 | #include <linux/poll.h> |
5a0e3ad6 | 27 | #include <linux/slab.h> |
d081d470 | 28 | #include <linux/mutex.h> |
1da177e4 | 29 | #include <linux/spinlock.h> |
fd048866 | 30 | #include <linux/freezer.h> |
d081d470 | 31 | |
1da177e4 LT |
32 | #include "tpm.h" |
33 | ||
3122a88a KH |
34 | enum tpm_const { |
35 | TPM_MINOR = 224, /* officially assigned */ | |
7f366784 | 36 | TPM_BUFSIZE = 4096, |
3122a88a | 37 | TPM_NUM_DEVICES = 256, |
3122a88a | 38 | }; |
1da177e4 | 39 | |
9e18ee19 KJH |
40 | enum tpm_duration { |
41 | TPM_SHORT = 0, | |
42 | TPM_MEDIUM = 1, | |
43 | TPM_LONG = 2, | |
44 | TPM_UNDEFINED, | |
45 | }; | |
46 | ||
47 | #define TPM_MAX_ORDINAL 243 | |
48 | #define TPM_MAX_PROTECTED_ORDINAL 12 | |
49 | #define TPM_PROTECTED_ORDINAL_MASK 0xFF | |
50 | ||
9b3056cc DT |
51 | /* |
52 | * Bug workaround - some TPM's don't flush the most | |
53 | * recently changed pcr on suspend, so force the flush | |
54 | * with an extend to the selected _unused_ non-volatile pcr. | |
55 | */ | |
56 | static int tpm_suspend_pcr; | |
57 | module_param_named(suspend_pcr, tpm_suspend_pcr, uint, 0644); | |
58 | MODULE_PARM_DESC(suspend_pcr, | |
59 | "PCR to use for dummy writes to faciltate flush on suspend."); | |
60 | ||
1da177e4 LT |
61 | static LIST_HEAD(tpm_chip_list); |
62 | static DEFINE_SPINLOCK(driver_lock); | |
10685a95 | 63 | static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES); |
1da177e4 | 64 | |
9e18ee19 KJH |
65 | /* |
66 | * Array with one entry per ordinal defining the maximum amount | |
67 | * of time the chip could take to return the result. The ordinal | |
68 | * designation of short, medium or long is defined in a table in | |
69 | * TCG Specification TPM Main Part 2 TPM Structures Section 17. The | |
70 | * values of the SHORT, MEDIUM, and LONG durations are retrieved | |
71 | * from the chip during initialization with a call to tpm_get_timeouts. | |
72 | */ | |
73 | static const u8 tpm_protected_ordinal_duration[TPM_MAX_PROTECTED_ORDINAL] = { | |
74 | TPM_UNDEFINED, /* 0 */ | |
75 | TPM_UNDEFINED, | |
76 | TPM_UNDEFINED, | |
77 | TPM_UNDEFINED, | |
78 | TPM_UNDEFINED, | |
79 | TPM_UNDEFINED, /* 5 */ | |
80 | TPM_UNDEFINED, | |
81 | TPM_UNDEFINED, | |
82 | TPM_UNDEFINED, | |
83 | TPM_UNDEFINED, | |
84 | TPM_SHORT, /* 10 */ | |
85 | TPM_SHORT, | |
86 | }; | |
87 | ||
88 | static const u8 tpm_ordinal_duration[TPM_MAX_ORDINAL] = { | |
89 | TPM_UNDEFINED, /* 0 */ | |
90 | TPM_UNDEFINED, | |
91 | TPM_UNDEFINED, | |
92 | TPM_UNDEFINED, | |
93 | TPM_UNDEFINED, | |
94 | TPM_UNDEFINED, /* 5 */ | |
95 | TPM_UNDEFINED, | |
96 | TPM_UNDEFINED, | |
97 | TPM_UNDEFINED, | |
98 | TPM_UNDEFINED, | |
99 | TPM_SHORT, /* 10 */ | |
100 | TPM_SHORT, | |
101 | TPM_MEDIUM, | |
102 | TPM_LONG, | |
103 | TPM_LONG, | |
104 | TPM_MEDIUM, /* 15 */ | |
105 | TPM_SHORT, | |
106 | TPM_SHORT, | |
107 | TPM_MEDIUM, | |
108 | TPM_LONG, | |
109 | TPM_SHORT, /* 20 */ | |
110 | TPM_SHORT, | |
111 | TPM_MEDIUM, | |
112 | TPM_MEDIUM, | |
113 | TPM_MEDIUM, | |
114 | TPM_SHORT, /* 25 */ | |
115 | TPM_SHORT, | |
116 | TPM_MEDIUM, | |
117 | TPM_SHORT, | |
118 | TPM_SHORT, | |
119 | TPM_MEDIUM, /* 30 */ | |
120 | TPM_LONG, | |
121 | TPM_MEDIUM, | |
122 | TPM_SHORT, | |
123 | TPM_SHORT, | |
124 | TPM_SHORT, /* 35 */ | |
125 | TPM_MEDIUM, | |
126 | TPM_MEDIUM, | |
127 | TPM_UNDEFINED, | |
128 | TPM_UNDEFINED, | |
129 | TPM_MEDIUM, /* 40 */ | |
130 | TPM_LONG, | |
131 | TPM_MEDIUM, | |
132 | TPM_SHORT, | |
133 | TPM_SHORT, | |
134 | TPM_SHORT, /* 45 */ | |
135 | TPM_SHORT, | |
136 | TPM_SHORT, | |
137 | TPM_SHORT, | |
138 | TPM_LONG, | |
139 | TPM_MEDIUM, /* 50 */ | |
140 | TPM_MEDIUM, | |
141 | TPM_UNDEFINED, | |
142 | TPM_UNDEFINED, | |
143 | TPM_UNDEFINED, | |
144 | TPM_UNDEFINED, /* 55 */ | |
145 | TPM_UNDEFINED, | |
146 | TPM_UNDEFINED, | |
147 | TPM_UNDEFINED, | |
148 | TPM_UNDEFINED, | |
149 | TPM_MEDIUM, /* 60 */ | |
150 | TPM_MEDIUM, | |
151 | TPM_MEDIUM, | |
152 | TPM_SHORT, | |
153 | TPM_SHORT, | |
154 | TPM_MEDIUM, /* 65 */ | |
155 | TPM_UNDEFINED, | |
156 | TPM_UNDEFINED, | |
157 | TPM_UNDEFINED, | |
158 | TPM_UNDEFINED, | |
159 | TPM_SHORT, /* 70 */ | |
160 | TPM_SHORT, | |
161 | TPM_UNDEFINED, | |
162 | TPM_UNDEFINED, | |
163 | TPM_UNDEFINED, | |
164 | TPM_UNDEFINED, /* 75 */ | |
165 | TPM_UNDEFINED, | |
166 | TPM_UNDEFINED, | |
167 | TPM_UNDEFINED, | |
168 | TPM_UNDEFINED, | |
169 | TPM_LONG, /* 80 */ | |
170 | TPM_UNDEFINED, | |
171 | TPM_MEDIUM, | |
172 | TPM_LONG, | |
173 | TPM_SHORT, | |
174 | TPM_UNDEFINED, /* 85 */ | |
175 | TPM_UNDEFINED, | |
176 | TPM_UNDEFINED, | |
177 | TPM_UNDEFINED, | |
178 | TPM_UNDEFINED, | |
179 | TPM_SHORT, /* 90 */ | |
180 | TPM_SHORT, | |
181 | TPM_SHORT, | |
182 | TPM_SHORT, | |
183 | TPM_SHORT, | |
184 | TPM_UNDEFINED, /* 95 */ | |
185 | TPM_UNDEFINED, | |
186 | TPM_UNDEFINED, | |
187 | TPM_UNDEFINED, | |
188 | TPM_UNDEFINED, | |
189 | TPM_MEDIUM, /* 100 */ | |
190 | TPM_SHORT, | |
191 | TPM_SHORT, | |
192 | TPM_UNDEFINED, | |
193 | TPM_UNDEFINED, | |
194 | TPM_UNDEFINED, /* 105 */ | |
195 | TPM_UNDEFINED, | |
196 | TPM_UNDEFINED, | |
197 | TPM_UNDEFINED, | |
198 | TPM_UNDEFINED, | |
199 | TPM_SHORT, /* 110 */ | |
200 | TPM_SHORT, | |
201 | TPM_SHORT, | |
202 | TPM_SHORT, | |
203 | TPM_SHORT, | |
204 | TPM_SHORT, /* 115 */ | |
205 | TPM_SHORT, | |
206 | TPM_SHORT, | |
207 | TPM_UNDEFINED, | |
208 | TPM_UNDEFINED, | |
209 | TPM_LONG, /* 120 */ | |
210 | TPM_LONG, | |
211 | TPM_MEDIUM, | |
212 | TPM_UNDEFINED, | |
213 | TPM_SHORT, | |
214 | TPM_SHORT, /* 125 */ | |
215 | TPM_SHORT, | |
216 | TPM_LONG, | |
217 | TPM_SHORT, | |
218 | TPM_SHORT, | |
219 | TPM_SHORT, /* 130 */ | |
220 | TPM_MEDIUM, | |
221 | TPM_UNDEFINED, | |
222 | TPM_SHORT, | |
223 | TPM_MEDIUM, | |
224 | TPM_UNDEFINED, /* 135 */ | |
225 | TPM_UNDEFINED, | |
226 | TPM_UNDEFINED, | |
227 | TPM_UNDEFINED, | |
228 | TPM_UNDEFINED, | |
229 | TPM_SHORT, /* 140 */ | |
230 | TPM_SHORT, | |
231 | TPM_UNDEFINED, | |
232 | TPM_UNDEFINED, | |
233 | TPM_UNDEFINED, | |
234 | TPM_UNDEFINED, /* 145 */ | |
235 | TPM_UNDEFINED, | |
236 | TPM_UNDEFINED, | |
237 | TPM_UNDEFINED, | |
238 | TPM_UNDEFINED, | |
239 | TPM_SHORT, /* 150 */ | |
240 | TPM_MEDIUM, | |
241 | TPM_MEDIUM, | |
242 | TPM_SHORT, | |
243 | TPM_SHORT, | |
244 | TPM_UNDEFINED, /* 155 */ | |
245 | TPM_UNDEFINED, | |
246 | TPM_UNDEFINED, | |
247 | TPM_UNDEFINED, | |
248 | TPM_UNDEFINED, | |
249 | TPM_SHORT, /* 160 */ | |
250 | TPM_SHORT, | |
251 | TPM_SHORT, | |
252 | TPM_SHORT, | |
253 | TPM_UNDEFINED, | |
254 | TPM_UNDEFINED, /* 165 */ | |
255 | TPM_UNDEFINED, | |
256 | TPM_UNDEFINED, | |
257 | TPM_UNDEFINED, | |
258 | TPM_UNDEFINED, | |
259 | TPM_LONG, /* 170 */ | |
260 | TPM_UNDEFINED, | |
261 | TPM_UNDEFINED, | |
262 | TPM_UNDEFINED, | |
263 | TPM_UNDEFINED, | |
264 | TPM_UNDEFINED, /* 175 */ | |
265 | TPM_UNDEFINED, | |
266 | TPM_UNDEFINED, | |
267 | TPM_UNDEFINED, | |
268 | TPM_UNDEFINED, | |
269 | TPM_MEDIUM, /* 180 */ | |
270 | TPM_SHORT, | |
271 | TPM_MEDIUM, | |
272 | TPM_MEDIUM, | |
273 | TPM_MEDIUM, | |
274 | TPM_MEDIUM, /* 185 */ | |
275 | TPM_SHORT, | |
276 | TPM_UNDEFINED, | |
277 | TPM_UNDEFINED, | |
278 | TPM_UNDEFINED, | |
279 | TPM_UNDEFINED, /* 190 */ | |
280 | TPM_UNDEFINED, | |
281 | TPM_UNDEFINED, | |
282 | TPM_UNDEFINED, | |
283 | TPM_UNDEFINED, | |
284 | TPM_UNDEFINED, /* 195 */ | |
285 | TPM_UNDEFINED, | |
286 | TPM_UNDEFINED, | |
287 | TPM_UNDEFINED, | |
288 | TPM_UNDEFINED, | |
289 | TPM_SHORT, /* 200 */ | |
290 | TPM_UNDEFINED, | |
291 | TPM_UNDEFINED, | |
292 | TPM_UNDEFINED, | |
293 | TPM_SHORT, | |
294 | TPM_SHORT, /* 205 */ | |
295 | TPM_SHORT, | |
296 | TPM_SHORT, | |
297 | TPM_SHORT, | |
298 | TPM_SHORT, | |
299 | TPM_MEDIUM, /* 210 */ | |
300 | TPM_UNDEFINED, | |
301 | TPM_MEDIUM, | |
302 | TPM_MEDIUM, | |
303 | TPM_MEDIUM, | |
304 | TPM_UNDEFINED, /* 215 */ | |
305 | TPM_MEDIUM, | |
306 | TPM_UNDEFINED, | |
307 | TPM_UNDEFINED, | |
308 | TPM_SHORT, | |
309 | TPM_SHORT, /* 220 */ | |
310 | TPM_SHORT, | |
311 | TPM_SHORT, | |
312 | TPM_SHORT, | |
313 | TPM_SHORT, | |
314 | TPM_UNDEFINED, /* 225 */ | |
315 | TPM_UNDEFINED, | |
316 | TPM_UNDEFINED, | |
317 | TPM_UNDEFINED, | |
318 | TPM_UNDEFINED, | |
319 | TPM_SHORT, /* 230 */ | |
320 | TPM_LONG, | |
321 | TPM_MEDIUM, | |
322 | TPM_UNDEFINED, | |
323 | TPM_UNDEFINED, | |
324 | TPM_UNDEFINED, /* 235 */ | |
325 | TPM_UNDEFINED, | |
326 | TPM_UNDEFINED, | |
327 | TPM_UNDEFINED, | |
328 | TPM_UNDEFINED, | |
329 | TPM_SHORT, /* 240 */ | |
330 | TPM_UNDEFINED, | |
331 | TPM_MEDIUM, | |
332 | }; | |
333 | ||
1da177e4 LT |
334 | static void user_reader_timeout(unsigned long ptr) |
335 | { | |
336 | struct tpm_chip *chip = (struct tpm_chip *) ptr; | |
337 | ||
09e12f9f KJH |
338 | schedule_work(&chip->work); |
339 | } | |
340 | ||
c4028958 | 341 | static void timeout_work(struct work_struct *work) |
09e12f9f | 342 | { |
c4028958 | 343 | struct tpm_chip *chip = container_of(work, struct tpm_chip, work); |
09e12f9f | 344 | |
d081d470 | 345 | mutex_lock(&chip->buffer_mutex); |
1da177e4 LT |
346 | atomic_set(&chip->data_pending, 0); |
347 | memset(chip->data_buffer, 0, TPM_BUFSIZE); | |
d081d470 | 348 | mutex_unlock(&chip->buffer_mutex); |
1da177e4 LT |
349 | } |
350 | ||
9e18ee19 KJH |
351 | /* |
352 | * Returns max number of jiffies to wait | |
353 | */ | |
354 | unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, | |
355 | u32 ordinal) | |
356 | { | |
357 | int duration_idx = TPM_UNDEFINED; | |
358 | int duration = 0; | |
359 | ||
360 | if (ordinal < TPM_MAX_ORDINAL) | |
361 | duration_idx = tpm_ordinal_duration[ordinal]; | |
362 | else if ((ordinal & TPM_PROTECTED_ORDINAL_MASK) < | |
363 | TPM_MAX_PROTECTED_ORDINAL) | |
364 | duration_idx = | |
365 | tpm_protected_ordinal_duration[ordinal & | |
366 | TPM_PROTECTED_ORDINAL_MASK]; | |
367 | ||
8d1dc20e | 368 | if (duration_idx != TPM_UNDEFINED) |
36b20020 | 369 | duration = chip->vendor.duration[duration_idx]; |
8d1dc20e | 370 | if (duration <= 0) |
9e18ee19 | 371 | return 2 * 60 * HZ; |
8d1dc20e LT |
372 | else |
373 | return duration; | |
9e18ee19 KJH |
374 | } |
375 | EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration); | |
376 | ||
1da177e4 LT |
377 | /* |
378 | * Internal kernel interface to transmit TPM commands | |
379 | */ | |
380 | static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | |
381 | size_t bufsiz) | |
382 | { | |
d9e5b6bf | 383 | ssize_t rc; |
9e18ee19 | 384 | u32 count, ordinal; |
700d8bdc | 385 | unsigned long stop; |
1da177e4 | 386 | |
6b07d30a PH |
387 | if (bufsiz > TPM_BUFSIZE) |
388 | bufsiz = TPM_BUFSIZE; | |
389 | ||
81179bb6 | 390 | count = be32_to_cpu(*((__be32 *) (buf + 2))); |
9e18ee19 | 391 | ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); |
1da177e4 LT |
392 | if (count == 0) |
393 | return -ENODATA; | |
394 | if (count > bufsiz) { | |
e659a3fe | 395 | dev_err(chip->dev, |
b76be681 | 396 | "invalid count value %x %zx \n", count, bufsiz); |
1da177e4 LT |
397 | return -E2BIG; |
398 | } | |
399 | ||
d081d470 | 400 | mutex_lock(&chip->tpm_mutex); |
1da177e4 | 401 | |
90dda520 | 402 | if ((rc = chip->vendor.send(chip, (u8 *) buf, count)) < 0) { |
e659a3fe | 403 | dev_err(chip->dev, |
d9e5b6bf KH |
404 | "tpm_transmit: tpm_send: error %zd\n", rc); |
405 | goto out; | |
1da177e4 LT |
406 | } |
407 | ||
27084efe LD |
408 | if (chip->vendor.irq) |
409 | goto out_recv; | |
410 | ||
9e18ee19 | 411 | stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal); |
1da177e4 | 412 | do { |
90dda520 KJH |
413 | u8 status = chip->vendor.status(chip); |
414 | if ((status & chip->vendor.req_complete_mask) == | |
415 | chip->vendor.req_complete_val) | |
1da177e4 | 416 | goto out_recv; |
d9e5b6bf | 417 | |
90dda520 | 418 | if ((status == chip->vendor.req_canceled)) { |
e659a3fe | 419 | dev_err(chip->dev, "Operation Canceled\n"); |
d9e5b6bf KH |
420 | rc = -ECANCELED; |
421 | goto out; | |
422 | } | |
423 | ||
424 | msleep(TPM_TIMEOUT); /* CHECK */ | |
1da177e4 | 425 | rmb(); |
700d8bdc | 426 | } while (time_before(jiffies, stop)); |
1da177e4 | 427 | |
90dda520 | 428 | chip->vendor.cancel(chip); |
e659a3fe | 429 | dev_err(chip->dev, "Operation Timed out\n"); |
d9e5b6bf KH |
430 | rc = -ETIME; |
431 | goto out; | |
1da177e4 LT |
432 | |
433 | out_recv: | |
90dda520 | 434 | rc = chip->vendor.recv(chip, (u8 *) buf, bufsiz); |
d9e5b6bf | 435 | if (rc < 0) |
e659a3fe | 436 | dev_err(chip->dev, |
d9e5b6bf KH |
437 | "tpm_transmit: tpm_recv: error %zd\n", rc); |
438 | out: | |
d081d470 | 439 | mutex_unlock(&chip->tpm_mutex); |
d9e5b6bf | 440 | return rc; |
1da177e4 LT |
441 | } |
442 | ||
443 | #define TPM_DIGEST_SIZE 20 | |
beed53a1 | 444 | #define TPM_RET_CODE_IDX 6 |
beed53a1 KJH |
445 | |
446 | enum tpm_capabilities { | |
08837438 RA |
447 | TPM_CAP_FLAG = cpu_to_be32(4), |
448 | TPM_CAP_PROP = cpu_to_be32(5), | |
449 | CAP_VERSION_1_1 = cpu_to_be32(0x06), | |
450 | CAP_VERSION_1_2 = cpu_to_be32(0x1A) | |
beed53a1 KJH |
451 | }; |
452 | ||
453 | enum tpm_sub_capabilities { | |
08837438 RA |
454 | TPM_CAP_PROP_PCR = cpu_to_be32(0x101), |
455 | TPM_CAP_PROP_MANUFACTURER = cpu_to_be32(0x103), | |
456 | TPM_CAP_FLAG_PERM = cpu_to_be32(0x108), | |
457 | TPM_CAP_FLAG_VOL = cpu_to_be32(0x109), | |
458 | TPM_CAP_PROP_OWNER = cpu_to_be32(0x111), | |
459 | TPM_CAP_PROP_TIS_TIMEOUT = cpu_to_be32(0x115), | |
460 | TPM_CAP_PROP_TIS_DURATION = cpu_to_be32(0x120), | |
beed53a1 | 461 | |
1da177e4 LT |
462 | }; |
463 | ||
08837438 RA |
464 | static ssize_t transmit_cmd(struct tpm_chip *chip, struct tpm_cmd_t *cmd, |
465 | int len, const char *desc) | |
beed53a1 KJH |
466 | { |
467 | int err; | |
468 | ||
08837438 | 469 | len = tpm_transmit(chip,(u8 *) cmd, len); |
beed53a1 KJH |
470 | if (len < 0) |
471 | return len; | |
b9e3238a RA |
472 | else if (len < TPM_HEADER_SIZE) |
473 | return -EFAULT; | |
474 | ||
475 | err = be32_to_cpu(cmd->header.out.return_code); | |
476 | if (err != 0) | |
477 | dev_err(chip->dev, "A TPM error (%d) occurred %s\n", err, desc); | |
478 | ||
479 | return err; | |
beed53a1 KJH |
480 | } |
481 | ||
08837438 RA |
482 | #define TPM_INTERNAL_RESULT_SIZE 200 |
483 | #define TPM_TAG_RQU_COMMAND cpu_to_be16(193) | |
484 | #define TPM_ORD_GET_CAP cpu_to_be32(101) | |
485 | ||
486 | static const struct tpm_input_header tpm_getcap_header = { | |
487 | .tag = TPM_TAG_RQU_COMMAND, | |
488 | .length = cpu_to_be32(22), | |
489 | .ordinal = TPM_ORD_GET_CAP | |
490 | }; | |
491 | ||
492 | ssize_t tpm_getcap(struct device *dev, __be32 subcap_id, cap_t *cap, | |
493 | const char *desc) | |
494 | { | |
495 | struct tpm_cmd_t tpm_cmd; | |
496 | int rc; | |
497 | struct tpm_chip *chip = dev_get_drvdata(dev); | |
498 | ||
499 | tpm_cmd.header.in = tpm_getcap_header; | |
500 | if (subcap_id == CAP_VERSION_1_1 || subcap_id == CAP_VERSION_1_2) { | |
501 | tpm_cmd.params.getcap_in.cap = subcap_id; | |
502 | /*subcap field not necessary */ | |
503 | tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(0); | |
504 | tpm_cmd.header.in.length -= cpu_to_be32(sizeof(__be32)); | |
505 | } else { | |
506 | if (subcap_id == TPM_CAP_FLAG_PERM || | |
507 | subcap_id == TPM_CAP_FLAG_VOL) | |
508 | tpm_cmd.params.getcap_in.cap = TPM_CAP_FLAG; | |
509 | else | |
510 | tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP; | |
511 | tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); | |
512 | tpm_cmd.params.getcap_in.subcap = subcap_id; | |
513 | } | |
514 | rc = transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, desc); | |
515 | if (!rc) | |
516 | *cap = tpm_cmd.params.getcap_out.cap; | |
517 | return rc; | |
518 | } | |
519 | ||
08e96e48 KJH |
520 | void tpm_gen_interrupt(struct tpm_chip *chip) |
521 | { | |
08837438 | 522 | struct tpm_cmd_t tpm_cmd; |
08e96e48 KJH |
523 | ssize_t rc; |
524 | ||
08837438 RA |
525 | tpm_cmd.header.in = tpm_getcap_header; |
526 | tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP; | |
527 | tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); | |
528 | tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT; | |
08e96e48 | 529 | |
08837438 | 530 | rc = transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, |
08e96e48 KJH |
531 | "attempting to determine the timeouts"); |
532 | } | |
533 | EXPORT_SYMBOL_GPL(tpm_gen_interrupt); | |
534 | ||
2b30a90f | 535 | int tpm_get_timeouts(struct tpm_chip *chip) |
08e96e48 | 536 | { |
08837438 RA |
537 | struct tpm_cmd_t tpm_cmd; |
538 | struct timeout_t *timeout_cap; | |
539 | struct duration_t *duration_cap; | |
08e96e48 KJH |
540 | ssize_t rc; |
541 | u32 timeout; | |
e3e1a1e1 | 542 | unsigned int scale = 1; |
08e96e48 | 543 | |
08837438 RA |
544 | tpm_cmd.header.in = tpm_getcap_header; |
545 | tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP; | |
546 | tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); | |
547 | tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT; | |
08e96e48 | 548 | |
08837438 | 549 | rc = transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, |
08e96e48 KJH |
550 | "attempting to determine the timeouts"); |
551 | if (rc) | |
552 | goto duration; | |
553 | ||
829bf067 SB |
554 | if (be32_to_cpu(tpm_cmd.header.out.return_code) != 0 || |
555 | be32_to_cpu(tpm_cmd.header.out.length) | |
556 | != sizeof(tpm_cmd.header.out) + sizeof(u32) + 4 * sizeof(u32)) | |
2b30a90f | 557 | return -EINVAL; |
08e96e48 | 558 | |
08837438 | 559 | timeout_cap = &tpm_cmd.params.getcap_out.cap.timeout; |
08e96e48 | 560 | /* Don't overwrite default if value is 0 */ |
08837438 | 561 | timeout = be32_to_cpu(timeout_cap->a); |
e3e1a1e1 SB |
562 | if (timeout && timeout < 1000) { |
563 | /* timeouts in msec rather usec */ | |
564 | scale = 1000; | |
62592101 | 565 | chip->vendor.timeout_adjusted = true; |
e3e1a1e1 | 566 | } |
08e96e48 | 567 | if (timeout) |
e3e1a1e1 | 568 | chip->vendor.timeout_a = usecs_to_jiffies(timeout * scale); |
08837438 | 569 | timeout = be32_to_cpu(timeout_cap->b); |
08e96e48 | 570 | if (timeout) |
e3e1a1e1 | 571 | chip->vendor.timeout_b = usecs_to_jiffies(timeout * scale); |
08837438 | 572 | timeout = be32_to_cpu(timeout_cap->c); |
08e96e48 | 573 | if (timeout) |
e3e1a1e1 | 574 | chip->vendor.timeout_c = usecs_to_jiffies(timeout * scale); |
08837438 | 575 | timeout = be32_to_cpu(timeout_cap->d); |
08e96e48 | 576 | if (timeout) |
e3e1a1e1 | 577 | chip->vendor.timeout_d = usecs_to_jiffies(timeout * scale); |
08e96e48 KJH |
578 | |
579 | duration: | |
08837438 RA |
580 | tpm_cmd.header.in = tpm_getcap_header; |
581 | tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP; | |
582 | tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4); | |
583 | tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_DURATION; | |
08e96e48 | 584 | |
08837438 | 585 | rc = transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, |
08e96e48 KJH |
586 | "attempting to determine the durations"); |
587 | if (rc) | |
2b30a90f | 588 | return rc; |
08e96e48 | 589 | |
979b1406 SB |
590 | if (be32_to_cpu(tpm_cmd.header.out.return_code) != 0 || |
591 | be32_to_cpu(tpm_cmd.header.out.length) | |
592 | != sizeof(tpm_cmd.header.out) + sizeof(u32) + 3 * sizeof(u32)) | |
2b30a90f | 593 | return -EINVAL; |
979b1406 | 594 | |
08837438 | 595 | duration_cap = &tpm_cmd.params.getcap_out.cap.duration; |
08e96e48 | 596 | chip->vendor.duration[TPM_SHORT] = |
08837438 | 597 | usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_short)); |
e934acca SB |
598 | chip->vendor.duration[TPM_MEDIUM] = |
599 | usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_medium)); | |
600 | chip->vendor.duration[TPM_LONG] = | |
601 | usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_long)); | |
602 | ||
292cf4a8 VK |
603 | /* The Broadcom BCM0102 chipset in a Dell Latitude D820 gets the above |
604 | * value wrong and apparently reports msecs rather than usecs. So we | |
605 | * fix up the resulting too-small TPM_SHORT value to make things work. | |
e934acca | 606 | * We also scale the TPM_MEDIUM and -_LONG values by 1000. |
292cf4a8 | 607 | */ |
e934acca | 608 | if (chip->vendor.duration[TPM_SHORT] < (HZ / 100)) { |
292cf4a8 | 609 | chip->vendor.duration[TPM_SHORT] = HZ; |
e934acca SB |
610 | chip->vendor.duration[TPM_MEDIUM] *= 1000; |
611 | chip->vendor.duration[TPM_LONG] *= 1000; | |
04ab2293 | 612 | chip->vendor.duration_adjusted = true; |
e934acca SB |
613 | dev_info(chip->dev, "Adjusting TPM timeout parameters."); |
614 | } | |
2b30a90f | 615 | return 0; |
08e96e48 KJH |
616 | } |
617 | EXPORT_SYMBOL_GPL(tpm_get_timeouts); | |
618 | ||
d97c6ade SB |
619 | #define TPM_ORD_CONTINUE_SELFTEST 83 |
620 | #define CONTINUE_SELFTEST_RESULT_SIZE 10 | |
621 | ||
622 | static struct tpm_input_header continue_selftest_header = { | |
623 | .tag = TPM_TAG_RQU_COMMAND, | |
624 | .length = cpu_to_be32(10), | |
625 | .ordinal = cpu_to_be32(TPM_ORD_CONTINUE_SELFTEST), | |
626 | }; | |
627 | ||
628 | /** | |
629 | * tpm_continue_selftest -- run TPM's selftest | |
630 | * @chip: TPM chip to use | |
631 | * | |
632 | * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing | |
633 | * a TPM error code. | |
634 | */ | |
68d6e671 | 635 | static int tpm_continue_selftest(struct tpm_chip *chip) |
08e96e48 | 636 | { |
d97c6ade SB |
637 | int rc; |
638 | struct tpm_cmd_t cmd; | |
08e96e48 | 639 | |
d97c6ade SB |
640 | cmd.header.in = continue_selftest_header; |
641 | rc = transmit_cmd(chip, &cmd, CONTINUE_SELFTEST_RESULT_SIZE, | |
642 | "continue selftest"); | |
643 | return rc; | |
08e96e48 | 644 | } |
08e96e48 KJH |
645 | |
646 | ssize_t tpm_show_enabled(struct device * dev, struct device_attribute * attr, | |
647 | char *buf) | |
648 | { | |
08837438 | 649 | cap_t cap; |
08e96e48 KJH |
650 | ssize_t rc; |
651 | ||
08837438 RA |
652 | rc = tpm_getcap(dev, TPM_CAP_FLAG_PERM, &cap, |
653 | "attempting to determine the permanent enabled state"); | |
654 | if (rc) | |
08e96e48 | 655 | return 0; |
ec288bd3 | 656 | |
08837438 | 657 | rc = sprintf(buf, "%d\n", !cap.perm_flags.disable); |
ec288bd3 | 658 | return rc; |
08e96e48 KJH |
659 | } |
660 | EXPORT_SYMBOL_GPL(tpm_show_enabled); | |
661 | ||
662 | ssize_t tpm_show_active(struct device * dev, struct device_attribute * attr, | |
663 | char *buf) | |
664 | { | |
08837438 | 665 | cap_t cap; |
08e96e48 KJH |
666 | ssize_t rc; |
667 | ||
08837438 RA |
668 | rc = tpm_getcap(dev, TPM_CAP_FLAG_PERM, &cap, |
669 | "attempting to determine the permanent active state"); | |
670 | if (rc) | |
08e96e48 | 671 | return 0; |
ec288bd3 | 672 | |
08837438 | 673 | rc = sprintf(buf, "%d\n", !cap.perm_flags.deactivated); |
ec288bd3 | 674 | return rc; |
08e96e48 KJH |
675 | } |
676 | EXPORT_SYMBOL_GPL(tpm_show_active); | |
677 | ||
678 | ssize_t tpm_show_owned(struct device * dev, struct device_attribute * attr, | |
679 | char *buf) | |
680 | { | |
08837438 | 681 | cap_t cap; |
08e96e48 KJH |
682 | ssize_t rc; |
683 | ||
08837438 RA |
684 | rc = tpm_getcap(dev, TPM_CAP_PROP_OWNER, &cap, |
685 | "attempting to determine the owner state"); | |
686 | if (rc) | |
08e96e48 | 687 | return 0; |
ec288bd3 | 688 | |
08837438 | 689 | rc = sprintf(buf, "%d\n", cap.owned); |
ec288bd3 | 690 | return rc; |
08e96e48 KJH |
691 | } |
692 | EXPORT_SYMBOL_GPL(tpm_show_owned); | |
693 | ||
694 | ssize_t tpm_show_temp_deactivated(struct device * dev, | |
695 | struct device_attribute * attr, char *buf) | |
696 | { | |
08837438 | 697 | cap_t cap; |
08e96e48 KJH |
698 | ssize_t rc; |
699 | ||
08837438 RA |
700 | rc = tpm_getcap(dev, TPM_CAP_FLAG_VOL, &cap, |
701 | "attempting to determine the temporary state"); | |
702 | if (rc) | |
08e96e48 | 703 | return 0; |
ec288bd3 | 704 | |
08837438 | 705 | rc = sprintf(buf, "%d\n", cap.stclear_flags.deactivated); |
ec288bd3 | 706 | return rc; |
08e96e48 KJH |
707 | } |
708 | EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated); | |
709 | ||
659aaf2b RA |
710 | /* |
711 | * tpm_chip_find_get - return tpm_chip for given chip number | |
712 | */ | |
713 | static struct tpm_chip *tpm_chip_find_get(int chip_num) | |
714 | { | |
8920d5ad | 715 | struct tpm_chip *pos, *chip = NULL; |
659aaf2b RA |
716 | |
717 | rcu_read_lock(); | |
718 | list_for_each_entry_rcu(pos, &tpm_chip_list, list) { | |
719 | if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num) | |
720 | continue; | |
721 | ||
8920d5ad RA |
722 | if (try_module_get(pos->dev->driver->owner)) { |
723 | chip = pos; | |
659aaf2b | 724 | break; |
8920d5ad | 725 | } |
659aaf2b RA |
726 | } |
727 | rcu_read_unlock(); | |
8920d5ad | 728 | return chip; |
659aaf2b RA |
729 | } |
730 | ||
731 | #define TPM_ORDINAL_PCRREAD cpu_to_be32(21) | |
732 | #define READ_PCR_RESULT_SIZE 30 | |
733 | static struct tpm_input_header pcrread_header = { | |
734 | .tag = TPM_TAG_RQU_COMMAND, | |
735 | .length = cpu_to_be32(14), | |
736 | .ordinal = TPM_ORDINAL_PCRREAD | |
1da177e4 LT |
737 | }; |
738 | ||
68d6e671 | 739 | static int __tpm_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf) |
659aaf2b RA |
740 | { |
741 | int rc; | |
742 | struct tpm_cmd_t cmd; | |
743 | ||
744 | cmd.header.in = pcrread_header; | |
745 | cmd.params.pcrread_in.pcr_idx = cpu_to_be32(pcr_idx); | |
23acb98d | 746 | rc = transmit_cmd(chip, &cmd, READ_PCR_RESULT_SIZE, |
659aaf2b RA |
747 | "attempting to read a pcr value"); |
748 | ||
749 | if (rc == 0) | |
750 | memcpy(res_buf, cmd.params.pcrread_out.pcr_result, | |
751 | TPM_DIGEST_SIZE); | |
752 | return rc; | |
753 | } | |
754 | ||
755 | /** | |
756 | * tpm_pcr_read - read a pcr value | |
757 | * @chip_num: tpm idx # or ANY | |
758 | * @pcr_idx: pcr idx to retrieve | |
759 | * @res_buf: TPM_PCR value | |
760 | * size of res_buf is 20 bytes (or NULL if you don't care) | |
761 | * | |
762 | * The TPM driver should be built-in, but for whatever reason it | |
763 | * isn't, protect against the chip disappearing, by incrementing | |
764 | * the module usage count. | |
765 | */ | |
766 | int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf) | |
767 | { | |
768 | struct tpm_chip *chip; | |
769 | int rc; | |
770 | ||
771 | chip = tpm_chip_find_get(chip_num); | |
772 | if (chip == NULL) | |
773 | return -ENODEV; | |
774 | rc = __tpm_pcr_read(chip, pcr_idx, res_buf); | |
a0e39349 | 775 | tpm_chip_put(chip); |
659aaf2b RA |
776 | return rc; |
777 | } | |
778 | EXPORT_SYMBOL_GPL(tpm_pcr_read); | |
779 | ||
780 | /** | |
781 | * tpm_pcr_extend - extend pcr value with hash | |
782 | * @chip_num: tpm idx # or AN& | |
783 | * @pcr_idx: pcr idx to extend | |
784 | * @hash: hash value used to extend pcr value | |
785 | * | |
786 | * The TPM driver should be built-in, but for whatever reason it | |
787 | * isn't, protect against the chip disappearing, by incrementing | |
788 | * the module usage count. | |
789 | */ | |
790 | #define TPM_ORD_PCR_EXTEND cpu_to_be32(20) | |
0afd9056 | 791 | #define EXTEND_PCR_RESULT_SIZE 34 |
659aaf2b RA |
792 | static struct tpm_input_header pcrextend_header = { |
793 | .tag = TPM_TAG_RQU_COMMAND, | |
794 | .length = cpu_to_be32(34), | |
795 | .ordinal = TPM_ORD_PCR_EXTEND | |
796 | }; | |
797 | ||
798 | int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash) | |
799 | { | |
800 | struct tpm_cmd_t cmd; | |
801 | int rc; | |
802 | struct tpm_chip *chip; | |
803 | ||
804 | chip = tpm_chip_find_get(chip_num); | |
805 | if (chip == NULL) | |
806 | return -ENODEV; | |
807 | ||
808 | cmd.header.in = pcrextend_header; | |
659aaf2b RA |
809 | cmd.params.pcrextend_in.pcr_idx = cpu_to_be32(pcr_idx); |
810 | memcpy(cmd.params.pcrextend_in.hash, hash, TPM_DIGEST_SIZE); | |
0afd9056 | 811 | rc = transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, |
659aaf2b RA |
812 | "attempting extend a PCR value"); |
813 | ||
a0e39349 | 814 | tpm_chip_put(chip); |
659aaf2b RA |
815 | return rc; |
816 | } | |
817 | EXPORT_SYMBOL_GPL(tpm_pcr_extend); | |
818 | ||
68d6e671 SB |
819 | /** |
820 | * tpm_do_selftest - have the TPM continue its selftest and wait until it | |
821 | * can receive further commands | |
822 | * @chip: TPM chip to use | |
823 | * | |
824 | * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing | |
825 | * a TPM error code. | |
826 | */ | |
827 | int tpm_do_selftest(struct tpm_chip *chip) | |
828 | { | |
829 | int rc; | |
830 | u8 digest[TPM_DIGEST_SIZE]; | |
831 | unsigned int loops; | |
832 | unsigned int delay_msec = 1000; | |
833 | unsigned long duration; | |
834 | ||
835 | duration = tpm_calc_ordinal_duration(chip, | |
836 | TPM_ORD_CONTINUE_SELFTEST); | |
837 | ||
838 | loops = jiffies_to_msecs(duration) / delay_msec; | |
839 | ||
840 | rc = tpm_continue_selftest(chip); | |
841 | /* This may fail if there was no TPM driver during a suspend/resume | |
842 | * cycle; some may return 10 (BAD_ORDINAL), others 28 (FAILEDSELFTEST) | |
843 | */ | |
844 | if (rc) | |
845 | return rc; | |
846 | ||
847 | do { | |
848 | rc = __tpm_pcr_read(chip, 0, digest); | |
849 | if (rc != TPM_WARN_DOING_SELFTEST) | |
850 | return rc; | |
851 | msleep(delay_msec); | |
852 | } while (--loops > 0); | |
853 | ||
854 | return rc; | |
855 | } | |
856 | EXPORT_SYMBOL_GPL(tpm_do_selftest); | |
857 | ||
c749ba91 MZ |
858 | int tpm_send(u32 chip_num, void *cmd, size_t buflen) |
859 | { | |
860 | struct tpm_chip *chip; | |
861 | int rc; | |
862 | ||
863 | chip = tpm_chip_find_get(chip_num); | |
864 | if (chip == NULL) | |
865 | return -ENODEV; | |
866 | ||
867 | rc = transmit_cmd(chip, cmd, buflen, "attempting tpm_cmd"); | |
868 | ||
869 | tpm_chip_put(chip); | |
870 | return rc; | |
871 | } | |
872 | EXPORT_SYMBOL_GPL(tpm_send); | |
873 | ||
6659ca2a KH |
874 | ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr, |
875 | char *buf) | |
1da177e4 | 876 | { |
08837438 | 877 | cap_t cap; |
659aaf2b | 878 | u8 digest[TPM_DIGEST_SIZE]; |
beed53a1 | 879 | ssize_t rc; |
81179bb6 | 880 | int i, j, num_pcrs; |
1da177e4 | 881 | char *str = buf; |
e659a3fe | 882 | struct tpm_chip *chip = dev_get_drvdata(dev); |
1da177e4 | 883 | |
08837438 | 884 | rc = tpm_getcap(dev, TPM_CAP_PROP_PCR, &cap, |
beed53a1 | 885 | "attempting to determine the number of PCRS"); |
08837438 | 886 | if (rc) |
e234bc97 | 887 | return 0; |
1da177e4 | 888 | |
08837438 | 889 | num_pcrs = be32_to_cpu(cap.num_pcrs); |
1da177e4 | 890 | for (i = 0; i < num_pcrs; i++) { |
659aaf2b | 891 | rc = __tpm_pcr_read(chip, i, digest); |
beed53a1 | 892 | if (rc) |
08837438 | 893 | break; |
1da177e4 LT |
894 | str += sprintf(str, "PCR-%02d: ", i); |
895 | for (j = 0; j < TPM_DIGEST_SIZE; j++) | |
659aaf2b | 896 | str += sprintf(str, "%02X ", digest[j]); |
1da177e4 LT |
897 | str += sprintf(str, "\n"); |
898 | } | |
899 | return str - buf; | |
900 | } | |
6659ca2a | 901 | EXPORT_SYMBOL_GPL(tpm_show_pcrs); |
1da177e4 LT |
902 | |
903 | #define READ_PUBEK_RESULT_SIZE 314 | |
08837438 RA |
904 | #define TPM_ORD_READPUBEK cpu_to_be32(124) |
905 | struct tpm_input_header tpm_readpubek_header = { | |
906 | .tag = TPM_TAG_RQU_COMMAND, | |
907 | .length = cpu_to_be32(30), | |
908 | .ordinal = TPM_ORD_READPUBEK | |
1da177e4 LT |
909 | }; |
910 | ||
6659ca2a KH |
911 | ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr, |
912 | char *buf) | |
1da177e4 | 913 | { |
2df7111f | 914 | u8 *data; |
08837438 | 915 | struct tpm_cmd_t tpm_cmd; |
beed53a1 | 916 | ssize_t err; |
81179bb6 | 917 | int i, rc; |
1da177e4 LT |
918 | char *str = buf; |
919 | ||
e659a3fe | 920 | struct tpm_chip *chip = dev_get_drvdata(dev); |
1da177e4 | 921 | |
08837438 RA |
922 | tpm_cmd.header.in = tpm_readpubek_header; |
923 | err = transmit_cmd(chip, &tpm_cmd, READ_PUBEK_RESULT_SIZE, | |
beed53a1 KJH |
924 | "attempting to read the PUBEK"); |
925 | if (err) | |
34d6e075 | 926 | goto out; |
1da177e4 LT |
927 | |
928 | /* | |
929 | ignore header 10 bytes | |
930 | algorithm 32 bits (1 == RSA ) | |
931 | encscheme 16 bits | |
932 | sigscheme 16 bits | |
933 | parameters (RSA 12->bytes: keybit, #primes, expbit) | |
934 | keylenbytes 32 bits | |
935 | 256 byte modulus | |
936 | ignore checksum 20 bytes | |
937 | */ | |
08837438 | 938 | data = tpm_cmd.params.readpubek_out_buffer; |
1da177e4 LT |
939 | str += |
940 | sprintf(str, | |
5a79444f SB |
941 | "Algorithm: %02X %02X %02X %02X\n" |
942 | "Encscheme: %02X %02X\n" | |
943 | "Sigscheme: %02X %02X\n" | |
944 | "Parameters: %02X %02X %02X %02X " | |
945 | "%02X %02X %02X %02X " | |
946 | "%02X %02X %02X %02X\n" | |
947 | "Modulus length: %d\n" | |
948 | "Modulus:\n", | |
949 | data[0], data[1], data[2], data[3], | |
950 | data[4], data[5], | |
951 | data[6], data[7], | |
952 | data[12], data[13], data[14], data[15], | |
953 | data[16], data[17], data[18], data[19], | |
954 | data[20], data[21], data[22], data[23], | |
955 | be32_to_cpu(*((__be32 *) (data + 24)))); | |
1da177e4 LT |
956 | |
957 | for (i = 0; i < 256; i++) { | |
5a79444f | 958 | str += sprintf(str, "%02X ", data[i + 28]); |
1da177e4 LT |
959 | if ((i + 1) % 16 == 0) |
960 | str += sprintf(str, "\n"); | |
961 | } | |
34d6e075 | 962 | out: |
beed53a1 | 963 | rc = str - buf; |
2df7111f | 964 | return rc; |
1da177e4 | 965 | } |
6659ca2a | 966 | EXPORT_SYMBOL_GPL(tpm_show_pubek); |
1da177e4 | 967 | |
1da177e4 | 968 | |
6659ca2a KH |
969 | ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr, |
970 | char *buf) | |
1da177e4 | 971 | { |
08837438 | 972 | cap_t cap; |
beed53a1 | 973 | ssize_t rc; |
1da177e4 LT |
974 | char *str = buf; |
975 | ||
08837438 | 976 | rc = tpm_getcap(dev, TPM_CAP_PROP_MANUFACTURER, &cap, |
beed53a1 | 977 | "attempting to determine the manufacturer"); |
08837438 | 978 | if (rc) |
beed53a1 | 979 | return 0; |
1da177e4 | 980 | str += sprintf(str, "Manufacturer: 0x%x\n", |
08837438 | 981 | be32_to_cpu(cap.manufacturer_id)); |
1da177e4 | 982 | |
08837438 RA |
983 | rc = tpm_getcap(dev, CAP_VERSION_1_1, &cap, |
984 | "attempting to determine the 1.1 version"); | |
beed53a1 | 985 | if (rc) |
08837438 | 986 | return 0; |
beed53a1 KJH |
987 | str += sprintf(str, |
988 | "TCG version: %d.%d\nFirmware version: %d.%d\n", | |
08837438 RA |
989 | cap.tpm_version.Major, cap.tpm_version.Minor, |
990 | cap.tpm_version.revMajor, cap.tpm_version.revMinor); | |
1da177e4 LT |
991 | return str - buf; |
992 | } | |
6659ca2a KH |
993 | EXPORT_SYMBOL_GPL(tpm_show_caps); |
994 | ||
08e96e48 KJH |
995 | ssize_t tpm_show_caps_1_2(struct device * dev, |
996 | struct device_attribute * attr, char *buf) | |
997 | { | |
08837438 RA |
998 | cap_t cap; |
999 | ssize_t rc; | |
08e96e48 KJH |
1000 | char *str = buf; |
1001 | ||
08837438 RA |
1002 | rc = tpm_getcap(dev, TPM_CAP_PROP_MANUFACTURER, &cap, |
1003 | "attempting to determine the manufacturer"); | |
1004 | if (rc) | |
08e96e48 | 1005 | return 0; |
08e96e48 | 1006 | str += sprintf(str, "Manufacturer: 0x%x\n", |
08837438 RA |
1007 | be32_to_cpu(cap.manufacturer_id)); |
1008 | rc = tpm_getcap(dev, CAP_VERSION_1_2, &cap, | |
1009 | "attempting to determine the 1.2 version"); | |
1010 | if (rc) | |
1011 | return 0; | |
08e96e48 KJH |
1012 | str += sprintf(str, |
1013 | "TCG version: %d.%d\nFirmware version: %d.%d\n", | |
08837438 RA |
1014 | cap.tpm_version_1_2.Major, cap.tpm_version_1_2.Minor, |
1015 | cap.tpm_version_1_2.revMajor, | |
1016 | cap.tpm_version_1_2.revMinor); | |
08e96e48 KJH |
1017 | return str - buf; |
1018 | } | |
1019 | EXPORT_SYMBOL_GPL(tpm_show_caps_1_2); | |
1020 | ||
04ab2293 SB |
1021 | ssize_t tpm_show_durations(struct device *dev, struct device_attribute *attr, |
1022 | char *buf) | |
1023 | { | |
1024 | struct tpm_chip *chip = dev_get_drvdata(dev); | |
1025 | ||
403d1d03 SB |
1026 | if (chip->vendor.duration[TPM_LONG] == 0) |
1027 | return 0; | |
1028 | ||
04ab2293 SB |
1029 | return sprintf(buf, "%d %d %d [%s]\n", |
1030 | jiffies_to_usecs(chip->vendor.duration[TPM_SHORT]), | |
1031 | jiffies_to_usecs(chip->vendor.duration[TPM_MEDIUM]), | |
1032 | jiffies_to_usecs(chip->vendor.duration[TPM_LONG]), | |
1033 | chip->vendor.duration_adjusted | |
1034 | ? "adjusted" : "original"); | |
1035 | } | |
1036 | EXPORT_SYMBOL_GPL(tpm_show_durations); | |
1037 | ||
62592101 SB |
1038 | ssize_t tpm_show_timeouts(struct device *dev, struct device_attribute *attr, |
1039 | char *buf) | |
1040 | { | |
1041 | struct tpm_chip *chip = dev_get_drvdata(dev); | |
1042 | ||
1043 | return sprintf(buf, "%d %d %d %d [%s]\n", | |
1044 | jiffies_to_usecs(chip->vendor.timeout_a), | |
1045 | jiffies_to_usecs(chip->vendor.timeout_b), | |
1046 | jiffies_to_usecs(chip->vendor.timeout_c), | |
1047 | jiffies_to_usecs(chip->vendor.timeout_d), | |
1048 | chip->vendor.timeout_adjusted | |
1049 | ? "adjusted" : "original"); | |
1050 | } | |
1051 | EXPORT_SYMBOL_GPL(tpm_show_timeouts); | |
1052 | ||
6659ca2a KH |
1053 | ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr, |
1054 | const char *buf, size_t count) | |
1055 | { | |
1056 | struct tpm_chip *chip = dev_get_drvdata(dev); | |
1057 | if (chip == NULL) | |
1058 | return 0; | |
1059 | ||
90dda520 | 1060 | chip->vendor.cancel(chip); |
6659ca2a KH |
1061 | return count; |
1062 | } | |
1063 | EXPORT_SYMBOL_GPL(tpm_store_cancel); | |
1da177e4 | 1064 | |
fd048866 RA |
1065 | int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, |
1066 | wait_queue_head_t *queue) | |
1067 | { | |
1068 | unsigned long stop; | |
1069 | long rc; | |
1070 | u8 status; | |
1071 | ||
1072 | /* check current status */ | |
1073 | status = chip->vendor.status(chip); | |
1074 | if ((status & mask) == mask) | |
1075 | return 0; | |
1076 | ||
1077 | stop = jiffies + timeout; | |
1078 | ||
1079 | if (chip->vendor.irq) { | |
1080 | again: | |
1081 | timeout = stop - jiffies; | |
1082 | if ((long)timeout <= 0) | |
1083 | return -ETIME; | |
1084 | rc = wait_event_interruptible_timeout(*queue, | |
1085 | ((chip->vendor.status(chip) | |
1086 | & mask) == mask), | |
1087 | timeout); | |
1088 | if (rc > 0) | |
1089 | return 0; | |
1090 | if (rc == -ERESTARTSYS && freezing(current)) { | |
1091 | clear_thread_flag(TIF_SIGPENDING); | |
1092 | goto again; | |
1093 | } | |
1094 | } else { | |
1095 | do { | |
1096 | msleep(TPM_TIMEOUT); | |
1097 | status = chip->vendor.status(chip); | |
1098 | if ((status & mask) == mask) | |
1099 | return 0; | |
1100 | } while (time_before(jiffies, stop)); | |
1101 | } | |
1102 | return -ETIME; | |
1103 | } | |
1104 | EXPORT_SYMBOL_GPL(wait_for_tpm_stat); | |
1da177e4 LT |
1105 | /* |
1106 | * Device file system interface to the TPM | |
f89c5edb RA |
1107 | * |
1108 | * It's assured that the chip will be opened just once, | |
1109 | * by the check of is_open variable, which is protected | |
1110 | * by driver_lock. | |
1da177e4 LT |
1111 | */ |
1112 | int tpm_open(struct inode *inode, struct file *file) | |
1113 | { | |
f02a9364 | 1114 | int minor = iminor(inode); |
1da177e4 LT |
1115 | struct tpm_chip *chip = NULL, *pos; |
1116 | ||
f02a9364 RA |
1117 | rcu_read_lock(); |
1118 | list_for_each_entry_rcu(pos, &tpm_chip_list, list) { | |
90dda520 | 1119 | if (pos->vendor.miscdev.minor == minor) { |
1da177e4 | 1120 | chip = pos; |
f02a9364 | 1121 | get_device(chip->dev); |
1da177e4 LT |
1122 | break; |
1123 | } | |
1124 | } | |
f02a9364 | 1125 | rcu_read_unlock(); |
1da177e4 | 1126 | |
f02a9364 RA |
1127 | if (!chip) |
1128 | return -ENODEV; | |
1da177e4 | 1129 | |
dc36d32c | 1130 | if (test_and_set_bit(0, &chip->is_open)) { |
b888c87b | 1131 | dev_dbg(chip->dev, "Another process owns this TPM\n"); |
f02a9364 RA |
1132 | put_device(chip->dev); |
1133 | return -EBUSY; | |
1da177e4 LT |
1134 | } |
1135 | ||
1309d7af | 1136 | chip->data_buffer = kzalloc(TPM_BUFSIZE, GFP_KERNEL); |
1da177e4 | 1137 | if (chip->data_buffer == NULL) { |
dc36d32c | 1138 | clear_bit(0, &chip->is_open); |
e659a3fe | 1139 | put_device(chip->dev); |
1da177e4 LT |
1140 | return -ENOMEM; |
1141 | } | |
1142 | ||
1143 | atomic_set(&chip->data_pending, 0); | |
1144 | ||
1145 | file->private_data = chip; | |
1146 | return 0; | |
1da177e4 | 1147 | } |
1da177e4 LT |
1148 | EXPORT_SYMBOL_GPL(tpm_open); |
1149 | ||
f02a9364 RA |
1150 | /* |
1151 | * Called on file close | |
1152 | */ | |
1da177e4 LT |
1153 | int tpm_release(struct inode *inode, struct file *file) |
1154 | { | |
1155 | struct tpm_chip *chip = file->private_data; | |
1da177e4 | 1156 | |
4bdec11f | 1157 | del_singleshot_timer_sync(&chip->user_read_timer); |
2e5c44c9 | 1158 | flush_work_sync(&chip->work); |
5e976d55 | 1159 | file->private_data = NULL; |
1da177e4 | 1160 | atomic_set(&chip->data_pending, 0); |
f02a9364 | 1161 | kfree(chip->data_buffer); |
dc36d32c | 1162 | clear_bit(0, &chip->is_open); |
e659a3fe | 1163 | put_device(chip->dev); |
1da177e4 LT |
1164 | return 0; |
1165 | } | |
1da177e4 LT |
1166 | EXPORT_SYMBOL_GPL(tpm_release); |
1167 | ||
b888c87b | 1168 | ssize_t tpm_write(struct file *file, const char __user *buf, |
3c2f606a | 1169 | size_t size, loff_t *off) |
1da177e4 LT |
1170 | { |
1171 | struct tpm_chip *chip = file->private_data; | |
01476001 | 1172 | size_t in_size = size, out_size; |
1da177e4 LT |
1173 | |
1174 | /* cannot perform a write until the read has cleared | |
1175 | either via tpm_read or a user_read_timer timeout */ | |
700d8bdc NA |
1176 | while (atomic_read(&chip->data_pending) != 0) |
1177 | msleep(TPM_TIMEOUT); | |
1da177e4 | 1178 | |
d081d470 | 1179 | mutex_lock(&chip->buffer_mutex); |
1da177e4 LT |
1180 | |
1181 | if (in_size > TPM_BUFSIZE) | |
1182 | in_size = TPM_BUFSIZE; | |
1183 | ||
1184 | if (copy_from_user | |
1185 | (chip->data_buffer, (void __user *) buf, in_size)) { | |
d081d470 | 1186 | mutex_unlock(&chip->buffer_mutex); |
1da177e4 LT |
1187 | return -EFAULT; |
1188 | } | |
1189 | ||
1190 | /* atomic tpm command send and result receive */ | |
1191 | out_size = tpm_transmit(chip, chip->data_buffer, TPM_BUFSIZE); | |
1192 | ||
1193 | atomic_set(&chip->data_pending, out_size); | |
d081d470 | 1194 | mutex_unlock(&chip->buffer_mutex); |
1da177e4 LT |
1195 | |
1196 | /* Set a timeout by which the reader must come claim the result */ | |
fe3fd483 | 1197 | mod_timer(&chip->user_read_timer, jiffies + (60 * HZ)); |
1da177e4 LT |
1198 | |
1199 | return in_size; | |
1200 | } | |
1da177e4 LT |
1201 | EXPORT_SYMBOL_GPL(tpm_write); |
1202 | ||
3c2f606a KJH |
1203 | ssize_t tpm_read(struct file *file, char __user *buf, |
1204 | size_t size, loff_t *off) | |
1da177e4 LT |
1205 | { |
1206 | struct tpm_chip *chip = file->private_data; | |
01476001 | 1207 | ssize_t ret_size; |
3321c07a | 1208 | int rc; |
1da177e4 | 1209 | |
5b44bd58 | 1210 | del_singleshot_timer_sync(&chip->user_read_timer); |
2e5c44c9 | 1211 | flush_work_sync(&chip->work); |
5b44bd58 KH |
1212 | ret_size = atomic_read(&chip->data_pending); |
1213 | atomic_set(&chip->data_pending, 0); | |
1214 | if (ret_size > 0) { /* relay data */ | |
1215 | if (size < ret_size) | |
1216 | ret_size = size; | |
1da177e4 | 1217 | |
d081d470 | 1218 | mutex_lock(&chip->buffer_mutex); |
3321c07a PH |
1219 | rc = copy_to_user(buf, chip->data_buffer, ret_size); |
1220 | memset(chip->data_buffer, 0, ret_size); | |
1221 | if (rc) | |
5b44bd58 | 1222 | ret_size = -EFAULT; |
3321c07a | 1223 | |
d081d470 | 1224 | mutex_unlock(&chip->buffer_mutex); |
1da177e4 LT |
1225 | } |
1226 | ||
1227 | return ret_size; | |
1228 | } | |
1da177e4 LT |
1229 | EXPORT_SYMBOL_GPL(tpm_read); |
1230 | ||
e659a3fe | 1231 | void tpm_remove_hardware(struct device *dev) |
1da177e4 | 1232 | { |
e659a3fe | 1233 | struct tpm_chip *chip = dev_get_drvdata(dev); |
1da177e4 LT |
1234 | |
1235 | if (chip == NULL) { | |
e659a3fe | 1236 | dev_err(dev, "No device data found\n"); |
1da177e4 LT |
1237 | return; |
1238 | } | |
1239 | ||
1240 | spin_lock(&driver_lock); | |
f02a9364 | 1241 | list_del_rcu(&chip->list); |
1da177e4 | 1242 | spin_unlock(&driver_lock); |
f02a9364 | 1243 | synchronize_rcu(); |
1da177e4 | 1244 | |
90dda520 | 1245 | misc_deregister(&chip->vendor.miscdev); |
90dda520 | 1246 | sysfs_remove_group(&dev->kobj, chip->vendor.attr_group); |
55a82ab3 | 1247 | tpm_bios_log_teardown(chip->bios_dir); |
1da177e4 | 1248 | |
5bd91f18 RM |
1249 | /* write it this way to be explicit (chip->dev == dev) */ |
1250 | put_device(chip->dev); | |
1da177e4 | 1251 | } |
e659a3fe | 1252 | EXPORT_SYMBOL_GPL(tpm_remove_hardware); |
1da177e4 | 1253 | |
225a9be2 RA |
1254 | #define TPM_ORD_SAVESTATE cpu_to_be32(152) |
1255 | #define SAVESTATE_RESULT_SIZE 10 | |
1256 | ||
1257 | static struct tpm_input_header savestate_header = { | |
1258 | .tag = TPM_TAG_RQU_COMMAND, | |
1259 | .length = cpu_to_be32(10), | |
1260 | .ordinal = TPM_ORD_SAVESTATE | |
1261 | }; | |
1262 | ||
1da177e4 LT |
1263 | /* |
1264 | * We are about to suspend. Save the TPM state | |
1265 | * so that it can be restored. | |
1266 | */ | |
ce2c87d4 | 1267 | int tpm_pm_suspend(struct device *dev, pm_message_t pm_state) |
1da177e4 | 1268 | { |
ce2c87d4 | 1269 | struct tpm_chip *chip = dev_get_drvdata(dev); |
225a9be2 RA |
1270 | struct tpm_cmd_t cmd; |
1271 | int rc; | |
1272 | ||
1273 | u8 dummy_hash[TPM_DIGEST_SIZE] = { 0 }; | |
2490c681 | 1274 | |
1da177e4 LT |
1275 | if (chip == NULL) |
1276 | return -ENODEV; | |
1277 | ||
225a9be2 RA |
1278 | /* for buggy tpm, flush pcrs with extend to selected dummy */ |
1279 | if (tpm_suspend_pcr) { | |
1280 | cmd.header.in = pcrextend_header; | |
1281 | cmd.params.pcrextend_in.pcr_idx = cpu_to_be32(tpm_suspend_pcr); | |
1282 | memcpy(cmd.params.pcrextend_in.hash, dummy_hash, | |
1283 | TPM_DIGEST_SIZE); | |
1284 | rc = transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, | |
1285 | "extending dummy pcr before suspend"); | |
1286 | } | |
1287 | ||
1288 | /* now do the actual savestate */ | |
1289 | cmd.header.in = savestate_header; | |
1290 | rc = transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE, | |
1291 | "sending savestate before suspend"); | |
1292 | return rc; | |
1da177e4 | 1293 | } |
1da177e4 LT |
1294 | EXPORT_SYMBOL_GPL(tpm_pm_suspend); |
1295 | ||
1296 | /* | |
1297 | * Resume from a power safe. The BIOS already restored | |
1298 | * the TPM state. | |
1299 | */ | |
ce2c87d4 | 1300 | int tpm_pm_resume(struct device *dev) |
1da177e4 | 1301 | { |
ce2c87d4 | 1302 | struct tpm_chip *chip = dev_get_drvdata(dev); |
1da177e4 LT |
1303 | |
1304 | if (chip == NULL) | |
1305 | return -ENODEV; | |
1306 | ||
1da177e4 LT |
1307 | return 0; |
1308 | } | |
1da177e4 LT |
1309 | EXPORT_SYMBOL_GPL(tpm_pm_resume); |
1310 | ||
253115b7 RA |
1311 | /* In case vendor provided release function, call it too.*/ |
1312 | ||
1313 | void tpm_dev_vendor_release(struct tpm_chip *chip) | |
1314 | { | |
1315 | if (chip->vendor.release) | |
1316 | chip->vendor.release(chip->dev); | |
1317 | ||
1318 | clear_bit(chip->dev_num, dev_mask); | |
1319 | kfree(chip->vendor.miscdev.name); | |
1320 | } | |
1321 | EXPORT_SYMBOL_GPL(tpm_dev_vendor_release); | |
1322 | ||
1323 | ||
5bd91f18 RM |
1324 | /* |
1325 | * Once all references to platform device are down to 0, | |
1326 | * release all allocated structures. | |
5bd91f18 | 1327 | */ |
cbb2ed4a | 1328 | void tpm_dev_release(struct device *dev) |
5bd91f18 RM |
1329 | { |
1330 | struct tpm_chip *chip = dev_get_drvdata(dev); | |
1331 | ||
253115b7 | 1332 | tpm_dev_vendor_release(chip); |
5bd91f18 | 1333 | |
253115b7 | 1334 | chip->release(dev); |
5bd91f18 RM |
1335 | kfree(chip); |
1336 | } | |
253115b7 | 1337 | EXPORT_SYMBOL_GPL(tpm_dev_release); |
5bd91f18 | 1338 | |
1da177e4 LT |
1339 | /* |
1340 | * Called from tpm_<specific>.c probe function only for devices | |
1341 | * the driver has determined it should claim. Prior to calling | |
1342 | * this function the specific probe function has called pci_enable_device | |
1343 | * upon errant exit from this function specific probe function should call | |
1344 | * pci_disable_device | |
1345 | */ | |
f02a9364 RA |
1346 | struct tpm_chip *tpm_register_hardware(struct device *dev, |
1347 | const struct tpm_vendor_specific *entry) | |
1da177e4 | 1348 | { |
6f9beccb KJH |
1349 | #define DEVNAME_SIZE 7 |
1350 | ||
1351 | char *devname; | |
1da177e4 | 1352 | struct tpm_chip *chip; |
1da177e4 LT |
1353 | |
1354 | /* Driver specific per-device data */ | |
b888c87b | 1355 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
8e39c933 PW |
1356 | devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); |
1357 | ||
dd78c943 AM |
1358 | if (chip == NULL || devname == NULL) |
1359 | goto out_free; | |
1da177e4 | 1360 | |
d081d470 MK |
1361 | mutex_init(&chip->buffer_mutex); |
1362 | mutex_init(&chip->tpm_mutex); | |
1da177e4 LT |
1363 | INIT_LIST_HEAD(&chip->list); |
1364 | ||
c4028958 | 1365 | INIT_WORK(&chip->work, timeout_work); |
09e12f9f | 1366 | |
40565f19 JS |
1367 | setup_timer(&chip->user_read_timer, user_reader_timeout, |
1368 | (unsigned long)chip); | |
fe3fd483 | 1369 | |
90dda520 | 1370 | memcpy(&chip->vendor, entry, sizeof(struct tpm_vendor_specific)); |
1da177e4 | 1371 | |
10685a95 | 1372 | chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES); |
1da177e4 | 1373 | |
10685a95 | 1374 | if (chip->dev_num >= TPM_NUM_DEVICES) { |
b888c87b | 1375 | dev_err(dev, "No available tpm device numbers\n"); |
dd78c943 | 1376 | goto out_free; |
1da177e4 | 1377 | } else if (chip->dev_num == 0) |
90dda520 | 1378 | chip->vendor.miscdev.minor = TPM_MINOR; |
1da177e4 | 1379 | else |
90dda520 | 1380 | chip->vendor.miscdev.minor = MISC_DYNAMIC_MINOR; |
1da177e4 | 1381 | |
10685a95 KJH |
1382 | set_bit(chip->dev_num, dev_mask); |
1383 | ||
6f9beccb | 1384 | scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num); |
90dda520 | 1385 | chip->vendor.miscdev.name = devname; |
1da177e4 | 1386 | |
94fbcded | 1387 | chip->vendor.miscdev.parent = dev; |
e659a3fe | 1388 | chip->dev = get_device(dev); |
5bd91f18 RM |
1389 | chip->release = dev->release; |
1390 | dev->release = tpm_dev_release; | |
1391 | dev_set_drvdata(dev, chip); | |
1da177e4 | 1392 | |
90dda520 | 1393 | if (misc_register(&chip->vendor.miscdev)) { |
e659a3fe | 1394 | dev_err(chip->dev, |
1da177e4 | 1395 | "unable to misc_register %s, minor %d\n", |
90dda520 KJH |
1396 | chip->vendor.miscdev.name, |
1397 | chip->vendor.miscdev.minor); | |
5bd91f18 | 1398 | put_device(chip->dev); |
e0dd03ca | 1399 | return NULL; |
1da177e4 LT |
1400 | } |
1401 | ||
f33d9bd5 | 1402 | if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) { |
5d469ec0 | 1403 | misc_deregister(&chip->vendor.miscdev); |
5bd91f18 | 1404 | put_device(chip->dev); |
f02a9364 | 1405 | |
f33d9bd5 JG |
1406 | return NULL; |
1407 | } | |
1da177e4 | 1408 | |
55a82ab3 KJH |
1409 | chip->bios_dir = tpm_bios_log_setup(devname); |
1410 | ||
f02a9364 RA |
1411 | /* Make chip available */ |
1412 | spin_lock(&driver_lock); | |
1413 | list_add_rcu(&chip->list, &tpm_chip_list); | |
1414 | spin_unlock(&driver_lock); | |
1415 | ||
e0dd03ca | 1416 | return chip; |
dd78c943 AM |
1417 | |
1418 | out_free: | |
1419 | kfree(chip); | |
1420 | kfree(devname); | |
1421 | return NULL; | |
1da177e4 | 1422 | } |
1da177e4 LT |
1423 | EXPORT_SYMBOL_GPL(tpm_register_hardware); |
1424 | ||
1da177e4 LT |
1425 | MODULE_AUTHOR("Leendert van Doorn ([email protected])"); |
1426 | MODULE_DESCRIPTION("TPM Driver"); | |
1427 | MODULE_VERSION("2.0"); | |
1428 | MODULE_LICENSE("GPL"); |