summaryrefslogtreecommitdiffstats
path: root/include/linux/tpm.h
diff options
context:
space:
mode:
authorRoberto Sassu <roberto.sassu@huawei.com>2019-02-06 11:24:50 -0500
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2019-02-13 02:48:51 -0500
commit901615cb916dc955fb7bda4e34402bf263532e4a (patch)
treeaf217a92b23d5288074251d6735978375f1785c6 /include/linux/tpm.h
parent879b589210a9a0c9f77d301aaf0ddee20f2c5052 (diff)
tpm: move tpm_chip definition to include/linux/tpm.h
The tpm_chip structure contains the list of PCR banks currently allocated in the TPM. When support for crypto agility will be added to the TPM driver, users of the driver have to provide a digest for each allocated bank to tpm_pcr_extend(). With this patch, they can obtain the PCR bank algorithms directly from chip->allocated_banks. Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'include/linux/tpm.h')
-rw-r--r--include/linux/tpm.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index afd022fc9d3d..816e686a73ac 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -22,6 +22,10 @@
22#ifndef __LINUX_TPM_H__ 22#ifndef __LINUX_TPM_H__
23#define __LINUX_TPM_H__ 23#define __LINUX_TPM_H__
24 24
25#include <linux/hw_random.h>
26#include <linux/acpi.h>
27#include <linux/cdev.h>
28#include <linux/fs.h>
25#include <crypto/hash_info.h> 29#include <crypto/hash_info.h>
26 30
27#define TPM_DIGEST_SIZE 20 /* Max TPM v1.2 PCR size */ 31#define TPM_DIGEST_SIZE 20 /* Max TPM v1.2 PCR size */
@@ -75,6 +79,93 @@ struct tpm_class_ops {
75 void (*clk_enable)(struct tpm_chip *chip, bool value); 79 void (*clk_enable)(struct tpm_chip *chip, bool value);
76}; 80};
77 81
82#define TPM_NUM_EVENT_LOG_FILES 3
83
84/* Indexes the duration array */
85enum tpm_duration {
86 TPM_SHORT = 0,
87 TPM_MEDIUM = 1,
88 TPM_LONG = 2,
89 TPM_LONG_LONG = 3,
90 TPM_UNDEFINED,
91 TPM_NUM_DURATIONS = TPM_UNDEFINED,
92};
93
94#define TPM_PPI_VERSION_LEN 3
95
96struct tpm_space {
97 u32 context_tbl[3];
98 u8 *context_buf;
99 u32 session_tbl[3];
100 u8 *session_buf;
101};
102
103struct tpm_bios_log {
104 void *bios_event_log;
105 void *bios_event_log_end;
106};
107
108struct tpm_chip_seqops {
109 struct tpm_chip *chip;
110 const struct seq_operations *seqops;
111};
112
113struct tpm_chip {
114 struct device dev;
115 struct device devs;
116 struct cdev cdev;
117 struct cdev cdevs;
118
119 /* A driver callback under ops cannot be run unless ops_sem is held
120 * (sometimes implicitly, eg for the sysfs code). ops becomes null
121 * when the driver is unregistered, see tpm_try_get_ops.
122 */
123 struct rw_semaphore ops_sem;
124 const struct tpm_class_ops *ops;
125
126 struct tpm_bios_log log;
127 struct tpm_chip_seqops bin_log_seqops;
128 struct tpm_chip_seqops ascii_log_seqops;
129
130 unsigned int flags;
131
132 int dev_num; /* /dev/tpm# */
133 unsigned long is_open; /* only one allowed */
134
135 char hwrng_name[64];
136 struct hwrng hwrng;
137
138 struct mutex tpm_mutex; /* tpm is processing */
139
140 unsigned long timeout_a; /* jiffies */
141 unsigned long timeout_b; /* jiffies */
142 unsigned long timeout_c; /* jiffies */
143 unsigned long timeout_d; /* jiffies */
144 bool timeout_adjusted;
145 unsigned long duration[TPM_NUM_DURATIONS]; /* jiffies */
146 bool duration_adjusted;
147
148 struct dentry *bios_dir[TPM_NUM_EVENT_LOG_FILES];
149
150 const struct attribute_group *groups[3];
151 unsigned int groups_cnt;
152
153 u32 nr_allocated_banks;
154 struct tpm_bank_info *allocated_banks;
155#ifdef CONFIG_ACPI
156 acpi_handle acpi_dev_handle;
157 char ppi_version[TPM_PPI_VERSION_LEN + 1];
158#endif /* CONFIG_ACPI */
159
160 struct tpm_space work_space;
161 u32 last_cc;
162 u32 nr_commands;
163 u32 *cc_attrs_tbl;
164
165 /* active locality */
166 int locality;
167};
168
78#if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE) 169#if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
79 170
80extern int tpm_is_tpm2(struct tpm_chip *chip); 171extern int tpm_is_tpm2(struct tpm_chip *chip);