tpm_eventlog.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef __TPM_EVENTLOG_H__
  2. #define __TPM_EVENTLOG_H__
  3. #include <crypto/hash_info.h>
  4. #define TCG_EVENT_NAME_LEN_MAX 255
  5. #define MAX_TEXT_EVENT 1000 /* Max event string length */
  6. #define ACPI_TCPA_SIG "TCPA" /* 0x41504354 /'TCPA' */
  7. #define TPM2_ACTIVE_PCR_BANKS 3
  8. #ifdef CONFIG_PPC64
  9. #define do_endian_conversion(x) be32_to_cpu(x)
  10. #else
  11. #define do_endian_conversion(x) x
  12. #endif
  13. enum bios_platform_class {
  14. BIOS_CLIENT = 0x00,
  15. BIOS_SERVER = 0x01,
  16. };
  17. struct tcpa_event {
  18. u32 pcr_index;
  19. u32 event_type;
  20. u8 pcr_value[20]; /* SHA1 */
  21. u32 event_size;
  22. u8 event_data[0];
  23. };
  24. enum tcpa_event_types {
  25. PREBOOT = 0,
  26. POST_CODE,
  27. UNUSED,
  28. NO_ACTION,
  29. SEPARATOR,
  30. ACTION,
  31. EVENT_TAG,
  32. SCRTM_CONTENTS,
  33. SCRTM_VERSION,
  34. CPU_MICROCODE,
  35. PLATFORM_CONFIG_FLAGS,
  36. TABLE_OF_DEVICES,
  37. COMPACT_HASH,
  38. IPL,
  39. IPL_PARTITION_DATA,
  40. NONHOST_CODE,
  41. NONHOST_CONFIG,
  42. NONHOST_INFO,
  43. };
  44. struct tcpa_pc_event {
  45. u32 event_id;
  46. u32 event_size;
  47. u8 event_data[0];
  48. };
  49. enum tcpa_pc_event_ids {
  50. SMBIOS = 1,
  51. BIS_CERT,
  52. POST_BIOS_ROM,
  53. ESCD,
  54. CMOS,
  55. NVRAM,
  56. OPTION_ROM_EXEC,
  57. OPTION_ROM_CONFIG,
  58. OPTION_ROM_MICROCODE = 10,
  59. S_CRTM_VERSION,
  60. S_CRTM_CONTENTS,
  61. POST_CONTENTS,
  62. HOST_TABLE_OF_DEVICES,
  63. };
  64. /* http://www.trustedcomputinggroup.org/tcg-efi-protocol-specification/ */
  65. struct tcg_efi_specid_event_algs {
  66. u16 alg_id;
  67. u16 digest_size;
  68. } __packed;
  69. struct tcg_efi_specid_event {
  70. u8 signature[16];
  71. u32 platform_class;
  72. u8 spec_version_minor;
  73. u8 spec_version_major;
  74. u8 spec_errata;
  75. u8 uintnsize;
  76. u32 num_algs;
  77. struct tcg_efi_specid_event_algs digest_sizes[TPM2_ACTIVE_PCR_BANKS];
  78. u8 vendor_info_size;
  79. u8 vendor_info[0];
  80. } __packed;
  81. struct tcg_pcr_event {
  82. u32 pcr_idx;
  83. u32 event_type;
  84. u8 digest[20];
  85. u32 event_size;
  86. u8 event[0];
  87. } __packed;
  88. struct tcg_event_field {
  89. u32 event_size;
  90. u8 event[0];
  91. } __packed;
  92. struct tcg_pcr_event2 {
  93. u32 pcr_idx;
  94. u32 event_type;
  95. u32 count;
  96. struct tpm2_digest digests[TPM2_ACTIVE_PCR_BANKS];
  97. struct tcg_event_field event;
  98. } __packed;
  99. extern const struct seq_operations tpm2_binary_b_measurements_seqops;
  100. #if defined(CONFIG_ACPI)
  101. int tpm_read_log_acpi(struct tpm_chip *chip);
  102. #else
  103. static inline int tpm_read_log_acpi(struct tpm_chip *chip)
  104. {
  105. return -ENODEV;
  106. }
  107. #endif
  108. #if defined(CONFIG_OF)
  109. int tpm_read_log_of(struct tpm_chip *chip);
  110. #else
  111. static inline int tpm_read_log_of(struct tpm_chip *chip)
  112. {
  113. return -ENODEV;
  114. }
  115. #endif
  116. int tpm_bios_log_setup(struct tpm_chip *chip);
  117. void tpm_bios_log_teardown(struct tpm_chip *chip);
  118. #endif