Split off the tpm_crb_reset function part from tpm_crb_realize
that we need to run every time the machine resets.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
hw/tpm/tpm_crb.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
index 687d255..624e2e9 100644
--- a/hw/tpm/tpm_crb.c
+++ b/hw/tpm/tpm_crb.c
@@ -232,6 +232,11 @@ static void tpm_crb_realize(DeviceState *dev, Error **errp)
TPM_CRB_ADDR_BASE, &s->mmio);
memory_region_add_subregion(get_system_memory(),
TPM_CRB_ADDR_BASE + sizeof(s->regs), &s->cmdmem);
+}
+
+static void tpm_crb_reset(DeviceState *dev)
+{
+ CRBState *s = CRB(dev);
tpm_backend_reset(s->tpmbe);
@@ -274,6 +279,7 @@ static void tpm_crb_class_init(ObjectClass *klass, void *data)
dc->realize = tpm_crb_realize;
dc->props = tpm_crb_properties;
+ dc->reset = tpm_crb_reset;
dc->vmsd = &vmstate_tpm_crb;
dc->user_creatable = true;
tc->model = TPM_MODEL_TPM_CRB;
--
2.5.5
On 02/01/2018 06:23 PM, Stefan Berger wrote:
> Split off the tpm_crb_reset function part from tpm_crb_realize
> that we need to run every time the machine resets.
>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
> hw/tpm/tpm_crb.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
> index 687d255..624e2e9 100644
> --- a/hw/tpm/tpm_crb.c
> +++ b/hw/tpm/tpm_crb.c
> @@ -232,6 +232,11 @@ static void tpm_crb_realize(DeviceState *dev, Error **errp)
> TPM_CRB_ADDR_BASE, &s->mmio);
> memory_region_add_subregion(get_system_memory(),
> TPM_CRB_ADDR_BASE + sizeof(s->regs), &s->cmdmem);
> +}
> +
> +static void tpm_crb_reset(DeviceState *dev)
> +{
> + CRBState *s = CRB(dev);
>
> tpm_backend_reset(s->tpmbe);
>
> @@ -274,6 +279,7 @@ static void tpm_crb_class_init(ObjectClass *klass, void *data)
>
> dc->realize = tpm_crb_realize;
> dc->props = tpm_crb_properties;
> + dc->reset = tpm_crb_reset;
> dc->vmsd = &vmstate_tpm_crb;
> dc->user_creatable = true;
> tc->model = TPM_MODEL_TPM_CRB;
So this splt-off unfortunately causes the tpm-crb-test to fail since the
reset function is not called. I wonder how to trigger that? Do we need
to call tpm_crb_reset now from tpm_crb_realize just to make the tests
work ? Or is there a function we can call in the test case to trigger
the device reset ?
© 2016 - 2026 Red Hat, Inc.