aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@linux.intel.com>2013-12-19 07:38:18 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-01-05 10:07:15 -0500
commit1569a4c4cebaf358eff12633830baeaf6507fed0 (patch)
tree7ee80bb3bdd0ae2c276d762f55953b0a579c1712 /drivers/char/tpm
parent84b1667dea233d2af29b5138bfd2d70417cfa720 (diff)
ACPI / TPM: detect PPI features by checking availability of _DSM functions
Detecting physical presence interface features by checking availbility of corresponding ACPI _DSM functions, it should be more accurate than checking TPM version number. Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r--drivers/char/tpm/tpm_ppi.c45
1 files changed, 19 insertions, 26 deletions
diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
index d542ac6d0ae0..117fab6daf39 100644
--- a/drivers/char/tpm/tpm_ppi.c
+++ b/drivers/char/tpm/tpm_ppi.c
@@ -23,39 +23,31 @@ static const u8 tpm_ppi_uuid[] = {
23 0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53 23 0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53
24}; 24};
25 25
26static char *tpm_device_name = "TPM";
27static char tpm_ppi_version[PPI_VERSION_LEN + 1]; 26static char tpm_ppi_version[PPI_VERSION_LEN + 1];
28static acpi_handle tpm_ppi_handle; 27static acpi_handle tpm_ppi_handle;
29 28
30static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context, 29static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context,
31 void **return_value) 30 void **return_value)
32{ 31{
33 acpi_status status = AE_OK; 32 union acpi_object *obj;
34 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
35 33
36 status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer); 34 if (!acpi_check_dsm(handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
37 if (ACPI_FAILURE(status)) 35 1 << TPM_PPI_FN_VERSION))
38 return AE_OK; 36 return AE_OK;
39 37
40 if (strstr(buffer.pointer, context) != NULL) { 38 /* Cache version string */
41 union acpi_object *obj; 39 obj = acpi_evaluate_dsm_typed(handle, tpm_ppi_uuid,
42 40 TPM_PPI_REVISION_ID, TPM_PPI_FN_VERSION,
43 /* Cache version string */ 41 NULL, ACPI_TYPE_STRING);
44 obj = acpi_evaluate_dsm_typed(handle, tpm_ppi_uuid, 42 if (obj) {
45 TPM_PPI_REVISION_ID, TPM_PPI_FN_VERSION, 43 strlcpy(tpm_ppi_version, obj->string.pointer,
46 NULL, ACPI_TYPE_STRING); 44 PPI_VERSION_LEN + 1);
47 if (obj) { 45 ACPI_FREE(obj);
48 strlcpy(tpm_ppi_version, obj->string.pointer,
49 PPI_VERSION_LEN + 1);
50 ACPI_FREE(obj);
51 }
52
53 *return_value = handle;
54 status = AE_CTRL_TERMINATE;
55 } 46 }
56 kfree(buffer.pointer);
57 47
58 return status; 48 *return_value = handle;
49
50 return AE_CTRL_TERMINATE;
59} 51}
60 52
61static inline union acpi_object * 53static inline union acpi_object *
@@ -118,7 +110,8 @@ static ssize_t tpm_store_ppi_request(struct device *dev,
118 * is updated with function index from SUBREQ to SUBREQ2 since PPI 110 * is updated with function index from SUBREQ to SUBREQ2 since PPI
119 * version 1.1 111 * version 1.1
120 */ 112 */
121 if (strcmp(tpm_ppi_version, "1.1") >= 0) 113 if (acpi_check_dsm(tpm_ppi_handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
114 1 << TPM_PPI_FN_SUBREQ2))
122 func = TPM_PPI_FN_SUBREQ2; 115 func = TPM_PPI_FN_SUBREQ2;
123 116
124 /* 117 /*
@@ -272,7 +265,8 @@ static ssize_t show_ppi_operations(char *buf, u32 start, u32 end)
272 "User not required", 265 "User not required",
273 }; 266 };
274 267
275 if (strcmp(tpm_ppi_version, "1.2") < 0) 268 if (!acpi_check_dsm(tpm_ppi_handle, tpm_ppi_uuid, TPM_PPI_REVISION_ID,
269 1 << TPM_PPI_FN_GETOPR))
276 return -EPERM; 270 return -EPERM;
277 271
278 tmp.integer.type = ACPI_TYPE_INTEGER; 272 tmp.integer.type = ACPI_TYPE_INTEGER;
@@ -334,8 +328,7 @@ int tpm_add_ppi(struct kobject *parent)
334{ 328{
335 /* Cache TPM ACPI handle and version string */ 329 /* Cache TPM ACPI handle and version string */
336 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 330 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
337 ppi_callback, NULL, 331 ppi_callback, NULL, NULL, &tpm_ppi_handle);
338 tpm_device_name, &tpm_ppi_handle);
339 if (tpm_ppi_handle == NULL) 332 if (tpm_ppi_handle == NULL)
340 return -ENODEV; 333 return -ENODEV;
341 334