All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] vTPM/aarch64 ACPI support
@ 2020-05-02 20:35 Eric Auger
  2020-05-02 20:35 ` [PATCH 1/2] arm/acpi: TPM2 ACPI table support Eric Auger
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Eric Auger @ 2020-05-02 20:35 UTC (permalink / raw)
  To: eric.auger.pro, eric.auger, stefanb, peter.maydell, qemu-devel,
	qemu-arm, imammedo, shannon.zhaosl, mst
  Cc: marcandre.lureau, drjones, gshan, lersek, ardb

Those 2 patches bring MMIO TPM TIS ACPI support in machvirt.   
The TPM2.0 table is added and the TPM2 device object is described
in the DSDT.

Many thanks to Ard for his support.

Tested with LUKS partition automatic decryption.

Best Regards

Eric

This series can be found at:
https://github.com/eauger/qemu/tree/v5.0-tpm-acpi-v1

Eric Auger (2):
  arm/acpi: TPM2 ACPI table support
  arm/acpi: Add the TPM2.0 device under the DSDT

 include/sysemu/tpm.h     |  2 ++
 hw/arm/virt-acpi-build.c | 70 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] arm/acpi: TPM2 ACPI table support
  2020-05-02 20:35 [PATCH 0/2] vTPM/aarch64 ACPI support Eric Auger
@ 2020-05-02 20:35 ` Eric Auger
  2020-05-03 14:13   ` Stefan Berger
  2020-05-02 20:35 ` [PATCH 2/2] arm/acpi: Add the TPM2.0 device under the DSDT Eric Auger
  2020-05-02 22:00 ` [PATCH 0/2] vTPM/aarch64 ACPI support no-reply
  2 siblings, 1 reply; 7+ messages in thread
From: Eric Auger @ 2020-05-02 20:35 UTC (permalink / raw)
  To: eric.auger.pro, eric.auger, stefanb, peter.maydell, qemu-devel,
	qemu-arm, imammedo, shannon.zhaosl, mst
  Cc: marcandre.lureau, drjones, gshan, lersek, ardb

Add a TPM2 ACPI table if a TPM2.0 sysbus device has been
dynamically instantiated.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 include/sysemu/tpm.h     |  2 ++
 hw/arm/virt-acpi-build.c | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

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/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 81d41a3990..cc5863eaf2 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -41,11 +41,13 @@
 #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 "sysemu/numa.h"
 #include "sysemu/reset.h"
+#include "sysemu/tpm.h"
 #include "kvm_arm.h"
 #include "migration/vmstate.h"
 
@@ -704,6 +706,35 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
     build_fadt(table_data, linker, &fadt, NULL, NULL);
 }
 
+static void
+build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)
+{
+    Acpi20TPM2 *tpm2_ptr = acpi_data_push(table_data, sizeof *tpm2_ptr);
+    unsigned log_addr_size = sizeof(tpm2_ptr->log_area_start_address);
+    unsigned log_addr_offset =
+        (char *)&tpm2_ptr->log_area_start_address - table_data->data;
+
+    tpm2_ptr->platform_class = cpu_to_le16(TPM2_ACPI_CLASS_CLIENT);
+    if (TPM_IS_TIS_SYSBUS(tpm_find())) {
+        tpm2_ptr->control_area_address = cpu_to_le64(0);
+        tpm2_ptr->start_method = cpu_to_le32(TPM2_START_METHOD_MMIO);
+    } else {
+        g_warn_if_reached();
+    }
+
+    tpm2_ptr->log_area_minimum_length = cpu_to_le32(TPM_LOG_AREA_MINIMUM_SIZE);
+    acpi_data_push(tcpalog, le32_to_cpu(tpm2_ptr->log_area_minimum_length));
+
+    /* log area start address to be filled by Guest linker */
+    bios_linker_loader_alloc(linker, ACPI_BUILD_TPMLOG_FILE,
+                             tcpalog, 1, false);
+    bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
+                                   log_addr_offset, log_addr_size,
+                                   ACPI_BUILD_TPMLOG_FILE, 0);
+    build_header(linker, table_data,
+                 (void *)tpm2_ptr, "TPM2", sizeof(*tpm2_ptr), 4, NULL, NULL);
+}
+
 /* DSDT */
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
@@ -831,6 +862,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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] arm/acpi: Add the TPM2.0 device under the DSDT
  2020-05-02 20:35 [PATCH 0/2] vTPM/aarch64 ACPI support Eric Auger
  2020-05-02 20:35 ` [PATCH 1/2] arm/acpi: TPM2 ACPI table support Eric Auger
@ 2020-05-02 20:35 ` Eric Auger
  2020-05-03 14:19   ` Stefan Berger
  2020-05-04  5:21   ` Michael S. Tsirkin
  2020-05-02 22:00 ` [PATCH 0/2] vTPM/aarch64 ACPI support no-reply
  2 siblings, 2 replies; 7+ messages in thread
From: Eric Auger @ 2020-05-02 20:35 UTC (permalink / raw)
  To: eric.auger.pro, eric.auger, stefanb, peter.maydell, qemu-devel,
	qemu-arm, imammedo, shannon.zhaosl, mst
  Cc: marcandre.lureau, drjones, gshan, lersek, ardb

In case it is dynamically instantiated, add the TPM 2.0 device object
under the DSDT table in the ACPI namespace. Its HID is MSFT0101
while its current resource settings (CRS) property is initialized
with the guest physical address and MMIO size of the device.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 hw/arm/virt-acpi-build.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index cc5863eaf2..0cb9cdb2ce 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -45,6 +45,7 @@
 #include "hw/pci/pcie_host.h"
 #include "hw/pci/pci.h"
 #include "hw/arm/virt.h"
+#include "hw/platform-bus.h"
 #include "sysemu/numa.h"
 #include "sysemu/reset.h"
 #include "sysemu/tpm.h"
@@ -362,6 +363,38 @@ static void acpi_dsdt_add_power_button(Aml *scope)
     aml_append(scope, dev);
 }
 
+static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms)
+{
+    hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS].base;
+    PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
+    MemoryRegion *sbdev_mr;
+    SysBusDevice *sbdev;
+    hwaddr tpm_base;
+
+    sbdev = (SysBusDevice *)object_dynamic_cast(OBJECT(tpm_find()),
+                                                TYPE_SYS_BUS_DEVICE);
+    if (!sbdev) {
+        return;
+    }
+
+    tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
+    assert(tpm_base != -1);
+
+    tpm_base += pbus_base;
+
+    sbdev_mr = sysbus_mmio_get_region(sbdev, 0);
+
+    Aml *dev = aml_device("TPM0");
+    aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
+    aml_append(dev, aml_name_decl("_UID", aml_int(0)));
+
+    Aml *crs = aml_resource_template();
+    aml_append(crs,
+               aml_memory32_fixed(tpm_base, sbdev_mr->size, AML_READ_WRITE));
+    aml_append(dev, aml_name_decl("_CRS", crs));
+    aml_append(scope, dev);
+}
+
 static void
 build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
@@ -785,6 +818,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     }
 
     acpi_dsdt_add_power_button(scope);
+    acpi_dsdt_add_tpm(scope, vms);
 
     aml_append(dsdt, scope);
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] vTPM/aarch64 ACPI support
  2020-05-02 20:35 [PATCH 0/2] vTPM/aarch64 ACPI support Eric Auger
  2020-05-02 20:35 ` [PATCH 1/2] arm/acpi: TPM2 ACPI table support Eric Auger
  2020-05-02 20:35 ` [PATCH 2/2] arm/acpi: Add the TPM2.0 device under the DSDT Eric Auger
@ 2020-05-02 22:00 ` no-reply
  2 siblings, 0 replies; 7+ messages in thread
From: no-reply @ 2020-05-02 22:00 UTC (permalink / raw)
  To: eric.auger
  Cc: peter.maydell, drjones, gshan, shannon.zhaosl, mst, qemu-devel,
	eric.auger, qemu-arm, marcandre.lureau, imammedo, eric.auger.pro,
	lersek, ardb, stefanb

Patchew URL: https://patchew.org/QEMU/20200502203536.15011-1-eric.auger@redhat.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===

  CC      x86_64-softmmu/target/i386/smm_helper.o
  CC      aarch64-softmmu/hw/arm/orangepi.o
/tmp/qemu-test/src/hw/arm/virt-acpi-build.c: In function 'acpi_dsdt_add_tpm':
/tmp/qemu-test/src/hw/arm/virt-acpi-build.c:393:53: error: incompatible type for argument 2 of 'aml_memory32_fixed'
                aml_memory32_fixed(tpm_base, sbdev_mr->size, AML_READ_WRITE));
                                             ~~~~~~~~^~~~~~
In file included from /tmp/qemu-test/src/hw/arm/virt-acpi-build.c:39:
/tmp/qemu-test/src/include/hw/acpi/aml-build.h:317:6: note: expected 'uint32_t' {aka 'unsigned int'} but argument is of type 'Int128' {aka 'struct Int128'}
 Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,
      ^~~~~~~~~~~~~~~~~~
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: hw/arm/virt-acpi-build.o] Error 1
make[1]: *** Waiting for unfinished jobs....
  CC      x86_64-softmmu/target/i386/svm_helper.o
  CC      x86_64-softmmu/target/i386/kvm-stub.o
---
  CC      x86_64-softmmu/softmmu/main.o
  CC      x86_64-softmmu/gdbstub-xml.o
  CC      x86_64-softmmu/trace/generated-helpers.o
make: *** [Makefile:527: aarch64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
  LINK    x86_64-softmmu/qemu-system-x86_64w.exe
  GEN     x86_64-softmmu/qemu-system-x86_64.exe
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=0a6f397fde554332865bf4ebe15583d2', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-4bk1lfg4/src/docker-src.2020-05-02-17.54.35.24242:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=0a6f397fde554332865bf4ebe15583d2
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-4bk1lfg4/src'
make: *** [docker-run-test-mingw@fedora] Error 2

real    6m0.460s
user    0m8.733s


The full log is available at
http://patchew.org/logs/20200502203536.15011-1-eric.auger@redhat.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] arm/acpi: TPM2 ACPI table support
  2020-05-02 20:35 ` [PATCH 1/2] arm/acpi: TPM2 ACPI table support Eric Auger
@ 2020-05-03 14:13   ` Stefan Berger
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Berger @ 2020-05-03 14:13 UTC (permalink / raw)
  To: Eric Auger, eric.auger.pro, peter.maydell, qemu-devel, qemu-arm,
	imammedo, shannon.zhaosl, mst
  Cc: marcandre.lureau, drjones, gshan, lersek, ardb

On 5/2/20 4:35 PM, Eric Auger wrote:
> Add a TPM2 ACPI table if a TPM2.0 sysbus device has been
> dynamically instantiated.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
>   include/sysemu/tpm.h     |  2 ++
>   hw/arm/virt-acpi-build.c | 36 ++++++++++++++++++++++++++++++++++++
>   2 files changed, 38 insertions(+)
>
> 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/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 81d41a3990..cc5863eaf2 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -41,11 +41,13 @@
>   #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 "sysemu/numa.h"
>   #include "sysemu/reset.h"
> +#include "sysemu/tpm.h"
>   #include "kvm_arm.h"
>   #include "migration/vmstate.h"
>   
> @@ -704,6 +706,35 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
>       build_fadt(table_data, linker, &fadt, NULL, NULL);
>   }
>   
> +static void
> +build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)
> +{
> +    Acpi20TPM2 *tpm2_ptr = acpi_data_push(table_data, sizeof *tpm2_ptr);
> +    unsigned log_addr_size = sizeof(tpm2_ptr->log_area_start_address);
> +    unsigned log_addr_offset =
> +        (char *)&tpm2_ptr->log_area_start_address - table_data->data;
> +
> +    tpm2_ptr->platform_class = cpu_to_le16(TPM2_ACPI_CLASS_CLIENT);
> +    if (TPM_IS_TIS_SYSBUS(tpm_find())) {
> +        tpm2_ptr->control_area_address = cpu_to_le64(0);
> +        tpm2_ptr->start_method = cpu_to_le32(TPM2_START_METHOD_MMIO);
> +    } else {
> +        g_warn_if_reached();
> +    }
> +
> +    tpm2_ptr->log_area_minimum_length = cpu_to_le32(TPM_LOG_AREA_MINIMUM_SIZE);
> +    acpi_data_push(tcpalog, le32_to_cpu(tpm2_ptr->log_area_minimum_length));
> +
> +    /* log area start address to be filled by Guest linker */
> +    bios_linker_loader_alloc(linker, ACPI_BUILD_TPMLOG_FILE,
> +                             tcpalog, 1, false);
> +    bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
> +                                   log_addr_offset, log_addr_size,
> +                                   ACPI_BUILD_TPMLOG_FILE, 0);
> +    build_header(linker, table_data,
> +                 (void *)tpm2_ptr, "TPM2", sizeof(*tpm2_ptr), 4, NULL, NULL);
> +}
> +
>   /* DSDT */
>   static void
>   build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
> @@ -831,6 +862,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);

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] arm/acpi: Add the TPM2.0 device under the DSDT
  2020-05-02 20:35 ` [PATCH 2/2] arm/acpi: Add the TPM2.0 device under the DSDT Eric Auger
@ 2020-05-03 14:19   ` Stefan Berger
  2020-05-04  5:21   ` Michael S. Tsirkin
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Berger @ 2020-05-03 14:19 UTC (permalink / raw)
  To: Eric Auger, eric.auger.pro, peter.maydell, qemu-devel, qemu-arm,
	imammedo, shannon.zhaosl, mst
  Cc: marcandre.lureau, drjones, gshan, lersek, ardb

On 5/2/20 4:35 PM, Eric Auger wrote:
> In case it is dynamically instantiated, add the TPM 2.0 device object
> under the DSDT table in the ACPI namespace. Its HID is MSFT0101
> while its current resource settings (CRS) property is initialized
> with the guest physical address and MMIO size of the device.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
>   hw/arm/virt-acpi-build.c | 34 ++++++++++++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)
>
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index cc5863eaf2..0cb9cdb2ce 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -45,6 +45,7 @@
>   #include "hw/pci/pcie_host.h"
>   #include "hw/pci/pci.h"
>   #include "hw/arm/virt.h"
> +#include "hw/platform-bus.h"
>   #include "sysemu/numa.h"
>   #include "sysemu/reset.h"
>   #include "sysemu/tpm.h"
> @@ -362,6 +363,38 @@ static void acpi_dsdt_add_power_button(Aml *scope)
>       aml_append(scope, dev);
>   }
>   
> +static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms)
> +{
> +    hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS].base;
> +    PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
> +    MemoryRegion *sbdev_mr;
> +    SysBusDevice *sbdev;
> +    hwaddr tpm_base;
> +
> +    sbdev = (SysBusDevice *)object_dynamic_cast(OBJECT(tpm_find()),
> +                                                TYPE_SYS_BUS_DEVICE);
> +    if (!sbdev) {
> +        return;
> +    }
> +
> +    tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
> +    assert(tpm_base != -1);
> +
> +    tpm_base += pbus_base;
> +
> +    sbdev_mr = sysbus_mmio_get_region(sbdev, 0);
> +
> +    Aml *dev = aml_device("TPM0");
> +    aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
> +    aml_append(dev, aml_name_decl("_UID", aml_int(0)));
> +
> +    Aml *crs = aml_resource_template();
> +    aml_append(crs,
> +               aml_memory32_fixed(tpm_base, sbdev_mr->size, AML_READ_WRITE));
> +    aml_append(dev, aml_name_decl("_CRS", crs));
> +    aml_append(scope, dev);
> +}
> +
>   static void
>   build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>   {
> @@ -785,6 +818,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>       }
>   
>       acpi_dsdt_add_power_button(scope);
> +    acpi_dsdt_add_tpm(scope, vms);
>   
>       aml_append(dsdt, scope);
>   

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] arm/acpi: Add the TPM2.0 device under the DSDT
  2020-05-02 20:35 ` [PATCH 2/2] arm/acpi: Add the TPM2.0 device under the DSDT Eric Auger
  2020-05-03 14:19   ` Stefan Berger
@ 2020-05-04  5:21   ` Michael S. Tsirkin
  1 sibling, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2020-05-04  5:21 UTC (permalink / raw)
  To: Eric Auger
  Cc: peter.maydell, drjones, gshan, qemu-devel, shannon.zhaosl,
	qemu-arm, marcandre.lureau, imammedo, eric.auger.pro, lersek,
	ardb, stefanb

On Sat, May 02, 2020 at 10:35:36PM +0200, Eric Auger wrote:
> In case it is dynamically instantiated, add the TPM 2.0 device object
> under the DSDT table in the ACPI namespace. Its HID is MSFT0101
> while its current resource settings (CRS) property is initialized
> with the guest physical address and MMIO size of the device.
> 
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
>  hw/arm/virt-acpi-build.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index cc5863eaf2..0cb9cdb2ce 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -45,6 +45,7 @@
>  #include "hw/pci/pcie_host.h"
>  #include "hw/pci/pci.h"
>  #include "hw/arm/virt.h"
> +#include "hw/platform-bus.h"
>  #include "sysemu/numa.h"
>  #include "sysemu/reset.h"
>  #include "sysemu/tpm.h"
> @@ -362,6 +363,38 @@ static void acpi_dsdt_add_power_button(Aml *scope)
>      aml_append(scope, dev);
>  }
>  
> +static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms)
> +{
> +    hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS].base;
> +    PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
> +    MemoryRegion *sbdev_mr;
> +    SysBusDevice *sbdev;
> +    hwaddr tpm_base;
> +
> +    sbdev = (SysBusDevice *)object_dynamic_cast(OBJECT(tpm_find()),
> +                                                TYPE_SYS_BUS_DEVICE);
> +    if (!sbdev) {
> +        return;
> +    }
> +
> +    tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
> +    assert(tpm_base != -1);
> +
> +    tpm_base += pbus_base;
> +
> +    sbdev_mr = sysbus_mmio_get_region(sbdev, 0);
> +
> +    Aml *dev = aml_device("TPM0");
> +    aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
> +    aml_append(dev, aml_name_decl("_UID", aml_int(0)));
> +
> +    Aml *crs = aml_resource_template();
> +    aml_append(crs,
> +               aml_memory32_fixed(tpm_base, sbdev_mr->size, AML_READ_WRITE));

I don't think you are supposed to poke at memory region struct internals like
this.


> +    aml_append(dev, aml_name_decl("_CRS", crs));
> +    aml_append(scope, dev);
> +}
> +
>  static void
>  build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>  {
> @@ -785,6 +818,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>      }
>  
>      acpi_dsdt_add_power_button(scope);
> +    acpi_dsdt_add_tpm(scope, vms);
>  
>      aml_append(dsdt, scope);
>  
> -- 
> 2.20.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-04  5:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 20:35 [PATCH 0/2] vTPM/aarch64 ACPI support Eric Auger
2020-05-02 20:35 ` [PATCH 1/2] arm/acpi: TPM2 ACPI table support Eric Auger
2020-05-03 14:13   ` Stefan Berger
2020-05-02 20:35 ` [PATCH 2/2] arm/acpi: Add the TPM2.0 device under the DSDT Eric Auger
2020-05-03 14:19   ` Stefan Berger
2020-05-04  5:21   ` Michael S. Tsirkin
2020-05-02 22:00 ` [PATCH 0/2] vTPM/aarch64 ACPI support no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.