From: Joelle van Dyne <j@getutm.app>
To: qemu-devel@nongnu.org
Cc: Joelle van Dyne <j@getutm.app>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org (open list:Virt)
Subject: [PATCH 07/11] hw/arm/virt: add plug handler for TPM on SysBus
Date: Wed, 12 Jul 2023 20:51:12 -0700 [thread overview]
Message-ID: <20230713035232.48406-8-j@getutm.app> (raw)
In-Reply-To: <20230713035232.48406-1-j@getutm.app>
TPM needs to know its own base address in order to generate its DSDT
device entry.
Signed-off-by: Joelle van Dyne <j@getutm.app>
---
hw/arm/virt.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 7d9dbc2663..432148ef47 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2732,6 +2732,37 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
dev, &error_abort);
}
+#ifdef CONFIG_TPM
+static void virt_tpm_plug(VirtMachineState *vms, TPMIf *tpmif)
+{
+ PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
+ hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS].base;
+ SysBusDevice *sbdev = SYS_BUS_DEVICE(tpmif);
+ MemoryRegion *sbdev_mr;
+ hwaddr tpm_base;
+ uint64_t tpm_size;
+
+ if (!sbdev || !object_dynamic_cast(OBJECT(sbdev), TYPE_SYS_BUS_DEVICE)) {
+ 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);
+ tpm_size = memory_region_size(sbdev_mr);
+
+ if (object_property_find(OBJECT(sbdev), "baseaddr")) {
+ object_property_set_uint(OBJECT(sbdev), "baseaddr", tpm_base, NULL);
+ }
+ if (object_property_find(OBJECT(sbdev), "size")) {
+ object_property_set_uint(OBJECT(sbdev), "size", tpm_size, NULL);
+ }
+}
+#endif
+
static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
@@ -2803,6 +2834,12 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
vms->virtio_iommu_bdf = pci_get_bdf(pdev);
create_virtio_iommu_dt_bindings(vms);
}
+
+#ifdef CONFIG_TPM
+ if (object_dynamic_cast(OBJECT(dev), TYPE_TPM_IF)) {
+ virt_tpm_plug(vms, TPM_IF(dev));
+ }
+#endif
}
static void virt_dimm_unplug_request(HotplugHandler *hotplug_dev,
--
2.39.2 (Apple Git-143)
next prev parent reply other threads:[~2023-07-13 3:54 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 3:51 [PATCH 00/11] tpm: introduce TPM CRB SysBus device Joelle van Dyne
2023-07-13 3:51 ` [PATCH 01/11] tpm_crb: refactor common code Joelle van Dyne
2023-07-13 13:22 ` Stefan Berger
2023-07-13 3:51 ` [PATCH 02/11] tpm_crb: CTRL_RSP_ADDR is 64-bits wide Joelle van Dyne
2023-07-13 15:31 ` Stefan Berger
2023-07-13 3:51 ` [PATCH 03/11] tpm_ppi: refactor memory space initialization Joelle van Dyne
2023-07-13 16:00 ` Stefan Berger
2023-07-13 3:51 ` [PATCH 04/11] tpm_crb: use a single read-as-mem/write-as-mmio mapping Joelle van Dyne
2023-07-13 14:17 ` Stefan Berger
2023-07-13 14:50 ` Peter Maydell
2023-07-13 15:28 ` Stefan Berger
2023-07-13 15:34 ` Peter Maydell
2023-07-13 15:46 ` Stefan Berger
2023-07-13 15:55 ` Peter Maydell
2023-07-13 16:53 ` Stefan Berger
2023-07-13 17:07 ` Peter Maydell
2023-07-13 17:16 ` Stefan Berger
2023-07-13 17:18 ` Peter Maydell
2023-07-13 18:43 ` Stefan Berger
2023-07-14 10:05 ` Peter Maydell
2023-07-14 11:56 ` Stefan Berger
2023-07-14 17:38 ` Joelle van Dyne
2023-07-13 3:51 ` [PATCH 05/11] tpm_crb: use the ISA bus Joelle van Dyne
2023-07-13 18:35 ` Stefan Berger
2023-07-13 3:51 ` [PATCH 06/11] tpm_crb: move ACPI table building to device interface Joelle van Dyne
2023-07-13 16:08 ` Stefan Berger
2023-07-13 18:10 ` Joelle van Dyne
2023-07-13 18:30 ` Stefan Berger
2023-07-13 3:51 ` Joelle van Dyne [this message]
2023-07-13 13:13 ` [PATCH 07/11] hw/arm/virt: add plug handler for TPM on SysBus Stefan Berger
2023-07-13 15:31 ` Peter Maydell
2023-07-13 18:07 ` Joelle van Dyne
2023-07-13 3:51 ` [PATCH 08/11] hw/loongarch/virt: " Joelle van Dyne
2023-07-13 3:51 ` [PATCH 09/11] tpm_tis_sysbus: fix crash when PPI is enabled Joelle van Dyne
2023-07-13 16:49 ` Stefan Berger
2023-07-13 18:15 ` Joelle van Dyne
2023-07-13 18:31 ` Stefan Berger
2023-07-13 3:51 ` [PATCH 10/11] tpm_tis_sysbus: move DSDT AML generation to device Joelle van Dyne
2023-07-13 3:51 ` [PATCH 11/11] tpm_crb_sysbus: introduce TPM CRB SysBus device Joelle van Dyne
2023-07-13 13:07 ` [PATCH 00/11] tpm: " Stefan Berger
2023-07-13 17:35 ` Joelle van Dyne
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=20230713035232.48406-8-j@getutm.app \
--to=j@getutm.app \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).