[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241102062259.2521361-2-jarkko@kernel.org>
Date: Sat, 2 Nov 2024 08:22:57 +0200
From: Jarkko Sakkinen <jarkko@...nel.org>
To: jarkko@...nel.org,
Peter Huewe <peterhuewe@....de>,
Jason Gunthorpe <jgg@...pe.ca>
Cc: James.Bottomley@...senpartnership.com,
andrew.cooper3@...rix.com,
ardb@...nel.org,
baolu.lu@...ux.intel.com,
bp@...en8.de,
corbet@....net,
dave.hansen@...ux.intel.com,
davem@...emloft.net,
dpsmith@...rtussolutions.com,
dwmw2@...radead.org,
ebiederm@...ssion.com,
herbert@...dor.apana.org.au,
hpa@...or.com,
iommu@...ts.linux-foundation.org,
kanth.ghatraju@...cle.com,
kexec@...ts.infradead.org,
linux-crypto@...r.kernel.org,
linux-doc@...r.kernel.org,
linux-efi@...r.kernel.org,
linux-integrity@...r.kernel.org,
linux-kernel@...r.kernel.org,
luto@...capital.net,
mingo@...hat.com,
mjg59@...f.ucam.org,
nivedita@...m.mit.edu,
ross.philipson@...cle.com,
tglx@...utronix.de,
trenchboot-devel@...glegroups.com,
x86@...nel.org
Subject: [RFC PATCH v2 2/2] tpm: show the default locality in sysfs
From: Ross Philipson <ross.philipson@...cle.com>
Expose the default locality as read-only attribute through sysfs.
Signed-off-by: Ross Philipson <ross.philipson@...cle.com>
Signed-off-by: Jarkko Sakkinen <jarkko@...nel.org>
---
v2:
- A new patch.
- Import from the original Trenchboot patch set.
- Drop the store operation.
- Tested with https://codeberg.org/jarkko/tpm-set-locality-test/src/branch/main/src/main.rs
---
drivers/char/tpm/tpm-sysfs.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index 94231f052ea7..4f5e60b1e4c9 100644
--- a/drivers/char/tpm/tpm-sysfs.c
+++ b/drivers/char/tpm/tpm-sysfs.c
@@ -309,6 +309,14 @@ static ssize_t tpm_version_major_show(struct device *dev,
}
static DEVICE_ATTR_RO(tpm_version_major);
+static ssize_t locality_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct tpm_chip *chip = to_tpm_chip(dev);
+
+ return sprintf(buf, "%d\n", chip->default_locality);
+}
+static DEVICE_ATTR_RO(locality);
+
#ifdef CONFIG_TCG_TPM2_HMAC
static ssize_t null_name_show(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -336,6 +344,7 @@ static struct attribute *tpm1_dev_attrs[] = {
&dev_attr_durations.attr,
&dev_attr_timeouts.attr,
&dev_attr_tpm_version_major.attr,
+ &dev_attr_locality.attr,
NULL,
};
@@ -344,6 +353,7 @@ static struct attribute *tpm2_dev_attrs[] = {
#ifdef CONFIG_TCG_TPM2_HMAC
&dev_attr_null_name.attr,
#endif
+ &dev_attr_locality.attr,
NULL
};
--
2.47.0
Powered by blists - more mailing lists