Skip to content

Commit

Permalink
Workaround txt_heap.c by assuming EVTLOG_TPM2_TCG
Browse files Browse the repository at this point in the history
  • Loading branch information
lxylxy123456 committed Oct 14, 2022
1 parent e564f25 commit 26666e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 7 additions & 0 deletions xmhf/src/xmhf-core/xmhf-bootloader/txt.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,13 @@ int get_evtlog_type(acm_hdr_t *sinit)
//txt_caps_t sinit_caps = get_sinit_capabilities(g_sinit);
txt_caps_t sinit_caps;
sinit_caps._raw = get_sinit_capabilities(sinit);
if (sinit_caps.tcg_event_log_format) {
printf("get_evtlog_type(): returning EVTLOG_TPM2_TCG\n");
} else {
printf("get_evtlog_type(): returning EVTLOG_TPM2_LEGACY\n");
// TODO: Workaround: txt_heap.c assumes EVTLOG_TPM2_TCG.
HALT_ON_ERRORCOND(0);
}
return sinit_caps.tcg_event_log_format ? EVTLOG_TPM2_TCG : EVTLOG_TPM2_LEGACY;
} else {
printf("SINIT not found\n");
Expand Down
9 changes: 4 additions & 5 deletions xmhf/src/xmhf-core/xmhf-bootloader/txt_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* Changes made include:
* Define NR_CPUS.
* Change type of lctx_addr from void * to uint32_t.
* TODO: TPM 2.0 not supported yet.
* TODO: Hardcoding get_evtlog_type() to EVTLOG_TPM2_TCG.
*/

/*
Expand Down Expand Up @@ -753,10 +753,10 @@ uint64_t calc_os_sinit_data_size(uint32_t version)
2 * sizeof(heap_ext_data_element_t) +
sizeof(heap_event_log_ptr_elt_t)
};
// XMHF: TODO: TPM 2.0 not supported yet.
#if 0
struct tpm_if *tpm = get_tpm();
int log_type = get_evtlog_type();
// TODO: Hardcoding get_evtlog_type() to EVTLOG_TPM2_TCG.
//int log_type = get_evtlog_type();
int log_type = EVTLOG_TPM2_TCG;

if ( log_type == EVTLOG_TPM2_TCG ) {
size[2] = sizeof(os_sinit_data_t) + sizeof(uint64_t) +
Expand All @@ -775,7 +775,6 @@ uint64_t calc_os_sinit_data_size(uint32_t version)
2 * sizeof(heap_ext_data_element_t) + 4 +
count*sizeof(heap_event_log_descr_t);
}
#endif

if ( version >= 6 )
return size[2];
Expand Down

0 comments on commit 26666e7

Please sign in to comment.