qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Eric Auger <eric.auger@redhat.com>,
	Shannon Zhao <shannon.zhaosl@gmail.com>,
	qemu-arm@nongnu.org, Igor Mammedov <imammedo@redhat.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	Stefan Berger <stefanb@linux.ibm.com>
Subject: [PULL 14/19] arm/acpi: Add the TPM2.0 device under the DSDT
Date: Wed, 24 Jun 2020 19:07:05 -0400	[thread overview]
Message-ID: <20200624230609.703104-15-mst@redhat.com> (raw)
In-Reply-To: <20200624230609.703104-1-mst@redhat.com>

From: Eric Auger <eric.auger@redhat.com>

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>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>

Message-Id: <20200622140620.17229-3-eric.auger@redhat.com>
Tested-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@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 ca31f70f7f..1384a2cf2a 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -46,6 +46,7 @@
 #include "hw/pci/pci.h"
 #include "hw/arm/virt.h"
 #include "hw/mem/nvdimm.h"
+#include "hw/platform-bus.h"
 #include "sysemu/numa.h"
 #include "sysemu/reset.h"
 #include "sysemu/tpm.h"
@@ -364,6 +365,38 @@ static void acpi_dsdt_add_power_button(Aml *scope)
     aml_append(scope, dev);
 }
 
+static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms)
+{
+    PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
+    hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS].base;
+    SysBusDevice *sbdev = SYS_BUS_DEVICE(tpm_find());
+    MemoryRegion *sbdev_mr;
+    hwaddr tpm_base;
+
+    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,
+                                  (uint32_t)memory_region_size(sbdev_mr),
+                                  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)
 {
@@ -762,6 +795,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);
 
-- 
MST



  parent reply	other threads:[~2020-06-24 23:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 23:06 [PULL 00/19] virtio,acpi,pci: fixes, cleanups, tools Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 01/19] qtest: allow DSDT acpi table changes Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 02/19] acpi: bios-tables-test: show more context on asl diffs Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 03/19] acpi: move aml builder code for floppy device Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 04/19] floppy: make isa_fdc_get_drive_max_chs static Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 05/19] floppy: move cmos_get_fd_drive_type() from pc Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 06/19] acpi: move aml builder code for i8042 (kbd+mouse) device Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 07/19] acpi: factor out fw_cfg_add_acpi_dsdt() Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 08/19] acpi: simplify build_isa_devices_aml() Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 09/19] acpi: drop serial/parallel enable bits from dsdt Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 10/19] acpi: drop build_piix4_pm() Michael S. Tsirkin
2020-06-24 23:06 ` [PULL 11/19] acpi: q35: drop _SB.PCI0.ISA.LPCD opregion Michael S. Tsirkin
2020-06-24 23:07 ` [PULL 12/19] tests/acpi: update expected data files Michael S. Tsirkin
2020-06-24 23:07 ` [PULL 13/19] acpi: Some build_tpm2() code reshape Michael S. Tsirkin
2020-06-24 23:07 ` Michael S. Tsirkin [this message]
2020-06-24 23:07 ` [PULL 15/19] docs/specs/tpm: ACPI boot now supported for TPM/ARM Michael S. Tsirkin
2020-06-24 23:07 ` [PULL 16/19] Stop vhost-user sending uninitialized mmap_offsets Michael S. Tsirkin
2020-06-24 23:07 ` [PULL 17/19] Rename use_acpi_pci_hotplug to more appropriate use_acpi_hotplug_bridge Michael S. Tsirkin
2020-06-24 23:07 ` [PULL 18/19] tests/qtest/bios-tables: Only run the TPM test with CONFIG_TPM enabled Michael S. Tsirkin
2020-06-24 23:07 ` [PULL 19/19] tests: disassemble-asm.sh: generate AML in readable format Michael S. Tsirkin
2020-06-25  5:47 ` [PULL 00/19] virtio,acpi,pci: fixes, cleanups, tools Thomas Huth
2020-06-25  6:49   ` Michael S. Tsirkin
2020-06-25 20:20 ` Peter Maydell

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=20200624230609.703104-15-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=ardb@kernel.org \
    --cc=eric.auger@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shannon.zhaosl@gmail.com \
    --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).