Skip to content

Commit

Permalink
arch/x86/tpm.c: fix appending to event log of TPM1
Browse files Browse the repository at this point in the history
Just like TPM2 case this code path also needs extra handling on AMD
because TXT-compatible data prepared by SKL is stored inside of vendor
data field of TCG header.

Signed-off-by: Sergii Dmytruk <[email protected]>
  • Loading branch information
SergiiDmytruk authored and krystian-hebel committed Apr 26, 2024
1 parent bf433b3 commit e19e079
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions xen/arch/x86/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ struct TPM12_PCREvent {
uint8_t Data[];
};

struct tpm1_spec_id_event {
uint32_t pcrIndex;
uint32_t eventType;
uint8_t digest[20];
uint32_t eventSize;
uint8_t signature[16];
uint32_t platformClass;
uint8_t specVersionMinor;
uint8_t specVersionMajor;
uint8_t specErrata;
uint8_t uintnSize;
uint8_t vendorInfoSize;
uint8_t vendorInfo[0]; /* variable number of members */
} __packed;

struct txt_ev_log_container_12 {
char Signature[20]; /* "TXT Event Container", null-terminated */
uint8_t Reserved[12];
Expand Down Expand Up @@ -409,6 +424,15 @@ static void *create_log_event12(struct txt_ev_log_container_12 *evt_log,
{
struct TPM12_PCREvent *new_entry;

if ( is_amd_cpu() ) {
/*
* On AMD, TXT-compatible structure is stored as vendor data of
* TCG-defined event log header.
*/
struct tpm1_spec_id_event *spec_id = (void *)evt_log;
evt_log = (struct txt_ev_log_container_12 *)&spec_id->vendorInfo[0];
}

new_entry = (void *)(((uint8_t *)evt_log) + evt_log->NextEventOffset);

/*
Expand Down

0 comments on commit e19e079

Please sign in to comment.