[coreboot-gerrit] Change in ...coreboot[master]: src/arch/x86/acpi.c: Create log area and extend TPM2 table

Michał Żygowski (Code Review) gerrit at coreboot.org
Thu Nov 22 17:04:48 CET 2018


Michał Żygowski has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/29800


Change subject: src/arch/x86/acpi.c: Create log area and extend TPM2 table
......................................................................

src/arch/x86/acpi.c: Create log area and extend TPM2 table

According to newest TCG ACPI Specification for Family 1.2 and 2.0
Version 1.2, Revision 8, TPM2 ACPI table has two more fields LAML and LASA.

Update the table structure definition, create the log area for TPM2 in
coreboot tables and fill the missing fields in TPM2 table. TPM2 should be
now probed well in SeaBIOS rel-1.12.0 or master.

Tested on apu2 with Infineon SLB9665 TT2.0.

Signed-off-by: Michał Żygowski <michal.zygowski at 3mdeb.com>
Change-Id: Ie482cba0a3093aae996f7431251251f145fe64f3
---
M src/arch/x86/acpi.c
M src/arch/x86/include/arch/acpi.h
M src/commonlib/include/commonlib/cbmem_id.h
3 files changed, 42 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/00/29800/1

diff --git a/src/arch/x86/acpi.c b/src/arch/x86/acpi.c
index f54aa19..5c41d68 100644
--- a/src/arch/x86/acpi.c
+++ b/src/arch/x86/acpi.c
@@ -308,12 +308,43 @@
 	header->checksum = acpi_checksum((void *)tcpa, header->length);
 }
 
+static void *get_tpm2_log(u32 *size)
+{
+	const struct cbmem_entry *ce;
+	const u32 tpm2_default_log_len = 0x10000;
+	void *lasa;
+	ce = cbmem_entry_find(CBMEM_ID_TPM2_TCG_LOG);
+	if (ce) {
+		lasa = cbmem_entry_start(ce);
+		*size = cbmem_entry_size(ce);
+		printk(BIOS_DEBUG, "TPM2 log found at %p\n", lasa);
+		return lasa;
+	}
+	lasa = cbmem_add(CBMEM_ID_TPM2_TCG_LOG, tpm2_default_log_len);
+	if (!lasa) {
+		printk(BIOS_ERR, "TPM2 log creation failed\n");
+		return NULL;
+	}
+
+	printk(BIOS_DEBUG, "TPM2 log created at %p\n", lasa);
+	memset(lasa, 0, tpm2_default_log_len);
+
+	*size = tpm2_default_log_len;
+	return lasa;
+}
+
 static void acpi_create_tpm2(acpi_tpm2_t *tpm2)
 {
 	acpi_header_t *header = &(tpm2->header);
+	u32 tpm2_log_len;
+	void *lasa;
 
 	memset((void *)tpm2, 0, sizeof(acpi_tpm2_t));
 
+	lasa = get_tpm2_log(&tpm2_log_len);
+	if (!lasa)
+		return;
+
 	/* Fill out header fields. */
 	memcpy(header->signature, "TPM2", 4);
 	memcpy(header->oem_id, OEM_ID, 6);
@@ -330,6 +361,13 @@
 	/* coreboot only supports the TIS interface driver. */
 	tpm2->start_method = 6;
 	memset(tpm2->msp, 0, sizeof(tpm2->msp));
+	/*
+	 * Log area fields are optional, but otherwise the table length will be
+	 * to small and SeaBIOS will complain. Initialize the TPM2 log table
+	 * and fill the fields.
+	 */
+	tpm2->laml = tpm2_log_len;
+	tpm2->lasa = (uintptr_t) lasa;
 
 	/* Calculate checksum. */
 	header->checksum = acpi_checksum((void *)tpm2, header->length);
diff --git a/src/arch/x86/include/arch/acpi.h b/src/arch/x86/include/arch/acpi.h
index b5205c0..050f0a4 100644
--- a/src/arch/x86/include/arch/acpi.h
+++ b/src/arch/x86/include/arch/acpi.h
@@ -198,6 +198,8 @@
 	u64 control_area;
 	u32 start_method;
 	u8  msp[12];
+	u32 laml;
+	u64 lasa;
 } __packed acpi_tpm2_t;
 
 typedef struct acpi_mcfg_mmconfig {
diff --git a/src/commonlib/include/commonlib/cbmem_id.h b/src/commonlib/include/commonlib/cbmem_id.h
index 042ea6e..2e0eeb6 100644
--- a/src/commonlib/include/commonlib/cbmem_id.h
+++ b/src/commonlib/include/commonlib/cbmem_id.h
@@ -65,6 +65,7 @@
 #define CBMEM_ID_TCPA_LOG	0x54435041
 #define CBMEM_ID_TCPA_TCG_LOG	0x54445041
 #define CBMEM_ID_TIMESTAMP	0x54494d45
+#define CBMEM_ID_TPM2_TCG_LOG	0x54504d32
 #define CBMEM_ID_VBOOT_HANDOFF	0x780074f0
 #define CBMEM_ID_VBOOT_SEL_REG	0x780074f1
 #define CBMEM_ID_VBOOT_WORKBUF	0x78007343
@@ -121,6 +122,7 @@
 	{ CBMEM_ID_TCPA_LOG,		"TCPA LOG   " }, \
 	{ CBMEM_ID_TCPA_TCG_LOG,	"TCPA TCGLOG" }, \
 	{ CBMEM_ID_TIMESTAMP,		"TIME STAMP " }, \
+	{ CBMEM_ID_TPM2_TCG_LOG,	"TPM2 TCGLOG" }, \
 	{ CBMEM_ID_VBOOT_HANDOFF,	"VBOOT      " }, \
 	{ CBMEM_ID_VBOOT_SEL_REG,	"VBOOT SEL  " }, \
 	{ CBMEM_ID_VBOOT_WORKBUF,	"VBOOT WORK " }, \

-- 
To view, visit https://review.coreboot.org/c/coreboot/+/29800
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ie482cba0a3093aae996f7431251251f145fe64f3
Gerrit-Change-Number: 29800
Gerrit-PatchSet: 1
Gerrit-Owner: Michał Żygowski <michal.zygowski at 3mdeb.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181122/767cb752/attachment-0001.html>


More information about the coreboot-gerrit mailing list