1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun============= 4*4882a593SmuzhiyunTPM Event Log 5*4882a593Smuzhiyun============= 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunThis document briefly describes what TPM log is and how it is handed 8*4882a593Smuzhiyunover from the preboot firmware to the operating system. 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunIntroduction 11*4882a593Smuzhiyun============ 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunThe preboot firmware maintains an event log that gets new entries every 14*4882a593Smuzhiyuntime something gets hashed by it to any of the PCR registers. The events 15*4882a593Smuzhiyunare segregated by their type and contain the value of the hashed PCR 16*4882a593Smuzhiyunregister. Typically, the preboot firmware will hash the components to 17*4882a593Smuzhiyunwho execution is to be handed over or actions relevant to the boot 18*4882a593Smuzhiyunprocess. 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunThe main application for this is remote attestation and the reason why 21*4882a593Smuzhiyunit is useful is nicely put in the very first section of [1]: 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun"Attestation is used to provide information about the platform’s state 24*4882a593Smuzhiyunto a challenger. However, PCR contents are difficult to interpret; 25*4882a593Smuzhiyuntherefore, attestation is typically more useful when the PCR contents 26*4882a593Smuzhiyunare accompanied by a measurement log. While not trusted on their own, 27*4882a593Smuzhiyunthe measurement log contains a richer set of information than do the PCR 28*4882a593Smuzhiyuncontents. The PCR contents are used to provide the validation of the 29*4882a593Smuzhiyunmeasurement log." 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunUEFI event log 32*4882a593Smuzhiyun============== 33*4882a593Smuzhiyun 34*4882a593SmuzhiyunUEFI provided event log has a few somewhat weird quirks. 35*4882a593Smuzhiyun 36*4882a593SmuzhiyunBefore calling ExitBootServices() Linux EFI stub copies the event log to 37*4882a593Smuzhiyuna custom configuration table defined by the stub itself. Unfortunately, 38*4882a593Smuzhiyunthe events generated by ExitBootServices() don't end up in the table. 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunThe firmware provides so called final events configuration table to sort 41*4882a593Smuzhiyunout this issue. Events gets mirrored to this table after the first time 42*4882a593SmuzhiyunEFI_TCG2_PROTOCOL.GetEventLog() gets called. 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunThis introduces another problem: nothing guarantees that it is not called 45*4882a593Smuzhiyunbefore the Linux EFI stub gets to run. Thus, it needs to calculate and save the 46*4882a593Smuzhiyunfinal events table size while the stub is still running to the custom 47*4882a593Smuzhiyunconfiguration table so that the TPM driver can later on skip these events when 48*4882a593Smuzhiyunconcatenating two halves of the event log from the custom configuration table 49*4882a593Smuzhiyunand the final events table. 50*4882a593Smuzhiyun 51*4882a593SmuzhiyunReferences 52*4882a593Smuzhiyun========== 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun- [1] https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firmware-profile-specification/ 55*4882a593Smuzhiyun- [2] The final concatenation is done in drivers/char/tpm/eventlog/efi.c 56