<p>Michał Żygowski has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/c/coreboot/+/29800">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">src/arch/x86/acpi.c: Create log area and extend TPM2 table<br><br>According to newest TCG ACPI Specification for Family 1.2 and 2.0<br>Version 1.2, Revision 8, TPM2 ACPI table has two more fields LAML and LASA.<br><br>Update the table structure definition, create the log area for TPM2 in<br>coreboot tables and fill the missing fields in TPM2 table. TPM2 should be<br>now probed well in SeaBIOS rel-1.12.0 or master.<br><br>Tested on apu2 with Infineon SLB9665 TT2.0.<br><br>Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com><br>Change-Id: Ie482cba0a3093aae996f7431251251f145fe64f3<br>---<br>M src/arch/x86/acpi.c<br>M src/arch/x86/include/arch/acpi.h<br>M src/commonlib/include/commonlib/cbmem_id.h<br>3 files changed, 42 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/00/29800/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/arch/x86/acpi.c b/src/arch/x86/acpi.c</span><br><span>index f54aa19..5c41d68 100644</span><br><span>--- a/src/arch/x86/acpi.c</span><br><span>+++ b/src/arch/x86/acpi.c</span><br><span>@@ -308,12 +308,43 @@</span><br><span>      header->checksum = acpi_checksum((void *)tcpa, header->length);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void *get_tpm2_log(u32 *size)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       const struct cbmem_entry *ce;</span><br><span style="color: hsl(120, 100%, 40%);">+ const u32 tpm2_default_log_len = 0x10000;</span><br><span style="color: hsl(120, 100%, 40%);">+     void *lasa;</span><br><span style="color: hsl(120, 100%, 40%);">+   ce = cbmem_entry_find(CBMEM_ID_TPM2_TCG_LOG);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ce) {</span><br><span style="color: hsl(120, 100%, 40%);">+             lasa = cbmem_entry_start(ce);</span><br><span style="color: hsl(120, 100%, 40%);">+         *size = cbmem_entry_size(ce);</span><br><span style="color: hsl(120, 100%, 40%);">+         printk(BIOS_DEBUG, "TPM2 log found at %p\n", lasa);</span><br><span style="color: hsl(120, 100%, 40%);">+         return lasa;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+     lasa = cbmem_add(CBMEM_ID_TPM2_TCG_LOG, tpm2_default_log_len);</span><br><span style="color: hsl(120, 100%, 40%);">+        if (!lasa) {</span><br><span style="color: hsl(120, 100%, 40%);">+          printk(BIOS_ERR, "TPM2 log creation failed\n");</span><br><span style="color: hsl(120, 100%, 40%);">+             return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   printk(BIOS_DEBUG, "TPM2 log created at %p\n", lasa);</span><br><span style="color: hsl(120, 100%, 40%);">+       memset(lasa, 0, tpm2_default_log_len);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      *size = tpm2_default_log_len;</span><br><span style="color: hsl(120, 100%, 40%);">+ return lasa;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static void acpi_create_tpm2(acpi_tpm2_t *tpm2)</span><br><span> {</span><br><span>    acpi_header_t *header = &(tpm2->header);</span><br><span style="color: hsl(120, 100%, 40%);">+       u32 tpm2_log_len;</span><br><span style="color: hsl(120, 100%, 40%);">+     void *lasa;</span><br><span> </span><br><span>      memset((void *)tpm2, 0, sizeof(acpi_tpm2_t));</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+     lasa = get_tpm2_log(&tpm2_log_len);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (!lasa)</span><br><span style="color: hsl(120, 100%, 40%);">+            return;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>    /* Fill out header fields. */</span><br><span>        memcpy(header->signature, "TPM2", 4);</span><br><span>   memcpy(header->oem_id, OEM_ID, 6);</span><br><span>@@ -330,6 +361,13 @@</span><br><span>         /* coreboot only supports the TIS interface driver. */</span><br><span>       tpm2->start_method = 6;</span><br><span>   memset(tpm2->msp, 0, sizeof(tpm2->msp));</span><br><span style="color: hsl(120, 100%, 40%);">+        /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * Log area fields are optional, but otherwise the table length will be</span><br><span style="color: hsl(120, 100%, 40%);">+        * to small and SeaBIOS will complain. Initialize the TPM2 log table</span><br><span style="color: hsl(120, 100%, 40%);">+   * and fill the fields.</span><br><span style="color: hsl(120, 100%, 40%);">+        */</span><br><span style="color: hsl(120, 100%, 40%);">+   tpm2->laml = tpm2_log_len;</span><br><span style="color: hsl(120, 100%, 40%);">+ tpm2->lasa = (uintptr_t) lasa;</span><br><span> </span><br><span>        /* Calculate checksum. */</span><br><span>    header->checksum = acpi_checksum((void *)tpm2, header->length);</span><br><span>diff --git a/src/arch/x86/include/arch/acpi.h b/src/arch/x86/include/arch/acpi.h</span><br><span>index b5205c0..050f0a4 100644</span><br><span>--- a/src/arch/x86/include/arch/acpi.h</span><br><span>+++ b/src/arch/x86/include/arch/acpi.h</span><br><span>@@ -198,6 +198,8 @@</span><br><span>     u64 control_area;</span><br><span>    u32 start_method;</span><br><span>    u8  msp[12];</span><br><span style="color: hsl(120, 100%, 40%);">+  u32 laml;</span><br><span style="color: hsl(120, 100%, 40%);">+     u64 lasa;</span><br><span> } __packed acpi_tpm2_t;</span><br><span> </span><br><span> typedef struct acpi_mcfg_mmconfig {</span><br><span>diff --git a/src/commonlib/include/commonlib/cbmem_id.h b/src/commonlib/include/commonlib/cbmem_id.h</span><br><span>index 042ea6e..2e0eeb6 100644</span><br><span>--- a/src/commonlib/include/commonlib/cbmem_id.h</span><br><span>+++ b/src/commonlib/include/commonlib/cbmem_id.h</span><br><span>@@ -65,6 +65,7 @@</span><br><span> #define CBMEM_ID_TCPA_LOG   0x54435041</span><br><span> #define CBMEM_ID_TCPA_TCG_LOG     0x54445041</span><br><span> #define CBMEM_ID_TIMESTAMP        0x54494d45</span><br><span style="color: hsl(120, 100%, 40%);">+#define CBMEM_ID_TPM2_TCG_LOG       0x54504d32</span><br><span> #define CBMEM_ID_VBOOT_HANDOFF    0x780074f0</span><br><span> #define CBMEM_ID_VBOOT_SEL_REG    0x780074f1</span><br><span> #define CBMEM_ID_VBOOT_WORKBUF    0x78007343</span><br><span>@@ -121,6 +122,7 @@</span><br><span>     { CBMEM_ID_TCPA_LOG,            "TCPA LOG   " }, \</span><br><span>         { CBMEM_ID_TCPA_TCG_LOG,        "TCPA TCGLOG" }, \</span><br><span>         { CBMEM_ID_TIMESTAMP,           "TIME STAMP " }, \</span><br><span style="color: hsl(120, 100%, 40%);">+  { CBMEM_ID_TPM2_TCG_LOG,        "TPM2 TCGLOG" }, \</span><br><span>         { CBMEM_ID_VBOOT_HANDOFF,       "VBOOT      " }, \</span><br><span>         { CBMEM_ID_VBOOT_SEL_REG,       "VBOOT SEL  " }, \</span><br><span>         { CBMEM_ID_VBOOT_WORKBUF,       "VBOOT WORK " }, \</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/c/coreboot/+/29800">change 29800</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/c/coreboot/+/29800"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ie482cba0a3093aae996f7431251251f145fe64f3 </div>
<div style="display:none"> Gerrit-Change-Number: 29800 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Michał Żygowski <michal.zygowski@3mdeb.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>