diff options
author | Ashley Lai <adlai@linux.vnet.ibm.com> | 2012-08-14 19:35:32 -0400 |
---|---|---|
committer | Kent Yoder <key@linux.vnet.ibm.com> | 2012-08-22 17:22:47 -0400 |
commit | c5df39262dd59dbbffb1017fca0f1661408ac9d5 (patch) | |
tree | 80548294fa8b0c6f7581bbbadc511badeccaa42d | |
parent | 4a727429abec31c4f5d9607cebb4fb1cc21e1167 (diff) |
drivers/char/tpm: Add securityfs support for event log
This patch retrieves the event log data from the device tree
during file open. The event log data will then displayed through
securityfs.
Signed-off-by: Ashley Lai <adlai@us.ibm.com>
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
-rw-r--r-- | drivers/char/tpm/Makefile | 5 | ||||
-rw-r--r-- | drivers/char/tpm/tpm.h | 12 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_eventlog.h | 15 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_of.c | 73 |
4 files changed, 93 insertions, 12 deletions
diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile index 547509d02046..9080cc44e3c4 100644 --- a/drivers/char/tpm/Makefile +++ b/drivers/char/tpm/Makefile | |||
@@ -5,6 +5,11 @@ obj-$(CONFIG_TCG_TPM) += tpm.o | |||
5 | ifdef CONFIG_ACPI | 5 | ifdef CONFIG_ACPI |
6 | obj-$(CONFIG_TCG_TPM) += tpm_bios.o | 6 | obj-$(CONFIG_TCG_TPM) += tpm_bios.o |
7 | tpm_bios-objs += tpm_eventlog.o tpm_acpi.o | 7 | tpm_bios-objs += tpm_eventlog.o tpm_acpi.o |
8 | else | ||
9 | ifdef CONFIG_TCG_IBMVTPM | ||
10 | obj-$(CONFIG_TCG_TPM) += tpm_bios.o | ||
11 | tpm_bios-objs += tpm_eventlog.o tpm_of.o | ||
12 | endif | ||
8 | endif | 13 | endif |
9 | obj-$(CONFIG_TCG_TIS) += tpm_tis.o | 14 | obj-$(CONFIG_TCG_TIS) += tpm_tis.o |
10 | obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o | 15 | obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o |
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 870fde7459c5..f1af73821101 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h | |||
@@ -327,15 +327,3 @@ extern int tpm_pm_suspend(struct device *); | |||
327 | extern int tpm_pm_resume(struct device *); | 327 | extern int tpm_pm_resume(struct device *); |
328 | extern int wait_for_tpm_stat(struct tpm_chip *, u8, unsigned long, | 328 | extern int wait_for_tpm_stat(struct tpm_chip *, u8, unsigned long, |
329 | wait_queue_head_t *); | 329 | wait_queue_head_t *); |
330 | #ifdef CONFIG_ACPI | ||
331 | extern struct dentry ** tpm_bios_log_setup(char *); | ||
332 | extern void tpm_bios_log_teardown(struct dentry **); | ||
333 | #else | ||
334 | static inline struct dentry ** tpm_bios_log_setup(char *name) | ||
335 | { | ||
336 | return NULL; | ||
337 | } | ||
338 | static inline void tpm_bios_log_teardown(struct dentry **dir) | ||
339 | { | ||
340 | } | ||
341 | #endif | ||
diff --git a/drivers/char/tpm/tpm_eventlog.h b/drivers/char/tpm/tpm_eventlog.h index 8e23ccdf8a83..e7da086d6928 100644 --- a/drivers/char/tpm/tpm_eventlog.h +++ b/drivers/char/tpm/tpm_eventlog.h | |||
@@ -68,4 +68,19 @@ enum tcpa_pc_event_ids { | |||
68 | }; | 68 | }; |
69 | 69 | ||
70 | int read_log(struct tpm_bios_log *log); | 70 | int read_log(struct tpm_bios_log *log); |
71 | |||
72 | #if defined(CONFIG_TCG_IBMVTPM) || defined(CONFIG_TCG_IBMVTPM_MODULE) || \ | ||
73 | defined(CONFIG_ACPI) | ||
74 | extern struct dentry **tpm_bios_log_setup(char *); | ||
75 | extern void tpm_bios_log_teardown(struct dentry **); | ||
76 | #else | ||
77 | static inline struct dentry **tpm_bios_log_setup(char *name) | ||
78 | { | ||
79 | return NULL; | ||
80 | } | ||
81 | static inline void tpm_bios_log_teardown(struct dentry **dir) | ||
82 | { | ||
83 | } | ||
84 | #endif | ||
85 | |||
71 | #endif | 86 | #endif |
diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c new file mode 100644 index 000000000000..98ba2bd1a355 --- /dev/null +++ b/drivers/char/tpm/tpm_of.c | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * Copyright 2012 IBM Corporation | ||
3 | * | ||
4 | * Author: Ashley Lai <adlai@us.ibm.com> | ||
5 | * | ||
6 | * Maintained by: <tpmdd-devel@lists.sourceforge.net> | ||
7 | * | ||
8 | * Read the event log created by the firmware on PPC64 | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version | ||
13 | * 2 of the License, or (at your option) any later version. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #include <linux/slab.h> | ||
18 | #include <linux/of.h> | ||
19 | |||
20 | #include "tpm.h" | ||
21 | #include "tpm_eventlog.h" | ||
22 | |||
23 | int read_log(struct tpm_bios_log *log) | ||
24 | { | ||
25 | struct device_node *np; | ||
26 | const u32 *sizep; | ||
27 | const __be64 *basep; | ||
28 | |||
29 | if (log->bios_event_log != NULL) { | ||
30 | pr_err("%s: ERROR - Eventlog already initialized\n", __func__); | ||
31 | return -EFAULT; | ||
32 | } | ||
33 | |||
34 | np = of_find_node_by_name(NULL, "ibm,vtpm"); | ||
35 | if (!np) { | ||
36 | pr_err("%s: ERROR - IBMVTPM not supported\n", __func__); | ||
37 | return -ENODEV; | ||
38 | } | ||
39 | |||
40 | sizep = of_get_property(np, "linux,sml-size", NULL); | ||
41 | if (sizep == NULL) { | ||
42 | pr_err("%s: ERROR - SML size not found\n", __func__); | ||
43 | goto cleanup_eio; | ||
44 | } | ||
45 | if (*sizep == 0) { | ||
46 | pr_err("%s: ERROR - event log area empty\n", __func__); | ||
47 | goto cleanup_eio; | ||
48 | } | ||
49 | |||
50 | basep = of_get_property(np, "linux,sml-base", NULL); | ||
51 | if (basep == NULL) { | ||
52 | pr_err(KERN_ERR "%s: ERROR - SML not found\n", __func__); | ||
53 | goto cleanup_eio; | ||
54 | } | ||
55 | |||
56 | of_node_put(np); | ||
57 | log->bios_event_log = kmalloc(*sizep, GFP_KERNEL); | ||
58 | if (!log->bios_event_log) { | ||
59 | pr_err("%s: ERROR - Not enough memory for BIOS measurements\n", | ||
60 | __func__); | ||
61 | return -ENOMEM; | ||
62 | } | ||
63 | |||
64 | log->bios_event_log_end = log->bios_event_log + *sizep; | ||
65 | |||
66 | memcpy(log->bios_event_log, __va(be64_to_cpup(basep)), *sizep); | ||
67 | |||
68 | return 0; | ||
69 | |||
70 | cleanup_eio: | ||
71 | of_node_put(np); | ||
72 | return -EIO; | ||
73 | } | ||