aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorJason Gunthorpe <jgunthorpe@obsidianresearch.com>2016-01-07 19:36:22 -0500
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2016-02-09 21:11:29 -0500
commit4d627e672bd0e8af4e734fef93e806499d1e1277 (patch)
tree35b4ef1307c2156c9f2e80632c265e64a8b38ae3 /drivers/char
parentef7b81dc78642e1a33c890acf3214d1e04c90a8f (diff)
tpm_tis: Do not fall back to a hardcoded address for TPM2
If the ACPI tables do not declare a memory resource for the TPM2 then do not just fall back to the x86 default base address. Also be stricter when checking the ancillary TPM2 ACPI data and error out if any of this data is wrong rather than blindly assuming TPM1. Fixes: 399235dc6e95 ("tpm, tpm_tis: fix tpm_tis ACPI detection issue with TPM 2.0") Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Tested-by: Wilck, Martin <martin.wilck@ts.fujitsu.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Acked-by: Peter Huewe <peterhuewe@gmx.de>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/tpm/tpm_tis.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index d993fed51f23..2ccad8a8177f 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -121,39 +121,11 @@ static inline int is_itpm(struct acpi_device *dev)
121{ 121{
122 return has_hid(dev, "INTC0102"); 122 return has_hid(dev, "INTC0102");
123} 123}
124
125static inline int is_fifo(struct acpi_device *dev)
126{
127 struct acpi_table_tpm2 *tbl;
128 acpi_status st;
129
130 /* TPM 1.2 FIFO */
131 if (!has_hid(dev, "MSFT0101"))
132 return 1;
133
134 st = acpi_get_table(ACPI_SIG_TPM2, 1,
135 (struct acpi_table_header **) &tbl);
136 if (ACPI_FAILURE(st)) {
137 dev_err(&dev->dev, "failed to get TPM2 ACPI table\n");
138 return 0;
139 }
140
141 if (tbl->start_method != ACPI_TPM2_MEMORY_MAPPED)
142 return 0;
143
144 /* TPM 2.0 FIFO */
145 return 1;
146}
147#else 124#else
148static inline int is_itpm(struct acpi_device *dev) 125static inline int is_itpm(struct acpi_device *dev)
149{ 126{
150 return 0; 127 return 0;
151} 128}
152
153static inline int is_fifo(struct acpi_device *dev)
154{
155 return 1;
156}
157#endif 129#endif
158 130
159/* Before we attempt to access the TPM we must see that the valid bit is set. 131/* Before we attempt to access the TPM we must see that the valid bit is set.
@@ -979,11 +951,21 @@ static int tpm_check_resource(struct acpi_resource *ares, void *data)
979 951
980static int tpm_tis_acpi_init(struct acpi_device *acpi_dev) 952static int tpm_tis_acpi_init(struct acpi_device *acpi_dev)
981{ 953{
954 struct acpi_table_tpm2 *tbl;
955 acpi_status st;
982 struct list_head resources; 956 struct list_head resources;
983 struct tpm_info tpm_info = tis_default_info; 957 struct tpm_info tpm_info = {};
984 int ret; 958 int ret;
985 959
986 if (!is_fifo(acpi_dev)) 960 st = acpi_get_table(ACPI_SIG_TPM2, 1,
961 (struct acpi_table_header **) &tbl);
962 if (ACPI_FAILURE(st) || tbl->header.length < sizeof(*tbl)) {
963 dev_err(&acpi_dev->dev,
964 FW_BUG "failed to get TPM2 ACPI table\n");
965 return -EINVAL;
966 }
967
968 if (tbl->start_method != ACPI_TPM2_MEMORY_MAPPED)
987 return -ENODEV; 969 return -ENODEV;
988 970
989 INIT_LIST_HEAD(&resources); 971 INIT_LIST_HEAD(&resources);
@@ -995,6 +977,12 @@ static int tpm_tis_acpi_init(struct acpi_device *acpi_dev)
995 977
996 acpi_dev_free_resource_list(&resources); 978 acpi_dev_free_resource_list(&resources);
997 979
980 if (tpm_info.start == 0 && tpm_info.len == 0) {
981 dev_err(&acpi_dev->dev,
982 FW_BUG "TPM2 ACPI table does not define a memory resource\n");
983 return -EINVAL;
984 }
985
998 if (is_itpm(acpi_dev)) 986 if (is_itpm(acpi_dev))
999 itpm = true; 987 itpm = true;
1000 988