* [PATCH v2 0/6] Use tpm_transmit_cmd() consistently
@ 2016-06-25 21:44 Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 1/6] tpm: remove unnecessary externs from tpm.h Jarkko Sakkinen
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Jarkko Sakkinen @ 2016-06-25 21:44 UTC (permalink / raw)
To: Peter Huewe, Jason Gunthorpe
Cc: linux-security-module, Stefan Berger, Jarkko Sakkinen, open list,
moderated list:TPM DEVICE DRIVER
These commits update the subsystem consistently to use
tpm_transmit_cmd() throughout the subsystem the exception being
tpm_write() where it makes sense to use the raw interface because higher
level command handling is delegated to user space.
v2: Added commit that drops externs from all function declarations in
tpm.h as suggested by Jason Gunthorpe.
Jarkko Sakkinen (6):
tpm: remove unnecessary externs from tpm.h
tpm: unify tpm_gen_interrupt()
tpm: return error code from tpm_gen_interrupt()
tpm: use tpm_transmit_cmd() in tpm2_probe()
tpm: rename tpm_pcr_read_dev() to tpm1_pcr_read()
tpm: use tpm1_pcr_read() in tpm_do_selftest()
drivers/char/tpm/tpm-interface.c | 36 ++++++++++++++++++----------------
drivers/char/tpm/tpm-sysfs.c | 2 +-
drivers/char/tpm/tpm.h | 42 +++++++++++++++++++---------------------
drivers/char/tpm/tpm2-cmd.c | 21 +-------------------
drivers/char/tpm/tpm_tis_core.c | 7 +++----
5 files changed, 44 insertions(+), 64 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/6] tpm: remove unnecessary externs from tpm.h
2016-06-25 21:44 [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
@ 2016-06-25 21:44 ` Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 2/6] tpm: unify tpm_gen_interrupt() Jarkko Sakkinen
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Jarkko Sakkinen @ 2016-06-25 21:44 UTC (permalink / raw)
To: Peter Huewe, Jason Gunthorpe
Cc: linux-security-module, Stefan Berger, Jarkko Sakkinen,
Marcel Selhorst, moderated list:TPM DEVICE DRIVER, open list
Removed unnecessary externs from tpm.h.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
drivers/char/tpm/tpm.h | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 8890df2..80b5fa4 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -482,25 +482,25 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
size_t bufsiz);
ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, int len,
const char *desc);
-extern int tpm_get_timeouts(struct tpm_chip *);
-extern void tpm_gen_interrupt(struct tpm_chip *);
-extern int tpm_do_selftest(struct tpm_chip *);
-extern unsigned long tpm_calc_ordinal_duration(struct tpm_chip *, u32);
-extern int tpm_pm_suspend(struct device *);
-extern int tpm_pm_resume(struct device *);
-extern int wait_for_tpm_stat(struct tpm_chip *, u8, unsigned long,
- wait_queue_head_t *, bool);
+int tpm_get_timeouts(struct tpm_chip *chip);
+void tpm_gen_interrupt(struct tpm_chip *chip);
+int tpm_do_selftest(struct tpm_chip *chip);
+unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
+int tpm_pm_suspend(struct device *dev);
+int tpm_pm_resume(struct device *dev);
+int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
+ wait_queue_head_t *queue, bool check_cancel);
struct tpm_chip *tpm_chip_find_get(int chip_num);
__must_check int tpm_try_get_ops(struct tpm_chip *chip);
void tpm_put_ops(struct tpm_chip *chip);
-extern struct tpm_chip *tpm_chip_alloc(struct device *dev,
- const struct tpm_class_ops *ops);
-extern struct tpm_chip *tpmm_chip_alloc(struct device *pdev,
- const struct tpm_class_ops *ops);
-extern int tpm_chip_register(struct tpm_chip *chip);
-extern void tpm_chip_unregister(struct tpm_chip *chip);
+struct tpm_chip *tpm_chip_alloc(struct device *dev,
+ const struct tpm_class_ops *ops);
+struct tpm_chip *tpmm_chip_alloc(struct device *pdev,
+ const struct tpm_class_ops *ops);
+int tpm_chip_register(struct tpm_chip *chip);
+void tpm_chip_unregister(struct tpm_chip *chip);
void tpm_sysfs_add_device(struct tpm_chip *chip);
@@ -526,10 +526,10 @@ int tpm2_unseal_trusted(struct tpm_chip *chip,
ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id,
u32 *value, const char *desc);
-extern int tpm2_startup(struct tpm_chip *chip, u16 startup_type);
-extern void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
-extern unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *, u32);
-extern int tpm2_do_selftest(struct tpm_chip *chip);
-extern int tpm2_gen_interrupt(struct tpm_chip *chip);
-extern int tpm2_probe(struct tpm_chip *chip);
+int tpm2_startup(struct tpm_chip *chip, u16 startup_type);
+void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
+unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
+int tpm2_do_selftest(struct tpm_chip *chip);
+int tpm2_gen_interrupt(struct tpm_chip *chip);
+int tpm2_probe(struct tpm_chip *chip);
#endif
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/6] tpm: unify tpm_gen_interrupt()
2016-06-25 21:44 [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 1/6] tpm: remove unnecessary externs from tpm.h Jarkko Sakkinen
@ 2016-06-25 21:44 ` Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 3/6] tpm: return error code from tpm_gen_interrupt() Jarkko Sakkinen
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Jarkko Sakkinen @ 2016-06-25 21:44 UTC (permalink / raw)
To: Peter Huewe, Jason Gunthorpe
Cc: linux-security-module, Stefan Berger, Jarkko Sakkinen,
Marcel Selhorst, moderated list:TPM DEVICE DRIVER, open list
Migrated into single tpm_gen_interrupt() function and cleaned up the
whole construction in general because it was starting to turn into a
train wreck.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
drivers/char/tpm/tpm-interface.c | 23 ++++++++++++++---------
drivers/char/tpm/tpm.h | 2 --
drivers/char/tpm/tpm2-cmd.c | 17 -----------------
drivers/char/tpm/tpm_tis_core.c | 5 +----
4 files changed, 15 insertions(+), 32 deletions(-)
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 5e3c1b6..e953618 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -459,18 +459,23 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
return rc;
}
+/**
+ * tpm_gen_interrupt -- generate an interrupt by issuing an idempotent command
+ * @chip: TPM chip to use
+ *
+ * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
+ * a TPM error code.
+ */
void tpm_gen_interrupt(struct tpm_chip *chip)
{
- struct tpm_cmd_t tpm_cmd;
- ssize_t rc;
+ const char *desc = "attempting to generate an interrupt";
+ u32 cap2;
+ cap_t cap;
- tpm_cmd.header.in = tpm_getcap_header;
- tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
- tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
- tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
-
- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
- "attempting to determine the timeouts");
+ if (chip->flags & TPM_CHIP_FLAG_TPM2)
+ tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
+ else
+ tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc);
}
EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 80b5fa4..0f16d18 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -525,11 +525,9 @@ int tpm2_unseal_trusted(struct tpm_chip *chip,
struct trusted_key_options *options);
ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id,
u32 *value, const char *desc);
-
int tpm2_startup(struct tpm_chip *chip, u16 startup_type);
void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
int tpm2_do_selftest(struct tpm_chip *chip);
-int tpm2_gen_interrupt(struct tpm_chip *chip);
int tpm2_probe(struct tpm_chip *chip);
#endif
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index a1673dc..77ef027 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -897,23 +897,6 @@ int tpm2_do_selftest(struct tpm_chip *chip)
EXPORT_SYMBOL_GPL(tpm2_do_selftest);
/**
- * tpm2_gen_interrupt() - generate an interrupt
- * @chip: TPM chip to use
- *
- * 0 is returned when the operation is successful. If a negative number is
- * returned it remarks a POSIX error code. If a positive number is returned
- * it remarks a TPM error.
- */
-int tpm2_gen_interrupt(struct tpm_chip *chip)
-{
- u32 dummy;
-
- return tpm2_get_tpm_pt(chip, 0x100, &dummy,
- "attempting to generate an interrupt");
-}
-EXPORT_SYMBOL_GPL(tpm2_gen_interrupt);
-
-/**
* tpm2_probe() - probe TPM 2.0
* @chip: TPM chip to use
*
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 03a06b3..c7dc58d 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -580,10 +580,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
/* Generate an interrupt by having the core call through to
* tpm_tis_send
*/
- if (chip->flags & TPM_CHIP_FLAG_TPM2)
- tpm2_gen_interrupt(chip);
- else
- tpm_gen_interrupt(chip);
+ tpm_gen_interrupt(chip);
/* tpm_tis_send will either confirm the interrupt is working or it
* will call disable_irq which undoes all of the above.
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/6] tpm: return error code from tpm_gen_interrupt()
2016-06-25 21:44 [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 1/6] tpm: remove unnecessary externs from tpm.h Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 2/6] tpm: unify tpm_gen_interrupt() Jarkko Sakkinen
@ 2016-06-25 21:44 ` Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 4/6] tpm: use tpm_transmit_cmd() in tpm2_probe() Jarkko Sakkinen
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Jarkko Sakkinen @ 2016-06-25 21:44 UTC (permalink / raw)
To: Peter Huewe, Jason Gunthorpe
Cc: linux-security-module, Stefan Berger, Jarkko Sakkinen,
Marcel Selhorst, moderated list:TPM DEVICE DRIVER, open list
Return error code from tpm_gen_interrupt() and fail tpm_tis family of
drivers on a system error. It doesn't make sense to continue if we
cannot even reach the TPM.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
drivers/char/tpm/tpm-interface.c | 6 +++---
drivers/char/tpm/tpm.h | 2 +-
drivers/char/tpm/tpm_tis_core.c | 4 +++-
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index e953618..4aeacf3 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
* Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
* a TPM error code.
*/
-void tpm_gen_interrupt(struct tpm_chip *chip)
+int tpm_gen_interrupt(struct tpm_chip *chip)
{
const char *desc = "attempting to generate an interrupt";
u32 cap2;
cap_t cap;
if (chip->flags & TPM_CHIP_FLAG_TPM2)
- tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
+ return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
else
- tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc);
+ return tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc);
}
EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 0f16d18..8153f93 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -483,7 +483,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, int len,
const char *desc);
int tpm_get_timeouts(struct tpm_chip *chip);
-void tpm_gen_interrupt(struct tpm_chip *chip);
+int tpm_gen_interrupt(struct tpm_chip *chip);
int tpm_do_selftest(struct tpm_chip *chip);
unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
int tpm_pm_suspend(struct device *dev);
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index c7dc58d..79168ca 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -580,7 +580,9 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
/* Generate an interrupt by having the core call through to
* tpm_tis_send
*/
- tpm_gen_interrupt(chip);
+ rc = tpm_gen_interrupt(chip);
+ if (rc < 0)
+ return rc;
/* tpm_tis_send will either confirm the interrupt is working or it
* will call disable_irq which undoes all of the above.
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 4/6] tpm: use tpm_transmit_cmd() in tpm2_probe()
2016-06-25 21:44 [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
` (2 preceding siblings ...)
2016-06-25 21:44 ` [PATCH v2 3/6] tpm: return error code from tpm_gen_interrupt() Jarkko Sakkinen
@ 2016-06-25 21:44 ` Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 5/6] tpm: rename tpm_pcr_read_dev() to tpm1_pcr_read() Jarkko Sakkinen
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Jarkko Sakkinen @ 2016-06-25 21:44 UTC (permalink / raw)
To: Peter Huewe, Jason Gunthorpe
Cc: linux-security-module, Stefan Berger, Jarkko Sakkinen,
Marcel Selhorst, moderated list:TPM DEVICE DRIVER, open list
It is better to tpm_transmit_cmd() in tpm2_probe() in order to get
consistent command handling throughout the subsystem.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
drivers/char/tpm/tpm2-cmd.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 77ef027..a43e51a 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -913,11 +913,9 @@ int tpm2_probe(struct tpm_chip *chip)
cmd.params.get_tpm_pt_in.property_id = cpu_to_be32(0x100);
cmd.params.get_tpm_pt_in.property_cnt = cpu_to_be32(1);
- rc = tpm_transmit(chip, (const char *) &cmd, sizeof(cmd));
+ rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), NULL);
if (rc < 0)
return rc;
- else if (rc < TPM_HEADER_SIZE)
- return -EFAULT;
if (be16_to_cpu(cmd.header.out.tag) == TPM2_ST_NO_SESSIONS)
chip->flags |= TPM_CHIP_FLAG_TPM2;
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 5/6] tpm: rename tpm_pcr_read_dev() to tpm1_pcr_read()
2016-06-25 21:44 [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
` (3 preceding siblings ...)
2016-06-25 21:44 ` [PATCH v2 4/6] tpm: use tpm_transmit_cmd() in tpm2_probe() Jarkko Sakkinen
@ 2016-06-25 21:44 ` Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 6/6] tpm: use tpm1_pcr_read() in tpm_do_selftest() Jarkko Sakkinen
2016-07-06 14:21 ` [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
6 siblings, 0 replies; 9+ messages in thread
From: Jarkko Sakkinen @ 2016-06-25 21:44 UTC (permalink / raw)
To: Peter Huewe, Jason Gunthorpe
Cc: linux-security-module, Stefan Berger, Jarkko Sakkinen,
Marcel Selhorst, moderated list:TPM DEVICE DRIVER, open list
Gave more consistent name tpm1_pcr_read() as the TPM2 version is called
tpm2_pcr_read().
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
drivers/char/tpm/tpm-interface.c | 4 ++--
drivers/char/tpm/tpm-sysfs.c | 2 +-
drivers/char/tpm/tpm.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 4aeacf3..3995f5c 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -670,7 +670,7 @@ static struct tpm_input_header pcrread_header = {
.ordinal = TPM_ORDINAL_PCRREAD
};
-int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf)
+int tpm1_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf)
{
int rc;
struct tpm_cmd_t cmd;
@@ -732,7 +732,7 @@ int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf)
if (chip->flags & TPM_CHIP_FLAG_TPM2)
rc = tpm2_pcr_read(chip, pcr_idx, res_buf);
else
- rc = tpm_pcr_read_dev(chip, pcr_idx, res_buf);
+ rc = tpm1_pcr_read(chip, pcr_idx, res_buf);
tpm_put_ops(chip);
return rc;
}
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index b46cf70..a89d0e2 100644
--- a/drivers/char/tpm/tpm-sysfs.c
+++ b/drivers/char/tpm/tpm-sysfs.c
@@ -101,7 +101,7 @@ static ssize_t pcrs_show(struct device *dev, struct device_attribute *attr,
num_pcrs = be32_to_cpu(cap.num_pcrs);
for (i = 0; i < num_pcrs; i++) {
- rc = tpm_pcr_read_dev(chip, i, digest);
+ rc = tpm1_pcr_read(chip, i, digest);
if (rc)
break;
str += sprintf(str, "PCR-%02d: ", i);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 8153f93..9b34e3b 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -504,7 +504,7 @@ void tpm_chip_unregister(struct tpm_chip *chip);
void tpm_sysfs_add_device(struct tpm_chip *chip);
-int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf);
+int tpm1_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf);
#ifdef CONFIG_ACPI
extern void tpm_add_ppi(struct tpm_chip *chip);
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 6/6] tpm: use tpm1_pcr_read() in tpm_do_selftest()
2016-06-25 21:44 [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
` (4 preceding siblings ...)
2016-06-25 21:44 ` [PATCH v2 5/6] tpm: rename tpm_pcr_read_dev() to tpm1_pcr_read() Jarkko Sakkinen
@ 2016-06-25 21:44 ` Jarkko Sakkinen
2016-07-06 14:21 ` [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
6 siblings, 0 replies; 9+ messages in thread
From: Jarkko Sakkinen @ 2016-06-25 21:44 UTC (permalink / raw)
To: Peter Huewe, Jason Gunthorpe
Cc: linux-security-module, Stefan Berger, Jarkko Sakkinen,
Marcel Selhorst, moderated list:TPM DEVICE DRIVER, open list
Remove ad-hoc protocol message construction and call instead
tpm1_pcr_read().
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
drivers/char/tpm/tpm-interface.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 3995f5c..d0899fb 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -797,7 +797,7 @@ int tpm_do_selftest(struct tpm_chip *chip)
unsigned int loops;
unsigned int delay_msec = 100;
unsigned long duration;
- struct tpm_cmd_t cmd;
+ u8 dummy[TPM_DIGEST_SIZE];
duration = tpm_calc_ordinal_duration(chip, TPM_ORD_CONTINUE_SELFTEST);
@@ -812,9 +812,7 @@ int tpm_do_selftest(struct tpm_chip *chip)
do {
/* Attempt to read a PCR value */
- cmd.header.in = pcrread_header;
- cmd.params.pcrread_in.pcr_idx = cpu_to_be32(0);
- rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE);
+ rc = tpm1_pcr_read(chip, 0, dummy);
/* Some buggy TPMs will not respond to tpm_tis_ready() for
* around 300ms while the self test is ongoing, keep trying
* until the self test duration expires. */
@@ -829,7 +827,6 @@ int tpm_do_selftest(struct tpm_chip *chip)
if (rc < TPM_HEADER_SIZE)
return -EFAULT;
- rc = be32_to_cpu(cmd.header.out.return_code);
if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) {
dev_info(&chip->dev,
"TPM is disabled/deactivated (0x%X)\n", rc);
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/6] Use tpm_transmit_cmd() consistently
2016-06-25 21:44 [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
` (5 preceding siblings ...)
2016-06-25 21:44 ` [PATCH v2 6/6] tpm: use tpm1_pcr_read() in tpm_do_selftest() Jarkko Sakkinen
@ 2016-07-06 14:21 ` Jarkko Sakkinen
2016-07-18 18:10 ` [tpmdd-devel] " Jarkko Sakkinen
6 siblings, 1 reply; 9+ messages in thread
From: Jarkko Sakkinen @ 2016-07-06 14:21 UTC (permalink / raw)
To: Peter Huewe, Jason Gunthorpe
Cc: linux-security-module, Stefan Berger, open list,
moderated list:TPM DEVICE DRIVER
Pending for reviews. These are quite trivial patches.
/Jarkko
On Sun, Jun 26, 2016 at 12:44:45AM +0300, Jarkko Sakkinen wrote:
> These commits update the subsystem consistently to use
> tpm_transmit_cmd() throughout the subsystem the exception being
> tpm_write() where it makes sense to use the raw interface because higher
> level command handling is delegated to user space.
>
> v2: Added commit that drops externs from all function declarations in
> tpm.h as suggested by Jason Gunthorpe.
>
> Jarkko Sakkinen (6):
> tpm: remove unnecessary externs from tpm.h
> tpm: unify tpm_gen_interrupt()
> tpm: return error code from tpm_gen_interrupt()
> tpm: use tpm_transmit_cmd() in tpm2_probe()
> tpm: rename tpm_pcr_read_dev() to tpm1_pcr_read()
> tpm: use tpm1_pcr_read() in tpm_do_selftest()
>
> drivers/char/tpm/tpm-interface.c | 36 ++++++++++++++++++----------------
> drivers/char/tpm/tpm-sysfs.c | 2 +-
> drivers/char/tpm/tpm.h | 42 +++++++++++++++++++---------------------
> drivers/char/tpm/tpm2-cmd.c | 21 +-------------------
> drivers/char/tpm/tpm_tis_core.c | 7 +++----
> 5 files changed, 44 insertions(+), 64 deletions(-)
>
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [tpmdd-devel] [PATCH v2 0/6] Use tpm_transmit_cmd() consistently
2016-07-06 14:21 ` [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
@ 2016-07-18 18:10 ` Jarkko Sakkinen
0 siblings, 0 replies; 9+ messages in thread
From: Jarkko Sakkinen @ 2016-07-18 18:10 UTC (permalink / raw)
To: Peter Huewe, Jason Gunthorpe
Cc: linux-security-module, moderated list:TPM DEVICE DRIVER, open list
On Wed, Jul 06, 2016 at 05:21:43PM +0300, Jarkko Sakkinen wrote:
> Pending for reviews. These are quite trivial patches.
>
> /Jarkko
>
> On Sun, Jun 26, 2016 at 12:44:45AM +0300, Jarkko Sakkinen wrote:
> > These commits update the subsystem consistently to use
> > tpm_transmit_cmd() throughout the subsystem the exception being
> > tpm_write() where it makes sense to use the raw interface because higher
> > level command handling is delegated to user space.
> >
> > v2: Added commit that drops externs from all function declarations in
> > tpm.h as suggested by Jason Gunthorpe.
Jason, do you think I could apply these to master or do you see
anything wrong in them?
/Jarkko
> > Jarkko Sakkinen (6):
> > tpm: remove unnecessary externs from tpm.h
> > tpm: unify tpm_gen_interrupt()
> > tpm: return error code from tpm_gen_interrupt()
> > tpm: use tpm_transmit_cmd() in tpm2_probe()
> > tpm: rename tpm_pcr_read_dev() to tpm1_pcr_read()
> > tpm: use tpm1_pcr_read() in tpm_do_selftest()
> >
> > drivers/char/tpm/tpm-interface.c | 36 ++++++++++++++++++----------------
> > drivers/char/tpm/tpm-sysfs.c | 2 +-
> > drivers/char/tpm/tpm.h | 42 +++++++++++++++++++---------------------
> > drivers/char/tpm/tpm2-cmd.c | 21 +-------------------
> > drivers/char/tpm/tpm_tis_core.c | 7 +++----
> > 5 files changed, 44 insertions(+), 64 deletions(-)
> >
> > --
> > 2.7.4
> >
>
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> _______________________________________________
> tpmdd-devel mailing list
> tpmdd-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-07-18 18:11 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-25 21:44 [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 1/6] tpm: remove unnecessary externs from tpm.h Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 2/6] tpm: unify tpm_gen_interrupt() Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 3/6] tpm: return error code from tpm_gen_interrupt() Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 4/6] tpm: use tpm_transmit_cmd() in tpm2_probe() Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 5/6] tpm: rename tpm_pcr_read_dev() to tpm1_pcr_read() Jarkko Sakkinen
2016-06-25 21:44 ` [PATCH v2 6/6] tpm: use tpm1_pcr_read() in tpm_do_selftest() Jarkko Sakkinen
2016-07-06 14:21 ` [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen
2016-07-18 18:10 ` [tpmdd-devel] " 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).