Skip to content

Commit 189fc98

Browse files
committed
Merge tag 'tpmdd-next-20200122' of git://git.infradead.org/users/jjs/linux-tpmdd
Pull tpm updates from Jarkko Sakkinen: "This adds a new sysfs file for querying TPM major version, which can be used by the user space the TPM protocol used to communicate with the chip" * tag 'tpmdd-next-20200122' of git://git.infradead.org/users/jjs/linux-tpmdd: tpm: Add tpm_version_major sysfs file tpm: Update mailing list contact information in sysfs-class-tpm
2 parents f11ba7d + 7084edd commit 189fc98

File tree

2 files changed

+49
-18
lines changed

2 files changed

+49
-18
lines changed

Documentation/ABI/stable/sysfs-class-tpm

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
What: /sys/class/tpm/tpmX/device/
22
Date: April 2005
33
KernelVersion: 2.6.12
4-
4+
55
Description: The device/ directory under a specific TPM instance exposes
66
the properties of that TPM chip
77

88

99
What: /sys/class/tpm/tpmX/device/active
1010
Date: April 2006
1111
KernelVersion: 2.6.17
12-
12+
1313
Description: The "active" property prints a '1' if the TPM chip is accepting
1414
commands. An inactive TPM chip still contains all the state of
1515
an active chip (Storage Root Key, NVRAM, etc), and can be
@@ -21,15 +21,15 @@ Description: The "active" property prints a '1' if the TPM chip is accepting
2121
What: /sys/class/tpm/tpmX/device/cancel
2222
Date: June 2005
2323
KernelVersion: 2.6.13
24-
24+
2525
Description: The "cancel" property allows you to cancel the currently
2626
pending TPM command. Writing any value to cancel will call the
2727
TPM vendor specific cancel operation.
2828

2929
What: /sys/class/tpm/tpmX/device/caps
3030
Date: April 2005
3131
KernelVersion: 2.6.12
32-
32+
3333
Description: The "caps" property contains TPM manufacturer and version info.
3434

3535
Example output:
@@ -46,7 +46,7 @@ Description: The "caps" property contains TPM manufacturer and version info.
4646
What: /sys/class/tpm/tpmX/device/durations
4747
Date: March 2011
4848
KernelVersion: 3.1
49-
49+
5050
Description: The "durations" property shows the 3 vendor-specific values
5151
used to wait for a short, medium and long TPM command. All
5252
TPM commands are categorized as short, medium or long in
@@ -69,7 +69,7 @@ Description: The "durations" property shows the 3 vendor-specific values
6969
What: /sys/class/tpm/tpmX/device/enabled
7070
Date: April 2006
7171
KernelVersion: 2.6.17
72-
72+
7373
Description: The "enabled" property prints a '1' if the TPM chip is enabled,
7474
meaning that it should be visible to the OS. This property
7575
may be visible but produce a '0' after some operation that
@@ -78,15 +78,15 @@ Description: The "enabled" property prints a '1' if the TPM chip is enabled,
7878
What: /sys/class/tpm/tpmX/device/owned
7979
Date: April 2006
8080
KernelVersion: 2.6.17
81-
81+
8282
Description: The "owned" property produces a '1' if the TPM_TakeOwnership
8383
ordinal has been executed successfully in the chip. A '0'
8484
indicates that ownership hasn't been taken.
8585

8686
What: /sys/class/tpm/tpmX/device/pcrs
8787
Date: April 2005
8888
KernelVersion: 2.6.12
89-
89+
9090
Description: The "pcrs" property will dump the current value of all Platform
9191
Configuration Registers in the TPM. Note that since these
9292
values may be constantly changing, the output is only valid
@@ -109,7 +109,7 @@ Description: The "pcrs" property will dump the current value of all Platform
109109
What: /sys/class/tpm/tpmX/device/pubek
110110
Date: April 2005
111111
KernelVersion: 2.6.12
112-
112+
113113
Description: The "pubek" property will return the TPM's public endorsement
114114
key if possible. If the TPM has had ownership established and
115115
is version 1.2, the pubek will not be available without the
@@ -161,7 +161,7 @@ Description: The "pubek" property will return the TPM's public endorsement
161161
What: /sys/class/tpm/tpmX/device/temp_deactivated
162162
Date: April 2006
163163
KernelVersion: 2.6.17
164-
164+
165165
Description: The "temp_deactivated" property returns a '1' if the chip has
166166
been temporarily deactivated, usually until the next power
167167
cycle. Whether a warm boot (reboot) will clear a TPM chip
@@ -170,7 +170,7 @@ Description: The "temp_deactivated" property returns a '1' if the chip has
170170
What: /sys/class/tpm/tpmX/device/timeouts
171171
Date: March 2011
172172
KernelVersion: 3.1
173-
173+
174174
Description: The "timeouts" property shows the 4 vendor-specific values
175175
for the TPM's interface spec timeouts. The use of these
176176
timeouts is defined by the TPM interface spec that the chip
@@ -183,3 +183,14 @@ Description: The "timeouts" property shows the 4 vendor-specific values
183183
The four timeout values are shown in usecs, with a trailing
184184
"[original]" or "[adjusted]" depending on whether the values
185185
were scaled by the driver to be reported in usec from msecs.
186+
187+
What: /sys/class/tpm/tpmX/tpm_version_major
188+
Date: October 2019
189+
KernelVersion: 5.5
190+
191+
Description: The "tpm_version_major" property shows the TCG spec major version
192+
implemented by the TPM device.
193+
194+
Example output:
195+
196+
2

drivers/char/tpm/tpm-sysfs.c

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,17 @@ static ssize_t timeouts_show(struct device *dev, struct device_attribute *attr,
310310
}
311311
static DEVICE_ATTR_RO(timeouts);
312312

313-
static struct attribute *tpm_dev_attrs[] = {
313+
static ssize_t tpm_version_major_show(struct device *dev,
314+
struct device_attribute *attr, char *buf)
315+
{
316+
struct tpm_chip *chip = to_tpm_chip(dev);
317+
318+
return sprintf(buf, "%s\n", chip->flags & TPM_CHIP_FLAG_TPM2
319+
? "2" : "1");
320+
}
321+
static DEVICE_ATTR_RO(tpm_version_major);
322+
323+
static struct attribute *tpm1_dev_attrs[] = {
314324
&dev_attr_pubek.attr,
315325
&dev_attr_pcrs.attr,
316326
&dev_attr_enabled.attr,
@@ -321,18 +331,28 @@ static struct attribute *tpm_dev_attrs[] = {
321331
&dev_attr_cancel.attr,
322332
&dev_attr_durations.attr,
323333
&dev_attr_timeouts.attr,
334+
&dev_attr_tpm_version_major.attr,
324335
NULL,
325336
};
326337

327-
static const struct attribute_group tpm_dev_group = {
328-
.attrs = tpm_dev_attrs,
338+
static struct attribute *tpm2_dev_attrs[] = {
339+
&dev_attr_tpm_version_major.attr,
340+
NULL
341+
};
342+
343+
static const struct attribute_group tpm1_dev_group = {
344+
.attrs = tpm1_dev_attrs,
345+
};
346+
347+
static const struct attribute_group tpm2_dev_group = {
348+
.attrs = tpm2_dev_attrs,
329349
};
330350

331351
void tpm_sysfs_add_device(struct tpm_chip *chip)
332352
{
333-
if (chip->flags & TPM_CHIP_FLAG_TPM2)
334-
return;
335-
336353
WARN_ON(chip->groups_cnt != 0);
337-
chip->groups[chip->groups_cnt++] = &tpm_dev_group;
354+
if (chip->flags & TPM_CHIP_FLAG_TPM2)
355+
chip->groups[chip->groups_cnt++] = &tpm2_dev_group;
356+
else
357+
chip->groups[chip->groups_cnt++] = &tpm1_dev_group;
338358
}

0 commit comments

Comments
 (0)