svn commit: r357388 - head/sys/dev/tpm

Dimitry Andric dim at FreeBSD.org
Sat Feb 1 21:43:46 UTC 2020


Author: dim
Date: Sat Feb  1 21:43:45 2020
New Revision: 357388
URL: https://svnweb.freebsd.org/changeset/base/357388

Log:
  Amend r357367 by using register values from the TPM datasheet.
  
  As Ian Lepore noted, writing ~1 to a register might have a completely
  different effect than doing a regular read-modify-write operation.
  
  Follow the TCG_PC_Client_Platform_TPM_Profile_PTP_2.0_r1.03_v22
  datasheet instead, and use the actual values mentioned there:
  (uint32_t)1 to cancel the command, (uint32_t)0 to clear the field.
  
  MFC after:	3 days

Modified:
  head/sys/dev/tpm/tpm_crb.c

Modified: head/sys/dev/tpm/tpm_crb.c
==============================================================================
--- head/sys/dev/tpm/tpm_crb.c	Sat Feb  1 20:38:38 2020	(r357387)
+++ head/sys/dev/tpm/tpm_crb.c	Sat Feb  1 21:43:45 2020	(r357388)
@@ -70,7 +70,8 @@ __FBSDID("$FreeBSD$");
 #define	TPM_CRB_CTRL_STS_ERR_BIT	BIT(0)
 #define	TPM_CRB_CTRL_STS_IDLE_BIT	BIT(1)
 
-#define	TPM_CRB_CTRL_CANCEL_CMD		BIT(0)
+#define	TPM_CRB_CTRL_CANCEL_CMD		0x1
+#define	TPM_CRB_CTRL_CANCEL_CLEAR	0x0
 
 #define	TPM_CRB_CTRL_START_CMD		BIT(0)
 
@@ -298,7 +299,7 @@ tpmcrb_cancel_cmd(struct tpm_sc *sc)
 		return (false);
 	}
 
-	WR4(sc, TPM_CRB_CTRL_CANCEL, ~TPM_CRB_CTRL_CANCEL_CMD);
+	WR4(sc, TPM_CRB_CTRL_CANCEL, TPM_CRB_CTRL_CANCEL_CLEAR;
 	return (true);
 }
 
@@ -330,7 +331,7 @@ tpmcrb_transmit(struct tpm_sc *sc, size_t length)
 		return (EIO);
 	}
 	/* Clear cancellation bit */
-	WR4(sc, TPM_CRB_CTRL_CANCEL, ~TPM_CRB_CTRL_CANCEL_CMD);
+	WR4(sc, TPM_CRB_CTRL_CANCEL, TPM_CRB_CTRL_CANCEL_CLEAR;
 
 	/* Switch device to idle state if necessary */
 	if (!(RD4(sc, TPM_CRB_CTRL_STS) & TPM_CRB_CTRL_STS_IDLE_BIT)) {


More information about the svn-src-head mailing list