25 #include <linux/module.h>
26 #include <linux/slab.h>
32 static const char* tcpa_event_type_strings[] = {
43 "Platform Config Flags",
53 static const char* tcpa_pc_event_id_strings[] = {
64 "Option ROM microcode ",
72 static void *tpm_bios_measurements_start(
struct seq_file *
m, loff_t *
pos)
81 for (i = 0; i < *
pos; i++) {
84 if ((addr +
sizeof(
struct tcpa_event)) < limit) {
92 if ((addr +
sizeof(
struct tcpa_event)) >= limit)
104 static void *tpm_bios_measurements_next(
struct seq_file *m,
void *
v,
130 static void tpm_bios_measurements_stop(
struct seq_file *m,
void *v)
135 unsigned char * event_entry)
137 const char *
name =
"";
140 int i, n_len = 0, d_len = 0;
159 name = tcpa_event_type_strings[
event->event_type];
166 n_len =
event->event_size;
182 name = tcpa_pc_event_id_strings[pc_event->
event_id];
191 name = tcpa_pc_event_id_strings[pc_event->
event_id];
193 for (i = 0; i < 20; i++)
194 d_len +=
sprintf(&data[2*i],
"%02x",
205 n_len, name, d_len, data);
209 static int tpm_binary_bios_measurements_show(
struct seq_file *m,
void *v)
221 static int tpm_bios_measurements_release(
struct inode *
inode,
235 static int tpm_ascii_bios_measurements_show(
struct seq_file *m,
void *v)
241 unsigned char *event_entry =
242 (
unsigned char *) (v +
sizeof(
struct tcpa_event));
254 for (i = 0; i < 20; i++)
260 len += get_event_name(eventname, event, event_entry);
269 static const struct seq_operations tpm_ascii_b_measurments_seqops = {
270 .start = tpm_bios_measurements_start,
271 .next = tpm_bios_measurements_next,
272 .stop = tpm_bios_measurements_stop,
273 .show = tpm_ascii_bios_measurements_show,
276 static const struct seq_operations tpm_binary_b_measurments_seqops = {
277 .start = tpm_bios_measurements_start,
278 .next = tpm_bios_measurements_next,
279 .stop = tpm_bios_measurements_stop,
280 .show = tpm_binary_bios_measurements_show,
283 static int tpm_ascii_bios_measurements_open(
struct inode *inode,
298 err =
seq_open(file, &tpm_ascii_b_measurments_seqops);
314 static const struct file_operations tpm_ascii_bios_measurements_ops = {
315 .open = tpm_ascii_bios_measurements_open,
318 .release = tpm_bios_measurements_release,
321 static int tpm_binary_bios_measurements_open(
struct inode *inode,
336 err =
seq_open(file, &tpm_binary_b_measurments_seqops);
352 static const struct file_operations tpm_binary_bios_measurements_ops = {
353 .open = tpm_binary_bios_measurements_open,
356 .release = tpm_bios_measurements_release,
359 static int is_bad(
void *
p)
363 if (IS_ERR(p) && (PTR_ERR(p) != -
ENODEV))
370 struct dentry **
ret =
NULL, *tpm_dir, *bin_file, *ascii_file;
379 &tpm_binary_bios_measurements_ops);
380 if (is_bad(bin_file))
386 &tpm_ascii_bios_measurements_ops);
387 if (is_bad(ascii_file))
415 for (i = 0; i < 3; i++)