summaryrefslogtreecommitdiff
path: root/src/drivers/pc80/tpm
diff options
context:
space:
mode:
authorSergii Dmytruk <sergii.dmytruk@3mdeb.com>2022-10-29 16:57:07 +0300
committerFelix Held <felix-coreboot@felixheld.de>2022-12-05 14:46:43 +0000
commit0a89d5237edcec3015363e9a7a3bd8b014fec500 (patch)
tree71186da3863f0fc295ac60b60344f3c6e801eb0a /src/drivers/pc80/tpm
parent2393ad0bfb1cd23a0524e7b02a0fd75aff3bf274 (diff)
security/tpm: remove tis_close()
This function was never called from outside of drivers and src/drivers/pc80/tpm/tis.c was the only one doing it in a questionable way. tpm_vendor_cleanup() also isn't needed as one of tis_close() functions was its only caller. Change-Id: I9df76adfc21fca9fa1d1af7c40635ec0684ceb0f Ticket: https://ticket.coreboot.org/issues/433 Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/68989 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/drivers/pc80/tpm')
-rw-r--r--src/drivers/pc80/tpm/tis.c66
1 files changed, 14 insertions, 52 deletions
diff --git a/src/drivers/pc80/tpm/tis.c b/src/drivers/pc80/tpm/tis.c
index 06f543498f..ce88ae012d 100644
--- a/src/drivers/pc80/tpm/tis.c
+++ b/src/drivers/pc80/tpm/tis.c
@@ -20,6 +20,7 @@
#include <device/device.h>
#include <console/console.h>
#include <security/tpm/tis.h>
+#include <security/tpm/tss.h>
#include <device/pnp.h>
#include <drivers/tpm/tpm_ppi.h>
#include <timer.h>
@@ -316,11 +317,6 @@ static int tis_wait_access(int locality, u8 mask, u8 expected)
return TPM_TIMEOUT_ERR;
}
-static inline int tis_wait_dropped_access(int locality)
-{
- return tis_wait_access(locality, TIS_ACCESS_ACTIVE_LOCALITY, 0);
-}
-
static inline int tis_wait_received_access(int locality)
{
return tis_wait_access(locality, TIS_ACCESS_ACTIVE_LOCALITY,
@@ -337,11 +333,6 @@ static inline void tis_request_access(int locality)
tpm_write_access(TIS_ACCESS_REQUEST_USE, locality);
}
-static inline void tis_drop_access(int locality)
-{
- tpm_write_access(TIS_ACCESS_ACTIVE_LOCALITY, locality);
-}
-
/*
* PC Client Specific TPM Interface Specification section 11.2.12:
*
@@ -632,8 +623,7 @@ int tis_init(void)
/*
* tis_open()
*
- * Requests access to locality 0 for the caller. After all commands have been
- * completed the caller is supposed to call tis_close().
+ * Requests access to locality 0 for the caller.
*
* Returns 0 on success, TPM_DRIVER_ERR on failure.
*/
@@ -641,22 +631,21 @@ int tis_open(void)
{
u8 locality = 0; /* we use locality zero for everything */
- if (tis_close())
- return TPM_DRIVER_ERR;
+ if (!tis_has_access(locality)) {
+ /* request access to locality */
+ tis_request_access(locality);
- /* now request access to locality */
- tis_request_access(locality);
+ /* did we get a lock? */
+ if (tis_wait_received_access(locality)) {
+ printf("%s:%d - failed to lock locality %u\n",
+ __FILE__, __LINE__, locality);
+ return TPM_DRIVER_ERR;
+ }
- /* did we get a lock? */
- if (tis_wait_received_access(locality)) {
- printf("%s:%d - failed to lock locality %u\n",
- __FILE__, __LINE__, locality);
- return TPM_DRIVER_ERR;
+ /* Certain TPMs seem to need some delay here or they hang... */
+ udelay(10);
}
- /* Certain TPMs seem to need some delay here or they hang... */
- udelay(10);
-
if (tis_command_ready(locality) == TPM_TIMEOUT_ERR)
return TPM_DRIVER_ERR;
@@ -664,27 +653,6 @@ int tis_open(void)
}
/*
- * tis_close()
- *
- * terminate the current session with the TPM by releasing the locked
- * locality. Returns 0 on success of TPM_DRIVER_ERR on failure (in case lock
- * removal did not succeed).
- */
-int tis_close(void)
-{
- u8 locality = 0;
- if (tis_has_access(locality)) {
- tis_drop_access(locality);
- if (tis_wait_dropped_access(locality)) {
- printf("%s:%d - failed to release locality %u\n",
- __FILE__, __LINE__, locality);
- return TPM_DRIVER_ERR;
- }
- }
- return 0;
-}
-
-/*
* tis_sendrecv()
*
* Send the requested data to the TPM and then try to get its response
@@ -727,10 +695,8 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t send_size,
static int tis_setup_interrupt(int vector, int polarity)
{
u8 locality = 0;
- int has_access = tis_has_access(locality);
- /* Open connection and request access if not already granted */
- if (!has_access && tis_open() < 0)
+ if (tlcl_lib_init())
return TPM_DRIVER_ERR;
/* Set TPM interrupt vector */
@@ -739,10 +705,6 @@ static int tis_setup_interrupt(int vector, int polarity)
/* Set TPM interrupt polarity and disable interrupts */
tpm_write_int_polarity(polarity, locality);
- /* Close connection if it was opened */
- if (!has_access && tis_close() < 0)
- return TPM_DRIVER_ERR;
-
return 0;
}