qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	QEMU <qemu-devel@nongnu.org>, Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v5 2/4] tpm: implement virtual memory device for TPM PPI
Date: Wed, 27 Jun 2018 17:10:57 +0200	[thread overview]
Message-ID: <20180627171057.3e030eca@redhat.com> (raw)
In-Reply-To: <CAJ+F1C+5nS6DbFO4a2==j4b2w__Uh3WySEDqCyoEcMcCqWdY+Q@mail.gmail.com>

On Wed, 27 Jun 2018 16:29:51 +0200
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> On Wed, Jun 27, 2018 at 4:19 PM, Igor Mammedov <imammedo@redhat.com> wrote:
> > On Wed, 27 Jun 2018 08:53:28 -0400
> > Stefan Berger <stefanb@linux.vnet.ibm.com> wrote:
> >  
> >> On 06/27/2018 07:44 AM, Igor Mammedov wrote:  
> >> > On Tue, 26 Jun 2018 14:23:41 +0200
> >> > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> >> >  
> >> >> From: Stefan Berger <stefanb@linux.vnet.ibm.com>
> >> >>
> >> >> Implement a virtual memory device for the TPM Physical Presence interface.
> >> >> The memory is located at 0xFED45000 and used by ACPI to send messages to the
> >> >> firmware (BIOS) and by the firmware to provide parameters for each one of
> >> >> the supported codes.
> >> >>
> >> >> This device should be used by all TPM interfaces on x86 and can be added
> >> >> by calling tpm_ppi_init_io().
> >> >>
> >> >> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> >> >> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> >> >>
> >> >> ---
> >> >>
> >> >> v4 (Marc-André):
> >> >>   - pass TPM_PPI_ADDR_BASE as argument to tpm_ppi_init_io()
> >> >>   - only enable PPI if property is set
> >> >>
> >> >> v3 (Marc-André):
> >> >>   - merge CRB support
> >> >>   - use trace events instead of DEBUG printf
> >> >>   - headers inclusion simplification
> >> >>
> >> >> v2:
> >> >>   - moved to byte access since an infrequently used device;
> >> >>     this simplifies code
> >> >>   - increase size of device to 0x400
> >> >>   - move device to 0xfffef000 since SeaBIOS has some code at 0xffff0000:
> >> >>     'On the emulators, the bios at 0xf0000 is also at 0xffff0000'
> >> >> ---
> >> >>   hw/tpm/tpm_ppi.h      | 27 ++++++++++++++++++++
> >> >>   include/hw/acpi/tpm.h |  6 +++++
> >> >>   hw/tpm/tpm_crb.c      |  7 ++++++
> >> >>   hw/tpm/tpm_ppi.c      | 57 +++++++++++++++++++++++++++++++++++++++++++
> >> >>   hw/tpm/tpm_tis.c      |  7 ++++++
> >> >>   hw/tpm/Makefile.objs  |  2 +-
> >> >>   hw/tpm/trace-events   |  4 +++
> >> >>   7 files changed, 109 insertions(+), 1 deletion(-)
> >> >>   create mode 100644 hw/tpm/tpm_ppi.h
> >> >>   create mode 100644 hw/tpm/tpm_ppi.c
> >> >>
> >> >> diff --git a/hw/tpm/tpm_ppi.h b/hw/tpm/tpm_ppi.h
> >> >> new file mode 100644
> >> >> index 0000000000..ac7ad47238
> >> >> --- /dev/null
> >> >> +++ b/hw/tpm/tpm_ppi.h
> >> >> @@ -0,0 +1,27 @@
> >> >> +/*
> >> >> + * TPM Physical Presence Interface
> >> >> + *
> >> >> + * Copyright (C) 2018 IBM Corporation
> >> >> + *
> >> >> + * Authors:
> >> >> + *  Stefan Berger    <stefanb@us.ibm.com>
> >> >> + *
> >> >> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> >> >> + * See the COPYING file in the top-level directory.
> >> >> + */
> >> >> +#ifndef TPM_TPM_PPI_H
> >> >> +#define TPM_TPM_PPI_H
> >> >> +
> >> >> +#include "hw/acpi/tpm.h"
> >> >> +#include "exec/address-spaces.h"
> >> >> +
> >> >> +typedef struct TPMPPI {
> >> >> +    MemoryRegion mmio;
> >> >> +
> >> >> +    uint8_t ram[TPM_PPI_ADDR_SIZE];
> >> >> +} TPMPPI;  
> >> > I probably miss something obvious here,
> >> > 1st:
> >> > commit message says that memory reion is supposed to be interface
> >> > between FW and OSPM (i.e. totally guest internal thingy).
> >> > So question is:
> >> >    why do we register memory region at all?  
> >>
> >> One reason for the device itself was being able to debug the interaction
> >> of the guest with ACPI though I had additional instrumentation for that
> >> showing register contents.
> >> We need it to have some memory in the region where we place it. I
> >> suppose a memory_region_init_ram() would provide migration support
> >> automatically but cannot be used on memory where we have
> >> MemoryRegionOps. So we could drop most parts of the device and only run
> >> memory_region_init_ram() ?  
> > if QEMU doesn't need to touch it ever, you could do even better.
> > Use bios_linker to make FW allocate a reserved portion if guest RAM and
> > patch TPM aml code with allocated address. Then you won't have to worry
> > about migration as reserved area is already migrated as part of RAM.  
> 
> The location needs to be fixed across reboots (or content moved
> somehow..) And timing-wise, I am not sure the ACPI tables are
> installed and processed by firmware before the TPM PPI operation must
> be handled.
true,
maybe add a note/reason to commit message why bios_linker couldn't be used,
to prevent the same question being raised again or wasting cycles on
'optimizing' code later with bios_linker when nobody recalls why it can't be used.

> 
> >
> > Huge benefit here is that QEMU doesn't dictate address so no chance
> > of conflicts and related compat hacks in case we have to move it.
> >
> > To do it easily, I'd suggest to extract TPM from DSDT into a dedicated
> > SSDT table (see vmgenid_build_acpi() as example /you don't need
> > bios_linker_loader_write_pointer() part, later we can use it if
> > it would be necessary for QEMU to know address/)
> >  
> >>     Stefan
> >>  
> >
> >  
> 
> 
> 

  reply	other threads:[~2018-06-27 15:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-26 12:23 [Qemu-devel] [PATCH v5 0/4] Add support for TPM Physical Presence interface Marc-André Lureau
2018-06-26 12:23 ` [Qemu-devel] [PATCH v5 1/4] tpm: add a "ppi" boolean property Marc-André Lureau
2018-06-27 11:32   ` Igor Mammedov
2018-06-26 12:23 ` [Qemu-devel] [PATCH v5 2/4] tpm: implement virtual memory device for TPM PPI Marc-André Lureau
2018-06-27 11:44   ` Igor Mammedov
2018-06-27 12:53     ` Stefan Berger
2018-06-27 14:19       ` Igor Mammedov
2018-06-27 14:29         ` Marc-André Lureau
2018-06-27 15:10           ` Igor Mammedov [this message]
2018-06-27 14:36         ` Stefan Berger
2018-06-27 15:05           ` Igor Mammedov
2018-06-27 16:08             ` Laszlo Ersek
2018-06-26 12:23 ` [Qemu-devel] [PATCH v5 3/4] acpi: add fw_cfg file for TPM and PPI virtual memory device Marc-André Lureau
2018-06-27 12:01   ` Igor Mammedov
2018-06-27 12:59     ` Stefan Berger
2018-06-27 14:26       ` Igor Mammedov
2018-06-28 12:42         ` Marc-André Lureau
2018-06-28 13:06           ` Igor Mammedov
2018-06-26 12:23 ` [Qemu-devel] [PATCH v5 4/4] acpi: build TPM Physical Presence interface Marc-André Lureau
2018-06-26 18:57   ` Michael S. Tsirkin
2018-06-27 13:19   ` Igor Mammedov
2018-06-27 14:06     ` Stefan Berger
2018-06-27 14:29       ` Igor Mammedov
2018-06-28 15:24     ` Marc-André Lureau
2018-06-28 15:53       ` Stefan Berger
2018-06-29 14:09       ` Igor Mammedov
2018-06-29 14:19         ` 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=20180627171057.3e030eca@redhat.com \
    --to=imammedo@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --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).