qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Stefan Berger" <stefanb@linux.vnet.ibm.com>
Cc: "open list:sPAPR pseries" <qemu-ppc@nongnu.org>,
	QEMU <qemu-devel@nongnu.org>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PACTH v3 3/5] tpm_spapr: Support suspend and resume
Date: Thu, 12 Dec 2019 08:22:25 -0500	[thread overview]
Message-ID: <08e2a506-2a0e-f8d2-40ea-97429ff2c46c@linux.ibm.com> (raw)
In-Reply-To: <CAJ+F1CL6R5wwn6pnFTRaoTWqXUr7eTDAzMzT27M8zSkG2K7uEw@mail.gmail.com>

On 12/12/19 6:00 AM, Marc-André Lureau wrote:
> Hi
>
> On Wed, Dec 11, 2019 at 8:27 PM Stefan Berger
> <stefanb@linux.vnet.ibm.com> wrote:
>> Extend the tpm_spapr frontend with VM suspend and resume support.
>>
>> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
>> ---
>>   hw/tpm/tpm_spapr.c | 42 +++++++++++++++++++++++++++++++++++++++++-
>>   1 file changed, 41 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/tpm/tpm_spapr.c b/hw/tpm/tpm_spapr.c
>> index c4a67e2403..d9153bd95c 100644
>> --- a/hw/tpm/tpm_spapr.c
>> +++ b/hw/tpm/tpm_spapr.c
>> @@ -87,6 +87,8 @@ typedef struct {
>>       TPMVersion be_tpm_version;
>>
>>       size_t be_buffer_size;
>> +
>> +    bool deliver_response; /* whether to deliver response after VM resume */
>>   } SPAPRvTPMState;
>>
>>   static void tpm_spapr_show_buffer(const unsigned char *buffer,
>> @@ -339,9 +341,47 @@ static enum TPMVersion tpm_spapr_get_version(TPMIf *ti)
>>       return tpm_backend_get_tpm_version(s->be_driver);
>>   }
>>
>> +/* persistent state handling */
>> +
>> +static int tpm_spapr_pre_save(void *opaque)
>> +{
>> +    SPAPRvTPMState *s = opaque;
>> +
>> +    s->deliver_response = tpm_backend_finish_sync(s->be_driver);
>> +    /*
>> +     * we cannot deliver the results to the VM since DMA would touch VM memory
>> +     */
>> +
>> +    return 0;
>> +}
>> +
>> +static int tpm_spapr_post_load(void *opaque, int version_id)
>> +{
>> +    SPAPRvTPMState *s = opaque;
>> +
>> +    if (s->deliver_response) {
>> +        /* deliver the results to the VM via DMA */
>> +        tpm_spapr_request_completed(TPM_IF(s), 0);
> Why isn't it enough to rely on tpm_spapr_request_completed callback
> being called during pre-save when tpm_backend_finish_sync() is called?
> (like tis & crb)


When .pre_save is called the VM memory has been fully replicated and 
only the devices need to save their state, right? So TIS and CRB save 
the response in memory of the device for the OS driver to pick up after 
resume. The SPAPR device model is expected to write the response into VM 
memory using DMA but memory won't be marked dirty anymore and replicated 
(afaik). So we may have the mechanism of having 
tpm_spapr_request_completed() invoked but in addition we need to 
re-deliver a response after resume so that the OS driver reads the 
proper response then. I'll investigate, though...




  reply	other threads:[~2019-12-12 14:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-11 16:20 [PACTH v3 0/5] Add vTPM emulator supportfor ppc64 platform Stefan Berger
2019-12-11 16:20 ` [PACTH v3 1/5] tpm_spapr: Support TPM for ppc64 using CRQ based interface Stefan Berger
2019-12-12 11:05   ` Marc-André Lureau
2019-12-12 12:59     ` Stefan Berger
2019-12-11 16:20 ` [PACTH v3 2/5] tpm: Return bool from tpm_backend_finish_sync Stefan Berger
2019-12-11 16:20 ` [PACTH v3 3/5] tpm_spapr: Support suspend and resume Stefan Berger
2019-12-12 11:00   ` Marc-André Lureau
2019-12-12 13:22     ` Stefan Berger [this message]
2019-12-12 17:12       ` Stefan Berger
2019-12-11 16:20 ` [PACTH v3 4/5] hw/ppc/Kconfig: Enable TPMDEV as part of PSERIES config Stefan Berger
2019-12-11 16:20 ` [PACTH v3 5/5] docs: tpm: Add example command line for ppc64 and tpm-spapr Stefan Berger
2019-12-12 11:11   ` Marc-André Lureau

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=08e2a506-2a0e-f8d2-40ea-97429ff2c46c@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=marcandre.lureau@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).