Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1431232 > unrolled thread
| Started by | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| First post | 2016-06-25 23:50 +0200 |
| Last post | 2016-07-06 16:30 +0200 |
| Articles | 6 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-06-25 23:50 +0200
[PATCH v2 4/6] tpm: use tpm_transmit_cmd() in tpm2_probe() Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-06-25 23:50 +0200
[PATCH v2 3/6] tpm: return error code from tpm_gen_interrupt() Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-06-25 23:50 +0200
[PATCH v2 2/6] tpm: unify tpm_gen_interrupt() Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-06-25 23:50 +0200
[PATCH v2 1/6] tpm: remove unnecessary externs from tpm.h Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-06-25 23:50 +0200
Re: [PATCH v2 0/6] Use tpm_transmit_cmd() consistently Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-07-06 16:30 +0200
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2016-06-25 23:50 +0200 |
| Subject | [PATCH v2 0/6] Use tpm_transmit_cmd() consistently |
| Message-ID | <rO3CF-2iL-3@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2016-06-25 23:50 +0200 |
| Subject | [PATCH v2 4/6] tpm: use tpm_transmit_cmd() in tpm2_probe() |
| Message-ID | <rO3CG-2iL-15@gated-at.bofh.it> |
| In reply to | #1431232 |
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
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2016-06-25 23:50 +0200 |
| Subject | [PATCH v2 3/6] tpm: return error code from tpm_gen_interrupt() |
| Message-ID | <rO3CG-2iL-27@gated-at.bofh.it> |
| In reply to | #1431232 |
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
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2016-06-25 23:50 +0200 |
| Subject | [PATCH v2 2/6] tpm: unify tpm_gen_interrupt() |
| Message-ID | <rO3CG-2iL-37@gated-at.bofh.it> |
| In reply to | #1431232 |
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
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2016-06-25 23:50 +0200 |
| Subject | [PATCH v2 1/6] tpm: remove unnecessary externs from tpm.h |
| Message-ID | <rO3CG-2iL-47@gated-at.bofh.it> |
| In reply to | #1431232 |
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
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2016-07-06 16:30 +0200 |
| Message-ID | <rRVZT-1T1-11@gated-at.bofh.it> |
| In reply to | #1431232 |
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 >
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web