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