qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: Joelle van Dyne <j@getutm.app>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Stefan Berger <stefanb@linux.vnet.ibm.com>
Subject: Re: [PATCH 05/11] tpm_crb: use the ISA bus
Date: Thu, 13 Jul 2023 14:35:28 -0400	[thread overview]
Message-ID: <ed67cdd1-3987-7432-960e-36ce59face96@linux.ibm.com> (raw)
In-Reply-To: <20230713035232.48406-6-j@getutm.app>



On 7/12/23 23:51, Joelle van Dyne wrote:
> Since this device is gated to only build for targets with the PC
> configuration, we should use the ISA bus like with TPM TIS.
> 
> Signed-off-by: Joelle van Dyne <j@getutm.app>

I think this patch is good but I'd like to try it with resuming and old VM snapshot and for this to work we need 04/11 to have the registers in the VM state.


    Stefan
> ---
>   hw/tpm/tpm_crb.c | 52 ++++++++++++++++++++++++------------------------
>   hw/tpm/Kconfig   |  2 +-
>   2 files changed, 27 insertions(+), 27 deletions(-)
> 
> diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
> index 07c6868d8d..6144081d30 100644
> --- a/hw/tpm/tpm_crb.c
> +++ b/hw/tpm/tpm_crb.c
> @@ -22,6 +22,7 @@
>   #include "hw/qdev-properties.h"
>   #include "hw/pci/pci_ids.h"
>   #include "hw/acpi/tpm.h"
> +#include "hw/isa/isa.h"
>   #include "migration/vmstate.h"
>   #include "sysemu/tpm_backend.h"
>   #include "sysemu/tpm_util.h"
> @@ -34,7 +35,7 @@
>   #include "tpm_crb.h"
> 
>   struct CRBState {
> -    DeviceState parent_obj;
> +    ISADevice parent_obj;
> 
>       TPMCRBState state;
>   };
> @@ -43,49 +44,49 @@ typedef struct CRBState CRBState;
>   DECLARE_INSTANCE_CHECKER(CRBState, CRB,
>                            TYPE_TPM_CRB)
> 
> -static void tpm_crb_none_request_completed(TPMIf *ti, int ret)
> +static void tpm_crb_isa_request_completed(TPMIf *ti, int ret)
>   {
>       CRBState *s = CRB(ti);
> 
>       tpm_crb_request_completed(&s->state, ret);
>   }
> 
> -static enum TPMVersion tpm_crb_none_get_version(TPMIf *ti)
> +static enum TPMVersion tpm_crb_isa_get_version(TPMIf *ti)
>   {
>       CRBState *s = CRB(ti);
> 
>       return tpm_crb_get_version(&s->state);
>   }
> 
> -static int tpm_crb_none_pre_save(void *opaque)
> +static int tpm_crb_isa_pre_save(void *opaque)
>   {
>       CRBState *s = opaque;
> 
>       return tpm_crb_pre_save(&s->state);
>   }
> 
> -static const VMStateDescription vmstate_tpm_crb_none = {
> +static const VMStateDescription vmstate_tpm_crb_isa = {
>       .name = "tpm-crb",
> -    .pre_save = tpm_crb_none_pre_save,
> +    .pre_save = tpm_crb_isa_pre_save,
>       .fields = (VMStateField[]) {
>           VMSTATE_END_OF_LIST(),
>       }
>   };
> 
> -static Property tpm_crb_none_properties[] = {
> +static Property tpm_crb_isa_properties[] = {
>       DEFINE_PROP_TPMBE("tpmdev", CRBState, state.tpmbe),
>       DEFINE_PROP_BOOL("ppi", CRBState, state.ppi_enabled, true),
>       DEFINE_PROP_END_OF_LIST(),
>   };
> 
> -static void tpm_crb_none_reset(void *dev)
> +static void tpm_crb_isa_reset(void *dev)
>   {
>       CRBState *s = CRB(dev);
> 
>       return tpm_crb_reset(&s->state, TPM_CRB_ADDR_BASE);
>   }
> 
> -static void tpm_crb_none_realize(DeviceState *dev, Error **errp)
> +static void tpm_crb_isa_realize(DeviceState *dev, Error **errp)
>   {
>       CRBState *s = CRB(dev);
> 
> @@ -100,52 +101,51 @@ static void tpm_crb_none_realize(DeviceState *dev, Error **errp)
> 
>       tpm_crb_init_memory(OBJECT(s), &s->state, errp);
> 
> -    memory_region_add_subregion(get_system_memory(),
> +    memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
>           TPM_CRB_ADDR_BASE, &s->state.mmio);
> 
>       if (s->state.ppi_enabled) {
> -        memory_region_add_subregion(get_system_memory(),
> +        memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
>               TPM_PPI_ADDR_BASE, &s->state.ppi.ram);
>       }
> 
>       if (xen_enabled()) {
> -        tpm_crb_none_reset(dev);
> +        tpm_crb_isa_reset(dev);
>       } else {
> -        qemu_register_reset(tpm_crb_none_reset, dev);
> +        qemu_register_reset(tpm_crb_isa_reset, dev);
>       }
>   }
> 
> -static void tpm_crb_none_class_init(ObjectClass *klass, void *data)
> +static void tpm_crb_isa_class_init(ObjectClass *klass, void *data)
>   {
>       DeviceClass *dc = DEVICE_CLASS(klass);
>       TPMIfClass *tc = TPM_IF_CLASS(klass);
> 
> -    dc->realize = tpm_crb_none_realize;
> -    device_class_set_props(dc, tpm_crb_none_properties);
> -    dc->vmsd  = &vmstate_tpm_crb_none;
> +    dc->realize = tpm_crb_isa_realize;
> +    device_class_set_props(dc, tpm_crb_isa_properties);
> +    dc->vmsd  = &vmstate_tpm_crb_isa;
>       dc->user_creatable = true;
>       tc->model = TPM_MODEL_TPM_CRB;
> -    tc->get_version = tpm_crb_none_get_version;
> -    tc->request_completed = tpm_crb_none_request_completed;
> +    tc->get_version = tpm_crb_isa_get_version;
> +    tc->request_completed = tpm_crb_isa_request_completed;
> 
>       set_bit(DEVICE_CATEGORY_MISC, dc->categories);
>   }
> 
> -static const TypeInfo tpm_crb_none_info = {
> +static const TypeInfo tpm_crb_isa_info = {
>       .name = TYPE_TPM_CRB,
> -    /* could be TYPE_SYS_BUS_DEVICE (or LPC etc) */
> -    .parent = TYPE_DEVICE,
> +    .parent = TYPE_ISA_DEVICE,
>       .instance_size = sizeof(CRBState),
> -    .class_init  = tpm_crb_none_class_init,
> +    .class_init  = tpm_crb_isa_class_init,
>       .interfaces = (InterfaceInfo[]) {
>           { TYPE_TPM_IF },
>           { }
>       }
>   };
> 
> -static void tpm_crb_none_register(void)
> +static void tpm_crb_isa_register(void)
>   {
> -    type_register_static(&tpm_crb_none_info);
> +    type_register_static(&tpm_crb_isa_info);
>   }
> 
> -type_init(tpm_crb_none_register)
> +type_init(tpm_crb_isa_register)
> diff --git a/hw/tpm/Kconfig b/hw/tpm/Kconfig
> index a46663288c..1fd73fe617 100644
> --- a/hw/tpm/Kconfig
> +++ b/hw/tpm/Kconfig
> @@ -22,7 +22,7 @@ config TPM_TIS
> 
>   config TPM_CRB
>       bool
> -    depends on TPM && PC
> +    depends on TPM && ISA_BUS
>       select TPM_BACKEND
> 
>   config TPM_SPAPR


  reply	other threads:[~2023-07-13 18:36 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 [this message]
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 ` [PATCH 07/11] hw/arm/virt: add plug handler for TPM on SysBus Joelle van Dyne
2023-07-13 13:13   ` 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=ed67cdd1-3987-7432-960e-36ce59face96@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=j@getutm.app \
    --cc=pbonzini@redhat.com \
    --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).