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