tpm.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  1. /*
  2. * Copyright (C) 2004 IBM Corporation
  3. *
  4. * Authors:
  5. * Leendert van Doorn <leendert@watson.ibm.com>
  6. * Dave Safford <safford@watson.ibm.com>
  7. * Reiner Sailer <sailer@watson.ibm.com>
  8. * Kylene Hall <kjhall@us.ibm.com>
  9. *
  10. * Maintained by: <tpmdd-devel@lists.sourceforge.net>
  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
  22. * calls to msleep.
  23. *
  24. */
  25. #include <linux/poll.h>
  26. #include <linux/mutex.h>
  27. #include <linux/spinlock.h>
  28. #include <linux/smp_lock.h>
  29. #include "tpm.h"
  30. enum tpm_const {
  31. TPM_MINOR = 224, /* officially assigned */
  32. TPM_BUFSIZE = 2048,
  33. TPM_NUM_DEVICES = 256,
  34. };
  35. enum tpm_duration {
  36. TPM_SHORT = 0,
  37. TPM_MEDIUM = 1,
  38. TPM_LONG = 2,
  39. TPM_UNDEFINED,
  40. };
  41. #define TPM_MAX_ORDINAL 243
  42. #define TPM_MAX_PROTECTED_ORDINAL 12
  43. #define TPM_PROTECTED_ORDINAL_MASK 0xFF
  44. static LIST_HEAD(tpm_chip_list);
  45. static DEFINE_SPINLOCK(driver_lock);
  46. static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES);
  47. /*
  48. * Array with one entry per ordinal defining the maximum amount
  49. * of time the chip could take to return the result. The ordinal
  50. * designation of short, medium or long is defined in a table in
  51. * TCG Specification TPM Main Part 2 TPM Structures Section 17. The
  52. * values of the SHORT, MEDIUM, and LONG durations are retrieved
  53. * from the chip during initialization with a call to tpm_get_timeouts.
  54. */
  55. static const u8 tpm_protected_ordinal_duration[TPM_MAX_PROTECTED_ORDINAL] = {
  56. TPM_UNDEFINED, /* 0 */
  57. TPM_UNDEFINED,
  58. TPM_UNDEFINED,
  59. TPM_UNDEFINED,
  60. TPM_UNDEFINED,
  61. TPM_UNDEFINED, /* 5 */
  62. TPM_UNDEFINED,
  63. TPM_UNDEFINED,
  64. TPM_UNDEFINED,
  65. TPM_UNDEFINED,
  66. TPM_SHORT, /* 10 */
  67. TPM_SHORT,
  68. };
  69. static const u8 tpm_ordinal_duration[TPM_MAX_ORDINAL] = {
  70. TPM_UNDEFINED, /* 0 */
  71. TPM_UNDEFINED,
  72. TPM_UNDEFINED,
  73. TPM_UNDEFINED,
  74. TPM_UNDEFINED,
  75. TPM_UNDEFINED, /* 5 */
  76. TPM_UNDEFINED,
  77. TPM_UNDEFINED,
  78. TPM_UNDEFINED,
  79. TPM_UNDEFINED,
  80. TPM_SHORT, /* 10 */
  81. TPM_SHORT,
  82. TPM_MEDIUM,
  83. TPM_LONG,
  84. TPM_LONG,
  85. TPM_MEDIUM, /* 15 */
  86. TPM_SHORT,
  87. TPM_SHORT,
  88. TPM_MEDIUM,
  89. TPM_LONG,
  90. TPM_SHORT, /* 20 */
  91. TPM_SHORT,
  92. TPM_MEDIUM,
  93. TPM_MEDIUM,
  94. TPM_MEDIUM,
  95. TPM_SHORT, /* 25 */
  96. TPM_SHORT,
  97. TPM_MEDIUM,
  98. TPM_SHORT,
  99. TPM_SHORT,
  100. TPM_MEDIUM, /* 30 */
  101. TPM_LONG,
  102. TPM_MEDIUM,
  103. TPM_SHORT,
  104. TPM_SHORT,
  105. TPM_SHORT, /* 35 */
  106. TPM_MEDIUM,
  107. TPM_MEDIUM,
  108. TPM_UNDEFINED,
  109. TPM_UNDEFINED,
  110. TPM_MEDIUM, /* 40 */
  111. TPM_LONG,
  112. TPM_MEDIUM,
  113. TPM_SHORT,
  114. TPM_SHORT,
  115. TPM_SHORT, /* 45 */
  116. TPM_SHORT,
  117. TPM_SHORT,
  118. TPM_SHORT,
  119. TPM_LONG,
  120. TPM_MEDIUM, /* 50 */
  121. TPM_MEDIUM,
  122. TPM_UNDEFINED,
  123. TPM_UNDEFINED,
  124. TPM_UNDEFINED,
  125. TPM_UNDEFINED, /* 55 */
  126. TPM_UNDEFINED,
  127. TPM_UNDEFINED,
  128. TPM_UNDEFINED,
  129. TPM_UNDEFINED,
  130. TPM_MEDIUM, /* 60 */
  131. TPM_MEDIUM,
  132. TPM_MEDIUM,
  133. TPM_SHORT,
  134. TPM_SHORT,
  135. TPM_MEDIUM, /* 65 */
  136. TPM_UNDEFINED,
  137. TPM_UNDEFINED,
  138. TPM_UNDEFINED,
  139. TPM_UNDEFINED,
  140. TPM_SHORT, /* 70 */
  141. TPM_SHORT,
  142. TPM_UNDEFINED,
  143. TPM_UNDEFINED,
  144. TPM_UNDEFINED,
  145. TPM_UNDEFINED, /* 75 */
  146. TPM_UNDEFINED,
  147. TPM_UNDEFINED,
  148. TPM_UNDEFINED,
  149. TPM_UNDEFINED,
  150. TPM_LONG, /* 80 */
  151. TPM_UNDEFINED,
  152. TPM_MEDIUM,
  153. TPM_LONG,
  154. TPM_SHORT,
  155. TPM_UNDEFINED, /* 85 */
  156. TPM_UNDEFINED,
  157. TPM_UNDEFINED,
  158. TPM_UNDEFINED,
  159. TPM_UNDEFINED,
  160. TPM_SHORT, /* 90 */
  161. TPM_SHORT,
  162. TPM_SHORT,
  163. TPM_SHORT,
  164. TPM_SHORT,
  165. TPM_UNDEFINED, /* 95 */
  166. TPM_UNDEFINED,
  167. TPM_UNDEFINED,
  168. TPM_UNDEFINED,
  169. TPM_UNDEFINED,
  170. TPM_MEDIUM, /* 100 */
  171. TPM_SHORT,
  172. TPM_SHORT,
  173. TPM_UNDEFINED,
  174. TPM_UNDEFINED,
  175. TPM_UNDEFINED, /* 105 */
  176. TPM_UNDEFINED,
  177. TPM_UNDEFINED,
  178. TPM_UNDEFINED,
  179. TPM_UNDEFINED,
  180. TPM_SHORT, /* 110 */
  181. TPM_SHORT,
  182. TPM_SHORT,
  183. TPM_SHORT,
  184. TPM_SHORT,
  185. TPM_SHORT, /* 115 */
  186. TPM_SHORT,
  187. TPM_SHORT,
  188. TPM_UNDEFINED,
  189. TPM_UNDEFINED,
  190. TPM_LONG, /* 120 */
  191. TPM_LONG,
  192. TPM_MEDIUM,
  193. TPM_UNDEFINED,
  194. TPM_SHORT,
  195. TPM_SHORT, /* 125 */
  196. TPM_SHORT,
  197. TPM_LONG,
  198. TPM_SHORT,
  199. TPM_SHORT,
  200. TPM_SHORT, /* 130 */
  201. TPM_MEDIUM,
  202. TPM_UNDEFINED,
  203. TPM_SHORT,
  204. TPM_MEDIUM,
  205. TPM_UNDEFINED, /* 135 */
  206. TPM_UNDEFINED,
  207. TPM_UNDEFINED,
  208. TPM_UNDEFINED,
  209. TPM_UNDEFINED,
  210. TPM_SHORT, /* 140 */
  211. TPM_SHORT,
  212. TPM_UNDEFINED,
  213. TPM_UNDEFINED,
  214. TPM_UNDEFINED,
  215. TPM_UNDEFINED, /* 145 */
  216. TPM_UNDEFINED,
  217. TPM_UNDEFINED,
  218. TPM_UNDEFINED,
  219. TPM_UNDEFINED,
  220. TPM_SHORT, /* 150 */
  221. TPM_MEDIUM,
  222. TPM_MEDIUM,
  223. TPM_SHORT,
  224. TPM_SHORT,
  225. TPM_UNDEFINED, /* 155 */
  226. TPM_UNDEFINED,
  227. TPM_UNDEFINED,
  228. TPM_UNDEFINED,
  229. TPM_UNDEFINED,
  230. TPM_SHORT, /* 160 */
  231. TPM_SHORT,
  232. TPM_SHORT,
  233. TPM_SHORT,
  234. TPM_UNDEFINED,
  235. TPM_UNDEFINED, /* 165 */
  236. TPM_UNDEFINED,
  237. TPM_UNDEFINED,
  238. TPM_UNDEFINED,
  239. TPM_UNDEFINED,
  240. TPM_LONG, /* 170 */
  241. TPM_UNDEFINED,
  242. TPM_UNDEFINED,
  243. TPM_UNDEFINED,
  244. TPM_UNDEFINED,
  245. TPM_UNDEFINED, /* 175 */
  246. TPM_UNDEFINED,
  247. TPM_UNDEFINED,
  248. TPM_UNDEFINED,
  249. TPM_UNDEFINED,
  250. TPM_MEDIUM, /* 180 */
  251. TPM_SHORT,
  252. TPM_MEDIUM,
  253. TPM_MEDIUM,
  254. TPM_MEDIUM,
  255. TPM_MEDIUM, /* 185 */
  256. TPM_SHORT,
  257. TPM_UNDEFINED,
  258. TPM_UNDEFINED,
  259. TPM_UNDEFINED,
  260. TPM_UNDEFINED, /* 190 */
  261. TPM_UNDEFINED,
  262. TPM_UNDEFINED,
  263. TPM_UNDEFINED,
  264. TPM_UNDEFINED,
  265. TPM_UNDEFINED, /* 195 */
  266. TPM_UNDEFINED,
  267. TPM_UNDEFINED,
  268. TPM_UNDEFINED,
  269. TPM_UNDEFINED,
  270. TPM_SHORT, /* 200 */
  271. TPM_UNDEFINED,
  272. TPM_UNDEFINED,
  273. TPM_UNDEFINED,
  274. TPM_SHORT,
  275. TPM_SHORT, /* 205 */
  276. TPM_SHORT,
  277. TPM_SHORT,
  278. TPM_SHORT,
  279. TPM_SHORT,
  280. TPM_MEDIUM, /* 210 */
  281. TPM_UNDEFINED,
  282. TPM_MEDIUM,
  283. TPM_MEDIUM,
  284. TPM_MEDIUM,
  285. TPM_UNDEFINED, /* 215 */
  286. TPM_MEDIUM,
  287. TPM_UNDEFINED,
  288. TPM_UNDEFINED,
  289. TPM_SHORT,
  290. TPM_SHORT, /* 220 */
  291. TPM_SHORT,
  292. TPM_SHORT,
  293. TPM_SHORT,
  294. TPM_SHORT,
  295. TPM_UNDEFINED, /* 225 */
  296. TPM_UNDEFINED,
  297. TPM_UNDEFINED,
  298. TPM_UNDEFINED,
  299. TPM_UNDEFINED,
  300. TPM_SHORT, /* 230 */
  301. TPM_LONG,
  302. TPM_MEDIUM,
  303. TPM_UNDEFINED,
  304. TPM_UNDEFINED,
  305. TPM_UNDEFINED, /* 235 */
  306. TPM_UNDEFINED,
  307. TPM_UNDEFINED,
  308. TPM_UNDEFINED,
  309. TPM_UNDEFINED,
  310. TPM_SHORT, /* 240 */
  311. TPM_UNDEFINED,
  312. TPM_MEDIUM,
  313. };
  314. static void user_reader_timeout(unsigned long ptr)
  315. {
  316. struct tpm_chip *chip = (struct tpm_chip *) ptr;
  317. schedule_work(&chip->work);
  318. }
  319. static void timeout_work(struct work_struct *work)
  320. {
  321. struct tpm_chip *chip = container_of(work, struct tpm_chip, work);
  322. mutex_lock(&chip->buffer_mutex);
  323. atomic_set(&chip->data_pending, 0);
  324. memset(chip->data_buffer, 0, TPM_BUFSIZE);
  325. mutex_unlock(&chip->buffer_mutex);
  326. }
  327. /*
  328. * Returns max number of jiffies to wait
  329. */
  330. unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip,
  331. u32 ordinal)
  332. {
  333. int duration_idx = TPM_UNDEFINED;
  334. int duration = 0;
  335. if (ordinal < TPM_MAX_ORDINAL)
  336. duration_idx = tpm_ordinal_duration[ordinal];
  337. else if ((ordinal & TPM_PROTECTED_ORDINAL_MASK) <
  338. TPM_MAX_PROTECTED_ORDINAL)
  339. duration_idx =
  340. tpm_protected_ordinal_duration[ordinal &
  341. TPM_PROTECTED_ORDINAL_MASK];
  342. if (duration_idx != TPM_UNDEFINED)
  343. duration = chip->vendor.duration[duration_idx];
  344. if (duration <= 0)
  345. return 2 * 60 * HZ;
  346. else
  347. return duration;
  348. }
  349. EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);
  350. /*
  351. * Internal kernel interface to transmit TPM commands
  352. */
  353. static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
  354. size_t bufsiz)
  355. {
  356. ssize_t rc;
  357. u32 count, ordinal;
  358. unsigned long stop;
  359. count = be32_to_cpu(*((__be32 *) (buf + 2)));
  360. ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
  361. if (count == 0)
  362. return -ENODATA;
  363. if (count > bufsiz) {
  364. dev_err(chip->dev,
  365. "invalid count value %x %zx \n", count, bufsiz);
  366. return -E2BIG;
  367. }
  368. mutex_lock(&chip->tpm_mutex);
  369. if ((rc = chip->vendor.send(chip, (u8 *) buf, count)) < 0) {
  370. dev_err(chip->dev,
  371. "tpm_transmit: tpm_send: error %zd\n", rc);
  372. goto out;
  373. }
  374. if (chip->vendor.irq)
  375. goto out_recv;
  376. stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
  377. do {
  378. u8 status = chip->vendor.status(chip);
  379. if ((status & chip->vendor.req_complete_mask) ==
  380. chip->vendor.req_complete_val)
  381. goto out_recv;
  382. if ((status == chip->vendor.req_canceled)) {
  383. dev_err(chip->dev, "Operation Canceled\n");
  384. rc = -ECANCELED;
  385. goto out;
  386. }
  387. msleep(TPM_TIMEOUT); /* CHECK */
  388. rmb();
  389. } while (time_before(jiffies, stop));
  390. chip->vendor.cancel(chip);
  391. dev_err(chip->dev, "Operation Timed out\n");
  392. rc = -ETIME;
  393. goto out;
  394. out_recv:
  395. rc = chip->vendor.recv(chip, (u8 *) buf, bufsiz);
  396. if (rc < 0)
  397. dev_err(chip->dev,
  398. "tpm_transmit: tpm_recv: error %zd\n", rc);
  399. out:
  400. mutex_unlock(&chip->tpm_mutex);
  401. return rc;
  402. }
  403. #define TPM_DIGEST_SIZE 20
  404. #define TPM_ERROR_SIZE 10
  405. #define TPM_RET_CODE_IDX 6
  406. #define TPM_GET_CAP_RET_SIZE_IDX 10
  407. #define TPM_GET_CAP_RET_UINT32_1_IDX 14
  408. #define TPM_GET_CAP_RET_UINT32_2_IDX 18
  409. #define TPM_GET_CAP_RET_UINT32_3_IDX 22
  410. #define TPM_GET_CAP_RET_UINT32_4_IDX 26
  411. #define TPM_GET_CAP_PERM_DISABLE_IDX 16
  412. #define TPM_GET_CAP_PERM_INACTIVE_IDX 18
  413. #define TPM_GET_CAP_RET_BOOL_1_IDX 14
  414. #define TPM_GET_CAP_TEMP_INACTIVE_IDX 16
  415. #define TPM_CAP_IDX 13
  416. #define TPM_CAP_SUBCAP_IDX 21
  417. enum tpm_capabilities {
  418. TPM_CAP_FLAG = 4,
  419. TPM_CAP_PROP = 5,
  420. };
  421. enum tpm_sub_capabilities {
  422. TPM_CAP_PROP_PCR = 0x1,
  423. TPM_CAP_PROP_MANUFACTURER = 0x3,
  424. TPM_CAP_FLAG_PERM = 0x8,
  425. TPM_CAP_FLAG_VOL = 0x9,
  426. TPM_CAP_PROP_OWNER = 0x11,
  427. TPM_CAP_PROP_TIS_TIMEOUT = 0x15,
  428. TPM_CAP_PROP_TIS_DURATION = 0x20,
  429. };
  430. /*
  431. * This is a semi generic GetCapability command for use
  432. * with the capability type TPM_CAP_PROP or TPM_CAP_FLAG
  433. * and their associated sub_capabilities.
  434. */
  435. static const u8 tpm_cap[] = {
  436. 0, 193, /* TPM_TAG_RQU_COMMAND */
  437. 0, 0, 0, 22, /* length */
  438. 0, 0, 0, 101, /* TPM_ORD_GetCapability */
  439. 0, 0, 0, 0, /* TPM_CAP_<TYPE> */
  440. 0, 0, 0, 4, /* TPM_CAP_SUB_<TYPE> size */
  441. 0, 0, 1, 0 /* TPM_CAP_SUB_<TYPE> */
  442. };
  443. static ssize_t transmit_cmd(struct tpm_chip *chip, u8 *data, int len,
  444. char *desc)
  445. {
  446. int err;
  447. len = tpm_transmit(chip, data, len);
  448. if (len < 0)
  449. return len;
  450. if (len == TPM_ERROR_SIZE) {
  451. err = be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX)));
  452. dev_dbg(chip->dev, "A TPM error (%d) occurred %s\n", err, desc);
  453. return err;
  454. }
  455. return 0;
  456. }
  457. void tpm_gen_interrupt(struct tpm_chip *chip)
  458. {
  459. u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 30)];
  460. ssize_t rc;
  461. memcpy(data, tpm_cap, sizeof(tpm_cap));
  462. data[TPM_CAP_IDX] = TPM_CAP_PROP;
  463. data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_TIS_TIMEOUT;
  464. rc = transmit_cmd(chip, data, sizeof(data),
  465. "attempting to determine the timeouts");
  466. }
  467. EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
  468. void tpm_get_timeouts(struct tpm_chip *chip)
  469. {
  470. u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 30)];
  471. ssize_t rc;
  472. u32 timeout;
  473. memcpy(data, tpm_cap, sizeof(tpm_cap));
  474. data[TPM_CAP_IDX] = TPM_CAP_PROP;
  475. data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_TIS_TIMEOUT;
  476. rc = transmit_cmd(chip, data, sizeof(data),
  477. "attempting to determine the timeouts");
  478. if (rc)
  479. goto duration;
  480. if (be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_SIZE_IDX)))
  481. != 4 * sizeof(u32))
  482. goto duration;
  483. /* Don't overwrite default if value is 0 */
  484. timeout =
  485. be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)));
  486. if (timeout)
  487. chip->vendor.timeout_a = msecs_to_jiffies(timeout);
  488. timeout =
  489. be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_2_IDX)));
  490. if (timeout)
  491. chip->vendor.timeout_b = msecs_to_jiffies(timeout);
  492. timeout =
  493. be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_3_IDX)));
  494. if (timeout)
  495. chip->vendor.timeout_c = msecs_to_jiffies(timeout);
  496. timeout =
  497. be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_4_IDX)));
  498. if (timeout)
  499. chip->vendor.timeout_d = msecs_to_jiffies(timeout);
  500. duration:
  501. memcpy(data, tpm_cap, sizeof(tpm_cap));
  502. data[TPM_CAP_IDX] = TPM_CAP_PROP;
  503. data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_TIS_DURATION;
  504. rc = transmit_cmd(chip, data, sizeof(data),
  505. "attempting to determine the durations");
  506. if (rc)
  507. return;
  508. if (be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_SIZE_IDX)))
  509. != 3 * sizeof(u32))
  510. return;
  511. chip->vendor.duration[TPM_SHORT] =
  512. msecs_to_jiffies(be32_to_cpu
  513. (*((__be32 *) (data +
  514. TPM_GET_CAP_RET_UINT32_1_IDX))));
  515. chip->vendor.duration[TPM_MEDIUM] =
  516. msecs_to_jiffies(be32_to_cpu
  517. (*((__be32 *) (data +
  518. TPM_GET_CAP_RET_UINT32_2_IDX))));
  519. chip->vendor.duration[TPM_LONG] =
  520. msecs_to_jiffies(be32_to_cpu
  521. (*((__be32 *) (data +
  522. TPM_GET_CAP_RET_UINT32_3_IDX))));
  523. }
  524. EXPORT_SYMBOL_GPL(tpm_get_timeouts);
  525. void tpm_continue_selftest(struct tpm_chip *chip)
  526. {
  527. u8 data[] = {
  528. 0, 193, /* TPM_TAG_RQU_COMMAND */
  529. 0, 0, 0, 10, /* length */
  530. 0, 0, 0, 83, /* TPM_ORD_GetCapability */
  531. };
  532. tpm_transmit(chip, data, sizeof(data));
  533. }
  534. EXPORT_SYMBOL_GPL(tpm_continue_selftest);
  535. ssize_t tpm_show_enabled(struct device * dev, struct device_attribute * attr,
  536. char *buf)
  537. {
  538. u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 35)];
  539. ssize_t rc;
  540. struct tpm_chip *chip = dev_get_drvdata(dev);
  541. if (chip == NULL)
  542. return -ENODEV;
  543. memcpy(data, tpm_cap, sizeof(tpm_cap));
  544. data[TPM_CAP_IDX] = TPM_CAP_FLAG;
  545. data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_PERM;
  546. rc = transmit_cmd(chip, data, sizeof(data),
  547. "attemtping to determine the permanent state");
  548. if (rc)
  549. return 0;
  550. return sprintf(buf, "%d\n", !data[TPM_GET_CAP_PERM_DISABLE_IDX]);
  551. }
  552. EXPORT_SYMBOL_GPL(tpm_show_enabled);
  553. ssize_t tpm_show_active(struct device * dev, struct device_attribute * attr,
  554. char *buf)
  555. {
  556. u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 35)];
  557. ssize_t rc;
  558. struct tpm_chip *chip = dev_get_drvdata(dev);
  559. if (chip == NULL)
  560. return -ENODEV;
  561. memcpy(data, tpm_cap, sizeof(tpm_cap));
  562. data[TPM_CAP_IDX] = TPM_CAP_FLAG;
  563. data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_PERM;
  564. rc = transmit_cmd(chip, data, sizeof(data),
  565. "attemtping to determine the permanent state");
  566. if (rc)
  567. return 0;
  568. return sprintf(buf, "%d\n", !data[TPM_GET_CAP_PERM_INACTIVE_IDX]);
  569. }
  570. EXPORT_SYMBOL_GPL(tpm_show_active);
  571. ssize_t tpm_show_owned(struct device * dev, struct device_attribute * attr,
  572. char *buf)
  573. {
  574. u8 data[sizeof(tpm_cap)];
  575. ssize_t rc;
  576. struct tpm_chip *chip = dev_get_drvdata(dev);
  577. if (chip == NULL)
  578. return -ENODEV;
  579. memcpy(data, tpm_cap, sizeof(tpm_cap));
  580. data[TPM_CAP_IDX] = TPM_CAP_PROP;
  581. data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_OWNER;
  582. rc = transmit_cmd(chip, data, sizeof(data),
  583. "attempting to determine the owner state");
  584. if (rc)
  585. return 0;
  586. return sprintf(buf, "%d\n", data[TPM_GET_CAP_RET_BOOL_1_IDX]);
  587. }
  588. EXPORT_SYMBOL_GPL(tpm_show_owned);
  589. ssize_t tpm_show_temp_deactivated(struct device * dev,
  590. struct device_attribute * attr, char *buf)
  591. {
  592. u8 data[sizeof(tpm_cap)];
  593. ssize_t rc;
  594. struct tpm_chip *chip = dev_get_drvdata(dev);
  595. if (chip == NULL)
  596. return -ENODEV;
  597. memcpy(data, tpm_cap, sizeof(tpm_cap));
  598. data[TPM_CAP_IDX] = TPM_CAP_FLAG;
  599. data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_VOL;
  600. rc = transmit_cmd(chip, data, sizeof(data),
  601. "attempting to determine the temporary state");
  602. if (rc)
  603. return 0;
  604. return sprintf(buf, "%d\n", data[TPM_GET_CAP_TEMP_INACTIVE_IDX]);
  605. }
  606. EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated);
  607. static const u8 pcrread[] = {
  608. 0, 193, /* TPM_TAG_RQU_COMMAND */
  609. 0, 0, 0, 14, /* length */
  610. 0, 0, 0, 21, /* TPM_ORD_PcrRead */
  611. 0, 0, 0, 0 /* PCR index */
  612. };
  613. ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr,
  614. char *buf)
  615. {
  616. u8 data[max_t(int, max(ARRAY_SIZE(tpm_cap), ARRAY_SIZE(pcrread)), 30)];
  617. ssize_t rc;
  618. int i, j, num_pcrs;
  619. __be32 index;
  620. char *str = buf;
  621. struct tpm_chip *chip = dev_get_drvdata(dev);
  622. if (chip == NULL)
  623. return -ENODEV;
  624. memcpy(data, tpm_cap, sizeof(tpm_cap));
  625. data[TPM_CAP_IDX] = TPM_CAP_PROP;
  626. data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_PCR;
  627. rc = transmit_cmd(chip, data, sizeof(data),
  628. "attempting to determine the number of PCRS");
  629. if (rc)
  630. return 0;
  631. num_pcrs = be32_to_cpu(*((__be32 *) (data + 14)));
  632. for (i = 0; i < num_pcrs; i++) {
  633. memcpy(data, pcrread, sizeof(pcrread));
  634. index = cpu_to_be32(i);
  635. memcpy(data + 10, &index, 4);
  636. rc = transmit_cmd(chip, data, sizeof(data),
  637. "attempting to read a PCR");
  638. if (rc)
  639. goto out;
  640. str += sprintf(str, "PCR-%02d: ", i);
  641. for (j = 0; j < TPM_DIGEST_SIZE; j++)
  642. str += sprintf(str, "%02X ", *(data + 10 + j));
  643. str += sprintf(str, "\n");
  644. }
  645. out:
  646. return str - buf;
  647. }
  648. EXPORT_SYMBOL_GPL(tpm_show_pcrs);
  649. #define READ_PUBEK_RESULT_SIZE 314
  650. static const u8 readpubek[] = {
  651. 0, 193, /* TPM_TAG_RQU_COMMAND */
  652. 0, 0, 0, 30, /* length */
  653. 0, 0, 0, 124, /* TPM_ORD_ReadPubek */
  654. };
  655. ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr,
  656. char *buf)
  657. {
  658. u8 *data;
  659. ssize_t err;
  660. int i, rc;
  661. char *str = buf;
  662. struct tpm_chip *chip = dev_get_drvdata(dev);
  663. if (chip == NULL)
  664. return -ENODEV;
  665. data = kzalloc(READ_PUBEK_RESULT_SIZE, GFP_KERNEL);
  666. if (!data)
  667. return -ENOMEM;
  668. memcpy(data, readpubek, sizeof(readpubek));
  669. err = transmit_cmd(chip, data, READ_PUBEK_RESULT_SIZE,
  670. "attempting to read the PUBEK");
  671. if (err)
  672. goto out;
  673. /*
  674. ignore header 10 bytes
  675. algorithm 32 bits (1 == RSA )
  676. encscheme 16 bits
  677. sigscheme 16 bits
  678. parameters (RSA 12->bytes: keybit, #primes, expbit)
  679. keylenbytes 32 bits
  680. 256 byte modulus
  681. ignore checksum 20 bytes
  682. */
  683. str +=
  684. sprintf(str,
  685. "Algorithm: %02X %02X %02X %02X\nEncscheme: %02X %02X\n"
  686. "Sigscheme: %02X %02X\nParameters: %02X %02X %02X %02X"
  687. " %02X %02X %02X %02X %02X %02X %02X %02X\n"
  688. "Modulus length: %d\nModulus: \n",
  689. data[10], data[11], data[12], data[13], data[14],
  690. data[15], data[16], data[17], data[22], data[23],
  691. data[24], data[25], data[26], data[27], data[28],
  692. data[29], data[30], data[31], data[32], data[33],
  693. be32_to_cpu(*((__be32 *) (data + 34))));
  694. for (i = 0; i < 256; i++) {
  695. str += sprintf(str, "%02X ", data[i + 38]);
  696. if ((i + 1) % 16 == 0)
  697. str += sprintf(str, "\n");
  698. }
  699. out:
  700. rc = str - buf;
  701. kfree(data);
  702. return rc;
  703. }
  704. EXPORT_SYMBOL_GPL(tpm_show_pubek);
  705. #define CAP_VERSION_1_1 6
  706. #define CAP_VERSION_1_2 0x1A
  707. #define CAP_VERSION_IDX 13
  708. static const u8 cap_version[] = {
  709. 0, 193, /* TPM_TAG_RQU_COMMAND */
  710. 0, 0, 0, 18, /* length */
  711. 0, 0, 0, 101, /* TPM_ORD_GetCapability */
  712. 0, 0, 0, 0,
  713. 0, 0, 0, 0
  714. };
  715. ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr,
  716. char *buf)
  717. {
  718. u8 data[max_t(int, max(ARRAY_SIZE(tpm_cap), ARRAY_SIZE(cap_version)), 30)];
  719. ssize_t rc;
  720. char *str = buf;
  721. struct tpm_chip *chip = dev_get_drvdata(dev);
  722. if (chip == NULL)
  723. return -ENODEV;
  724. memcpy(data, tpm_cap, sizeof(tpm_cap));
  725. data[TPM_CAP_IDX] = TPM_CAP_PROP;
  726. data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_MANUFACTURER;
  727. rc = transmit_cmd(chip, data, sizeof(data),
  728. "attempting to determine the manufacturer");
  729. if (rc)
  730. return 0;
  731. str += sprintf(str, "Manufacturer: 0x%x\n",
  732. be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX))));
  733. memcpy(data, cap_version, sizeof(cap_version));
  734. data[CAP_VERSION_IDX] = CAP_VERSION_1_1;
  735. rc = transmit_cmd(chip, data, sizeof(data),
  736. "attempting to determine the 1.1 version");
  737. if (rc)
  738. goto out;
  739. str += sprintf(str,
  740. "TCG version: %d.%d\nFirmware version: %d.%d\n",
  741. (int) data[14], (int) data[15], (int) data[16],
  742. (int) data[17]);
  743. out:
  744. return str - buf;
  745. }
  746. EXPORT_SYMBOL_GPL(tpm_show_caps);
  747. ssize_t tpm_show_caps_1_2(struct device * dev,
  748. struct device_attribute * attr, char *buf)
  749. {
  750. u8 data[max_t(int, max(ARRAY_SIZE(tpm_cap), ARRAY_SIZE(cap_version)), 30)];
  751. ssize_t len;
  752. char *str = buf;
  753. struct tpm_chip *chip = dev_get_drvdata(dev);
  754. if (chip == NULL)
  755. return -ENODEV;
  756. memcpy(data, tpm_cap, sizeof(tpm_cap));
  757. data[TPM_CAP_IDX] = TPM_CAP_PROP;
  758. data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_MANUFACTURER;
  759. if ((len = tpm_transmit(chip, data, sizeof(data))) <=
  760. TPM_ERROR_SIZE) {
  761. dev_dbg(chip->dev, "A TPM error (%d) occurred "
  762. "attempting to determine the manufacturer\n",
  763. be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX))));
  764. return 0;
  765. }
  766. str += sprintf(str, "Manufacturer: 0x%x\n",
  767. be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX))));
  768. memcpy(data, cap_version, sizeof(cap_version));
  769. data[CAP_VERSION_IDX] = CAP_VERSION_1_2;
  770. if ((len = tpm_transmit(chip, data, sizeof(data))) <=
  771. TPM_ERROR_SIZE) {
  772. dev_err(chip->dev, "A TPM error (%d) occurred "
  773. "attempting to determine the 1.2 version\n",
  774. be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX))));
  775. goto out;
  776. }
  777. str += sprintf(str,
  778. "TCG version: %d.%d\nFirmware version: %d.%d\n",
  779. (int) data[16], (int) data[17], (int) data[18],
  780. (int) data[19]);
  781. out:
  782. return str - buf;
  783. }
  784. EXPORT_SYMBOL_GPL(tpm_show_caps_1_2);
  785. ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr,
  786. const char *buf, size_t count)
  787. {
  788. struct tpm_chip *chip = dev_get_drvdata(dev);
  789. if (chip == NULL)
  790. return 0;
  791. chip->vendor.cancel(chip);
  792. return count;
  793. }
  794. EXPORT_SYMBOL_GPL(tpm_store_cancel);
  795. /*
  796. * Device file system interface to the TPM
  797. */
  798. int tpm_open(struct inode *inode, struct file *file)
  799. {
  800. int rc = 0, minor = iminor(inode);
  801. struct tpm_chip *chip = NULL, *pos;
  802. lock_kernel();
  803. spin_lock(&driver_lock);
  804. list_for_each_entry(pos, &tpm_chip_list, list) {
  805. if (pos->vendor.miscdev.minor == minor) {
  806. chip = pos;
  807. break;
  808. }
  809. }
  810. if (chip == NULL) {
  811. rc = -ENODEV;
  812. goto err_out;
  813. }
  814. if (chip->num_opens) {
  815. dev_dbg(chip->dev, "Another process owns this TPM\n");
  816. rc = -EBUSY;
  817. goto err_out;
  818. }
  819. chip->num_opens++;
  820. get_device(chip->dev);
  821. spin_unlock(&driver_lock);
  822. chip->data_buffer = kmalloc(TPM_BUFSIZE * sizeof(u8), GFP_KERNEL);
  823. if (chip->data_buffer == NULL) {
  824. chip->num_opens--;
  825. put_device(chip->dev);
  826. unlock_kernel();
  827. return -ENOMEM;
  828. }
  829. atomic_set(&chip->data_pending, 0);
  830. file->private_data = chip;
  831. unlock_kernel();
  832. return 0;
  833. err_out:
  834. spin_unlock(&driver_lock);
  835. unlock_kernel();
  836. return rc;
  837. }
  838. EXPORT_SYMBOL_GPL(tpm_open);
  839. int tpm_release(struct inode *inode, struct file *file)
  840. {
  841. struct tpm_chip *chip = file->private_data;
  842. flush_scheduled_work();
  843. spin_lock(&driver_lock);
  844. file->private_data = NULL;
  845. del_singleshot_timer_sync(&chip->user_read_timer);
  846. atomic_set(&chip->data_pending, 0);
  847. chip->num_opens--;
  848. put_device(chip->dev);
  849. kfree(chip->data_buffer);
  850. spin_unlock(&driver_lock);
  851. return 0;
  852. }
  853. EXPORT_SYMBOL_GPL(tpm_release);
  854. ssize_t tpm_write(struct file *file, const char __user *buf,
  855. size_t size, loff_t *off)
  856. {
  857. struct tpm_chip *chip = file->private_data;
  858. int in_size = size, out_size;
  859. /* cannot perform a write until the read has cleared
  860. either via tpm_read or a user_read_timer timeout */
  861. while (atomic_read(&chip->data_pending) != 0)
  862. msleep(TPM_TIMEOUT);
  863. mutex_lock(&chip->buffer_mutex);
  864. if (in_size > TPM_BUFSIZE)
  865. in_size = TPM_BUFSIZE;
  866. if (copy_from_user
  867. (chip->data_buffer, (void __user *) buf, in_size)) {
  868. mutex_unlock(&chip->buffer_mutex);
  869. return -EFAULT;
  870. }
  871. /* atomic tpm command send and result receive */
  872. out_size = tpm_transmit(chip, chip->data_buffer, TPM_BUFSIZE);
  873. atomic_set(&chip->data_pending, out_size);
  874. mutex_unlock(&chip->buffer_mutex);
  875. /* Set a timeout by which the reader must come claim the result */
  876. mod_timer(&chip->user_read_timer, jiffies + (60 * HZ));
  877. return in_size;
  878. }
  879. EXPORT_SYMBOL_GPL(tpm_write);
  880. ssize_t tpm_read(struct file *file, char __user *buf,
  881. size_t size, loff_t *off)
  882. {
  883. struct tpm_chip *chip = file->private_data;
  884. int ret_size;
  885. del_singleshot_timer_sync(&chip->user_read_timer);
  886. flush_scheduled_work();
  887. ret_size = atomic_read(&chip->data_pending);
  888. atomic_set(&chip->data_pending, 0);
  889. if (ret_size > 0) { /* relay data */
  890. if (size < ret_size)
  891. ret_size = size;
  892. mutex_lock(&chip->buffer_mutex);
  893. if (copy_to_user(buf, chip->data_buffer, ret_size))
  894. ret_size = -EFAULT;
  895. mutex_unlock(&chip->buffer_mutex);
  896. }
  897. return ret_size;
  898. }
  899. EXPORT_SYMBOL_GPL(tpm_read);
  900. void tpm_remove_hardware(struct device *dev)
  901. {
  902. struct tpm_chip *chip = dev_get_drvdata(dev);
  903. if (chip == NULL) {
  904. dev_err(dev, "No device data found\n");
  905. return;
  906. }
  907. spin_lock(&driver_lock);
  908. list_del(&chip->list);
  909. spin_unlock(&driver_lock);
  910. misc_deregister(&chip->vendor.miscdev);
  911. sysfs_remove_group(&dev->kobj, chip->vendor.attr_group);
  912. tpm_bios_log_teardown(chip->bios_dir);
  913. /* write it this way to be explicit (chip->dev == dev) */
  914. put_device(chip->dev);
  915. }
  916. EXPORT_SYMBOL_GPL(tpm_remove_hardware);
  917. /*
  918. * We are about to suspend. Save the TPM state
  919. * so that it can be restored.
  920. */
  921. int tpm_pm_suspend(struct device *dev, pm_message_t pm_state)
  922. {
  923. struct tpm_chip *chip = dev_get_drvdata(dev);
  924. u8 savestate[] = {
  925. 0, 193, /* TPM_TAG_RQU_COMMAND */
  926. 0, 0, 0, 10, /* blob length (in bytes) */
  927. 0, 0, 0, 152 /* TPM_ORD_SaveState */
  928. };
  929. if (chip == NULL)
  930. return -ENODEV;
  931. tpm_transmit(chip, savestate, sizeof(savestate));
  932. return 0;
  933. }
  934. EXPORT_SYMBOL_GPL(tpm_pm_suspend);
  935. /*
  936. * Resume from a power safe. The BIOS already restored
  937. * the TPM state.
  938. */
  939. int tpm_pm_resume(struct device *dev)
  940. {
  941. struct tpm_chip *chip = dev_get_drvdata(dev);
  942. if (chip == NULL)
  943. return -ENODEV;
  944. return 0;
  945. }
  946. EXPORT_SYMBOL_GPL(tpm_pm_resume);
  947. /*
  948. * Once all references to platform device are down to 0,
  949. * release all allocated structures.
  950. * In case vendor provided release function,
  951. * call it too.
  952. */
  953. static void tpm_dev_release(struct device *dev)
  954. {
  955. struct tpm_chip *chip = dev_get_drvdata(dev);
  956. if (chip->vendor.release)
  957. chip->vendor.release(dev);
  958. chip->release(dev);
  959. clear_bit(chip->dev_num, dev_mask);
  960. kfree(chip->vendor.miscdev.name);
  961. kfree(chip);
  962. }
  963. /*
  964. * Called from tpm_<specific>.c probe function only for devices
  965. * the driver has determined it should claim. Prior to calling
  966. * this function the specific probe function has called pci_enable_device
  967. * upon errant exit from this function specific probe function should call
  968. * pci_disable_device
  969. */
  970. struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vendor_specific
  971. *entry)
  972. {
  973. #define DEVNAME_SIZE 7
  974. char *devname;
  975. struct tpm_chip *chip;
  976. /* Driver specific per-device data */
  977. chip = kzalloc(sizeof(*chip), GFP_KERNEL);
  978. devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL);
  979. if (chip == NULL || devname == NULL) {
  980. kfree(chip);
  981. kfree(devname);
  982. return NULL;
  983. }
  984. mutex_init(&chip->buffer_mutex);
  985. mutex_init(&chip->tpm_mutex);
  986. INIT_LIST_HEAD(&chip->list);
  987. INIT_WORK(&chip->work, timeout_work);
  988. setup_timer(&chip->user_read_timer, user_reader_timeout,
  989. (unsigned long)chip);
  990. memcpy(&chip->vendor, entry, sizeof(struct tpm_vendor_specific));
  991. chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES);
  992. if (chip->dev_num >= TPM_NUM_DEVICES) {
  993. dev_err(dev, "No available tpm device numbers\n");
  994. kfree(chip);
  995. return NULL;
  996. } else if (chip->dev_num == 0)
  997. chip->vendor.miscdev.minor = TPM_MINOR;
  998. else
  999. chip->vendor.miscdev.minor = MISC_DYNAMIC_MINOR;
  1000. set_bit(chip->dev_num, dev_mask);
  1001. scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num);
  1002. chip->vendor.miscdev.name = devname;
  1003. chip->vendor.miscdev.parent = dev;
  1004. chip->dev = get_device(dev);
  1005. chip->release = dev->release;
  1006. dev->release = tpm_dev_release;
  1007. dev_set_drvdata(dev, chip);
  1008. if (misc_register(&chip->vendor.miscdev)) {
  1009. dev_err(chip->dev,
  1010. "unable to misc_register %s, minor %d\n",
  1011. chip->vendor.miscdev.name,
  1012. chip->vendor.miscdev.minor);
  1013. put_device(chip->dev);
  1014. return NULL;
  1015. }
  1016. spin_lock(&driver_lock);
  1017. list_add(&chip->list, &tpm_chip_list);
  1018. spin_unlock(&driver_lock);
  1019. if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) {
  1020. list_del(&chip->list);
  1021. misc_deregister(&chip->vendor.miscdev);
  1022. put_device(chip->dev);
  1023. return NULL;
  1024. }
  1025. chip->bios_dir = tpm_bios_log_setup(devname);
  1026. return chip;
  1027. }
  1028. EXPORT_SYMBOL_GPL(tpm_register_hardware);
  1029. MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)");
  1030. MODULE_DESCRIPTION("TPM Driver");
  1031. MODULE_VERSION("2.0");
  1032. MODULE_LICENSE("GPL");