* [PATCH v4] tpm: Add tpm_version_major sysfs file
@ 2019-10-30 22:58 Jerry Snitselaar
2019-10-31 4:30 ` Mimi Zohar
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jerry Snitselaar @ 2019-10-30 22:58 UTC (permalink / raw)
To: linux-kernel
Cc: Jarkko Sakkinen, Mimi Zohar, Peter Huewe, Jason Gunthorpe,
linux-integrity
Easily determining what TCG version a tpm device implements
has been a pain point for userspace for a long time, so
add a sysfs file to report the TCG major version of a tpm device.
Also add an entry to Documentation/ABI/stable/sysfs-class-tpm
describing the new file.
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Mimi Zohar <zohar@linux.ibm.com>
Cc: Peter Huewe <peterhuewe@gmx.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-integrity@vger.kernel.org
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
v4: - Change file name to tpm_version_major
- Actually display just the major version.
- change structs to tpm1_* & tpm2_*
instead of tpm12_* tpm20_*.
v3: - Change file name to version_major.
v2: - Fix TCG usage in commit message.
- Add entry to sysfs-class-tpm in Documentation/ABI/stable
Documentation/ABI/stable/sysfs-class-tpm | 11 ++++++++
drivers/char/tpm/tpm-sysfs.c | 34 +++++++++++++++++++-----
2 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/Documentation/ABI/stable/sysfs-class-tpm b/Documentation/ABI/stable/sysfs-class-tpm
index c0e23830f56a..5468fedc493c 100644
--- a/Documentation/ABI/stable/sysfs-class-tpm
+++ b/Documentation/ABI/stable/sysfs-class-tpm
@@ -183,3 +183,14 @@ Description: The "timeouts" property shows the 4 vendor-specific values
The four timeout values are shown in usecs, with a trailing
"[original]" or "[adjusted]" depending on whether the values
were scaled by the driver to be reported in usec from msecs.
+
+What: /sys/class/tpm/tpmX/tpm_version_major
+Date: October 2019
+KernelVersion: 5.5
+Contact: linux-integrity@vger.kernel.org
+Description: The "tpm_version_major" property shows the TCG spec major version
+ implemented by the TPM device.
+
+ Example output:
+
+ 2
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index edfa89160010..12da71e72488 100644
--- a/drivers/char/tpm/tpm-sysfs.c
+++ b/drivers/char/tpm/tpm-sysfs.c
@@ -309,7 +309,17 @@ static ssize_t timeouts_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(timeouts);
-static struct attribute *tpm_dev_attrs[] = {
+static ssize_t tpm_version_major_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tpm_chip *chip = to_tpm_chip(dev);
+
+ return sprintf(buf, "%s\n", chip->flags & TPM_CHIP_FLAG_TPM2
+ ? "2" : "1");
+}
+static DEVICE_ATTR_RO(tpm_version_major);
+
+static struct attribute *tpm1_dev_attrs[] = {
&dev_attr_pubek.attr,
&dev_attr_pcrs.attr,
&dev_attr_enabled.attr,
@@ -320,18 +330,28 @@ static struct attribute *tpm_dev_attrs[] = {
&dev_attr_cancel.attr,
&dev_attr_durations.attr,
&dev_attr_timeouts.attr,
+ &dev_attr_tpm_version_major.attr,
NULL,
};
-static const struct attribute_group tpm_dev_group = {
- .attrs = tpm_dev_attrs,
+static struct attribute *tpm2_dev_attrs[] = {
+ &dev_attr_tpm_version_major.attr,
+ NULL
+};
+
+static const struct attribute_group tpm1_dev_group = {
+ .attrs = tpm1_dev_attrs,
+};
+
+static const struct attribute_group tpm2_dev_group = {
+ .attrs = tpm2_dev_attrs,
};
void tpm_sysfs_add_device(struct tpm_chip *chip)
{
- if (chip->flags & TPM_CHIP_FLAG_TPM2)
- return;
-
WARN_ON(chip->groups_cnt != 0);
- chip->groups[chip->groups_cnt++] = &tpm_dev_group;
+ if (chip->flags & TPM_CHIP_FLAG_TPM2)
+ chip->groups[chip->groups_cnt++] = &tpm2_dev_group;
+ else
+ chip->groups[chip->groups_cnt++] = &tpm1_dev_group;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4] tpm: Add tpm_version_major sysfs file
2019-10-30 22:58 [PATCH v4] tpm: Add tpm_version_major sysfs file Jerry Snitselaar
@ 2019-10-31 4:30 ` Mimi Zohar
2019-10-31 21:35 ` Jarkko Sakkinen
2019-11-28 1:08 ` Jerry Snitselaar
2 siblings, 0 replies; 7+ messages in thread
From: Mimi Zohar @ 2019-10-31 4:30 UTC (permalink / raw)
To: Jerry Snitselaar, linux-kernel
Cc: Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe, linux-integrity
On Wed, 2019-10-30 at 15:58 -0700, Jerry Snitselaar wrote:
> Easily determining what TCG version a tpm device implements
> has been a pain point for userspace for a long time, so
> add a sysfs file to report the TCG major version of a tpm device.
>
> Also add an entry to Documentation/ABI/stable/sysfs-class-tpm
> describing the new file.
>
> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Cc: Mimi Zohar <zohar@linux.ibm.com>
> Cc: Peter Huewe <peterhuewe@gmx.de>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: linux-integrity@vger.kernel.org
> Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
Thanks!
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] tpm: Add tpm_version_major sysfs file
2019-10-30 22:58 [PATCH v4] tpm: Add tpm_version_major sysfs file Jerry Snitselaar
2019-10-31 4:30 ` Mimi Zohar
@ 2019-10-31 21:35 ` Jarkko Sakkinen
2019-11-28 1:08 ` Jerry Snitselaar
2 siblings, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2019-10-31 21:35 UTC (permalink / raw)
To: Jerry Snitselaar
Cc: linux-kernel, Mimi Zohar, Peter Huewe, Jason Gunthorpe, linux-integrity
On Wed, Oct 30, 2019 at 03:58:43PM -0700, Jerry Snitselaar wrote:
> Easily determining what TCG version a tpm device implements
> has been a pain point for userspace for a long time, so
> add a sysfs file to report the TCG major version of a tpm device.
>
> Also add an entry to Documentation/ABI/stable/sysfs-class-tpm
> describing the new file.
>
> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Cc: Mimi Zohar <zohar@linux.ibm.com>
> Cc: Peter Huewe <peterhuewe@gmx.de>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: linux-integrity@vger.kernel.org
> Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
/Jarkko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] tpm: Add tpm_version_major sysfs file
2019-10-30 22:58 [PATCH v4] tpm: Add tpm_version_major sysfs file Jerry Snitselaar
2019-10-31 4:30 ` Mimi Zohar
2019-10-31 21:35 ` Jarkko Sakkinen
@ 2019-11-28 1:08 ` Jerry Snitselaar
2019-11-29 23:51 ` Jarkko Sakkinen
2 siblings, 1 reply; 7+ messages in thread
From: Jerry Snitselaar @ 2019-11-28 1:08 UTC (permalink / raw)
To: linux-kernel
Cc: Jarkko Sakkinen, Mimi Zohar, Peter Huewe, Jason Gunthorpe,
linux-integrity
On Wed Oct 30 19, Jerry Snitselaar wrote:
>Easily determining what TCG version a tpm device implements
>has been a pain point for userspace for a long time, so
>add a sysfs file to report the TCG major version of a tpm device.
>
>Also add an entry to Documentation/ABI/stable/sysfs-class-tpm
>describing the new file.
>
>Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
>Cc: Mimi Zohar <zohar@linux.ibm.com>
>Cc: Peter Huewe <peterhuewe@gmx.de>
>Cc: Jason Gunthorpe <jgg@ziepe.ca>
>Cc: linux-integrity@vger.kernel.org
>Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
>---
>v4: - Change file name to tpm_version_major
> - Actually display just the major version.
> - change structs to tpm1_* & tpm2_*
> instead of tpm12_* tpm20_*.
>v3: - Change file name to version_major.
>v2: - Fix TCG usage in commit message.
> - Add entry to sysfs-class-tpm in Documentation/ABI/stable
>
> Documentation/ABI/stable/sysfs-class-tpm | 11 ++++++++
> drivers/char/tpm/tpm-sysfs.c | 34 +++++++++++++++++++-----
> 2 files changed, 38 insertions(+), 7 deletions(-)
>
Anyone else have feedback?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] tpm: Add tpm_version_major sysfs file
2019-11-28 1:08 ` Jerry Snitselaar
@ 2019-11-29 23:51 ` Jarkko Sakkinen
2020-01-09 21:49 ` Jerry Snitselaar
0 siblings, 1 reply; 7+ messages in thread
From: Jarkko Sakkinen @ 2019-11-29 23:51 UTC (permalink / raw)
To: linux-kernel, Mimi Zohar, Peter Huewe, Jason Gunthorpe, linux-integrity
On Wed, Nov 27, 2019 at 06:08:26PM -0700, Jerry Snitselaar wrote:
> On Wed Oct 30 19, Jerry Snitselaar wrote:
> > Easily determining what TCG version a tpm device implements
> > has been a pain point for userspace for a long time, so
> > add a sysfs file to report the TCG major version of a tpm device.
> >
> > Also add an entry to Documentation/ABI/stable/sysfs-class-tpm
> > describing the new file.
> >
> > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > Cc: Mimi Zohar <zohar@linux.ibm.com>
> > Cc: Peter Huewe <peterhuewe@gmx.de>
> > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > Cc: linux-integrity@vger.kernel.org
> > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > ---
> > v4: - Change file name to tpm_version_major
> > - Actually display just the major version.
> > - change structs to tpm1_* & tpm2_*
> > instead of tpm12_* tpm20_*.
> > v3: - Change file name to version_major.
> > v2: - Fix TCG usage in commit message.
> > - Add entry to sysfs-class-tpm in Documentation/ABI/stable
> >
> > Documentation/ABI/stable/sysfs-class-tpm | 11 ++++++++
> > drivers/char/tpm/tpm-sysfs.c | 34 +++++++++++++++++++-----
> > 2 files changed, 38 insertions(+), 7 deletions(-)
> >
>
> Anyone else have feedback?
I can apply this after the issues on hand have been sorted out.
/Jarkko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] tpm: Add tpm_version_major sysfs file
2019-11-29 23:51 ` Jarkko Sakkinen
@ 2020-01-09 21:49 ` Jerry Snitselaar
2020-01-13 0:08 ` Jarkko Sakkinen
0 siblings, 1 reply; 7+ messages in thread
From: Jerry Snitselaar @ 2020-01-09 21:49 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: linux-kernel, Mimi Zohar, Peter Huewe, Jason Gunthorpe, linux-integrity
On Sat Nov 30 19, Jarkko Sakkinen wrote:
>On Wed, Nov 27, 2019 at 06:08:26PM -0700, Jerry Snitselaar wrote:
>> On Wed Oct 30 19, Jerry Snitselaar wrote:
>> > Easily determining what TCG version a tpm device implements
>> > has been a pain point for userspace for a long time, so
>> > add a sysfs file to report the TCG major version of a tpm device.
>> >
>> > Also add an entry to Documentation/ABI/stable/sysfs-class-tpm
>> > describing the new file.
>> >
>> > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
>> > Cc: Mimi Zohar <zohar@linux.ibm.com>
>> > Cc: Peter Huewe <peterhuewe@gmx.de>
>> > Cc: Jason Gunthorpe <jgg@ziepe.ca>
>> > Cc: linux-integrity@vger.kernel.org
>> > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
>> > ---
>> > v4: - Change file name to tpm_version_major
>> > - Actually display just the major version.
>> > - change structs to tpm1_* & tpm2_*
>> > instead of tpm12_* tpm20_*.
>> > v3: - Change file name to version_major.
>> > v2: - Fix TCG usage in commit message.
>> > - Add entry to sysfs-class-tpm in Documentation/ABI/stable
>> >
>> > Documentation/ABI/stable/sysfs-class-tpm | 11 ++++++++
>> > drivers/char/tpm/tpm-sysfs.c | 34 +++++++++++++++++++-----
>> > 2 files changed, 38 insertions(+), 7 deletions(-)
>> >
>>
>> Anyone else have feedback?
>
>I can apply this after the issues on hand have been sorted out.
>
>/Jarkko
>
Hi Jarkko,
Will this get queued up for 5.6?
Regards,
Jerry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] tpm: Add tpm_version_major sysfs file
2020-01-09 21:49 ` Jerry Snitselaar
@ 2020-01-13 0:08 ` Jarkko Sakkinen
0 siblings, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2020-01-13 0:08 UTC (permalink / raw)
To: linux-kernel, Mimi Zohar, Peter Huewe, Jason Gunthorpe, linux-integrity
On Thu, Jan 09, 2020 at 02:49:35PM -0700, Jerry Snitselaar wrote:
> On Sat Nov 30 19, Jarkko Sakkinen wrote:
> > On Wed, Nov 27, 2019 at 06:08:26PM -0700, Jerry Snitselaar wrote:
> > > On Wed Oct 30 19, Jerry Snitselaar wrote:
> > > > Easily determining what TCG version a tpm device implements
> > > > has been a pain point for userspace for a long time, so
> > > > add a sysfs file to report the TCG major version of a tpm device.
> > > >
> > > > Also add an entry to Documentation/ABI/stable/sysfs-class-tpm
> > > > describing the new file.
> > > >
> > > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > Cc: Mimi Zohar <zohar@linux.ibm.com>
> > > > Cc: Peter Huewe <peterhuewe@gmx.de>
> > > > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > > > Cc: linux-integrity@vger.kernel.org
> > > > Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> > > > ---
> > > > v4: - Change file name to tpm_version_major
> > > > - Actually display just the major version.
> > > > - change structs to tpm1_* & tpm2_*
> > > > instead of tpm12_* tpm20_*.
> > > > v3: - Change file name to version_major.
> > > > v2: - Fix TCG usage in commit message.
> > > > - Add entry to sysfs-class-tpm in Documentation/ABI/stable
> > > >
> > > > Documentation/ABI/stable/sysfs-class-tpm | 11 ++++++++
> > > > drivers/char/tpm/tpm-sysfs.c | 34 +++++++++++++++++++-----
> > > > 2 files changed, 38 insertions(+), 7 deletions(-)
> > > >
> > >
> > > Anyone else have feedback?
> >
> > I can apply this after the issues on hand have been sorted out.
> >
> > /Jarkko
> >
>
> Hi Jarkko,
>
> Will this get queued up for 5.6?
Thanks for reminding and apologies for forgetting this!
I'll see what I can do.
/Jarkko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-01-13 0:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 22:58 [PATCH v4] tpm: Add tpm_version_major sysfs file Jerry Snitselaar
2019-10-31 4:30 ` Mimi Zohar
2019-10-31 21:35 ` Jarkko Sakkinen
2019-11-28 1:08 ` Jerry Snitselaar
2019-11-29 23:51 ` Jarkko Sakkinen
2020-01-09 21:49 ` Jerry Snitselaar
2020-01-13 0:08 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).