Skip to contentSkip to conversation

Allow both TPM stacks to be compiled at the same time

PATCH New Miquel Raynal 3 participants 17 messages Jul 19, 2018 – Jul 30, 2018

lore
Share & tools
lore
#0 lore raw

v2 cover Allow both TPM stacks to be compiled at the same time

It was first decided that the user would choose the TPM version (1.x or 2.x) that he wants to use at compile time. After some time the decision has been made to change this and allow both stacks (and drivers) to be compiled at the same time. The primary benefit would be to be able to compile the maximum of code with only one Sandbox configuration.

This series removes this limitation by creating a 'tpm2' command (instead of two commands named 'tpm'). While test suites must be updated to use 'tpm2' instead of 'tpm' (in case both stacks are compiled), the user will not have to change anything as U-Boot prompt will find the closest matching command by default.

In the TPM private data a version entry is added, updated by TPMv2 drivers in the ->set_version() hook added in the uclass.

This has been tested with the tpm2.py test suite on Sandbox with either only the V1, only the V2 and with both versions selected.

Thanks,
Miquèl

Changes since v1:
=================
* Added Simon's Reviewed-by tags.
* Added a patch to remove TPM_DRIVER_SELECTED stale symbol from Kconfig.
* s/int rc/int ret/
* Removed conditionals from the code.
* Moved the TPM stack version selection in the probe, removed the ->set_version() helper.

Miquel Raynal (7):
tpm: fix typo in kernel doc
tpm: compile Sandbox driver by default
tpm: remove stale symbol in Kconfig
tpm: allow TPM v1 and v2 to be compiled at the same time test/py: tpm2: switch from 'tpm' to 'tpm2' command
tpm: make TPM_V2 be compiled by default
sandbox: compile both TPM stack versions and drivers

 cmd/tpm-common.c               | 24 +++++++++++++++++++++++-
 cmd/tpm-v1.c                   |  2 +-
 cmd/tpm-v2.c                   |  4 ++--
 configs/sandbox_defconfig      |  3 +++
 drivers/tpm/Kconfig            | 13 +++++--------
 drivers/tpm/tpm-uclass.c       |  3 ---
 drivers/tpm/tpm2_tis_sandbox.c |  3 +++
 drivers/tpm/tpm2_tis_spi.c     |  4 ++++
 include/tpm-common.h           | 42 +++++++++++++++++++++++++++++++++++-------
 test/py/tests/test_tpm2.py     | 40 ++++++++++++++++++++--------------------
 10 files changed, 96 insertions(+), 42 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH v2 1/7 tpm: fix typo in kernel doc

The udevice given to the open() function of course must be opened, not closed.

---
 include/tpm-common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/tpm-common.h +1 -1
index 734c2c9d53..68bf8fd627 100644
@@ -71,7 +71,7 @@ struct tpm_ops {
 	 * After all commands have been completed the caller should call
 	 * close().
 	 *
-	 * @dev:	Device to close
+	 * @dev:	Device to open
 	 * @return 0 ok OK, -ve on error
 	 */
 	int (*open)(struct udevice *dev);
Signature · 1 line
2.14.1
#2 lore raw

PATCH v2 1/7 tpm: fix typo in kernel doc

Quoted 5 lines · Miquel Raynal

The udevice given to the open() function of course must be opened, not closed.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180730/34d0c2cf/attachment.sig>
#3 lore raw

PATCH v2 2/7 tpm: compile Sandbox driver by default

In reply to Miquel Raynal

When Sandbox and the TPM stack are both selected, compile Sandbox TPM driver by default.

---
 drivers/tpm/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
drivers/tpm/Kconfig +2 -0
index 93264ddd34..5e3fb3267f 100644
@@ -20,6 +20,7 @@ if TPM_V1 && !TPM_V2
 config TPM_TIS_SANDBOX
 	bool "Enable sandbox TPM driver"
 	depends on TPM_V1 && SANDBOX
+	default y
 	help
 	  This driver emulates a TPMv1.x, providing access to base functions
 	  such as reading and writing TPM private data. This is enough to
@@ -132,6 +133,7 @@ if TPM_V2 && !TPM_V1
 config TPM2_TIS_SANDBOX
 	bool "Enable sandbox TPMv2.x driver"
 	depends on TPM_V2 && SANDBOX
+	default y
 	select TPM_DRIVER_SELECTED
 	help
 	  This driver emulates a TPMv2.x, providing access to base functions
Signature · 1 line
2.14.1
#4 lore raw

PATCH v2 2/7 tpm: compile Sandbox driver by default

Quoted 5 lines · Miquel Raynal

When Sandbox and the TPM stack are both selected, compile Sandbox TPM driver by default.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180730/9fd40291/attachment.sig>
#5 lore raw

PATCH v2 3/7 tpm: remove stale symbol in Kconfig

In reply to Miquel Raynal

The TPM_DRIVER_SELECTED symbol was used in one of the initial series about TPMv2 but its use has been dropped, making these selects useless, remove them.

---
 drivers/tpm/Kconfig | 3 ---
 1 file changed, 3 deletions(-)
drivers/tpm/Kconfig +0 -3
index 5e3fb3267f..da1ed8fd87 100644
@@ -63,7 +63,6 @@ config TPM_TIS_I2C_BURST_LIMITATION_LEN
 config TPM_TIS_LPC
 	bool "Enable support for Infineon SLB9635/45 TPMs on LPC"
 	depends on TPM_V1 && X86
-	select TPM_DRIVER_SELECTED
 	help
 	  This driver supports Infineon TPM devices connected on the LPC bus.
 	  The usual tpm operations and the 'tpm' command can be used to talk
@@ -134,7 +133,6 @@ config TPM2_TIS_SANDBOX
 	bool "Enable sandbox TPMv2.x driver"
 	depends on TPM_V2 && SANDBOX
 	default y
-	select TPM_DRIVER_SELECTED
 	help
 	  This driver emulates a TPMv2.x, providing access to base functions
 	  such as basic configuration, PCR extension and PCR read. Extended
@@ -143,7 +141,6 @@ config TPM2_TIS_SANDBOX
 config TPM2_TIS_SPI
 	bool "Enable support for TPMv2.x SPI chips"
 	depends on TPM_V2 && DM_SPI
-	select TPM_DRIVER_SELECTED
 	help
 	  This driver supports TPMv2.x devices connected on the SPI bus.
 	  The usual TPM operations and the 'tpm' command can be used to talk
Signature · 1 line
2.14.1
#6 lore raw

PATCH v2 3/7 tpm: remove stale symbol in Kconfig

Quoted 8 lines · Miquel Raynal

The TPM_DRIVER_SELECTED symbol was used in one of the initial series about TPMv2 but its use has been dropped, making these selects useless, remove them.

---
 drivers/tpm/Kconfig | 3 ---
 1 file changed, 3 deletions(-)
#7 lore raw

PATCH v2 3/7 tpm: remove stale symbol in Kconfig

In reply to Miquel Raynal
Quoted 6 lines · Miquel Raynal

The TPM_DRIVER_SELECTED symbol was used in one of the initial series about TPMv2 but its use has been dropped, making these selects useless, remove them.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180730/b8754faf/attachment.sig>
#8 lore raw

PATCH v2 4/7 tpm: allow TPM v1 and v2 to be compiled at the same time

In reply to Miquel Raynal

While there is probably no reason to do so in a real life situation, it will allow to compile test both stacks with the same sandbox defconfig.

As we cannot define two 'tpm' commands at the same time, the command for TPM v1 is still called 'tpm' and the one for TPM v2 'tpm2'. While this is the exact command name that must be written into eg. test files, any user already using the TPM v2 stack can continue to do so by just writing 'tpm' because as long as TPM v1 support is not compiled, U-Boot prompt will search for the closest command named after 'tpm'.

The command set can also be changed at runtime (not supported yet, but ready to be), but as one can compile only either one stack or the other, there is still one spot in the code where conditionals are used: to retrieve the v1 or v2 command set.

---
 cmd/tpm-common.c               | 24 +++++++++++++++++++++++-
 cmd/tpm-v1.c                   |  2 +-
 cmd/tpm-v2.c                   |  4 ++--
 drivers/tpm/Kconfig            |  7 ++-----
 drivers/tpm/tpm-uclass.c       |  3 ---
 drivers/tpm/tpm2_tis_sandbox.c |  3 +++
 drivers/tpm/tpm2_tis_spi.c     |  4 ++++
 include/tpm-common.h           | 40 ++++++++++++++++++++++++++++++++++------
 8 files changed, 69 insertions(+), 18 deletions(-)
cmd/tpm-common.c +23 -1
index 6cf9fcc9ac..56443862c2 100644
@@ -273,12 +273,34 @@ int do_tpm_init(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 int do_tpm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	cmd_tbl_t *tpm_commands, *cmd;
+	struct tpm_chip_priv *priv;
+	struct udevice *dev;
 	unsigned int size;
+	int ret;
 
 	if (argc < 2)
 		return CMD_RET_USAGE;
 
-	tpm_commands = get_tpm_commands(&size);
+	ret = get_tpm(&dev);
+	if (ret)
+		return ret;
+
+	priv = dev_get_uclass_priv(dev);
+
+	/* Below getters return NULL if the desired stack is not built */
+	switch (priv->version) {
+	case TPM_V1:
+		tpm_commands = get_tpm1_commands(&size);
+		break;
+	case TPM_V2:
+		tpm_commands = get_tpm2_commands(&size);
+		break;
+	default:
+		tpm_commands = NULL;
+	}
+
+	if (!tpm_commands)
+		return CMD_RET_USAGE;
 
 	cmd = find_cmd_tbl(argv[1], tpm_commands, size);
 	if (!cmd)
cmd/tpm-v1.c +1 -1
index 0874c4d7ba..69870002d4 100644
@@ -608,7 +608,7 @@ static cmd_tbl_t tpm1_commands[] = {
 #endif /* CONFIG_TPM_LIST_RESOURCES */
 };
 
-cmd_tbl_t *get_tpm_commands(unsigned int *size)
+cmd_tbl_t *get_tpm1_commands(unsigned int *size)
 {
 	*size = ARRAY_SIZE(tpm1_commands);
 
cmd/tpm-v2.c +2 -2
index 38add4f462..ffbf35a75c 100644
@@ -319,14 +319,14 @@ static cmd_tbl_t tpm2_commands[] = {
 			 do_tpm_pcr_setauthvalue, "", ""),
 };
 
-cmd_tbl_t *get_tpm_commands(unsigned int *size)
+cmd_tbl_t *get_tpm2_commands(unsigned int *size)
 {
 	*size = ARRAY_SIZE(tpm2_commands);
 
 	return tpm2_commands;
 }
 
-U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a TPMv2.x command",
+U_BOOT_CMD(tpm2, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a TPMv2.x command",
 "<command> [<arguments>]\n"
 "\n"
 "info\n"
drivers/tpm/Kconfig +2 -5
index da1ed8fd87..782a620f91 100644
@@ -4,9 +4,6 @@
 
 menu "TPM support"
 
-comment "Please select only one TPM revision"
-	depends on TPM_V1 && TPM_V2
-
 config TPM_V1
 	bool "TPMv1.x support"
 	depends on TPM
@@ -15,7 +12,7 @@ config TPM_V1
 	  Major TPM versions are not compatible at all, choose either
 	  one or the other. This option enables TPMv1.x drivers/commands.
 
-if TPM_V1 && !TPM_V2
+if TPM_V1
 
 config TPM_TIS_SANDBOX
 	bool "Enable sandbox TPM driver"
@@ -127,7 +124,7 @@ config TPM_V2
 	  Major TPM versions are not compatible at all, choose either
 	  one or the other. This option enables TPMv2.x drivers/commands.
 
-if TPM_V2 && !TPM_V1
+if TPM_V2
 
 config TPM2_TIS_SANDBOX
 	bool "Enable sandbox TPMv2.x driver"
drivers/tpm/tpm-uclass.c +0 -3
index 412697eedc..c83f53ab86 100644
@@ -7,11 +7,8 @@
 #include <common.h>
 #include <dm.h>
 #include <linux/unaligned/be_byteshift.h>
-#if defined(CONFIG_TPM_V1)
 #include <tpm-v1.h>
-#elif defined(CONFIG_TPM_V2)
 #include <tpm-v2.h>
-#endif
 #include "tpm_internal.h"
 
 int tpm_open(struct udevice *dev)
drivers/tpm/tpm2_tis_sandbox.c +3 -0
index 3240cc5dba..532d27ddd9 100644
@@ -590,6 +590,9 @@ static int sandbox_tpm2_probe(struct udevice *dev)
 	struct sandbox_tpm2 *tpm = dev_get_priv(dev);
 	struct tpm_chip_priv *priv = dev_get_uclass_priv(dev);
 
+	/* Use the TPM v2 stack */
+	priv->version = TPM_V2;
+
 	memset(tpm, 0, sizeof(*tpm));
 
 	priv->pcr_count = 32;
drivers/tpm/tpm2_tis_spi.c +4 -0
index c5d17a679d..8878130bd7 100644
@@ -510,6 +510,7 @@ static int tpm_tis_spi_cleanup(struct udevice *dev)
 static int tpm_tis_spi_open(struct udevice *dev)
 {
 	struct tpm_chip *chip = dev_get_priv(dev);
+	struct tpm_chip_priv *priv = dev_get_uclass_priv(dev);
 
 	if (chip->is_open)
 		return -EBUSY;
@@ -575,6 +576,9 @@ static int tpm_tis_spi_probe(struct udevice *dev)
 	struct tpm_chip *chip = dev_get_priv(dev);
 	int ret;
 
+	/* Use the TPM v2 stack */
+	priv->version = TPM_V2;
+
 	if (IS_ENABLED(CONFIG_DM_GPIO)) {
 		struct gpio_desc reset_gpio;
 
include/tpm-common.h +34 -6
index 68bf8fd627..5f8bc6bc52 100644
@@ -26,6 +26,16 @@ enum tpm_duration {
 /* Max buffer size supported by our tpm */
 #define TPM_DEV_BUFSIZE		1260
 
+/**
+ * enum tpm_version - The version of the TPM stack to be used
+ * @TPM_V1:		Use TPM v1.x stack
+ * @TPM_V2:		Use TPM v2.x stack
+ */
+enum tpm_version {
+	TPM_V1 = 0,
+	TPM_V2,
+};
+
 /**
  * struct tpm_chip_priv - Information about a TPM, stored by the uclass
  *
@@ -33,20 +43,23 @@ enum tpm_duration {
  * communcation is attempted. If the device has an xfer() method, this is
  * not needed. There is no need to set up @buf.
  *
+ * @version:		TPM stack to be used
  * @duration_ms:	Length of each duration type in milliseconds
  * @retry_time_ms:	Time to wait before retrying receive
+ * @buf:		Buffer used during the exchanges with the chip
  * @pcr_count:		Number of PCR per bank
  * @pcr_select_min:	Minimum size in bytes of the pcrSelect array
- * @buf:		Buffer used during the exchanges with the chip
  */
 struct tpm_chip_priv {
+	enum tpm_version version;
+
 	uint duration_ms[TPM_DURATION_COUNT];
 	uint retry_time_ms;
-#if defined(CONFIG_TPM_V2)
+	u8 buf[TPM_DEV_BUFSIZE + sizeof(u8)];  /* Max buffer size + addr */
+
+	/* TPM v2 specific data */
 	uint pcr_count;
 	uint pcr_select_min;
-#endif
-	u8 buf[TPM_DEV_BUFSIZE + sizeof(u8)];  /* Max buffer size + addr */
 };
 
 /**
@@ -208,10 +221,25 @@ int tpm_xfer(struct udevice *dev, const u8 *sendbuf, size_t send_size,
 int tpm_init(void);
 
 /**
- * Retrieve the array containing all the commands.
+ * Retrieve the array containing all the v1 (resp. v2) commands.
  *
  * @return a cmd_tbl_t array.
  */
-cmd_tbl_t *get_tpm_commands(unsigned int *size);
+#if defined(CONFIG_TPM_V1)
+cmd_tbl_t *get_tpm1_commands(unsigned int *size);
+#else
+static inline cmd_tbl_t *get_tpm1_commands(unsigned int *size)
+{
+	return NULL;
+}
+#endif
+#if defined(CONFIG_TPM_V2)
+cmd_tbl_t *get_tpm2_commands(unsigned int *size);
+#else
+static inline cmd_tbl_t *get_tpm2_commands(unsigned int *size)
+{
+	return NULL;
+}
+#endif
 
 #endif /* __TPM_COMMON_H */
Signature · 1 line
2.14.1
#9 lore raw

PATCH v2 4/7 tpm: allow TPM v1 and v2 to be compiled at the same time

Quoted 16 lines · Miquel Raynal

While there is probably no reason to do so in a real life situation, it will allow to compile test both stacks with the same sandbox defconfig.

As we cannot define two 'tpm' commands at the same time, the command for TPM v1 is still called 'tpm' and the one for TPM v2 'tpm2'. While this is the exact command name that must be written into eg. test files, any user already using the TPM v2 stack can continue to do so by just writing 'tpm' because as long as TPM v1 support is not compiled, U-Boot prompt will search for the closest command named after 'tpm'.

The command set can also be changed at runtime (not supported yet, but ready to be), but as one can compile only either one stack or the other, there is still one spot in the code where conditionals are used: to retrieve the v1 or v2 command set.

Quoted 10 lines
---
 cmd/tpm-common.c               | 24 +++++++++++++++++++++++-
 cmd/tpm-v1.c                   |  2 +-
 cmd/tpm-v2.c                   |  4 ++--
 drivers/tpm/Kconfig            |  7 ++-----
 drivers/tpm/tpm-uclass.c       |  3 ---
 drivers/tpm/tpm2_tis_sandbox.c |  3 +++
 drivers/tpm/tpm2_tis_spi.c     |  4 ++++
 include/tpm-common.h           | 40 ++++++++++++++++++++++++++++++++++------
 8 files changed, 69 insertions(+), 18 deletions(-)
#10 lore raw

PATCH v2 4/7 tpm: allow TPM v1 and v2 to be compiled at the same time

In reply to Miquel Raynal
Quoted 10 lines · Miquel Raynal

While there is probably no reason to do so in a real life situation, it will allow to compile test both stacks with the same sandbox defconfig.

As we cannot define two 'tpm' commands at the same time, the command for TPM v1 is still called 'tpm' and the one for TPM v2 'tpm2'. While this is the exact command name that must be written into eg. test files, any user already using the TPM v2 stack can continue to do so by just writing 'tpm' because as long as TPM v1 support is not compiled, U-Boot prompt will search for the closest command named after 'tpm'.

Quoted 7 lines

The command set can also be changed at runtime (not supported yet, but ready to be), but as one can compile only either one stack or the other, there is still one spot in the code where conditionals are used: to retrieve the v1 or v2 command set.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180730/d4feb181/attachment.sig>
#11 lore raw

PATCH v2 5/7 test/py: tpm2: switch from 'tpm' to 'tpm2' command

In reply to Miquel Raynal

While using the 'tpm' command should work on most cases, this test suite only works with TPMv2 and since the work to make both versions build at the same time, we might end up having both 'tpm' (TPMv1) and 'tpm2' (TPMv2) commands available at the same time. Ensure this test suite always use the right one.

---
 test/py/tests/test_tpm2.py | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)
test/py/tests/test_tpm2.py +20 -20
index 01ffb3178d..3e1f42d83e 100644
@@ -29,22 +29,22 @@ def force_init(u_boot_console, force=False):
     twice will spawn an error used to detect that the TPM was not reset and no
     initialization code should be run.
     """
-    output = u_boot_console.run_command('tpm init')
+    output = u_boot_console.run_command('tpm2 init')
     if force or not 'Error' in output:
         u_boot_console.run_command('echo --- start of init ---')
-        u_boot_console.run_command('tpm startup TPM2_SU_CLEAR')
-        u_boot_console.run_command('tpm self_test full')
-        u_boot_console.run_command('tpm clear TPM2_RH_LOCKOUT')
+        u_boot_console.run_command('tpm2 startup TPM2_SU_CLEAR')
+        u_boot_console.run_command('tpm2 self_test full')
+        u_boot_console.run_command('tpm2 clear TPM2_RH_LOCKOUT')
         output = u_boot_console.run_command('echo $?')
         if not output.endswith('0'):
-            u_boot_console.run_command('tpm clear TPM2_RH_PLATFORM')
+            u_boot_console.run_command('tpm2 clear TPM2_RH_PLATFORM')
         u_boot_console.run_command('echo --- end of init ---')
 
 @pytest.mark.buildconfigspec('cmd_tpm_v2')
 def test_tpm2_init(u_boot_console):
     """Init the software stack to use TPMv2 commands."""
 
-    u_boot_console.run_command('tpm init')
+    u_boot_console.run_command('tpm2 init')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -55,7 +55,7 @@ def test_tpm2_startup(u_boot_console):
     Initiate the TPM internal state machine.
     """
 
-    u_boot_console.run_command('tpm startup TPM2_SU_CLEAR')
+    u_boot_console.run_command('tpm2 startup TPM2_SU_CLEAR')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -66,7 +66,7 @@ def test_tpm2_self_test_full(u_boot_console):
     Ask the TPM to perform all self tests to also enable full capabilities.
     """
 
-    u_boot_console.run_command('tpm self_test full')
+    u_boot_console.run_command('tpm2 self_test full')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -78,7 +78,7 @@ def test_tpm2_continue_self_test(u_boot_console):
     to enter a fully operational state.
     """
 
-    u_boot_console.run_command('tpm self_test continue')
+    u_boot_console.run_command('tpm2 self_test continue')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -95,11 +95,11 @@ def test_tpm2_clear(u_boot_console):
     PLATFORM hierarchies are also available.
     """
 
-    u_boot_console.run_command('tpm clear TPM2_RH_LOCKOUT')
+    u_boot_console.run_command('tpm2 clear TPM2_RH_LOCKOUT')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
-    u_boot_console.run_command('tpm clear TPM2_RH_PLATFORM')
+    u_boot_console.run_command('tpm2 clear TPM2_RH_PLATFORM')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -115,13 +115,13 @@ def test_tpm2_change_auth(u_boot_console):
 
     force_init(u_boot_console)
 
-    u_boot_console.run_command('tpm change_auth TPM2_RH_LOCKOUT unicorn')
+    u_boot_console.run_command('tpm2 change_auth TPM2_RH_LOCKOUT unicorn')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
-    u_boot_console.run_command('tpm clear TPM2_RH_LOCKOUT unicorn')
+    u_boot_console.run_command('tpm2 clear TPM2_RH_LOCKOUT unicorn')
     output = u_boot_console.run_command('echo $?')
-    u_boot_console.run_command('tpm clear TPM2_RH_PLATFORM')
+    u_boot_console.run_command('tpm2 clear TPM2_RH_PLATFORM')
     assert output.endswith('0')
 
 @pytest.mark.buildconfigspec('cmd_tpm_v2')
@@ -140,7 +140,7 @@ def test_tpm2_get_capability(u_boot_console):
     force_init(u_boot_console)
     ram = u_boot_utils.find_ram_base(u_boot_console)
 
-    read_cap = u_boot_console.run_command('tpm get_capability 0x6 0x20e 0x200 1') #0x%x 1' % ram)
+    read_cap = u_boot_console.run_command('tpm2 get_capability 0x6 0x20e 0x200 1') #0x%x 1' % ram)
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
     assert 'Property 0x0000020e: 0x00000000' in read_cap
@@ -163,12 +163,12 @@ def test_tpm2_dam_parameters(u_boot_console):
     ram = u_boot_utils.find_ram_base(u_boot_console)
 
     # Set the DAM parameters to known values
-    u_boot_console.run_command('tpm dam_parameters 3 10 0')
+    u_boot_console.run_command('tpm2 dam_parameters 3 10 0')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
     # Check the values have been saved
-    read_cap = u_boot_console.run_command('tpm get_capability 0x6 0x20f 0x%x 3' % ram)
+    read_cap = u_boot_console.run_command('tpm2 get_capability 0x6 0x20f 0x%x 3' % ram)
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
     assert 'Property 0x0000020f: 0x00000003' in read_cap
@@ -185,7 +185,7 @@ def test_tpm2_pcr_read(u_boot_console):
     force_init(u_boot_console)
     ram = u_boot_utils.find_ram_base(u_boot_console) + 1024
 
-    read_pcr = u_boot_console.run_command('tpm pcr_read 0 0x%x' % ram)
+    read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % ram)
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -212,11 +212,11 @@ def test_tpm2_pcr_extend(u_boot_console):
     force_init(u_boot_console)
     ram = u_boot_utils.find_ram_base(u_boot_console) + 1024
 
-    u_boot_console.run_command('tpm pcr_extend 0 0x%x' % ram)
+    u_boot_console.run_command('tpm2 pcr_extend 0 0x%x' % ram)
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
-    read_pcr = u_boot_console.run_command('tpm pcr_read 0 0x%x' % ram)
+    read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % ram)
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
     assert 'f5 a5 fd 42 d1 6a 20 30 27 98 ef 6e d3 09 97 9b' in read_pcr
Signature · 1 line
2.14.1
#12 lore raw

PATCH v2 5/7 test/py: tpm2: switch from 'tpm' to 'tpm2' command

Quoted 8 lines · Miquel Raynal

While using the 'tpm' command should work on most cases, this test suite only works with TPMv2 and since the work to make both versions build at the same time, we might end up having both 'tpm' (TPMv1) and 'tpm2' (TPMv2) commands available at the same time. Ensure this test suite always use the right one.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180730/eca07757/attachment.sig>
#13 lore raw

PATCH v2 6/7 tpm: make TPM_V2 be compiled by default

In reply to Miquel Raynal

TPM_V1 was already compiled by default. Now that both can be compiled at the same time, compiled them both by default.

---
 drivers/tpm/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/tpm/Kconfig +1 -0
index 782a620f91..94629dffd2 100644
@@ -120,6 +120,7 @@ endif # TPM_V1
 config TPM_V2
 	bool "TPMv2.x support"
 	depends on TPM
+	default y
 	help
 	  Major TPM versions are not compatible at all, choose either
 	  one or the other. This option enables TPMv2.x drivers/commands.
Signature · 1 line
2.14.1
#14 lore raw

PATCH v2 6/7 tpm: make TPM_V2 be compiled by default

Quoted 5 lines · Miquel Raynal

TPM_V1 was already compiled by default. Now that both can be compiled at the same time, compiled them both by default.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180730/5010f685/attachment.sig>
#15 lore raw

PATCH v2 7/7 sandbox: compile both TPM stack versions and drivers

In reply to Miquel Raynal

Now that TPMv1 and TPMv2 can be compiled at the same time, let's compile them both with Sandbox as well as both drivers (and, it is already implied in Kconfig: both commands).

---
 configs/sandbox_defconfig | 3 +++
 1 file changed, 3 insertions(+)
configs/sandbox_defconfig +3 -0
index 2fc84a16c9..d5756d1173 100644
@@ -176,6 +176,7 @@ CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
 CONFIG_TPM_TIS_SANDBOX=y
+CONFIG_TPM2_TIS_SANDBOX=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_USB_EMUL=y
@@ -192,6 +193,8 @@ CONFIG_FS_CBFS=y
 CONFIG_FS_CRAMFS=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_TPM=y
+CONFIG_TPM_V1=y
+CONFIG_TPM_V2=y
 CONFIG_LZ4=y
 CONFIG_ERRNO_STR=y
 CONFIG_OF_LIBFDT_OVERLAY=y
Signature · 1 line
2.14.1
#16 lore raw

PATCH v2 7/7 sandbox: compile both TPM stack versions and drivers

Quoted 6 lines · Miquel Raynal

Now that TPMv1 and TPMv2 can be compiled at the same time, let's compile them both with Sandbox as well as both drivers (and, it is already implied in Kconfig: both commands).

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180730/cf6e51bd/attachment.sig>