From: Stefan Berger <address@hidden>
Add an SSDT ACPI table for the TPM device.
Add a TCPA table for BIOS logging area when a TPM is being used.
The latter follows this spec here:
http://www.trustedcomputinggroup.org/files/static_page_files/DCD4188E-1A4B-B294-D050A155FB6F7385/TCG_ACPIGeneralSpecification_PublicReview.pdf
Signed-off-by: Stefan Berger <address@hidden>
---
hw/i386/Makefile.objs | 3 ++-
hw/i386/acpi-build.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
hw/i386/acpi-defs.h | 11 +++++++++++
hw/i386/ssdt-tpm.dsl | 43 +++++++++++++++++++++++++++++++++++++++++++
hw/tpm/tpm_tis.h | 5 +----
include/hw/acpi/tpm.h | 29 +++++++++++++++++++++++++++++
include/sysemu/tpm.h | 5 +++++
7 files changed, 137 insertions(+), 5 deletions(-)
create mode 100644 hw/i386/ssdt-tpm.dsl
create mode 100644 include/hw/acpi/tpm.h
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 48014ab..3688cf8 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -10,7 +10,8 @@ obj-y += bios-linker-loader.o
hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \
hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \
hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \
- hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex
+ hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex \
+ hw/i386/ssdt-tpm.hex
iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
; then echo "$(2)"; else echo "$(3)"; fi ;)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index ebc5f03..d767e37 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -38,6 +38,8 @@
#include "hw/loader.h"
#include "hw/isa/isa.h"
#include "hw/acpi/memory_hotplug.h"
+#include "sysemu/tpm.h"
+#include "hw/acpi/tpm.h"
/* Supported chipsets: */
#include "hw/acpi/piix4.h"
@@ -75,6 +77,7 @@ typedef struct AcpiPmInfo {
typedef struct AcpiMiscInfo {
bool has_hpet;
+ bool has_tpm;
DECLARE_BITMAP(slot_hotplug_enable, PCI_SLOT_MAX);
const unsigned char *dsdt_code;
unsigned dsdt_size;
@@ -193,6 +196,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
static void acpi_get_misc_info(AcpiMiscInfo *info)
{
info->has_hpet = hpet_find();
+ info->has_tpm = tpm_find();
info->pvpanic_port = pvpanic_port();
}
@@ -681,6 +685,7 @@ static inline char acpi_get_hex(uint32_t val)
#include "hw/i386/ssdt-misc.hex"
#include "hw/i386/ssdt-pcihp.hex"
+#include "hw/i386/ssdt-tpm.hex"
static void
build_append_notify_method(GArray *device, const char *name,
@@ -1167,6 +1172,40 @@ build_hpet(GArray *table_data, GArray *linker)
(void *)hpet, "HPET", sizeof(*hpet), 1);
}
+static void
+build_tpm_tcpa(GArray *table_data, GArray *linker)
+{
+ Acpi20Tcpa *tcpa;
+ uint32_t log_area_minimum_length = TPM_LOG_AREA_MINIMUM_SIZE;
+ uint64_t log_area_start_address;
+ size_t len = log_area_minimum_length + sizeof(*tcpa);
+
+ log_area_start_address = table_data->len + sizeof(*tcpa);
+
+ tcpa = acpi_data_push(table_data, len);
+
+ tcpa->platform_class = cpu_to_le16(TPM_TCPA_ACPI_CLASS_CLIENT);
+ tcpa->log_area_minimum_length = cpu_to_le32(log_area_minimum_length);
+ tcpa->log_area_start_address = cpu_to_le64(log_area_start_address);
+
+ /* LASA address to be filled by Guest linker */