Messages in this thread | | | Date | Tue, 31 Oct 2023 17:37:47 -0400 | Subject | Re: [PATCH v6 05/14] x86: Secure Launch main header file | From | ross.philipson@oracle ... |
| |
On 5/12/23 9:10 AM, Ross Philipson wrote: > On 5/12/23 07:00, Matthew Garrett wrote: >> On Thu, May 04, 2023 at 02:50:14PM +0000, Ross Philipson wrote: >> >>> +static inline int tpm12_log_event(void *evtlog_base, u32 evtlog_size, >>> + u32 event_size, void *event) >>> +{ >>> + struct tpm12_event_log_header *evtlog = >>> + (struct tpm12_event_log_header *)evtlog_base; >>> + >>> + if (memcmp(evtlog->signature, TPM12_EVTLOG_SIGNATURE, >>> + sizeof(TPM12_EVTLOG_SIGNATURE))) >>> + return -EINVAL; >>> + >>> + if (evtlog->container_size > evtlog_size) >>> + return -EINVAL; >>> + >>> + if (evtlog->next_event_offset + event_size > >>> evtlog->container_size) >>> + return -E2BIG; >>> + >>> + memcpy(evtlog_base + evtlog->next_event_offset, event, event_size); >>> + evtlog->next_event_offset += event_size; >>> + >>> + return 0; >>> +} >>> + >>> +static inline int tpm20_log_event(struct >>> txt_heap_event_log_pointer2_1_element *elem, >>> + void *evtlog_base, u32 evtlog_size, >>> + u32 event_size, void *event) >>> +{ >>> + struct tcg_pcr_event *header = >>> + (struct tcg_pcr_event *)evtlog_base; >>> + >>> + /* Has to be at least big enough for the signature */ >>> + if (header->event_size < sizeof(TCG_SPECID_SIG)) >>> + return -EINVAL; >>> + >>> + if (memcmp((u8 *)header + sizeof(struct tcg_pcr_event), >>> + TCG_SPECID_SIG, sizeof(TCG_SPECID_SIG))) >>> + return -EINVAL; >>> + >>> + if (elem->allocated_event_container_size > evtlog_size) >>> + return -EINVAL; >>> + >>> + if (elem->next_record_offset + event_size > >>> + elem->allocated_event_container_size) >>> + return -E2BIG; >>> + >>> + memcpy(evtlog_base + elem->next_record_offset, event, event_size); >>> + elem->next_record_offset += event_size; >>> + >>> + return 0; >>> +} >>> + >> >> These seem like they'd potentially be useful outside the context of SL, >> maybe put them in a more generic location? Very much a nice to have, not >> a blocker from my side. > > Yea we can look into finding a nice home somewhere in the TPM event log > code for these.
After looking at it, it seems we would have to drag a whole bunch of TXT related structures into the TPM event log code. I don't think this is really worth it for what these functions do.
Thanks Ross
> >> >>> +/* >>> + * External functions avalailable in mainline kernel. >> >> Nit: "available" > > Ack > > Thanks > >> >
| |