aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2015-12-30 12:40:11 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-01-05 15:05:14 -0500
commit9ddea3b018fcb2e0d8d49a7e6c3c36763d4e93e0 (patch)
treead7bef1706c041aac529d9fdb9844cae2232e566
parentcac29f2504450a97e05a95fa6e76cdb9199eb879 (diff)
downloadseabios-hppa-9ddea3b018fcb2e0d8d49a7e6c3c36763d4e93e0.zip
seabios-hppa-9ddea3b018fcb2e0d8d49a7e6c3c36763d4e93e0.tar.gz
seabios-hppa-9ddea3b018fcb2e0d8d49a7e6c3c36763d4e93e0.tar.bz2
tpm: Don't use 16bit BIOS return codes in tpm_log_event()
Don't use the return codes from the 16bit BIOS spec in the internal tpm_log_event() and tpm_log_extend_event() functions. Only the 16bit BIOS interface code should need to handle the details of that spec. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/tcgbios.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/tcgbios.c b/src/tcgbios.c
index cebc239..5e8fa63 100644
--- a/src/tcgbios.c
+++ b/src/tcgbios.c
@@ -123,21 +123,21 @@ tpm_tcpa_probe(void)
* Output:
* Returns an error code in case of faiure, 0 in case of success
*/
-static u32
+static int
tpm_log_event(struct pcpes *pcpes, const void *event)
{
dprintf(DEBUG_tcg, "TCGBIOS: LASA = %p, next entry = %p\n",
tpm_state.log_area_start_address, tpm_state.log_area_next_entry);
if (tpm_state.log_area_next_entry == NULL)
- return TCG_PC_LOGOVERFLOW;
+ return -1;
u32 size = sizeof(*pcpes) + pcpes->eventdatasize;
if ((tpm_state.log_area_next_entry + size - tpm_state.log_area_start_address) >
tpm_state.log_area_minimum_length) {
dprintf(DEBUG_tcg, "TCGBIOS: LOG OVERFLOW: size = %d\n", size);
- return TCG_PC_LOGOVERFLOW;
+ return -1;
}
memcpy(tpm_state.log_area_next_entry, pcpes, sizeof(*pcpes));
@@ -282,11 +282,11 @@ determine_timeouts(void)
return 0;
}
-static u32
+static int
tpm_log_extend_event(struct pcpes *pcpes, const void *event)
{
if (pcpes->pcrindex >= 24)
- return TCG_INVALID_INPUT_PARA;
+ return -1;
struct tpm_req_extend tre = {
.hdr.tag = cpu_to_be16(TPM_TAG_RQU_CMD),
@@ -301,7 +301,7 @@ tpm_log_extend_event(struct pcpes *pcpes, const void *event)
u32 rc = tpmhw_transmit(0, &tre.hdr, &rsp, &resp_length,
TPM_DURATION_TYPE_SHORT);
if (rc || resp_length != sizeof(rsp) || rsp.hdr.errcode)
- return rc ?: TCG_TCG_COMMAND_ERROR;
+ return -1;
return tpm_log_event(pcpes, event);
}
@@ -339,8 +339,8 @@ tpm_add_measurement_to_log(u32 pcrindex, u32 event_type,
.eventdatasize = event_length,
};
tpm_fill_hash(&pcpes, hashdata, hashdata_length);
- u32 rc = tpm_log_extend_event(&pcpes, event);
- if (rc)
+ int ret = tpm_log_extend_event(&pcpes, event);
+ if (ret)
tpm_set_failure();
}
@@ -651,9 +651,11 @@ hash_log_extend_event_int(const struct hleei_short *hleei_s,
}
tpm_fill_hash(pcpes, hleei_s->hashdataptr, hleei_s->hashdatalen);
- rc = tpm_log_extend_event(pcpes, pcpes->event);
- if (rc)
+ int ret = tpm_log_extend_event(pcpes, pcpes->event);
+ if (ret) {
+ rc = TCG_TCG_COMMAND_ERROR;
goto err_exit;
+ }
hleeo->opblength = sizeof(struct hleeo);
hleeo->reserved = 0;
@@ -729,9 +731,11 @@ hash_log_event_int(const struct hlei *hlei, struct hleo *hleo)
}
tpm_fill_hash(pcpes, hlei->hashdataptr, hlei->hashdatalen);
- rc = tpm_log_event(pcpes, pcpes->event);
- if (rc)
+ int ret = tpm_log_event(pcpes, pcpes->event);
+ if (ret) {
+ rc = TCG_PC_LOGOVERFLOW;
goto err_exit;
+ }
/* updating the log was fine */
hleo->opblength = sizeof(struct hleo);
@@ -783,11 +787,11 @@ compact_hash_log_extend_event_int(u8 *buffer,
};
tpm_fill_hash(&pcpes, buffer, length);
- u32 rc = tpm_log_extend_event(&pcpes, &info);
- if (rc == 0)
- *edx_ptr = tpm_state.entry_count;
-
- return rc;
+ int ret = tpm_log_extend_event(&pcpes, &info);
+ if (ret)
+ return TCG_TCG_COMMAND_ERROR;
+ *edx_ptr = tpm_state.entry_count;
+ return 0;
}
void VISIBLE32FLAT