* [PATCH] tpm: Add major_version sysfs file
@ 2019-10-25 14:28 Jerry Snitselaar
2019-10-25 18:18 ` Mimi Zohar
2019-10-27 15:35 ` Jarkko Sakkinen
0 siblings, 2 replies; 10+ messages in thread
From: Jerry Snitselaar @ 2019-10-25 14:28 UTC (permalink / raw)
To: linux-kernel
Cc: Jarkko Sakkinen, 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 version of a tpm device.
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.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>
---
drivers/char/tpm/tpm-sysfs.c | 34 +++++++++++++++++++++++++++-------
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index edfa89160010..9372c2d6f0b3 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 major_version_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.0" : "1.2");
+}
+static DEVICE_ATTR_RO(major_version);
+
+static struct attribute *tpm12_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_major_version.attr,
NULL,
};
-static const struct attribute_group tpm_dev_group = {
- .attrs = tpm_dev_attrs,
+static struct attribute *tpm20_dev_attrs[] = {
+ &dev_attr_major_version.attr,
+ NULL
+};
+
+static const struct attribute_group tpm12_dev_group = {
+ .attrs = tpm12_dev_attrs,
+};
+
+static const struct attribute_group tpm20_dev_group = {
+ .attrs = tpm20_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++] = &tpm20_dev_group;
+ else
+ chip->groups[chip->groups_cnt++] = &tpm12_dev_group;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] tpm: Add major_version sysfs file
2019-10-25 14:28 [PATCH] tpm: Add major_version sysfs file Jerry Snitselaar
@ 2019-10-25 18:18 ` Mimi Zohar
2019-10-25 18:45 ` Jerry Snitselaar
2019-10-27 15:35 ` Jarkko Sakkinen
1 sibling, 1 reply; 10+ messages in thread
From: Mimi Zohar @ 2019-10-25 18:18 UTC (permalink / raw)
To: Jerry Snitselaar, linux-kernel
Cc: Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe, linux-integrity
On Fri, 2019-10-25 at 07:28 -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 version of a tpm device.
Use "TCG" uppercase consistently.
>
> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.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>
FYI, on my system(s) the new file is accessible as
/sys/class/tpm/tpm0/version_major. Does this need to be documented
anywhere?
> ---
> drivers/char/tpm/tpm-sysfs.c | 34 +++++++++++++++++++++++++++-------
> 1 file changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
> index edfa89160010..9372c2d6f0b3 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 major_version_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.0" : "1.2");
> +}
> +static DEVICE_ATTR_RO(major_version);
> +
> +static struct attribute *tpm12_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_major_version.attr,
> NULL,
> };
>
> -static const struct attribute_group tpm_dev_group = {
> - .attrs = tpm_dev_attrs,
> +static struct attribute *tpm20_dev_attrs[] = {
> + &dev_attr_major_version.attr,
> + NULL
> +};
> +
> +static const struct attribute_group tpm12_dev_group = {
> + .attrs = tpm12_dev_attrs,
> +};
> +
> +static const struct attribute_group tpm20_dev_group = {
> + .attrs = tpm20_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++] = &tpm20_dev_group;
> + else
> + chip->groups[chip->groups_cnt++] = &tpm12_dev_group;
> }
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] tpm: Add major_version sysfs file
2019-10-25 18:18 ` Mimi Zohar
@ 2019-10-25 18:45 ` Jerry Snitselaar
2019-10-25 19:15 ` Mimi Zohar
2019-10-25 19:32 ` Jason Gunthorpe
0 siblings, 2 replies; 10+ messages in thread
From: Jerry Snitselaar @ 2019-10-25 18:45 UTC (permalink / raw)
To: Mimi Zohar
Cc: linux-kernel, Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe,
linux-integrity
On Fri Oct 25 19, Mimi Zohar wrote:
>On Fri, 2019-10-25 at 07:28 -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 version of a tpm device.
>
>Use "TCG" uppercase consistently.
>
>>
>> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.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>
>
>FYI, on my system(s) the new file is accessible as
>/sys/class/tpm/tpm0/version_major. Does this need to be documented
>anywhere?
>
>
Yes, there should be an entry added to
Documentation/ABI/stable/sysfs-class-tpm.
I will fix that up and the TCG not being uppercase in a v2.
Should Documentation/ABI/stable/sysfs-class-tpm updated in
some way to reflect that those are all links under device
now and not actually there.
>> ---
>> drivers/char/tpm/tpm-sysfs.c | 34 +++++++++++++++++++++++++++-------
>> 1 file changed, 27 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
>> index edfa89160010..9372c2d6f0b3 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 major_version_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.0" : "1.2");
>> +}
>> +static DEVICE_ATTR_RO(major_version);
>> +
>> +static struct attribute *tpm12_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_major_version.attr,
>> NULL,
>> };
>>
>> -static const struct attribute_group tpm_dev_group = {
>> - .attrs = tpm_dev_attrs,
>> +static struct attribute *tpm20_dev_attrs[] = {
>> + &dev_attr_major_version.attr,
>> + NULL
>> +};
>> +
>> +static const struct attribute_group tpm12_dev_group = {
>> + .attrs = tpm12_dev_attrs,
>> +};
>> +
>> +static const struct attribute_group tpm20_dev_group = {
>> + .attrs = tpm20_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++] = &tpm20_dev_group;
>> + else
>> + chip->groups[chip->groups_cnt++] = &tpm12_dev_group;
>> }
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] tpm: Add major_version sysfs file
2019-10-25 18:45 ` Jerry Snitselaar
@ 2019-10-25 19:15 ` Mimi Zohar
2019-10-25 19:32 ` Jason Gunthorpe
1 sibling, 0 replies; 10+ messages in thread
From: Mimi Zohar @ 2019-10-25 19:15 UTC (permalink / raw)
To: Jerry Snitselaar
Cc: linux-kernel, Jarkko Sakkinen, Peter Huewe, Jason Gunthorpe,
linux-integrity
On Fri, 2019-10-25 at 11:45 -0700, Jerry Snitselaar wrote:
> On Fri Oct 25 19, Mimi Zohar wrote:
> >On Fri, 2019-10-25 at 07:28 -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 version of a tpm device.
> >
> >Use "TCG" uppercase consistently.
And "TPM"
> >
> >>
> >> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.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>
> >
> >FYI, on my system(s) the new file is accessible as
> >/sys/class/tpm/tpm0/version_major. Does this need to be documented
> >anywhere?
> >
> >
>
> Yes, there should be an entry added to
> Documentation/ABI/stable/sysfs-class-tpm.
> I will fix that up and the TCG not being uppercase in a v2.
>
> Should Documentation/ABI/stable/sysfs-class-tpm updated in
> some way to reflect that those are all links under device
> now and not actually there.
The importance is that there is a common file that can be used by
userspace applications, instead of having to search for it, not that
it is a link per-se.
Mimi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] tpm: Add major_version sysfs file
2019-10-25 18:45 ` Jerry Snitselaar
2019-10-25 19:15 ` Mimi Zohar
@ 2019-10-25 19:32 ` Jason Gunthorpe
2019-10-25 19:42 ` Mimi Zohar
1 sibling, 1 reply; 10+ messages in thread
From: Jason Gunthorpe @ 2019-10-25 19:32 UTC (permalink / raw)
To: Mimi Zohar, linux-kernel, Jarkko Sakkinen, Peter Huewe, linux-integrity
On Fri, Oct 25, 2019 at 11:45:22AM -0700, Jerry Snitselaar wrote:
> On Fri Oct 25 19, Mimi Zohar wrote:
> > On Fri, 2019-10-25 at 07:28 -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 version of a tpm device.
> >
> > Use "TCG" uppercase consistently.
> >
> > >
> > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.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>
> >
> > FYI, on my system(s) the new file is accessible as
> > /sys/class/tpm/tpm0/version_major. Does this need to be documented
> > anywhere?
> >
> >
>
> Yes, there should be an entry added to
> Documentation/ABI/stable/sysfs-class-tpm.
> I will fix that up and the TCG not being uppercase in a v2.
>
> Should Documentation/ABI/stable/sysfs-class-tpm updated in
> some way to reflect that those are all links under device
> now and not actually there.
Applications should not use the link version, that path was a
mistake. The link is for compatability with old userspace.
Jason
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] tpm: Add major_version sysfs file
2019-10-25 19:32 ` Jason Gunthorpe
@ 2019-10-25 19:42 ` Mimi Zohar
2019-10-27 23:01 ` Jason Gunthorpe
0 siblings, 1 reply; 10+ messages in thread
From: Mimi Zohar @ 2019-10-25 19:42 UTC (permalink / raw)
To: Jason Gunthorpe, linux-kernel, Jarkko Sakkinen, Peter Huewe,
linux-integrity
On Fri, 2019-10-25 at 16:32 -0300, Jason Gunthorpe wrote:
> On Fri, Oct 25, 2019 at 11:45:22AM -0700, Jerry Snitselaar wrote:
> > On Fri Oct 25 19, Mimi Zohar wrote:
> > Yes, there should be an entry added to
> > Documentation/ABI/stable/sysfs-class-tpm.
> > I will fix that up and the TCG not being uppercase in a v2.
> >
> > Should Documentation/ABI/stable/sysfs-class-tpm updated in
> > some way to reflect that those are all links under device
> > now and not actually there.
>
> Applications should not use the link version, that path was a
> mistake. The link is for compatability with old userspace.
Are you suggesting that userspace has to search for the device info?
That makes no sense.
Mimi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] tpm: Add major_version sysfs file
2019-10-25 19:42 ` Mimi Zohar
@ 2019-10-27 23:01 ` Jason Gunthorpe
0 siblings, 0 replies; 10+ messages in thread
From: Jason Gunthorpe @ 2019-10-27 23:01 UTC (permalink / raw)
To: Mimi Zohar; +Cc: linux-kernel, Jarkko Sakkinen, Peter Huewe, linux-integrity
On Fri, Oct 25, 2019 at 03:42:42PM -0400, Mimi Zohar wrote:
> On Fri, 2019-10-25 at 16:32 -0300, Jason Gunthorpe wrote:
> > On Fri, Oct 25, 2019 at 11:45:22AM -0700, Jerry Snitselaar wrote:
> > > On Fri Oct 25 19, Mimi Zohar wrote:
> > > Yes, there should be an entry added to
> > > Documentation/ABI/stable/sysfs-class-tpm.
> > > I will fix that up and the TCG not being uppercase in a v2.
> > >
> > > Should Documentation/ABI/stable/sysfs-class-tpm updated in
> > > some way to reflect that those are all links under device
> > > now and not actually there.
> >
> > Applications should not use the link version, that path was a
> > mistake. The link is for compatability with old userspace.
>
> Are you suggesting that userspace has to search for the device info?
> That makes no sense.
Why would it have to search?
Jason
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] tpm: Add major_version sysfs file
2019-10-25 14:28 [PATCH] tpm: Add major_version sysfs file Jerry Snitselaar
2019-10-25 18:18 ` Mimi Zohar
@ 2019-10-27 15:35 ` Jarkko Sakkinen
2019-10-27 23:00 ` Jason Gunthorpe
1 sibling, 1 reply; 10+ messages in thread
From: Jarkko Sakkinen @ 2019-10-27 15:35 UTC (permalink / raw)
To: Jerry Snitselaar
Cc: linux-kernel, Peter Huewe, Jason Gunthorpe, linux-integrity
On Fri, Oct 25, 2019 at 07:28:47AM -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 version of a tpm device.
>
> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.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>
Please use version_major (e.g. if there is ever version_minor
they order nicely alphabetically).
/Jarkko
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] tpm: Add major_version sysfs file
2019-10-27 15:35 ` Jarkko Sakkinen
@ 2019-10-27 23:00 ` Jason Gunthorpe
2019-10-29 9:14 ` Jarkko Sakkinen
0 siblings, 1 reply; 10+ messages in thread
From: Jason Gunthorpe @ 2019-10-27 23:00 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: Jerry Snitselaar, linux-kernel, Peter Huewe, linux-integrity
On Sun, Oct 27, 2019 at 05:35:41PM +0200, Jarkko Sakkinen wrote:
> On Fri, Oct 25, 2019 at 07:28:47AM -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 version of a tpm device.
> >
> > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.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>
>
> Please use version_major (e.g. if there is ever version_minor
> they order nicely alphabetically).
That is not the convention in sysfs
Jason
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] tpm: Add major_version sysfs file
2019-10-27 23:00 ` Jason Gunthorpe
@ 2019-10-29 9:14 ` Jarkko Sakkinen
0 siblings, 0 replies; 10+ messages in thread
From: Jarkko Sakkinen @ 2019-10-29 9:14 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Jerry Snitselaar, linux-kernel, Peter Huewe, linux-integrity
On Sun, Oct 27, 2019 at 08:00:46PM -0300, Jason Gunthorpe wrote:
> On Sun, Oct 27, 2019 at 05:35:41PM +0200, Jarkko Sakkinen wrote:
> > On Fri, Oct 25, 2019 at 07:28:47AM -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 version of a tpm device.
> > >
> > > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.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>
> >
> > Please use version_major (e.g. if there is ever version_minor
> > they order nicely alphabetically).
>
> That is not the convention in sysfs
What is wrong with that name?
/Jarkko
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-10-29 9:14 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 14:28 [PATCH] tpm: Add major_version sysfs file Jerry Snitselaar
2019-10-25 18:18 ` Mimi Zohar
2019-10-25 18:45 ` Jerry Snitselaar
2019-10-25 19:15 ` Mimi Zohar
2019-10-25 19:32 ` Jason Gunthorpe
2019-10-25 19:42 ` Mimi Zohar
2019-10-27 23:01 ` Jason Gunthorpe
2019-10-27 15:35 ` Jarkko Sakkinen
2019-10-27 23:00 ` Jason Gunthorpe
2019-10-29 9:14 ` 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).