public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jason Andryuk" <jandryuk@gmail.com>
To: devel@edk2.groups.io
Subject: TPM2 EventLog EFI vs. ACPI
Date: Fri, 16 Sep 2022 15:45:38 -0400	[thread overview]
Message-ID: <CAKf6xpuRA4nxW7GaahdEya3P4VfxmeT3sfO-WU=CPXd_QzYQxg@mail.gmail.com> (raw)

Hi,

I've noticed an issue with the TPM2 EventLog.  OVMF exposes the TPM
Event Log via EFI and ACPI, but they have different addresses.  The
EFI one retrievable by GetEventLog() is populated.  The ACPI is empty.
Oh, there are actually two EFI Event Logs for the two formats:
EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2
EFI_TCG2_EVENT_LOG_FORMAT_TCG_2

The debug log from the Fedora 36 OVMF shows:
Tcg2GetEventLog (EventLogLocation - 7EEB2000)
which matches the address retrieved with GetEventLog().
And hexdump-ing the TPM2 ACPI table shows 0x7fbe6000.

On a different build, I added output for both EFI logs, and the addresses are:
0x7ec3d000 - EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2
0x7ec1b000 - EFI_TCG2_EVENT_LOG_FORMAT_TCG_2
0x7fbe6000 - ACPI

The ACPI one is a little more user friendly as its address is
available through the table during runtime.  The EFI addresses can
only be grabbed before exiting boot services.

I think the issue is that the ACPI tables are created from Qemu fw_cfg
data, which allocates memory for the log and places the address in
ACPI tables.  Meanwhile,
SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c:SetupEventLog() allocates its own
event log memory.  SetupEventLog() saves the size and address in
PcdTpm2AcpiTableLaml & PcdTpm2AcpiTableLasa, but nothing puts those
values in the actual ACPI tables.

It seems like SetupEventLog would be better structured to check
existing ACPI tables and look for a log in a TPM2 section.  If found,
use that, otherwise create a new log area.

The other wrinkle is that the Tcg2 code is keeping two event logs in
the two formats.  It seems to me that for TPM2, it would be easier to
just keep only the newer EFI_TCG2_EVENT_LOG_FORMAT_TCG_2.  If support
for both is needed, then the EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 one
should share the same region as the ACPI table.

Regards,
Jason

             reply	other threads:[~2022-09-16 19:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16 19:45 Jason Andryuk [this message]
2022-09-17  2:28 ` [edk2-devel] TPM2 EventLog EFI vs. ACPI Andrew Fish
2022-09-17 18:30   ` Jason Andryuk
2022-09-18  0:10     ` Andrew Fish
2022-09-19  9:17 ` Igor Mammedov
2022-09-19 12:22   ` Stefan Berger
2022-09-19 16:55     ` Jason Andryuk
2022-09-19 17:39       ` Stefan Berger
2022-09-19 18:19         ` Jason Andryuk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKf6xpuRA4nxW7GaahdEya3P4VfxmeT3sfO-WU=CPXd_QzYQxg@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox