From: Stefan Berger <stefanb@linux.ibm.com>
To: Joelle van Dyne <j@getutm.app>, qemu-devel@nongnu.org
Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
Subject: Re: [PATCH v4 06/14] tpm-sysbus: add plug handler for TPM on SysBus
Date: Tue, 31 Oct 2023 09:19:37 -0400 [thread overview]
Message-ID: <c8b7f48d-7580-428c-a81f-1c22998a880a@linux.ibm.com> (raw)
In-Reply-To: <20231031040021.65582-7-j@getutm.app>
On 10/31/23 00:00, Joelle van Dyne wrote:
> 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>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
> include/sysemu/tpm.h | 4 ++++
> hw/tpm/tpm-sysbus.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
> hw/tpm/meson.build | 1 +
> 3 files changed, 52 insertions(+)
> create mode 100644 hw/tpm/tpm-sysbus.c
>
> diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
> index 1ee568b3b6..ffd300e607 100644
> --- a/include/sysemu/tpm.h
> +++ b/include/sysemu/tpm.h
> @@ -12,6 +12,8 @@
> #ifndef QEMU_TPM_H
> #define QEMU_TPM_H
>
> +#include "qemu/osdep.h"
> +#include "exec/hwaddr.h"
> #include "qapi/qapi-types-tpm.h"
> #include "qom/object.h"
>
> @@ -78,6 +80,8 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)
> return TPM_IF_GET_CLASS(ti)->get_version(ti);
> }
>
> +void tpm_sysbus_plug(TPMIf *tpmif, Object *pbus, hwaddr pbus_base);
> +
> #else /* CONFIG_TPM */
>
> #define tpm_init() (0)
> diff --git a/hw/tpm/tpm-sysbus.c b/hw/tpm/tpm-sysbus.c
> new file mode 100644
> index 0000000000..732ce34c73
> --- /dev/null
> +++ b/hw/tpm/tpm-sysbus.c
> @@ -0,0 +1,47 @@
> +/*
> + * tpm-sysbus.c - Support functions for SysBus TPM devices
> + *
> + * Copyright (c) 2023 QEMU contributors
> + *
> + * Authors:
> + * Joelle van Dyne <j@getutm.app>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +#include "sysemu/tpm.h"
> +#include "hw/platform-bus.h"
> +#include "hw/sysbus.h"
> +#include "qapi/error.h"
> +
> +/**
> + * Called from a machine's pre_plug handler to set the device's physical addr.
> + */
> +void tpm_sysbus_plug(TPMIf *tpmif, Object *pbus, hwaddr pbus_base)
> +{
> + PlatformBusDevice *pbusdev = PLATFORM_BUS_DEVICE(pbus);
> + SysBusDevice *sbdev = SYS_BUS_DEVICE(tpmif);
> + MemoryRegion *sbdev_mr;
> + hwaddr tpm_base;
> + uint64_t tpm_size;
> +
> + /* exit early if TPM is not a sysbus device */
> + if (!object_dynamic_cast(OBJECT(tpmif), TYPE_SYS_BUS_DEVICE)) {
> + return;
> + }
> +
> + assert(object_dynamic_cast(pbus, TYPE_PLATFORM_BUS_DEVICE));
> +
> + tpm_base = platform_bus_get_mmio_addr(pbusdev, 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);
> +
> + object_property_set_uint(OBJECT(sbdev), "x-baseaddr",
> + tpm_base, &error_abort);
> + object_property_set_uint(OBJECT(sbdev), "x-size",
> + tpm_size, &error_abort);
> +}
> diff --git a/hw/tpm/meson.build b/hw/tpm/meson.build
> index cb8204d5bc..3060ac05e8 100644
> --- a/hw/tpm/meson.build
> +++ b/hw/tpm/meson.build
> @@ -1,6 +1,7 @@
> system_ss.add(when: 'CONFIG_TPM_TIS', if_true: files('tpm_tis_common.c'))
> system_ss.add(when: 'CONFIG_TPM_TIS_ISA', if_true: files('tpm_tis_isa.c'))
> system_ss.add(when: 'CONFIG_TPM_TIS_SYSBUS', if_true: files('tpm_tis_sysbus.c'))
> +system_ss.add(when: 'CONFIG_TPM_TIS_SYSBUS', if_true: files('tpm-sysbus.c'))
> system_ss.add(when: 'CONFIG_TPM_TIS_I2C', if_true: files('tpm_tis_i2c.c'))
> system_ss.add(when: 'CONFIG_TPM_CRB', if_true: files('tpm_crb.c'))
> system_ss.add(when: 'CONFIG_TPM_CRB', if_true: files('tpm_crb_common.c'))
next prev parent reply other threads:[~2023-10-31 13:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-31 4:00 [PATCH v4 00/14] tpm: introduce TPM CRB SysBus device Joelle van Dyne
2023-10-31 4:00 ` [PATCH v4 01/14] tpm_crb: refactor common code Joelle van Dyne
2023-10-31 4:00 ` [PATCH v4 02/14] tpm_crb: CTRL_RSP_ADDR is 64-bits wide Joelle van Dyne
2023-10-31 4:00 ` [PATCH v4 03/14] tpm_ppi: refactor memory space initialization Joelle van Dyne
2023-10-31 4:00 ` [PATCH v4 04/14] tpm_crb: use a single read-as-mem/write-as-mmio mapping Joelle van Dyne
2023-11-01 21:25 ` Stefan Berger
2023-11-14 1:37 ` Joelle van Dyne
2023-10-31 4:00 ` [PATCH v4 05/14] tpm_crb: move ACPI table building to device interface Joelle van Dyne
2023-11-02 18:50 ` Stefan Berger
2023-11-03 2:37 ` Joelle van Dyne
2023-11-03 12:43 ` Stefan Berger
2023-10-31 4:00 ` [PATCH v4 06/14] tpm-sysbus: add plug handler for TPM on SysBus Joelle van Dyne
2023-10-31 13:19 ` Stefan Berger [this message]
2023-10-31 4:00 ` [PATCH v4 07/14] hw/arm/virt: connect TPM to platform bus Joelle van Dyne
2023-10-31 4:00 ` [PATCH v4 08/14] hw/loongarch/virt: " Joelle van Dyne
2023-10-31 4:00 ` [PATCH v4 09/14] tpm_tis_sysbus: move DSDT AML generation to device Joelle van Dyne
2023-10-31 4:00 ` [PATCH v4 10/14] tests: acpi: prepare for TPM CRB tests Joelle van Dyne
2023-10-31 4:00 ` [PATCH v4 11/14] tpm_crb_sysbus: introduce TPM CRB SysBus device Joelle van Dyne
2023-10-31 13:25 ` Stefan Berger
2023-10-31 4:00 ` [PATCH v4 12/14] tests: acpi: implement TPM CRB tests for ARM virt Joelle van Dyne
2023-10-31 4:00 ` [PATCH v4 13/14] tests: acpi: updated expected blobs for TPM CRB Joelle van Dyne
2023-10-31 12:43 ` Stefan Berger
2023-10-31 4:00 ` [PATCH v4 14/14] tests: add TPM-CRB sysbus tests for aarch64 Joelle van Dyne
2023-10-31 13:05 ` Stefan Berger
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=c8b7f48d-7580-428c-a81f-1c22998a880a@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=j@getutm.app \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.vnet.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).