[SeaBIOS] [PATCH 5/6] tpm: Don't call tpm_build_and_send_cmd() from tpm20_stirrandom()
Kevin O'Connor
kevin at koconnor.net
Thu Aug 11 17:18:02 CEST 2016
Instead call tpmhw_transmit() directly.
Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
src/std/tcg.h | 3 ++-
src/tcgbios.c | 14 ++++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/std/tcg.h b/src/std/tcg.h
index d5bf15a..61a759a 100644
--- a/src/std/tcg.h
+++ b/src/std/tcg.h
@@ -356,7 +356,8 @@ struct tpm_res_sha1complete {
/* TPM 2 data structures */
-struct tpm2b_stir {
+struct tpm2_req_stirrandom {
+ struct tpm_req_header hdr;
u16 size;
u64 stir;
} PACKED;
diff --git a/src/tcgbios.c b/src/tcgbios.c
index 5475535..10f8ba5 100644
--- a/src/tcgbios.c
+++ b/src/tcgbios.c
@@ -591,16 +591,22 @@ tpm_extend(struct tpm_log_entry *le, int digest_len)
static int
tpm20_stirrandom(void)
{
- struct tpm2b_stir stir = {
+ struct tpm2_req_stirrandom stir = {
+ .hdr.tag = cpu_to_be16(TPM2_ST_NO_SESSIONS),
+ .hdr.totlen = cpu_to_be32(sizeof(stir)),
+ .hdr.ordinal = cpu_to_be32(TPM2_CC_StirRandom),
.size = cpu_to_be16(sizeof(stir.stir)),
.stir = rdtscll(),
};
/* set more bits to stir with */
stir.stir += swab64(rdtscll());
- int ret = tpm_build_and_send_cmd(0, TPM2_CC_StirRandom,
- (u8 *)&stir, sizeof(stir),
- TPM_DURATION_TYPE_SHORT);
+ struct tpm_rsp_header rsp;
+ u32 resp_length = sizeof(rsp);
+ int ret = tpmhw_transmit(0, &stir.hdr, &rsp, &resp_length,
+ TPM_DURATION_TYPE_SHORT);
+ if (ret || resp_length != sizeof(rsp) || rsp.errcode)
+ ret = -1;
dprintf(DEBUG_tcg, "TCGBIOS: Return value from sending TPM2_CC_StirRandom = 0x%08x\n",
ret);
--
2.5.5
More information about the SeaBIOS
mailing list