From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
stefanb@linux.ibm.com, qemu-devel@nongnu.org,
qemu-arm@nongnu.org, peter.maydell@linaro.org
Cc: marcandre.lureau@redhat.com, drjones@redhat.com,
lersek@redhat.com, ardb@kernel.org, philmd@redhat.com
Subject: [PATCH v3 3/4] arm/acpi: TPM2 ACPI table support
Date: Mon, 1 Jun 2020 11:57:36 +0200 [thread overview]
Message-ID: <20200601095737.32671-4-eric.auger@redhat.com> (raw)
In-Reply-To: <20200601095737.32671-1-eric.auger@redhat.com>
Add a TPM2 ACPI table if a TPM2.0 sysbus device has been
dynamically instantiated.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
v2 -> v3:
- do not to need to create the log area anymore
v1 -> v2:
- reuse generic build_tpm2() and alloc log area externally
- call tpm_find() once in build_tpm2()
---
include/sysemu/tpm.h | 2 ++
hw/acpi/aml-build.c | 5 +++--
hw/arm/virt-acpi-build.c | 7 +++++++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index f37851b1aa..03fb25941c 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -50,6 +50,8 @@ typedef struct TPMIfClass {
#define TPM_IS_TIS_ISA(chr) \
object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS_ISA)
+#define TPM_IS_TIS_SYSBUS(chr) \
+ object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS_SYSBUS)
#define TPM_IS_CRB(chr) \
object_dynamic_cast(OBJECT(chr), TYPE_TPM_CRB)
#define TPM_IS_SPAPR(chr) \
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index b37052c1b4..d24e9e6c3a 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1885,17 +1885,18 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)
unsigned log_addr_offset =
(char *)&tpm2_ptr->log_area_start_address - table_data->data;
uint8_t start_method_params[12] = {};
+ TPMIf *tpmif = tpm_find();
/* platform class */
build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2);
/* reserved */
build_append_int_noprefix(table_data, 0, 2);
- if (TPM_IS_TIS_ISA(tpm_find())) {
+ if (TPM_IS_TIS_ISA(tpmif) || TPM_IS_TIS_SYSBUS(tpmif)) {
/* address of control area */
build_append_int_noprefix(table_data, 0, 8);
/* start method */
build_append_int_noprefix(table_data, TPM2_START_METHOD_MMIO, 4);
- } else if (TPM_IS_CRB(tpm_find())) {
+ } else if (TPM_IS_CRB(tpmif)) {
build_append_int_noprefix(table_data, TPM_CRB_ADDR_CTRL, 8);
build_append_int_noprefix(table_data, TPM2_START_METHOD_CRB, 4);
} else {
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 1b0a584c7b..6d152ab481 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -41,12 +41,14 @@
#include "hw/acpi/pci.h"
#include "hw/acpi/memory_hotplug.h"
#include "hw/acpi/generic_event_device.h"
+#include "hw/acpi/tpm.h"
#include "hw/pci/pcie_host.h"
#include "hw/pci/pci.h"
#include "hw/arm/virt.h"
#include "hw/mem/nvdimm.h"
#include "sysemu/numa.h"
#include "sysemu/reset.h"
+#include "sysemu/tpm.h"
#include "kvm_arm.h"
#include "migration/vmstate.h"
#include "hw/acpi/ghes.h"
@@ -844,6 +846,11 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
build_iort(tables_blob, tables->linker, vms);
}
+ if (tpm_get_version(tpm_find()) == TPM_VERSION_2_0) {
+ acpi_add_table(table_offsets, tables_blob);
+ build_tpm2(tables_blob, tables->linker, tables->tcpalog);
+ }
+
/* XSDT is pointed to by RSDP */
xsdt = tables_blob->len;
build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL);
--
2.20.1
next prev parent reply other threads:[~2020-06-01 10:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-01 9:57 [PATCH v3 0/4] vTPM/aarch64 ACPI support Eric Auger
2020-06-01 9:57 ` [PATCH v3 1/4] acpi: Convert build_tpm2() to build_append* API Eric Auger
2020-06-02 13:30 ` Stefan Berger
2020-06-02 13:55 ` Auger Eric
2020-06-02 14:24 ` Stefan Berger
2020-06-02 15:16 ` Auger Eric
2020-06-05 14:36 ` Igor Mammedov
2020-06-05 14:23 ` Igor Mammedov
2020-06-10 16:15 ` Auger Eric
2020-06-11 11:24 ` Igor Mammedov
2020-06-01 9:57 ` [PATCH v3 2/4] acpi: Move build_tpm2() in the generic part Eric Auger
2020-06-01 9:57 ` Eric Auger [this message]
2020-06-01 9:57 ` [PATCH v3 4/4] arm/acpi: Add the TPM2.0 device under the DSDT Eric Auger
2020-06-05 14:45 ` Igor Mammedov
2020-06-11 13:52 ` Auger Eric
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-all 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=20200601095737.32671-4-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=ardb@kernel.org \
--cc=drjones@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=lersek@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).