linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PULL] TPM: Smarter iTPM probing
@ 2012-02-14 19:01 Rajiv Andrade
  2012-02-14 23:44 ` James Morris
  0 siblings, 1 reply; 2+ messages in thread
From: Rajiv Andrade @ 2012-02-14 19:01 UTC (permalink / raw)
  To: James Morris, linux-kernel; +Cc: Tim Gardner, Stefan Berger

Hi James,

Please pull into your next branch the following changes since 
commit 4040153087478993cbf0809f444400a3c808074c:

  security: trim security.h (2012-02-14 10:45:42 +1100)

that are available in the git repository at:
  git://github.com/srajiv/tpm.git for-james

Stefan Berger (2):
      tpm_tis: Only probe iTPMs
      tpm_tis: Clean up after module_param cleanup

Tim Gardner (1):
      TPM: Zero buffer whole after copying to userspace

 drivers/char/tpm/tpm.c     |    3 ++-
 drivers/char/tpm/tpm.h     |    2 ++
 drivers/char/tpm/tpm_tis.c |   17 ++++++++++-------
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 32362cf..ad7c732 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1221,12 +1221,13 @@ ssize_t tpm_read(struct file *file, char __user *buf,
 	ret_size = atomic_read(&chip->data_pending);
 	atomic_set(&chip->data_pending, 0);
 	if (ret_size > 0) {	/* relay data */
+		ssize_t orig_ret_size = ret_size;
 		if (size < ret_size)
 			ret_size = size;
 
 		mutex_lock(&chip->buffer_mutex);
 		rc = copy_to_user(buf, chip->data_buffer, ret_size);
-		memset(chip->data_buffer, 0, ret_size);
+		memset(chip->data_buffer, 0, orig_ret_size);
 		if (rc)
 			ret_size = -EFAULT;
 
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 0105471..b1c5280 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -99,6 +99,8 @@ struct tpm_vendor_specific {
 	wait_queue_head_t int_queue;
 };
 
+#define TPM_VID_INTEL    0x8086
+
 struct tpm_chip {
 	struct device *dev;	/* Device stuff */
 
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index a174862..1250e33 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -367,7 +367,12 @@ static int probe_itpm(struct tpm_chip *chip)
 		0x00, 0x00, 0x00, 0xf1
 	};
 	size_t len = sizeof(cmd_getticks);
-	int rem_itpm = itpm;
+	bool rem_itpm = itpm;
+	u16 vendor = ioread16(chip->vendor.iobase + TPM_DID_VID(0));
+
+	/* probe only iTPMS */
+	if (vendor != TPM_VID_INTEL)
+		return 0;
 
 	itpm = 0;
 
@@ -390,9 +395,6 @@ static int probe_itpm(struct tpm_chip *chip)
 out:
 	itpm = rem_itpm;
 	tpm_tis_ready(chip);
-	/* some TPMs need a break here otherwise they will not work
-	 * correctly on the immediately subsequent command */
-	msleep(chip->vendor.timeout_b);
 	release_locality(chip, chip->vendor.locality, 0);
 
 	return rc;
@@ -508,7 +510,7 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
 			resource_size_t len, unsigned int irq)
 {
 	u32 vendor, intfcaps, intmask;
-	int rc, i, irq_s, irq_e;
+	int rc, i, irq_s, irq_e, probe;
 	struct tpm_chip *chip;
 
 	if (!(chip = tpm_register_hardware(dev, &tpm_tis)))
@@ -538,11 +540,12 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
 		 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0)));
 
 	if (!itpm) {
-		itpm = probe_itpm(chip);
-		if (itpm < 0) {
+		probe = probe_itpm(chip);
+		if (probe < 0) {
 			rc = -ENODEV;
 			goto out_err;
 		}
+		itpm = (probe == 0) ? 0 : 1;
 	}
 
 	if (itpm)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PULL] TPM: Smarter iTPM probing
  2012-02-14 19:01 [PULL] TPM: Smarter iTPM probing Rajiv Andrade
@ 2012-02-14 23:44 ` James Morris
  0 siblings, 0 replies; 2+ messages in thread
From: James Morris @ 2012-02-14 23:44 UTC (permalink / raw)
  To: Rajiv Andrade; +Cc: linux-kernel, Tim Gardner, Stefan Berger

On Tue, 14 Feb 2012, Rajiv Andrade wrote:

> Hi James,
> 
> Please pull into your next branch the following changes since commit
> 4040153087478993cbf0809f444400a3c808074c:
> 
>  security: trim security.h (2012-02-14 10:45:42 +1100)
> 
> that are available in the git repository at:
>  git://github.com/srajiv/tpm.git for-james

Applied, thanks.

-- 
James Morris
<jmorris@namei.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-14 23:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-14 19:01 [PULL] TPM: Smarter iTPM probing Rajiv Andrade
2012-02-14 23:44 ` James Morris

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).