Hi On Fri, Jan 19, 2018 at 3:46 PM, Stefan Berger <stef...@linux.vnet.ibm.com> wrote: > On 01/19/2018 09:11 AM, Marc-André Lureau wrote: >> >> From: Stefan Berger <stef...@linux.vnet.ibm.com> >> >> We need to synchronize with the backend thread to make sure that a command >> being processed by the external TPM emulator has completed and its >> response been received. In case the bottom half did not run, we run the >> function it is supposed to run. >> >> Signed-off-by: Stefan Berger <stef...@linux.vnet.ibm.com> >> [ Marc-André - drop memory_region_get_ram_ptr(cmdmem) copy as it >> should be migrated already ] >> Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > > > I think we need to delay this until the PPI device has been added since this > will extend the state of the CRB. >
That makes sense, I'll hand it back to you then :) > > >> --- >> hw/tpm/tpm_crb.c | 32 +++++++++++++++++++++++++++++++- >> 1 file changed, 31 insertions(+), 1 deletion(-) >> >> diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c >> index 908ca18d92..63d53384c5 100644 >> --- a/hw/tpm/tpm_crb.c >> +++ b/hw/tpm/tpm_crb.c >> @@ -257,9 +257,39 @@ static enum TPMVersion tpm_crb_get_version(TPMIf *ti) >> return tpm_backend_get_tpm_version(s->tpmbe); >> } >> >> +/* persistent state handling */ >> + >> +static int tpm_crb_pre_save(void *opaque) >> +{ >> + CRBState *s = opaque; >> + >> + tpm_backend_finish_sync(s->tpmbe); >> + >> + return 0; >> +} >> + >> static const VMStateDescription vmstate_tpm_crb = { >> .name = "tpm-crb", >> - .unmigratable = 1, >> + .pre_save = tpm_crb_pre_save, >> + .fields = (VMStateField[]) { >> + VMSTATE_UINT32(regs.loc_state.reg, CRBState), >> + VMSTATE_UINT32(regs.loc_ctrl, CRBState), >> + VMSTATE_UINT32(regs.loc_sts.reg, CRBState), >> + VMSTATE_UINT64(regs.intf_id.reg, CRBState), >> + VMSTATE_UINT64(regs.ctrl_ext, CRBState), >> + VMSTATE_UINT32(regs.ctrl_req, CRBState), >> + VMSTATE_UINT32(regs.ctrl_sts.reg, CRBState), >> + VMSTATE_UINT32(regs.ctrl_cancel, CRBState), >> + VMSTATE_UINT32(regs.ctrl_start, CRBState), >> + VMSTATE_UINT32(regs.ctrl_int_enable, CRBState), >> + VMSTATE_UINT32(regs.ctrl_int_sts, CRBState), >> + VMSTATE_UINT32(regs.ctrl_cmd_size, CRBState), >> + VMSTATE_UINT32(regs.ctrl_cmd_pa_low, CRBState), >> + VMSTATE_UINT32(regs.ctrl_rsp_size, CRBState), >> + VMSTATE_UINT64(regs.ctrl_rsp_pa, CRBState), >> + >> + VMSTATE_END_OF_LIST(), >> + } >> }; >> >> static Property tpm_crb_properties[] = { > > > > -- Marc-André Lureau