From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: Quan Xu <quan.xu@intel.com>,
stefano.stabellini@eu.citrix.com, eblake@redhat.com
Cc: wei.liu2@citrix.com, qemu-devel@nongnu.org,
xen-devel@lists.xen.org, aliguori@amazon.com,
pbonzini@redhat.com, dgdegra@tycho.nsa.gov
Subject: Re: [Qemu-devel] [PATCH v5 4/6] Qemu-Xen-vTPM: Qemu vTPM xenstubdoms backen.
Date: Wed, 15 Apr 2015 10:50:01 -0400 [thread overview]
Message-ID: <552E7A99.8010805@linux.vnet.ibm.com> (raw)
In-Reply-To: <1428649159-30879-5-git-send-email-quan.xu@intel.com>
On 04/10/2015 02:59 AM, Quan Xu wrote:
> This Patch provides the glue for the TPM_TIS(Qemu frontend) to Xen
> stubdom vTPM domain that provides the actual TPM functionality. It
> sends data and TPM commends with xen_vtpm_frontend. It is similar as
> another two vTPM backens:
> *vTPM passthrough backen Since QEMU 1.5.
> *vTPM libtpms-based backen.
>
> Some details:
> This part of the patch provides support for the spawning of a thread
> that will interact with stubdom vTPM domain by the xen_vtpm_frontend.
> It expects a signal from the frontend to wake and pick up the TPM
> command that is supposed to be processed and delivers the response
> packet using a callback function provided by the frontend.
>
> The backend connects itself to the frontend by filling out an interface
> structure with pointers to the function implementing support for various
> operations.
>
> (QEMU) vTPM XenStubdoms backen is initialized by Qemu command line options,
> "-tpmdev xenstubdoms,id=xenvtpm0 -device tpm-tis,tpmdev=xenvtpm0"
>
> Signed-off-by: Quan Xu <quan.xu@intel.com>
>
> --Changes in v5:
> -comments enhancement.
> ---
> hw/tpm/Makefile.objs | 2 +-
> hw/tpm/tpm_xenstubdoms.c | 256 +++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 257 insertions(+), 1 deletion(-)
> create mode 100644 hw/tpm/tpm_xenstubdoms.c
>
> diff --git a/hw/tpm/Makefile.objs b/hw/tpm/Makefile.objs
> index 57919fa..190e776 100644
> --- a/hw/tpm/Makefile.objs
> +++ b/hw/tpm/Makefile.objs
> @@ -1,3 +1,3 @@
> common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o
> common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o
> -common-obj-$(CONFIG_TPM_XENSTUBDOMS) += xen_vtpm_frontend.o
> +common-obj-$(CONFIG_TPM_XENSTUBDOMS) += tpm_xenstubdoms.o xen_vtpm_frontend.o
> diff --git a/hw/tpm/tpm_xenstubdoms.c b/hw/tpm/tpm_xenstubdoms.c
> new file mode 100644
> index 0000000..3d046fc
> --- /dev/null
> +++ b/hw/tpm/tpm_xenstubdoms.c
> @@ -0,0 +1,256 @@
> +/*
> + * Xen Stubdom vTPM driver
> + *
> + * Copyright (c) 2015 Intel Corporation
> + * Authors:
> + * Quan Xu <quan.xu@intel.com>
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, see <http://www.gnu.org/licenses/>
> + */
> +
> +#include <dirent.h>
> +#include "qemu-common.h"
> +#include "qapi/error.h"
> +#include "qemu/sockets.h"
> +#include "qemu/log.h"
> +#include "sysemu/tpm_backend.h"
> +#include "tpm_int.h"
> +#include "hw/hw.h"
> +#include "hw/i386/pc.h"
> +#include "hw/xen/xen_backend.h"
> +#include "sysemu/tpm_backend_int.h"
> +#include "tpm_tis.h"
> +
> +#ifdef DEBUG_TPM
> +#define DPRINTF(fmt, ...) \
> + do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
> +#else
> +#define DPRINTF(fmt, ...) \
> + do { } while (0)
> +#endif
> +
> +#define TYPE_TPM_XENSTUBDOMS "tpm-xenstubdoms"
> +#define TPM_XENSTUBDOMS(obj) \
> + OBJECT_CHECK(TPMXenstubdomsState, (obj), TYPE_TPM_XENSTUBDOMS)
> +
> +static const TPMDriverOps tpm_xenstubdoms_driver;
> +
> +/* Data structures */
> +typedef struct TPMXenstubdomsThreadParams {
> + TPMState *tpm_state;
> + TPMRecvDataCB *recv_data_callback;
> + TPMBackend *tb;
> +} TPMXenstubdomsThreadParams;
> +
> +struct TPMXenstubdomsState {
> + TPMBackend parent;
> + TPMBackendThread tbt;
> + TPMXenstubdomsThreadParams tpm_thread_params;
> + bool had_startup_error;
> +};
> +
> +typedef struct TPMXenstubdomsState TPMXenstubdomsState;
> +
> +/* Functions */
> +static void tpm_xenstubdoms_cancel_cmd(TPMBackend *tb);
> +
> +static int tpm_xenstubdoms_unix_transfer(const TPMLocality *locty_data)
> +{
> + size_t rlen;
> + struct XenDevice *xendev;
> + int ret;
> +
> + xendev = xen_find_xendev("vtpm", xen_domid, xenstore_dev);
> + if (xendev == NULL) {
> + xen_be_printf(xendev, 0, "Can not find vtpm device.\n");
> + return -1;
> + }
> +
> + ret = vtpm_send(xendev, locty_data->w_buffer.buffer,
> + locty_data->r_buffer.size, locty_data->w_offset);
> + if (ret < 0) {
> + xen_be_printf(xendev, 0, "Can not send vtpm command.\n");
> + return -1;
> + }
> +
> + vtpm_recv(xendev, locty_data->r_buffer.buffer, locty_data->r_buffer.size,
> + &rlen);
> + return 0;
> +}
> +
> +static void tpm_xenstubdoms_worker_thread(gpointer data,
> + gpointer user_data)
> +{
> + TPMXenstubdomsThreadParams *thr_parms = user_data;
> + TPMBackendCmd cmd = (TPMBackendCmd)data;
> +
> + switch (cmd) {
> + case TPM_BACKEND_CMD_PROCESS_CMD:
> + tpm_xenstubdoms_unix_transfer(thr_parms->tpm_state->locty_data);
> + thr_parms->recv_data_callback(thr_parms->tpm_state,
> + thr_parms->tpm_state->locty_number,
> + false);
Didn't look at this before. I still think you should reorder the patches.
Rest looks good.
Stefan
next prev parent reply other threads:[~2015-04-15 14:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-10 6:59 [Qemu-devel] [PATCH v5 0/6] QEMU:Xen stubdom vTPM for HVM virtual machine(QEMU patch) Quan Xu
2015-04-10 6:59 ` [Qemu-devel] [PATCH v5 1/6] Qemu-Xen-vTPM: Support for Xen stubdom vTPM command line options Quan Xu
2015-04-10 13:22 ` Eric Blake
2015-04-13 2:32 ` Xu, Quan
2015-04-10 6:59 ` [Qemu-devel] [PATCH v5 2/6] Qemu-Xen-vTPM: Xen frontend driver infrastructure Quan Xu
2015-04-10 6:59 ` [Qemu-devel] [PATCH v5 3/6] " Quan Xu
2015-04-15 14:44 ` Stefan Berger
2015-04-15 15:07 ` Daniel De Graaf
2015-04-16 1:03 ` Xu, Quan
2015-04-10 6:59 ` [Qemu-devel] [PATCH v5 4/6] Qemu-Xen-vTPM: Qemu vTPM xenstubdoms backen Quan Xu
2015-04-15 14:50 ` Stefan Berger [this message]
2015-04-16 1:07 ` Xu, Quan
2015-04-10 6:59 ` [Qemu-devel] [PATCH v5 5/6] Qemu-Xen-vTPM: QEMU machine class is initialized before tpm_init() Quan Xu
2015-04-10 6:59 ` [Qemu-devel] [PATCH v5 6/6] Qemu-Xen-vTPM: Add a parameter indicating whether the command that was a selftest Quan Xu
2015-04-12 20:50 ` Stefan Berger
2015-04-13 2:15 ` Xu, Quan
2015-04-15 14:56 ` Stefan Berger
2015-04-16 1:04 ` Xu, Quan
2015-04-13 22:35 ` Stefan Berger
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=552E7A99.8010805@linux.vnet.ibm.com \
--to=stefanb@linux.vnet.ibm.com \
--cc=aliguori@amazon.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quan.xu@intel.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/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).