tpm.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. /*
  2. * Copyright (C) 2004 IBM Corporation
  3. * Copyright (C) 2015 Intel Corporation
  4. *
  5. * Authors:
  6. * Leendert van Doorn <leendert@watson.ibm.com>
  7. * Dave Safford <safford@watson.ibm.com>
  8. * Reiner Sailer <sailer@watson.ibm.com>
  9. * Kylene Hall <kjhall@us.ibm.com>
  10. *
  11. * Maintained by: <tpmdd-devel@lists.sourceforge.net>
  12. *
  13. * Device driver for TCG/TCPA TPM (trusted platform module).
  14. * Specifications at www.trustedcomputinggroup.org
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License as
  18. * published by the Free Software Foundation, version 2 of the
  19. * License.
  20. *
  21. */
  22. #ifndef __TPM_H__
  23. #define __TPM_H__
  24. #include <linux/module.h>
  25. #include <linux/delay.h>
  26. #include <linux/fs.h>
  27. #include <linux/hw_random.h>
  28. #include <linux/mutex.h>
  29. #include <linux/sched.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/io.h>
  32. #include <linux/tpm.h>
  33. #include <linux/acpi.h>
  34. #include <linux/cdev.h>
  35. #include <linux/highmem.h>
  36. #include <linux/tpm_eventlog.h>
  37. #include <crypto/hash_info.h>
  38. #ifdef CONFIG_X86
  39. #include <asm/intel-family.h>
  40. #endif
  41. enum tpm_const {
  42. TPM_MINOR = 224, /* officially assigned */
  43. TPM_BUFSIZE = 4096,
  44. TPM_NUM_DEVICES = 65536,
  45. TPM_RETRY = 50, /* 5 seconds */
  46. TPM_NUM_EVENT_LOG_FILES = 3,
  47. };
  48. enum tpm_timeout {
  49. TPM_TIMEOUT = 5, /* msecs */
  50. TPM_TIMEOUT_RETRY = 100, /* msecs */
  51. TPM_TIMEOUT_RANGE_US = 300 /* usecs */
  52. };
  53. /* TPM addresses */
  54. enum tpm_addr {
  55. TPM_SUPERIO_ADDR = 0x2E,
  56. TPM_ADDR = 0x4E,
  57. };
  58. /* Indexes the duration array */
  59. enum tpm_duration {
  60. TPM_SHORT = 0,
  61. TPM_MEDIUM = 1,
  62. TPM_LONG = 2,
  63. TPM_LONG_LONG = 3,
  64. TPM_UNDEFINED,
  65. TPM_NUM_DURATIONS = TPM_UNDEFINED,
  66. };
  67. #define TPM_WARN_RETRY 0x800
  68. #define TPM_WARN_DOING_SELFTEST 0x802
  69. #define TPM_ERR_DEACTIVATED 0x6
  70. #define TPM_ERR_DISABLED 0x7
  71. #define TPM_ERR_INVALID_POSTINIT 38
  72. #define TPM_HEADER_SIZE 10
  73. enum tpm2_const {
  74. TPM2_PLATFORM_PCR = 24,
  75. TPM2_PCR_SELECT_MIN = ((TPM2_PLATFORM_PCR + 7) / 8),
  76. };
  77. enum tpm2_timeouts {
  78. TPM2_TIMEOUT_A = 750,
  79. TPM2_TIMEOUT_B = 2000,
  80. TPM2_TIMEOUT_C = 200,
  81. TPM2_TIMEOUT_D = 30,
  82. TPM2_DURATION_SHORT = 20,
  83. TPM2_DURATION_MEDIUM = 750,
  84. TPM2_DURATION_LONG = 2000,
  85. TPM2_DURATION_LONG_LONG = 300000,
  86. TPM2_DURATION_DEFAULT = 120000,
  87. };
  88. enum tpm2_structures {
  89. TPM2_ST_NO_SESSIONS = 0x8001,
  90. TPM2_ST_SESSIONS = 0x8002,
  91. };
  92. /* Indicates from what layer of the software stack the error comes from */
  93. #define TSS2_RC_LAYER_SHIFT 16
  94. #define TSS2_RESMGR_TPM_RC_LAYER (11 << TSS2_RC_LAYER_SHIFT)
  95. enum tpm2_return_codes {
  96. TPM2_RC_SUCCESS = 0x0000,
  97. TPM2_RC_HASH = 0x0083, /* RC_FMT1 */
  98. TPM2_RC_HANDLE = 0x008B,
  99. TPM2_RC_INITIALIZE = 0x0100, /* RC_VER1 */
  100. TPM2_RC_FAILURE = 0x0101,
  101. TPM2_RC_DISABLED = 0x0120,
  102. TPM2_RC_COMMAND_CODE = 0x0143,
  103. TPM2_RC_TESTING = 0x090A, /* RC_WARN */
  104. TPM2_RC_REFERENCE_H0 = 0x0910,
  105. TPM2_RC_RETRY = 0x0922,
  106. };
  107. enum tpm2_algorithms {
  108. TPM2_ALG_ERROR = 0x0000,
  109. TPM2_ALG_SHA1 = 0x0004,
  110. TPM2_ALG_KEYEDHASH = 0x0008,
  111. TPM2_ALG_SHA256 = 0x000B,
  112. TPM2_ALG_SHA384 = 0x000C,
  113. TPM2_ALG_SHA512 = 0x000D,
  114. TPM2_ALG_NULL = 0x0010,
  115. TPM2_ALG_SM3_256 = 0x0012,
  116. };
  117. enum tpm2_command_codes {
  118. TPM2_CC_FIRST = 0x011F,
  119. TPM2_CC_CREATE_PRIMARY = 0x0131,
  120. TPM2_CC_SELF_TEST = 0x0143,
  121. TPM2_CC_STARTUP = 0x0144,
  122. TPM2_CC_SHUTDOWN = 0x0145,
  123. TPM2_CC_CREATE = 0x0153,
  124. TPM2_CC_LOAD = 0x0157,
  125. TPM2_CC_UNSEAL = 0x015E,
  126. TPM2_CC_CONTEXT_LOAD = 0x0161,
  127. TPM2_CC_CONTEXT_SAVE = 0x0162,
  128. TPM2_CC_FLUSH_CONTEXT = 0x0165,
  129. TPM2_CC_GET_CAPABILITY = 0x017A,
  130. TPM2_CC_GET_RANDOM = 0x017B,
  131. TPM2_CC_PCR_READ = 0x017E,
  132. TPM2_CC_PCR_EXTEND = 0x0182,
  133. TPM2_CC_LAST = 0x018F,
  134. };
  135. enum tpm2_permanent_handles {
  136. TPM2_RS_PW = 0x40000009,
  137. };
  138. enum tpm2_capabilities {
  139. TPM2_CAP_HANDLES = 1,
  140. TPM2_CAP_COMMANDS = 2,
  141. TPM2_CAP_PCRS = 5,
  142. TPM2_CAP_TPM_PROPERTIES = 6,
  143. };
  144. enum tpm2_properties {
  145. TPM_PT_TOTAL_COMMANDS = 0x0129,
  146. };
  147. enum tpm2_startup_types {
  148. TPM2_SU_CLEAR = 0x0000,
  149. TPM2_SU_STATE = 0x0001,
  150. };
  151. enum tpm2_cc_attrs {
  152. TPM2_CC_ATTR_CHANDLES = 25,
  153. TPM2_CC_ATTR_RHANDLE = 28,
  154. };
  155. #define TPM_VID_INTEL 0x8086
  156. #define TPM_VID_WINBOND 0x1050
  157. #define TPM_VID_STM 0x104A
  158. #define TPM_PPI_VERSION_LEN 3
  159. struct tpm_space {
  160. u32 context_tbl[3];
  161. u8 *context_buf;
  162. u32 session_tbl[3];
  163. u8 *session_buf;
  164. };
  165. enum tpm_chip_flags {
  166. TPM_CHIP_FLAG_TPM2 = BIT(1),
  167. TPM_CHIP_FLAG_IRQ = BIT(2),
  168. TPM_CHIP_FLAG_VIRTUAL = BIT(3),
  169. TPM_CHIP_FLAG_HAVE_TIMEOUTS = BIT(4),
  170. TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5),
  171. };
  172. struct tpm_bios_log {
  173. void *bios_event_log;
  174. void *bios_event_log_end;
  175. };
  176. struct tpm_chip_seqops {
  177. struct tpm_chip *chip;
  178. const struct seq_operations *seqops;
  179. };
  180. struct tpm_chip {
  181. struct device dev;
  182. struct device devs;
  183. struct cdev cdev;
  184. struct cdev cdevs;
  185. /* A driver callback under ops cannot be run unless ops_sem is held
  186. * (sometimes implicitly, eg for the sysfs code). ops becomes null
  187. * when the driver is unregistered, see tpm_try_get_ops.
  188. */
  189. struct rw_semaphore ops_sem;
  190. const struct tpm_class_ops *ops;
  191. struct tpm_bios_log log;
  192. struct tpm_chip_seqops bin_log_seqops;
  193. struct tpm_chip_seqops ascii_log_seqops;
  194. unsigned int flags;
  195. int dev_num; /* /dev/tpm# */
  196. unsigned long is_open; /* only one allowed */
  197. char hwrng_name[64];
  198. struct hwrng hwrng;
  199. struct mutex tpm_mutex; /* tpm is processing */
  200. unsigned long timeout_a; /* jiffies */
  201. unsigned long timeout_b; /* jiffies */
  202. unsigned long timeout_c; /* jiffies */
  203. unsigned long timeout_d; /* jiffies */
  204. bool timeout_adjusted;
  205. unsigned long duration[TPM_NUM_DURATIONS]; /* jiffies */
  206. bool duration_adjusted;
  207. struct dentry *bios_dir[TPM_NUM_EVENT_LOG_FILES];
  208. const struct attribute_group *groups[3];
  209. unsigned int groups_cnt;
  210. u16 active_banks[7];
  211. #ifdef CONFIG_ACPI
  212. acpi_handle acpi_dev_handle;
  213. char ppi_version[TPM_PPI_VERSION_LEN + 1];
  214. #endif /* CONFIG_ACPI */
  215. struct tpm_space work_space;
  216. u32 nr_commands;
  217. u32 *cc_attrs_tbl;
  218. /* active locality */
  219. int locality;
  220. };
  221. #define to_tpm_chip(d) container_of(d, struct tpm_chip, dev)
  222. struct tpm_input_header {
  223. __be16 tag;
  224. __be32 length;
  225. __be32 ordinal;
  226. } __packed;
  227. struct tpm_output_header {
  228. __be16 tag;
  229. __be32 length;
  230. __be32 return_code;
  231. } __packed;
  232. #define TPM_TAG_RQU_COMMAND 193
  233. struct stclear_flags_t {
  234. __be16 tag;
  235. u8 deactivated;
  236. u8 disableForceClear;
  237. u8 physicalPresence;
  238. u8 physicalPresenceLock;
  239. u8 bGlobalLock;
  240. } __packed;
  241. struct tpm_version_t {
  242. u8 Major;
  243. u8 Minor;
  244. u8 revMajor;
  245. u8 revMinor;
  246. } __packed;
  247. struct tpm_version_1_2_t {
  248. __be16 tag;
  249. u8 Major;
  250. u8 Minor;
  251. u8 revMajor;
  252. u8 revMinor;
  253. } __packed;
  254. struct timeout_t {
  255. __be32 a;
  256. __be32 b;
  257. __be32 c;
  258. __be32 d;
  259. } __packed;
  260. struct duration_t {
  261. __be32 tpm_short;
  262. __be32 tpm_medium;
  263. __be32 tpm_long;
  264. } __packed;
  265. struct permanent_flags_t {
  266. __be16 tag;
  267. u8 disable;
  268. u8 ownership;
  269. u8 deactivated;
  270. u8 readPubek;
  271. u8 disableOwnerClear;
  272. u8 allowMaintenance;
  273. u8 physicalPresenceLifetimeLock;
  274. u8 physicalPresenceHWEnable;
  275. u8 physicalPresenceCMDEnable;
  276. u8 CEKPUsed;
  277. u8 TPMpost;
  278. u8 TPMpostLock;
  279. u8 FIPS;
  280. u8 operator;
  281. u8 enableRevokeEK;
  282. u8 nvLocked;
  283. u8 readSRKPub;
  284. u8 tpmEstablished;
  285. u8 maintenanceDone;
  286. u8 disableFullDALogicInfo;
  287. } __packed;
  288. typedef union {
  289. struct permanent_flags_t perm_flags;
  290. struct stclear_flags_t stclear_flags;
  291. __u8 owned;
  292. __be32 num_pcrs;
  293. struct tpm_version_t tpm_version;
  294. struct tpm_version_1_2_t tpm_version_1_2;
  295. __be32 manufacturer_id;
  296. struct timeout_t timeout;
  297. struct duration_t duration;
  298. } cap_t;
  299. enum tpm_capabilities {
  300. TPM_CAP_FLAG = 4,
  301. TPM_CAP_PROP = 5,
  302. TPM_CAP_VERSION_1_1 = 0x06,
  303. TPM_CAP_VERSION_1_2 = 0x1A,
  304. };
  305. enum tpm_sub_capabilities {
  306. TPM_CAP_PROP_PCR = 0x101,
  307. TPM_CAP_PROP_MANUFACTURER = 0x103,
  308. TPM_CAP_FLAG_PERM = 0x108,
  309. TPM_CAP_FLAG_VOL = 0x109,
  310. TPM_CAP_PROP_OWNER = 0x111,
  311. TPM_CAP_PROP_TIS_TIMEOUT = 0x115,
  312. TPM_CAP_PROP_TIS_DURATION = 0x120,
  313. };
  314. typedef union {
  315. struct tpm_input_header in;
  316. struct tpm_output_header out;
  317. } tpm_cmd_header;
  318. struct tpm_pcrread_out {
  319. u8 pcr_result[TPM_DIGEST_SIZE];
  320. } __packed;
  321. struct tpm_pcrread_in {
  322. __be32 pcr_idx;
  323. } __packed;
  324. /* 128 bytes is an arbitrary cap. This could be as large as TPM_BUFSIZE - 18
  325. * bytes, but 128 is still a relatively large number of random bytes and
  326. * anything much bigger causes users of struct tpm_cmd_t to start getting
  327. * compiler warnings about stack frame size. */
  328. #define TPM_MAX_RNG_DATA 128
  329. struct tpm_getrandom_out {
  330. __be32 rng_data_len;
  331. u8 rng_data[TPM_MAX_RNG_DATA];
  332. } __packed;
  333. struct tpm_getrandom_in {
  334. __be32 num_bytes;
  335. } __packed;
  336. typedef union {
  337. struct tpm_pcrread_in pcrread_in;
  338. struct tpm_pcrread_out pcrread_out;
  339. struct tpm_getrandom_in getrandom_in;
  340. struct tpm_getrandom_out getrandom_out;
  341. } tpm_cmd_params;
  342. struct tpm_cmd_t {
  343. tpm_cmd_header header;
  344. tpm_cmd_params params;
  345. } __packed;
  346. /* A string buffer type for constructing TPM commands. This is based on the
  347. * ideas of string buffer code in security/keys/trusted.h but is heap based
  348. * in order to keep the stack usage minimal.
  349. */
  350. enum tpm_buf_flags {
  351. TPM_BUF_OVERFLOW = BIT(0),
  352. };
  353. struct tpm_buf {
  354. struct page *data_page;
  355. unsigned int flags;
  356. u8 *data;
  357. };
  358. static inline int tpm_buf_init(struct tpm_buf *buf, u16 tag, u32 ordinal)
  359. {
  360. struct tpm_input_header *head;
  361. buf->data_page = alloc_page(GFP_HIGHUSER);
  362. if (!buf->data_page)
  363. return -ENOMEM;
  364. buf->flags = 0;
  365. buf->data = kmap(buf->data_page);
  366. head = (struct tpm_input_header *) buf->data;
  367. head->tag = cpu_to_be16(tag);
  368. head->length = cpu_to_be32(sizeof(*head));
  369. head->ordinal = cpu_to_be32(ordinal);
  370. return 0;
  371. }
  372. static inline void tpm_buf_destroy(struct tpm_buf *buf)
  373. {
  374. kunmap(buf->data_page);
  375. __free_page(buf->data_page);
  376. }
  377. static inline u32 tpm_buf_length(struct tpm_buf *buf)
  378. {
  379. struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
  380. return be32_to_cpu(head->length);
  381. }
  382. static inline u16 tpm_buf_tag(struct tpm_buf *buf)
  383. {
  384. struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
  385. return be16_to_cpu(head->tag);
  386. }
  387. static inline void tpm_buf_append(struct tpm_buf *buf,
  388. const unsigned char *new_data,
  389. unsigned int new_len)
  390. {
  391. struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
  392. u32 len = tpm_buf_length(buf);
  393. /* Return silently if overflow has already happened. */
  394. if (buf->flags & TPM_BUF_OVERFLOW)
  395. return;
  396. if ((len + new_len) > PAGE_SIZE) {
  397. WARN(1, "tpm_buf: overflow\n");
  398. buf->flags |= TPM_BUF_OVERFLOW;
  399. return;
  400. }
  401. memcpy(&buf->data[len], new_data, new_len);
  402. head->length = cpu_to_be32(len + new_len);
  403. }
  404. static inline void tpm_buf_append_u8(struct tpm_buf *buf, const u8 value)
  405. {
  406. tpm_buf_append(buf, &value, 1);
  407. }
  408. static inline void tpm_buf_append_u16(struct tpm_buf *buf, const u16 value)
  409. {
  410. __be16 value2 = cpu_to_be16(value);
  411. tpm_buf_append(buf, (u8 *) &value2, 2);
  412. }
  413. static inline void tpm_buf_append_u32(struct tpm_buf *buf, const u32 value)
  414. {
  415. __be32 value2 = cpu_to_be32(value);
  416. tpm_buf_append(buf, (u8 *) &value2, 4);
  417. }
  418. extern struct class *tpm_class;
  419. extern struct class *tpmrm_class;
  420. extern dev_t tpm_devt;
  421. extern const struct file_operations tpm_fops;
  422. extern const struct file_operations tpmrm_fops;
  423. extern struct idr dev_nums_idr;
  424. enum tpm_transmit_flags {
  425. TPM_TRANSMIT_UNLOCKED = BIT(0),
  426. TPM_TRANSMIT_RAW = BIT(1),
  427. };
  428. ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
  429. u8 *buf, size_t bufsiz, unsigned int flags);
  430. ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space,
  431. void *buf, size_t bufsiz,
  432. size_t min_rsp_body_length, unsigned int flags,
  433. const char *desc);
  434. int tpm_startup(struct tpm_chip *chip);
  435. ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap,
  436. const char *desc, size_t min_cap_length);
  437. int tpm_get_timeouts(struct tpm_chip *);
  438. int tpm1_auto_startup(struct tpm_chip *chip);
  439. int tpm_do_selftest(struct tpm_chip *chip);
  440. unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
  441. int tpm_pm_suspend(struct device *dev);
  442. int tpm_pm_resume(struct device *dev);
  443. static inline void tpm_msleep(unsigned int delay_msec)
  444. {
  445. usleep_range((delay_msec * 1000) - TPM_TIMEOUT_RANGE_US,
  446. delay_msec * 1000);
  447. };
  448. struct tpm_chip *tpm_chip_find_get(struct tpm_chip *chip);
  449. __must_check int tpm_try_get_ops(struct tpm_chip *chip);
  450. void tpm_put_ops(struct tpm_chip *chip);
  451. struct tpm_chip *tpm_chip_alloc(struct device *dev,
  452. const struct tpm_class_ops *ops);
  453. struct tpm_chip *tpmm_chip_alloc(struct device *pdev,
  454. const struct tpm_class_ops *ops);
  455. int tpm_chip_register(struct tpm_chip *chip);
  456. void tpm_chip_unregister(struct tpm_chip *chip);
  457. void tpm_sysfs_add_device(struct tpm_chip *chip);
  458. int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf);
  459. #ifdef CONFIG_ACPI
  460. extern void tpm_add_ppi(struct tpm_chip *chip);
  461. #else
  462. static inline void tpm_add_ppi(struct tpm_chip *chip)
  463. {
  464. }
  465. #endif
  466. static inline u32 tpm2_rc_value(u32 rc)
  467. {
  468. return (rc & BIT(7)) ? rc & 0xff : rc;
  469. }
  470. int tpm2_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf);
  471. int tpm2_pcr_extend(struct tpm_chip *chip, int pcr_idx, u32 count,
  472. struct tpm2_digest *digests);
  473. int tpm2_get_random(struct tpm_chip *chip, u8 *out, size_t max);
  474. void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
  475. unsigned int flags);
  476. int tpm2_seal_trusted(struct tpm_chip *chip,
  477. struct trusted_key_payload *payload,
  478. struct trusted_key_options *options);
  479. int tpm2_unseal_trusted(struct tpm_chip *chip,
  480. struct trusted_key_payload *payload,
  481. struct trusted_key_options *options);
  482. ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id,
  483. u32 *value, const char *desc);
  484. int tpm2_auto_startup(struct tpm_chip *chip);
  485. void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
  486. unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
  487. int tpm2_probe(struct tpm_chip *chip);
  488. int tpm2_find_cc(struct tpm_chip *chip, u32 cc);
  489. int tpm2_init_space(struct tpm_space *space);
  490. void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space);
  491. int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u32 cc,
  492. u8 *cmd);
  493. int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space,
  494. u32 cc, u8 *buf, size_t *bufsiz);
  495. extern const struct seq_operations tpm2_binary_b_measurements_seqops;
  496. #if defined(CONFIG_ACPI)
  497. int tpm_read_log_acpi(struct tpm_chip *chip);
  498. #else
  499. static inline int tpm_read_log_acpi(struct tpm_chip *chip)
  500. {
  501. return -ENODEV;
  502. }
  503. #endif
  504. #if defined(CONFIG_OF)
  505. int tpm_read_log_of(struct tpm_chip *chip);
  506. #else
  507. static inline int tpm_read_log_of(struct tpm_chip *chip)
  508. {
  509. return -ENODEV;
  510. }
  511. #endif
  512. #if defined(CONFIG_EFI)
  513. int tpm_read_log_efi(struct tpm_chip *chip);
  514. #else
  515. static inline int tpm_read_log_efi(struct tpm_chip *chip)
  516. {
  517. return -ENODEV;
  518. }
  519. #endif
  520. int tpm_bios_log_setup(struct tpm_chip *chip);
  521. void tpm_bios_log_teardown(struct tpm_chip *chip);
  522. #endif