From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509993695458565.4561414241899; Mon, 6 Nov 2017 10:41:35 -0800 (PST) Received: from localhost ([::1]:49716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKt-0007P7-8j for importer@patchew.org; Mon, 06 Nov 2017 13:41:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJ6-0006B3-HU for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJ5-00048U-Mg for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49914) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJ5-00048E-GM for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:35 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 908BA85A05; Mon, 6 Nov 2017 18:39:34 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id F31AE60561; Mon, 6 Nov 2017 18:39:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 908BA85A05 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:38:58 +0100 Message-Id: <20171106183925.16747-2-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 06 Nov 2017 18:39:34 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 01/28] tpm-tis: remove unused locty_number X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This field slipped in commit 5086bf9784. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_tis.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 7402528b25..c5c534d7f2 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -89,7 +89,6 @@ struct TPMState { qemu_irq irq; uint32_t irq_num; =20 - uint8_t locty_number; TPMBackendCmd cmd; =20 char *backend; --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509993709209694.0546996244251; Mon, 6 Nov 2017 10:41:49 -0800 (PST) Received: from localhost ([::1]:49717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKy-0007TG-2A for importer@patchew.org; Mon, 06 Nov 2017 13:41:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJ9-0006D6-KW for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJ8-00049l-Qy for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55838) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJ8-000492-Hy for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:38 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8ECB54E33B; Mon, 6 Nov 2017 18:39:37 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 038F5600D3; Mon, 6 Nov 2017 18:39:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8ECB54E33B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:38:59 +0100 Message-Id: <20171106183925.16747-3-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 06 Nov 2017 18:39:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 02/28] tpm: move TpmIf in include/sysemu/tpm.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is a better location than hw/tpm, since we are going to use the interface from outside hw/tpm. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_int.h | 22 +--------------------- include/sysemu/tpm.h | 19 +++++++++++++++++++ backends/tpm.c | 1 - 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/hw/tpm/tpm_int.h b/hw/tpm/tpm_int.h index 9c045b6691..1df5883f3c 100644 --- a/hw/tpm/tpm_int.h +++ b/hw/tpm/tpm_int.h @@ -13,28 +13,8 @@ #define TPM_TPM_INT_H =20 #include "qemu/osdep.h" -#include "qom/object.h" =20 -#define TYPE_TPM_IF "tpm-if" -#define TPM_IF_CLASS(klass) \ - OBJECT_CLASS_CHECK(TPMIfClass, (klass), TYPE_TPM_IF) -#define TPM_IF_GET_CLASS(obj) \ - OBJECT_GET_CLASS(TPMIfClass, (obj), TYPE_TPM_IF) -#define TPM_IF(obj) \ - INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF) - -typedef struct TPMIf { - Object parent_obj; -} TPMIf; - -typedef struct TPMIfClass { - InterfaceClass parent_class; - - /* run in thread pool by backend */ - void (*request_completed)(TPMIf *obj); -} TPMIfClass; - -#define TPM_STANDARD_CMDLINE_OPTS \ +#define TPM_STANDARD_CMDLINE_OPTS \ { \ .name =3D "type", \ .type =3D QEMU_OPT_STRING, \ diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index d7a2bd8556..452cdb9cb7 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -27,6 +27,25 @@ typedef enum TPMVersion { TPM_VERSION_2_0 =3D 2, } TPMVersion; =20 +#define TYPE_TPM_IF "tpm-if" +#define TPM_IF_CLASS(klass) \ + OBJECT_CLASS_CHECK(TPMIfClass, (klass), TYPE_TPM_IF) +#define TPM_IF_GET_CLASS(obj) \ + OBJECT_GET_CLASS(TPMIfClass, (obj), TYPE_TPM_IF) +#define TPM_IF(obj) \ + INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF) + +typedef struct TPMIf { + Object parent_obj; +} TPMIf; + +typedef struct TPMIfClass { + InterfaceClass parent_class; + + /* run in thread pool by backend */ + void (*request_completed)(TPMIf *obj); +} TPMIfClass; + TPMVersion tpm_tis_get_tpm_version(Object *obj); =20 #define TYPE_TPM_TIS "tpm-tis" diff --git a/backends/tpm.c b/backends/tpm.c index 5763f6f369..1e416d7f90 100644 --- a/backends/tpm.c +++ b/backends/tpm.c @@ -17,7 +17,6 @@ #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "sysemu/tpm.h" -#include "hw/tpm/tpm_int.h" #include "qemu/thread.h" =20 static void tpm_backend_worker_thread(gpointer data, gpointer user_data) --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509993849737667.2379255091962; Mon, 6 Nov 2017 10:44:09 -0800 (PST) Received: from localhost ([::1]:49728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmNR-0001Yq-NY for importer@patchew.org; Mon, 06 Nov 2017 13:44:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJH-0006J4-E0 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJE-0004G8-A1 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJE-0004Fv-12 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:44 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0205513AAB; Mon, 6 Nov 2017 18:39:43 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EDC2190C0; Mon, 6 Nov 2017 18:39:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0205513AAB Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:00 +0100 Message-Id: <20171106183925.16747-4-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Nov 2017 18:39:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 03/28] tpm-backend: store TPMIf interface, improve backend_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Store the TPM interface, the actual object may be different from TPMState. Keep a reference on the interface, and check the backend wasn't already initialized. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm.h | 2 +- include/sysemu/tpm_backend.h | 6 +++--- backends/tpm.c | 11 +++++++++-- hw/tpm/tpm_emulator.c | 4 ++-- hw/tpm/tpm_passthrough.c | 4 ++-- hw/tpm/tpm_tis.c | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 452cdb9cb7..fb1719e5e4 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -12,8 +12,8 @@ #ifndef QEMU_TPM_H #define QEMU_TPM_H =20 -#include "qemu/option.h" #include "qom/object.h" +#include "qapi-types.h" =20 typedef struct TPMState TPMState; =20 diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index 03ea5a3400..b5f21ed8f1 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -43,8 +43,8 @@ struct TPMBackend { Object parent; =20 /*< protected >*/ + TPMIf *tpmif; bool opened; - TPMState *tpm_state; GThreadPool *thread_pool; bool had_startup_error; =20 @@ -96,14 +96,14 @@ enum TpmType tpm_backend_get_type(TPMBackend *s); /** * tpm_backend_init: * @s: the backend to initialized - * @state: TPMState + * @tpmif: TPM interface * @datacb: callback for sending data to frontend * * Initialize the backend with the given variables. * * Returns 0 on success. */ -int tpm_backend_init(TPMBackend *s, TPMState *state); +int tpm_backend_init(TPMBackend *s, TPMIf *tpmif); =20 /** * tpm_backend_startup_tpm: diff --git a/backends/tpm.c b/backends/tpm.c index 1e416d7f90..86f0e7e915 100644 --- a/backends/tpm.c +++ b/backends/tpm.c @@ -43,9 +43,15 @@ enum TpmType tpm_backend_get_type(TPMBackend *s) return k->type; } =20 -int tpm_backend_init(TPMBackend *s, TPMState *state) +int tpm_backend_init(TPMBackend *s, TPMIf *tpmif) { - s->tpm_state =3D state; + if (s->tpmif) { + return -1; + } + + s->tpmif =3D tpmif; + object_ref(OBJECT(tpmif)); + s->had_startup_error =3D false; =20 return 0; @@ -193,6 +199,7 @@ static void tpm_backend_instance_finalize(Object *obj) { TPMBackend *s =3D TPM_BACKEND(obj); =20 + object_unref(OBJECT(s->tpmif)); g_free(s->id); tpm_backend_thread_end(s); } diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index 9aaec8e3ef..6bf025c7e2 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -176,7 +176,7 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_e= mu, uint8_t locty_number, static void tpm_emulator_handle_request(TPMBackend *tb, TPMBackendCmd *cmd) { TPMEmulator *tpm_emu =3D TPM_EMULATOR(tb); - TPMIfClass *tic =3D TPM_IF_GET_CLASS(tb->tpm_state); + TPMIfClass *tic =3D TPM_IF_GET_CLASS(tb->tpmif); Error *err =3D NULL; =20 DPRINTF("processing TPM command"); @@ -191,7 +191,7 @@ static void tpm_emulator_handle_request(TPMBackend *tb,= TPMBackendCmd *cmd) goto error; } =20 - tic->request_completed(TPM_IF(tb->tpm_state)); + tic->request_completed(tb->tpmif); return; =20 error: diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index c440aff4b2..2ad74badca 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -139,14 +139,14 @@ err_exit: static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd *= cmd) { TPMPassthruState *tpm_pt =3D TPM_PASSTHROUGH(tb); - TPMIfClass *tic =3D TPM_IF_GET_CLASS(tb->tpm_state); + TPMIfClass *tic =3D TPM_IF_GET_CLASS(tb->tpmif); =20 DPRINTF("tpm_passthrough: processing command %p\n", cmd); =20 tpm_passthrough_unix_tx_bufs(tpm_pt, cmd->in, cmd->in_len, cmd->out, cmd->out_len, &cmd->selftest_do= ne); =20 - tic->request_completed(TPM_IF(tb->tpm_state)); + tic->request_completed(tb->tpmif); } =20 static void tpm_passthrough_reset(TPMBackend *tb) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index c5c534d7f2..34ceec91c3 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -1078,7 +1078,7 @@ static void tpm_tis_realizefn(DeviceState *dev, Error= **errp) =20 s->be_driver->fe_model =3D TPM_MODEL_TPM_TIS; =20 - if (tpm_backend_init(s->be_driver, s)) { + if (tpm_backend_init(s->be_driver, TPM_IF(s))) { error_setg(errp, "tpm_tis: backend driver with id %s could not be " "initialized", s->backend); return; --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509993714122444.28692762391097; Mon, 6 Nov 2017 10:41:54 -0800 (PST) Received: from localhost ([::1]:49718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmLC-0007gD-78 for importer@patchew.org; Mon, 06 Nov 2017 13:41:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJK-0006LG-31 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJJ-0004Hz-8G for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44078) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJJ-0004Hl-2S for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:49 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A27AC058ECE; Mon, 6 Nov 2017 18:39:48 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64CD15D6A3; Mon, 6 Nov 2017 18:39:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0A27AC058ECE Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:01 +0100 Message-Id: <20171106183925.16747-5-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 06 Nov 2017 18:39:48 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 04/28] tpm-tis: no longer expose TPMState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that there is an interface instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm.h | 2 -- hw/tpm/tpm_tis.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index fb1719e5e4..7a1713a81e 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -15,8 +15,6 @@ #include "qom/object.h" #include "qapi-types.h" =20 -typedef struct TPMState TPMState; - int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); int tpm_init(void); void tpm_cleanup(void); diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 34ceec91c3..4a8a2ffc79 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -72,7 +72,7 @@ typedef struct TPMLocality { TPMSizedBuffer r_buffer; } TPMLocality; =20 -struct TPMState { +typedef struct TPMState { ISADevice busdev; MemoryRegion mmio; =20 @@ -94,7 +94,7 @@ struct TPMState { char *backend; TPMBackend *be_driver; TPMVersion be_tpm_version; -}; +} TPMState; =20 #define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS) =20 --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994019572852.3312618504058; Mon, 6 Nov 2017 10:46:59 -0800 (PST) Received: from localhost ([::1]:49745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmQ8-0003ud-Pq for importer@patchew.org; Mon, 06 Nov 2017 13:46:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJT-0006TG-Q5 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJN-0004J2-M0 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46040) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJN-0004Il-Cv for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F8A7C058EC4; Mon, 6 Nov 2017 18:39:52 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E7A25D6A3; Mon, 6 Nov 2017 18:39:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6F8A7C058EC4 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:02 +0100 Message-Id: <20171106183925.16747-6-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 06 Nov 2017 18:39:52 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 05/28] tpm-be: call request_completed() out of thread X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Lift from the backend implementation the responsability to call the request_completed() callback outside of thread context. This also simplify frontend/interface work, as they no longer need to care whether the callback is called from a different thread. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm.h | 1 - include/sysemu/tpm_backend.h | 1 + backends/tpm.c | 15 ++++++++++++++- hw/tpm/tpm_emulator.c | 2 -- hw/tpm/tpm_passthrough.c | 3 --- hw/tpm/tpm_tis.c | 34 ++++++++++++---------------------- 6 files changed, 27 insertions(+), 29 deletions(-) diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 7a1713a81e..e0879620e7 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -40,7 +40,6 @@ typedef struct TPMIf { typedef struct TPMIfClass { InterfaceClass parent_class; =20 - /* run in thread pool by backend */ void (*request_completed)(TPMIf *obj); } TPMIfClass; =20 diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index b5f21ed8f1..c5d1a6818a 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -47,6 +47,7 @@ struct TPMBackend { bool opened; GThreadPool *thread_pool; bool had_startup_error; + QEMUBH *bh; =20 /* */ char *id; diff --git a/backends/tpm.c b/backends/tpm.c index 86f0e7e915..58f823d54c 100644 --- a/backends/tpm.c +++ b/backends/tpm.c @@ -18,14 +18,25 @@ #include "qapi/qmp/qerror.h" #include "sysemu/tpm.h" #include "qemu/thread.h" +#include "qemu/main-loop.h" + +static void tpm_backend_request_completed_bh(void *opaque) +{ + TPMBackend *s =3D TPM_BACKEND(opaque); + TPMIfClass *tic =3D TPM_IF_GET_CLASS(s->tpmif); + + tic->request_completed(s->tpmif); +} =20 static void tpm_backend_worker_thread(gpointer data, gpointer user_data) { TPMBackend *s =3D TPM_BACKEND(user_data); - TPMBackendClass *k =3D TPM_BACKEND_GET_CLASS(s); + TPMBackendClass *k =3D TPM_BACKEND_GET_CLASS(s); =20 assert(k->handle_request !=3D NULL); k->handle_request(s, (TPMBackendCmd *)data); + + qemu_bh_schedule(s->bh); } =20 static void tpm_backend_thread_end(TPMBackend *s) @@ -193,6 +204,7 @@ static void tpm_backend_instance_init(Object *obj) tpm_backend_prop_set_opened, NULL); s->fe_model =3D -1; + s->bh =3D qemu_bh_new(tpm_backend_request_completed_bh, s); } =20 static void tpm_backend_instance_finalize(Object *obj) @@ -202,6 +214,7 @@ static void tpm_backend_instance_finalize(Object *obj) object_unref(OBJECT(s->tpmif)); g_free(s->id); tpm_backend_thread_end(s); + qemu_bh_delete(s->bh); } =20 static const TypeInfo tpm_backend_info =3D { diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index 6bf025c7e2..883e8c0c2d 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -176,7 +176,6 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_e= mu, uint8_t locty_number, static void tpm_emulator_handle_request(TPMBackend *tb, TPMBackendCmd *cmd) { TPMEmulator *tpm_emu =3D TPM_EMULATOR(tb); - TPMIfClass *tic =3D TPM_IF_GET_CLASS(tb->tpmif); Error *err =3D NULL; =20 DPRINTF("processing TPM command"); @@ -191,7 +190,6 @@ static void tpm_emulator_handle_request(TPMBackend *tb,= TPMBackendCmd *cmd) goto error; } =20 - tic->request_completed(tb->tpmif); return; =20 error: diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 2ad74badca..8c002e4da6 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -139,14 +139,11 @@ err_exit: static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd *= cmd) { TPMPassthruState *tpm_pt =3D TPM_PASSTHROUGH(tb); - TPMIfClass *tic =3D TPM_IF_GET_CLASS(tb->tpmif); =20 DPRINTF("tpm_passthrough: processing command %p\n", cmd); =20 tpm_passthrough_unix_tx_bufs(tpm_pt, cmd->in, cmd->in_len, cmd->out, cmd->out_len, &cmd->selftest_do= ne); - - tic->request_completed(tb->tpmif); } =20 static void tpm_passthrough_reset(TPMBackend *tb) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 4a8a2ffc79..f81aaf10c3 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -76,7 +76,6 @@ typedef struct TPMState { ISADevice busdev; MemoryRegion mmio; =20 - QEMUBH *bh; uint32_t offset; uint8_t buf[TPM_TIS_BUFFER_MAX]; =20 @@ -410,10 +409,20 @@ static void tpm_tis_prep_abort(TPMState *s, uint8_t l= octy, uint8_t newlocty) tpm_tis_abort(s, locty); } =20 -static void tpm_tis_receive_bh(void *opaque) +/* + * Callback from the TPM to indicate that the response was received. + */ +static void tpm_tis_request_completed(TPMIf *ti) { - TPMState *s =3D opaque; + TPMState *s =3D TPM(ti); uint8_t locty =3D s->cmd.locty; + uint8_t l; + + if (s->cmd.selftest_done) { + for (l =3D 0; l < TPM_TIS_NUM_LOCALITIES; l++) { + s->loc[locty].sts |=3D TPM_TIS_STS_SELFTEST_DONE; + } + } =20 tpm_tis_sts_set(&s->loc[locty], TPM_TIS_STS_VALID | TPM_TIS_STS_DATA_AVAILABLE); @@ -431,23 +440,6 @@ static void tpm_tis_receive_bh(void *opaque) TPM_TIS_INT_DATA_AVAILABLE | TPM_TIS_INT_STS_VALID); } =20 -static void tpm_tis_request_completed(TPMIf *ti) -{ - TPMState *s =3D TPM(ti); - - bool is_selftest_done =3D s->cmd.selftest_done; - uint8_t locty =3D s->cmd.locty; - uint8_t l; - - if (is_selftest_done) { - for (l =3D 0; l < TPM_TIS_NUM_LOCALITIES; l++) { - s->loc[locty].sts |=3D TPM_TIS_STS_SELFTEST_DONE; - } - } - - qemu_bh_schedule(s->bh); -} - /* * Read a byte of response data */ @@ -1090,8 +1082,6 @@ static void tpm_tis_realizefn(DeviceState *dev, Error= **errp) return; } =20 - s->bh =3D qemu_bh_new(tpm_tis_receive_bh, s); - isa_init_irq(&s->busdev, &s->irq, s->irq_num); =20 memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)), --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509993847064315.0267893606708; Mon, 6 Nov 2017 10:44:07 -0800 (PST) Received: from localhost ([::1]:49727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmNP-0001Ws-33 for importer@patchew.org; Mon, 06 Nov 2017 13:44:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJW-0006W0-FI for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJS-0004Kv-DR for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJS-0004KM-7x for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:39:58 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 41FFF8047F; Mon, 6 Nov 2017 18:39:57 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id B320E5C552; Mon, 6 Nov 2017 18:39:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 41FFF8047F Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:03 +0100 Message-Id: <20171106183925.16747-7-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 06 Nov 2017 18:39:57 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 06/28] tpm-be: report error instead of front-end X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Backend can give more accurate error description, and lift out the job from the frontend. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm_backend.h | 3 ++- backends/tpm.c | 3 ++- hw/tpm/tpm_tis.c | 4 +--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index c5d1a6818a..df9ebd0e81 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -99,12 +99,13 @@ enum TpmType tpm_backend_get_type(TPMBackend *s); * @s: the backend to initialized * @tpmif: TPM interface * @datacb: callback for sending data to frontend + * @errp: a pointer to return the #Error object if an error occurs. * * Initialize the backend with the given variables. * * Returns 0 on success. */ -int tpm_backend_init(TPMBackend *s, TPMIf *tpmif); +int tpm_backend_init(TPMBackend *s, TPMIf *tpmif, Error **errp); =20 /** * tpm_backend_startup_tpm: diff --git a/backends/tpm.c b/backends/tpm.c index 58f823d54c..7b108bd5d8 100644 --- a/backends/tpm.c +++ b/backends/tpm.c @@ -54,9 +54,10 @@ enum TpmType tpm_backend_get_type(TPMBackend *s) return k->type; } =20 -int tpm_backend_init(TPMBackend *s, TPMIf *tpmif) +int tpm_backend_init(TPMBackend *s, TPMIf *tpmif, Error **errp) { if (s->tpmif) { + error_setg(errp, "TPM backend '%s' is already initialized", s->id); return -1; } =20 diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index f81aaf10c3..2febc8bd08 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -1070,9 +1070,7 @@ static void tpm_tis_realizefn(DeviceState *dev, Error= **errp) =20 s->be_driver->fe_model =3D TPM_MODEL_TPM_TIS; =20 - if (tpm_backend_init(s->be_driver, TPM_IF(s))) { - error_setg(errp, "tpm_tis: backend driver with id %s could not be " - "initialized", s->backend); + if (tpm_backend_init(s->be_driver, TPM_IF(s), errp)) { return; } =20 --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994015265435.58646579919; Mon, 6 Nov 2017 10:46:55 -0800 (PST) Received: from localhost ([::1]:49744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmQ0-0003nc-2V for importer@patchew.org; Mon, 06 Nov 2017 13:46:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJZ-0006YG-Dv for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJY-0004Mb-IA for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49617) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJY-0004ML-9X for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:04 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51919B5B0; Mon, 6 Nov 2017 18:40:03 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8482A5D9CD; Mon, 6 Nov 2017 18:39:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51919B5B0 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:04 +0100 Message-Id: <20171106183925.16747-8-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 06 Nov 2017 18:40:03 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 07/28] tpm-be: ask model to the TPM interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" No need to store the mode in the backend, or to let the frontend set it itself. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm.h | 1 + include/sysemu/tpm_backend.h | 1 - backends/tpm.c | 4 ++-- hw/tpm/tpm_tis.c | 3 +-- tpm.c | 3 ++- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index e0879620e7..7b407caf25 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -40,6 +40,7 @@ typedef struct TPMIf { typedef struct TPMIfClass { InterfaceClass parent_class; =20 + enum TpmModel model; void (*request_completed)(TPMIf *obj); } TPMIfClass; =20 diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index df9ebd0e81..665e807a73 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -51,7 +51,6 @@ struct TPMBackend { =20 /* */ char *id; - enum TpmModel fe_model; =20 QLIST_ENTRY(TPMBackend) list; }; diff --git a/backends/tpm.c b/backends/tpm.c index 7b108bd5d8..0c48d18775 100644 --- a/backends/tpm.c +++ b/backends/tpm.c @@ -148,9 +148,10 @@ TPMInfo *tpm_backend_query_tpm(TPMBackend *s) { TPMInfo *info =3D g_new0(TPMInfo, 1); TPMBackendClass *k =3D TPM_BACKEND_GET_CLASS(s); + TPMIfClass *tic =3D TPM_IF_GET_CLASS(s->tpmif); =20 info->id =3D g_strdup(s->id); - info->model =3D s->fe_model; + info->model =3D tic->model; if (k->get_tpm_options) { info->options =3D k->get_tpm_options(s); } @@ -204,7 +205,6 @@ static void tpm_backend_instance_init(Object *obj) tpm_backend_prop_get_opened, tpm_backend_prop_set_opened, NULL); - s->fe_model =3D -1; s->bh =3D qemu_bh_new(tpm_backend_request_completed_bh, s); } =20 diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 2febc8bd08..c1b738c29f 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -1068,8 +1068,6 @@ static void tpm_tis_realizefn(DeviceState *dev, Error= **errp) return; } =20 - s->be_driver->fe_model =3D TPM_MODEL_TPM_TIS; - if (tpm_backend_init(s->be_driver, TPM_IF(s), errp)) { return; } @@ -1104,6 +1102,7 @@ static void tpm_tis_class_init(ObjectClass *klass, vo= id *data) dc->props =3D tpm_tis_properties; dc->reset =3D tpm_tis_reset; dc->vmsd =3D &vmstate_tpm_tis; + tc->model =3D TPM_MODEL_TPM_TIS; tc->request_completed =3D tpm_tis_request_completed; } =20 diff --git a/tpm.c b/tpm.c index ab5d29e91e..4320f44c9f 100644 --- a/tpm.c +++ b/tpm.c @@ -200,9 +200,10 @@ TPMInfoList *qmp_query_tpm(Error **errp) TPMInfoList *info, *head =3D NULL, *cur_item =3D NULL; =20 QLIST_FOREACH(drv, &tpm_backends, list) { - if (!tpm_models[drv->fe_model]) { + if (!drv->tpmif) { continue; } + info =3D g_new0(TPMInfoList, 1); info->value =3D tpm_backend_query_tpm(drv); =20 --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 150999417403816.330515827576278; Mon, 6 Nov 2017 10:49:34 -0800 (PST) Received: from localhost ([::1]:49754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmSe-0006Ee-5W for importer@patchew.org; Mon, 06 Nov 2017 13:49:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJi-0006gS-8N for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJd-0004No-7l for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46546) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJc-0004NR-VM for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:09 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0309BC0587CB; Mon, 6 Nov 2017 18:40:08 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EEDB60561; Mon, 6 Nov 2017 18:40:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0309BC0587CB Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:05 +0100 Message-Id: <20171106183925.16747-9-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 06 Nov 2017 18:40:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 08/28] tpm: remove unused opened code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm_backend.h | 12 ------------ backends/tpm.c | 42 ----------------------------------------= -- tpm.c | 6 ------ 3 files changed, 60 deletions(-) diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index 665e807a73..904e5b1026 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -80,8 +80,6 @@ struct TPMBackendClass { =20 TpmTypeOptions *(*get_tpm_options)(TPMBackend *t); =20 - void (*opened)(TPMBackend *s, Error **errp); - void (*handle_request)(TPMBackend *s, TPMBackendCmd *cmd); }; =20 @@ -171,16 +169,6 @@ bool tpm_backend_get_tpm_established_flag(TPMBackend *= s); */ int tpm_backend_reset_tpm_established_flag(TPMBackend *s, uint8_t locty); =20 -/** - * tpm_backend_open: - * @s: the backend to open - * @errp: a pointer to return the #Error object if an error occurs. - * - * This function will open the backend if it is not already open. Calling= this - * function on an already opened backend will not result in an error. - */ -void tpm_backend_open(TPMBackend *s, Error **errp); - /** * tpm_backend_get_tpm_version: * @s: the backend to call into diff --git a/backends/tpm.c b/backends/tpm.c index 0c48d18775..7e636fbc7a 100644 --- a/backends/tpm.c +++ b/backends/tpm.c @@ -159,52 +159,10 @@ TPMInfo *tpm_backend_query_tpm(TPMBackend *s) return info; } =20 -static bool tpm_backend_prop_get_opened(Object *obj, Error **errp) -{ - TPMBackend *s =3D TPM_BACKEND(obj); - - return s->opened; -} - -void tpm_backend_open(TPMBackend *s, Error **errp) -{ - object_property_set_bool(OBJECT(s), true, "opened", errp); -} - -static void tpm_backend_prop_set_opened(Object *obj, bool value, Error **e= rrp) -{ - TPMBackend *s =3D TPM_BACKEND(obj); - TPMBackendClass *k =3D TPM_BACKEND_GET_CLASS(s); - Error *local_err =3D NULL; - - if (value =3D=3D s->opened) { - return; - } - - if (!value && s->opened) { - error_setg(errp, QERR_PERMISSION_DENIED); - return; - } - - if (k->opened) { - k->opened(s, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - } - - s->opened =3D true; -} - static void tpm_backend_instance_init(Object *obj) { TPMBackend *s =3D TPM_BACKEND(obj); =20 - object_property_add_bool(obj, "opened", - tpm_backend_prop_get_opened, - tpm_backend_prop_set_opened, - NULL); s->bh =3D qemu_bh_new(tpm_backend_request_completed_bh, s); } =20 diff --git a/tpm.c b/tpm.c index 4320f44c9f..32d398aadf 100644 --- a/tpm.c +++ b/tpm.c @@ -132,12 +132,6 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts= , Error **errp) return 1; } =20 - tpm_backend_open(drv, &local_err); - if (local_err) { - error_report_err(local_err); - return 1; - } - QLIST_INSERT_HEAD(&tpm_backends, drv, list); =20 return 0; --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509993841560473.492805305983; Mon, 6 Nov 2017 10:44:01 -0800 (PST) Received: from localhost ([::1]:49726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmNH-0001Qs-NC for importer@patchew.org; Mon, 06 Nov 2017 13:43:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJj-0006hu-NA for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJi-0004Qf-TR for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39648) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJi-0004Ph-Lz for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:14 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD641629; Mon, 6 Nov 2017 18:40:13 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 489C860C90; Mon, 6 Nov 2017 18:40:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AD641629 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:06 +0100 Message-Id: <20171106183925.16747-10-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Nov 2017 18:40:13 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 09/28] tpm-passthrough: don't save guessed cancel_path in options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The value is later unneeded, and may leak if the free visitor doesn't consider it since has_cancel_path is false. And for consistency with "path" it shouldn't be returned in get_tpm_options(). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 8c002e4da6..048edb1a1a 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -226,9 +226,7 @@ static int tpm_passthrough_open_sysfs_cancel(TPMPassthr= uState *tpm_pt) if (snprintf(path, sizeof(path), "/sys/class/misc/%s/device/cancel= ", dev) < sizeof(path)) { fd =3D qemu_open(path, O_WRONLY); - if (fd >=3D 0) { - tpm_pt->options->cancel_path =3D g_strdup(path); - } else { + if (fd < 0) { error_report("tpm_passthrough: Could not open TPM cancel " "path %s : %s", path, strerror(errno)); } --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994013194476.521941655918; Mon, 6 Nov 2017 10:46:53 -0800 (PST) Received: from localhost ([::1]:49743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmPq-0003gq-8F for importer@patchew.org; Mon, 06 Nov 2017 13:46:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJu-0006xR-2M for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJp-0004Yg-04 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53398) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJo-0004Xe-Nz for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:20 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7A5085A05; Mon, 6 Nov 2017 18:40:19 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C06E5C8AC; Mon, 6 Nov 2017 18:40:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A7A5085A05 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:07 +0100 Message-Id: <20171106183925.16747-11-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 06 Nov 2017 18:40:19 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 10/28] tpm-be: update optional function pointers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" QEMU code doesn't generally have assert() for mandatory callbacks/function pointers, probably because the crash is pretty obvious. Document the methods instead of going into the code. Make get_tpm_options() mandatory to implement (since all backend implementation have it). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm_backend.h | 5 ++++- backends/tpm.c | 9 +-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index 904e5b1026..ce8dee58cf 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -65,15 +65,18 @@ struct TPMBackendClass { =20 TPMBackend *(*create)(QemuOpts *opts, const char *id); =20 - /* start up the TPM on the backend */ + /* start up the TPM on the backend - optional */ int (*startup_tpm)(TPMBackend *t); =20 + /* optional */ void (*reset)(TPMBackend *t); =20 void (*cancel_cmd)(TPMBackend *t); =20 + /* optional */ bool (*get_tpm_established_flag)(TPMBackend *t); =20 + /* optional */ int (*reset_tpm_established_flag)(TPMBackend *t, uint8_t locty); =20 TPMVersion (*get_tpm_version)(TPMBackend *t); diff --git a/backends/tpm.c b/backends/tpm.c index 7e636fbc7a..7777467c44 100644 --- a/backends/tpm.c +++ b/backends/tpm.c @@ -33,7 +33,6 @@ static void tpm_backend_worker_thread(gpointer data, gpoi= nter user_data) TPMBackend *s =3D TPM_BACKEND(user_data); TPMBackendClass *k =3D TPM_BACKEND_GET_CLASS(s); =20 - assert(k->handle_request !=3D NULL); k->handle_request(s, (TPMBackendCmd *)data); =20 qemu_bh_schedule(s->bh); @@ -114,8 +113,6 @@ void tpm_backend_cancel_cmd(TPMBackend *s) { TPMBackendClass *k =3D TPM_BACKEND_GET_CLASS(s); =20 - assert(k->cancel_cmd); - k->cancel_cmd(s); } =20 @@ -139,8 +136,6 @@ TPMVersion tpm_backend_get_tpm_version(TPMBackend *s) { TPMBackendClass *k =3D TPM_BACKEND_GET_CLASS(s); =20 - assert(k->get_tpm_version); - return k->get_tpm_version(s); } =20 @@ -152,9 +147,7 @@ TPMInfo *tpm_backend_query_tpm(TPMBackend *s) =20 info->id =3D g_strdup(s->id); info->model =3D tic->model; - if (k->get_tpm_options) { - info->options =3D k->get_tpm_options(s); - } + info->options =3D k->get_tpm_options(s); =20 return info; } --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994342615171.9390710301642; Mon, 6 Nov 2017 10:52:22 -0800 (PST) Received: from localhost ([::1]:49767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmVL-0000CR-AU for importer@patchew.org; Mon, 06 Nov 2017 13:52:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJv-0006ys-J0 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJs-0004c0-48 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57704) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJr-0004aW-SY for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:23 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8F9B7E42C; Mon, 6 Nov 2017 18:40:22 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC92C5C552; Mon, 6 Nov 2017 18:40:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B8F9B7E42C Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:08 +0100 Message-Id: <20171106183925.16747-12-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 06 Nov 2017 18:40:22 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 11/28] tpm-passthrough: pass TPMPassthruState to handle_device_opts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It doesn't need TPMBackend. Also reorder arguments for consistency. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 048edb1a1a..9326cbfdc9 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -239,9 +239,9 @@ static int tpm_passthrough_open_sysfs_cancel(TPMPassthr= uState *tpm_pt) return fd; } =20 -static int tpm_passthrough_handle_device_opts(QemuOpts *opts, TPMBackend *= tb) +static int +tpm_passthrough_handle_device_opts(TPMPassthruState *tpm_pt, QemuOpts *opt= s) { - TPMPassthruState *tpm_pt =3D TPM_PASSTHROUGH(tb); const char *value; =20 value =3D qemu_opt_get(opts, "cancel-path"); @@ -292,7 +292,7 @@ static TPMBackend *tpm_passthrough_create(QemuOpts *opt= s, const char *id) =20 tb->id =3D g_strdup(id); =20 - if (tpm_passthrough_handle_device_opts(opts, tb)) { + if (tpm_passthrough_handle_device_opts(tpm_pt, opts)) { goto err_exit; } =20 --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509993864918234.48906257960914; Mon, 6 Nov 2017 10:44:24 -0800 (PST) Received: from localhost ([::1]:49729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmNh-0001mK-3C for importer@patchew.org; Mon, 06 Nov 2017 13:44:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmJy-00071w-E2 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmJw-0004ei-Jy for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39932) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmJw-0004e9-6d for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:28 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 217DF13A8A; Mon, 6 Nov 2017 18:40:27 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9290600D3; Mon, 6 Nov 2017 18:40:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 217DF13A8A Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:09 +0100 Message-Id: <20171106183925.16747-13-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Nov 2017 18:40:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 12/28] tpm-backend: move set 'id' to common code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm_backend.h | 2 +- hw/tpm/tpm_emulator.c | 12 +++--------- hw/tpm/tpm_passthrough.c | 9 +++------ tpm.c | 3 ++- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index ce8dee58cf..1ad27ec374 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -63,7 +63,7 @@ struct TPMBackendClass { /* get a descriptive text of the backend to display to the user */ const char *desc; =20 - TPMBackend *(*create)(QemuOpts *opts, const char *id); + TPMBackend *(*create)(QemuOpts *opts); =20 /* start up the TPM on the backend - optional */ int (*startup_tpm)(TPMBackend *t); diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index 883e8c0c2d..ff5fcbae03 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -453,22 +453,16 @@ err: return -1; } =20 -static TPMBackend *tpm_emulator_create(QemuOpts *opts, const char *id) +static TPMBackend *tpm_emulator_create(QemuOpts *opts) { TPMBackend *tb =3D TPM_BACKEND(object_new(TYPE_TPM_EMULATOR)); =20 - tb->id =3D g_strdup(id); - if (tpm_emulator_handle_device_opts(TPM_EMULATOR(tb), opts)) { - goto err_exit; + object_unref(OBJECT(tb)); + return NULL; } =20 return tb; - -err_exit: - object_unref(OBJECT(tb)); - - return NULL; } =20 static TpmTypeOptions *tpm_emulator_get_tpm_options(TPMBackend *tb) diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 9326cbfdc9..7371d50739 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -284,13 +284,10 @@ tpm_passthrough_handle_device_opts(TPMPassthruState *= tpm_pt, QemuOpts *opts) return 1; } =20 -static TPMBackend *tpm_passthrough_create(QemuOpts *opts, const char *id) +static TPMBackend *tpm_passthrough_create(QemuOpts *opts) { Object *obj =3D object_new(TYPE_TPM_PASSTHROUGH); - TPMBackend *tb =3D TPM_BACKEND(obj); - TPMPassthruState *tpm_pt =3D TPM_PASSTHROUGH(tb); - - tb->id =3D g_strdup(id); + TPMPassthruState *tpm_pt =3D TPM_PASSTHROUGH(obj); =20 if (tpm_passthrough_handle_device_opts(tpm_pt, opts)) { goto err_exit; @@ -301,7 +298,7 @@ static TPMBackend *tpm_passthrough_create(QemuOpts *opt= s, const char *id) goto err_exit; } =20 - return tb; + return TPM_BACKEND(obj); =20 err_exit: object_unref(obj); diff --git a/tpm.c b/tpm.c index 32d398aadf..520f449234 100644 --- a/tpm.c +++ b/tpm.c @@ -127,11 +127,12 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opt= s, Error **errp) return 1; } =20 - drv =3D be->create(opts, id); + drv =3D be->create(opts); if (!drv) { return 1; } =20 + drv->id =3D g_strdup(id); QLIST_INSERT_HEAD(&tpm_backends, drv, list); =20 return 0; --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994024890134.4522072496825; Mon, 6 Nov 2017 10:47:04 -0800 (PST) Received: from localhost ([::1]:49746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmQJ-00043q-Dw for importer@patchew.org; Mon, 06 Nov 2017 13:47:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmK6-00079L-Iz for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmK1-0004hW-O0 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57986) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmK1-0004hD-HY for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:33 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 90C7F80F6C; Mon, 6 Nov 2017 18:40:32 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4079B5D9C7; Mon, 6 Nov 2017 18:40:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 90C7F80F6C Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:10 +0100 Message-Id: <20171106183925.16747-14-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 06 Nov 2017 18:40:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 13/28] tpm-passthrough: make it safer to destroy after creation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Check fds values before closing, to avoid close(-1). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 7371d50739..aa9167e3c6 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -347,8 +347,12 @@ static void tpm_passthrough_inst_finalize(Object *obj) =20 tpm_passthrough_cancel_cmd(TPM_BACKEND(obj)); =20 - qemu_close(tpm_pt->tpm_fd); - qemu_close(tpm_pt->cancel_fd); + if (tpm_pt->tpm_fd >=3D 0) { + qemu_close(tpm_pt->tpm_fd); + } + if (tpm_pt->cancel_fd >=3D 0) { + qemu_close(tpm_pt->cancel_fd); + } qapi_free_TPMPassthroughOptions(tpm_pt->options); } =20 --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994182305971.9936687680207; Mon, 6 Nov 2017 10:49:42 -0800 (PST) Received: from localhost ([::1]:49755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmSo-0006LE-FY for importer@patchew.org; Mon, 06 Nov 2017 13:49:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmK9-0007Av-4w for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmK8-0004m1-7q for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53874) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmK8-0004kq-1o for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:40 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10798883BD; Mon, 6 Nov 2017 18:40:39 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id B032A60C90; Mon, 6 Nov 2017 18:40:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 10798883BD Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:11 +0100 Message-Id: <20171106183925.16747-15-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 06 Nov 2017 18:40:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 14/28] tpm-passthrough: simplify create() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use a similar code as tpm_emulator_create(), call handle_opts() and handle failure cleanup with object_unref() in create(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/tpm/tpm_passthrough.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index aa9167e3c6..788be3847d 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -261,49 +261,33 @@ tpm_passthrough_handle_device_opts(TPMPassthruState *= tpm_pt, QemuOpts *opts) if (tpm_pt->tpm_fd < 0) { error_report("Cannot access TPM device using '%s': %s", tpm_pt->tpm_dev, strerror(errno)); - goto err_free_parameters; + return -1; } =20 if (tpm_util_test_tpmdev(tpm_pt->tpm_fd, &tpm_pt->tpm_version)) { error_report("'%s' is not a TPM device.", tpm_pt->tpm_dev); - goto err_close_tpmdev; + return -1; } =20 - return 0; - - err_close_tpmdev: - qemu_close(tpm_pt->tpm_fd); - tpm_pt->tpm_fd =3D -1; - - err_free_parameters: - qapi_free_TPMPassthroughOptions(tpm_pt->options); - tpm_pt->options =3D NULL; - tpm_pt->tpm_dev =3D NULL; + tpm_pt->cancel_fd =3D tpm_passthrough_open_sysfs_cancel(tpm_pt); + if (tpm_pt->cancel_fd < 0) { + return -1; + } =20 - return 1; + return 0; } =20 static TPMBackend *tpm_passthrough_create(QemuOpts *opts) { Object *obj =3D object_new(TYPE_TPM_PASSTHROUGH); - TPMPassthruState *tpm_pt =3D TPM_PASSTHROUGH(obj); =20 - if (tpm_passthrough_handle_device_opts(tpm_pt, opts)) { - goto err_exit; - } - - tpm_pt->cancel_fd =3D tpm_passthrough_open_sysfs_cancel(tpm_pt); - if (tpm_pt->cancel_fd < 0) { - goto err_exit; + if (tpm_passthrough_handle_device_opts(TPM_PASSTHROUGH(obj), opts)) { + object_unref(obj); + return NULL; } =20 return TPM_BACKEND(obj); - -err_exit: - object_unref(obj); - - return NULL; } =20 static TpmTypeOptions *tpm_passthrough_get_tpm_options(TPMBackend *tb) --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994497606138.56088454425446; Mon, 6 Nov 2017 10:54:57 -0800 (PST) Received: from localhost ([::1]:49778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmXr-0002ZD-P1 for importer@patchew.org; Mon, 06 Nov 2017 13:54:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKB-0007Dg-Vn for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKB-0004p3-6X for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54130) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKB-0004ne-0Z for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:43 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10DAC7F7A9; Mon, 6 Nov 2017 18:40:42 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2364C5D9C7; Mon, 6 Nov 2017 18:40:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 10DAC7F7A9 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:12 +0100 Message-Id: <20171106183925.16747-16-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 06 Nov 2017 18:40:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 15/28] tpm-passthrough: workaround a possible race X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The TPM backend processing thread has common shared variable race issues. (they should not be so easy to reach since guest interaction with the device is slow compared to host emulation) An obvious one is setting op_cancelled from device thread after calling write(cancel_fd). The backend thread may return before the device thread has set the variable. Instead set it before cancellation. Even if the write() failed, the end result is command get possibly cancelled (even if cancellation came from external sources it doesn't matter much). It's worth to consider removing the backend processing thread for now. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 788be3847d..73554aa792 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -89,6 +89,7 @@ static int tpm_passthrough_unix_tx_bufs(TPMPassthruState = *tpm_pt, bool is_selftest; const struct tpm_resp_hdr *hdr; =20 + /* FIXME: protect shared variables or use other sync mechanism */ tpm_pt->tpm_op_canceled =3D false; tpm_pt->tpm_executing =3D true; *selftest_done =3D false; @@ -178,12 +179,11 @@ static void tpm_passthrough_cancel_cmd(TPMBackend *tb) */ if (tpm_pt->tpm_executing) { if (tpm_pt->cancel_fd >=3D 0) { + tpm_pt->tpm_op_canceled =3D true; n =3D write(tpm_pt->cancel_fd, "-", 1); if (n !=3D 1) { error_report("Canceling TPM command failed: %s", strerror(errno)); - } else { - tpm_pt->tpm_op_canceled =3D true; } } else { error_report("Cannot cancel TPM command due to missing " --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994632617514.1119355280367; Mon, 6 Nov 2017 10:57:12 -0800 (PST) Received: from localhost ([::1]:49793 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBma7-0004vk-Ma for importer@patchew.org; Mon, 06 Nov 2017 13:57:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKG-0007I9-VY for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKE-0004tH-0X for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54074) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKD-0004sc-Pg for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:45 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BAEF3820FD; Mon, 6 Nov 2017 18:40:44 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26DAA60C90; Mon, 6 Nov 2017 18:40:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BAEF3820FD Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:13 +0100 Message-Id: <20171106183925.16747-17-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 06 Nov 2017 18:40:44 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 16/28] tpm-tis: simplify header inclusion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_tis.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index c1b738c29f..254f8bd6cb 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -24,17 +24,12 @@ =20 #include "qemu/osdep.h" #include "hw/isa/isa.h" -#include "sysemu/tpm_backend.h" -#include "tpm_int.h" -#include "sysemu/block-backend.h" -#include "exec/address-spaces.h" -#include "hw/hw.h" -#include "hw/i386/pc.h" -#include "hw/pci/pci_ids.h" #include "qapi/error.h" -#include "qemu-common.h" -#include "qemu/main-loop.h" + #include "hw/acpi/tpm.h" +#include "hw/pci/pci_ids.h" +#include "sysemu/tpm_backend.h" +#include "tpm_int.h" =20 #define TPM_TIS_NUM_LOCALITIES 5 /* per spec */ #define TPM_TIS_LOCALITY_SHIFT 12 --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994224591618.2922108018162; Mon, 6 Nov 2017 10:50:24 -0800 (PST) Received: from localhost ([::1]:49757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmTX-0006yR-IE for importer@patchew.org; Mon, 06 Nov 2017 13:50:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKJ-0007Kr-SA for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKJ-000509-11 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:65088) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKI-0004zJ-R0 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:50 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C145A552C7; Mon, 6 Nov 2017 18:40:49 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB4BA6A023; Mon, 6 Nov 2017 18:40:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C145A552C7 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:14 +0100 Message-Id: <20171106183925.16747-18-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Nov 2017 18:40:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 17/28] tpm: rename qemu_find_tpm() -> qemu_find_tpm_be() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" find_tpm() will be introduced to lookup the TPM device. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm_backend.h | 2 +- hw/tpm/tpm_tis.c | 2 +- tpm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index 1ad27ec374..c42d83aaef 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -192,7 +192,7 @@ TPMVersion tpm_backend_get_tpm_version(TPMBackend *s); */ TPMInfo *tpm_backend_query_tpm(TPMBackend *s); =20 -TPMBackend *qemu_find_tpm(const char *id); +TPMBackend *qemu_find_tpm_be(const char *id); =20 void tpm_register_model(enum TpmModel model); =20 diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 254f8bd6cb..1e846f1201 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -1056,7 +1056,7 @@ static void tpm_tis_realizefn(DeviceState *dev, Error= **errp) { TPMState *s =3D TPM(dev); =20 - s->be_driver =3D qemu_find_tpm(s->backend); + s->be_driver =3D qemu_find_tpm_be(s->backend); if (!s->be_driver) { error_setg(errp, "tpm_tis: backend driver with id %s could not be " "found", s->backend); diff --git a/tpm.c b/tpm.c index 520f449234..4661dfc46e 100644 --- a/tpm.c +++ b/tpm.c @@ -69,7 +69,7 @@ static void tpm_display_backend_drivers(void) /* * Find the TPM with the given Id */ -TPMBackend *qemu_find_tpm(const char *id) +TPMBackend *qemu_find_tpm_be(const char *id) { TPMBackend *drv; =20 --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150999419670776.54127698217951; Mon, 6 Nov 2017 10:49:56 -0800 (PST) Received: from localhost ([::1]:49756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmT2-0006Y9-RC for importer@patchew.org; Mon, 06 Nov 2017 13:49:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKR-0007SA-Op for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKP-00056o-44 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58756) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKO-00055E-UO for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:40:57 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EEF6D80F9C; Mon, 6 Nov 2017 18:40:55 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id E11E95D6A9; Mon, 6 Nov 2017 18:40:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EEF6D80F9C Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:15 +0100 Message-Id: <20171106183925.16747-19-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 06 Nov 2017 18:40:56 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 18/28] tpm: lookup the the TPM interface instead of TIS device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amarnath.valluri@intel.com, Eduardo Habkost , "Michael S. Tsirkin" , stefanb@linux.vnet.ibm.com, Paolo Bonzini , Igor Mammedov , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This will allow to introduce new devices implementing TPM. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm.h | 25 +++++++++++++++---------- hw/i386/acpi-build.c | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 7b407caf25..2fe0f1e120 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -19,7 +19,7 @@ int tpm_config_parse(QemuOptsList *opts_list, const char = *optarg); int tpm_init(void); void tpm_cleanup(void); =20 -typedef enum TPMVersion { +typedef enum TPMVersion { TPM_VERSION_UNSPEC =3D 0, TPM_VERSION_1_2 =3D 1, TPM_VERSION_2_0 =3D 2, @@ -44,20 +44,25 @@ typedef struct TPMIfClass { void (*request_completed)(TPMIf *obj); } TPMIfClass; =20 -TPMVersion tpm_tis_get_tpm_version(Object *obj); - #define TYPE_TPM_TIS "tpm-tis" =20 -static inline TPMVersion tpm_get_version(void) +/* returns NULL unless there is exactly one TPM device */ +static inline TPMIf *tpm_find(void) { -#ifdef CONFIG_TPM - Object *obj =3D object_resolve_path_type("", TYPE_TPM_TIS, NULL); + Object *obj =3D object_resolve_path_type("", TYPE_TPM_IF, NULL); + + return TPM_IF(obj); +} =20 - if (obj) { - return tpm_tis_get_tpm_version(obj); +TPMVersion tpm_tis_get_tpm_version(Object *obj); + +static inline TPMVersion tpm_get_version(TPMIf *ti) +{ + if (!ti) { + return TPM_VERSION_UNSPEC; } -#endif - return TPM_VERSION_UNSPEC; + + return tpm_tis_get_tpm_version(OBJECT(ti)); } =20 #endif /* QEMU_TPM_H */ diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 73519ab3ac..cdb4aa9835 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -208,7 +208,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info) } =20 info->has_hpet =3D hpet_find(); - info->tpm_version =3D tpm_get_version(); + info->tpm_version =3D tpm_get_version(tpm_find()); info->pvpanic_port =3D pvpanic_port(); info->applesmc_io_base =3D applesmc_port(); } --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994364937875.5663102807955; Mon, 6 Nov 2017 10:52:44 -0800 (PST) Received: from localhost ([::1]:49769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmVh-0000de-5s for importer@patchew.org; Mon, 06 Nov 2017 13:52:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKV-0007VD-6h for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKU-0005CO-AL for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40922) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKU-0005Bu-4N for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:02 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A08915557; Mon, 6 Nov 2017 18:41:01 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AC1760C8D; Mon, 6 Nov 2017 18:40:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2A08915557 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:16 +0100 Message-Id: <20171106183925.16747-20-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Nov 2017 18:41:01 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 19/28] tpm: add TPM interface to lookup TPM version X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Do not hardcode TPM device model to lookup version, use an interface instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm.h | 5 ++--- hw/tpm/tpm_tis.c | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 2fe0f1e120..650b4b8565 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -42,6 +42,7 @@ typedef struct TPMIfClass { =20 enum TpmModel model; void (*request_completed)(TPMIf *obj); + enum TPMVersion (*get_version)(TPMIf *obj); } TPMIfClass; =20 #define TYPE_TPM_TIS "tpm-tis" @@ -54,15 +55,13 @@ static inline TPMIf *tpm_find(void) return TPM_IF(obj); } =20 -TPMVersion tpm_tis_get_tpm_version(Object *obj); - static inline TPMVersion tpm_get_version(TPMIf *ti) { if (!ti) { return TPM_VERSION_UNSPEC; } =20 - return tpm_tis_get_tpm_version(OBJECT(ti)); + return TPM_IF_GET_CLASS(ti)->get_version(ti); } =20 #endif /* QEMU_TPM_H */ diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 1e846f1201..a0b39b6211 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -990,9 +990,9 @@ static void tpm_tis_realloc_buffer(TPMSizedBuffer *sb) /* * Get the TPMVersion of the backend device being used */ -TPMVersion tpm_tis_get_tpm_version(Object *obj) +static enum TPMVersion tpm_tis_get_tpm_version(TPMIf *ti) { - TPMState *s =3D TPM(obj); + TPMState *s =3D TPM(ti); =20 return tpm_backend_get_tpm_version(s->be_driver); } @@ -1098,6 +1098,7 @@ static void tpm_tis_class_init(ObjectClass *klass, vo= id *data) dc->reset =3D tpm_tis_reset; dc->vmsd =3D &vmstate_tpm_tis; tc->model =3D TPM_MODEL_TPM_TIS; + tc->get_version =3D tpm_tis_get_tpm_version; tc->request_completed =3D tpm_tis_request_completed; } =20 --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994514694751.7547263742999; Mon, 6 Nov 2017 10:55:14 -0800 (PST) Received: from localhost ([::1]:49780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmYA-0002qO-SJ for importer@patchew.org; Mon, 06 Nov 2017 13:55:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKb-0007ax-Vv for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKX-0005GV-2r for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56240) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKW-0005Fc-SX for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:05 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C94D3C04AC57; Mon, 6 Nov 2017 18:41:03 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E09360C8D; Mon, 6 Nov 2017 18:41:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C94D3C04AC57 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:17 +0100 Message-Id: <20171106183925.16747-21-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 06 Nov 2017 18:41:04 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 20/28] tpm: add tpm_cmd_get_size() to tpm_util X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function is generally useful and used in the following patches. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_util.h | 8 +++++++- hw/tpm/tpm_tis.c | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/tpm/tpm_util.h b/hw/tpm/tpm_util.h index 2f7c96146d..aca10c97bf 100644 --- a/hw/tpm/tpm_util.h +++ b/hw/tpm/tpm_util.h @@ -22,7 +22,8 @@ #ifndef TPM_TPM_UTIL_H #define TPM_TPM_UTIL_H =20 -#include "sysemu/tpm_backend.h" +#include "sysemu/tpm.h" +#include "qemu/bswap.h" =20 void tpm_util_write_fatal_error_response(uint8_t *out, uint32_t out_len); =20 @@ -30,4 +31,9 @@ bool tpm_util_is_selftest(const uint8_t *in, uint32_t in_= len); =20 int tpm_util_test_tpmdev(int tpm_fd, TPMVersion *tpm_version); =20 +static inline uint32_t tpm_cmd_get_size(const void *b) +{ + return be32_to_cpu(*(const uint32_t *)(b + 2)); +} + #endif /* TPM_TPM_UTIL_H */ diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index a0b39b6211..d313347144 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -30,6 +30,7 @@ #include "hw/pci/pci_ids.h" #include "sysemu/tpm_backend.h" #include "tpm_int.h" +#include "tpm_util.h" =20 #define TPM_TIS_NUM_LOCALITIES 5 /* per spec */ #define TPM_TIS_LOCALITY_SHIFT 12 @@ -215,7 +216,7 @@ static uint8_t tpm_tis_locality_from_addr(hwaddr addr) =20 static uint32_t tpm_tis_get_size_from_buffer(const TPMSizedBuffer *sb) { - return be32_to_cpu(*(uint32_t *)&sb->buffer[2]); + return tpm_cmd_get_size(sb->buffer); } =20 static void tpm_tis_show_buffer(const TPMSizedBuffer *sb, const char *stri= ng) --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994667100978.7330019684928; Mon, 6 Nov 2017 10:57:47 -0800 (PST) Received: from localhost ([::1]:49794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmaL-00057B-Hw for importer@patchew.org; Mon, 06 Nov 2017 13:57:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKf-0007cf-Hy for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKe-0005Ph-Kp for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKe-0005PK-C3 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:12 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60DABC049D5F; Mon, 6 Nov 2017 18:41:11 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4D5E5C8AC; Mon, 6 Nov 2017 18:41:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 60DABC049D5F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:18 +0100 Message-Id: <20171106183925.16747-22-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 06 Nov 2017 18:41:11 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 21/28] acpi: change TPM TIS data conditions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amarnath.valluri@intel.com, Eduardo Habkost , "Michael S. Tsirkin" , stefanb@linux.vnet.ibm.com, Paolo Bonzini , Igor Mammedov , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The device should be exposed if present. It shouldn't have an undefined version (or else backend init failed, and device should fail too). Finally, make the fields specific to TIS device model. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm.h | 3 +++ hw/i386/acpi-build.c | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 650b4b8565..852e02687c 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -47,6 +47,9 @@ typedef struct TPMIfClass { =20 #define TYPE_TPM_TIS "tpm-tis" =20 +#define TPM_IS_TIS(chr) \ + object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS) + /* returns NULL unless there is exactly one TPM device */ static inline TPMIf *tpm_find(void) { diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index cdb4aa9835..dd1420b410 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2038,7 +2038,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, } } =20 - if (misc->tpm_version !=3D TPM_VERSION_UNSPEC) { + if (TPM_IS_TIS(tpm_find())) { aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE, TPM_TIS_ADDR_SIZE, AML_READ_WRITE)); } @@ -2204,7 +2204,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, /* Scan all PCI buses. Generate tables to support hotplug. */ build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en); =20 - if (misc->tpm_version !=3D TPM_VERSION_UNSPEC) { + if (TPM_IS_TIS(tpm_find())) { dev =3D aml_device("ISA.TPM"); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31"= ))); aml_append(dev, aml_name_decl("_STA", aml_int(0xF))); @@ -2281,8 +2281,12 @@ build_tpm2(GArray *table_data, BIOSLinker *linker) tpm2_ptr =3D acpi_data_push(table_data, sizeof *tpm2_ptr); =20 tpm2_ptr->platform_class =3D cpu_to_le16(TPM2_ACPI_CLASS_CLIENT); - tpm2_ptr->control_area_address =3D cpu_to_le64(0); - tpm2_ptr->start_method =3D cpu_to_le32(TPM2_START_METHOD_MMIO); + if (TPM_IS_TIS(tpm_find())) { + tpm2_ptr->control_area_address =3D cpu_to_le64(0); + tpm2_ptr->start_method =3D cpu_to_le32(TPM2_START_METHOD_MMIO); + } else { + g_warn_if_reached(); + } =20 build_header(linker, table_data, (void *)tpm2_ptr, "TPM2", sizeof(*tpm2_ptr), 4, NULL, NUL= L); --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15099945431661015.2182364978679; Mon, 6 Nov 2017 10:55:43 -0800 (PST) Received: from localhost ([::1]:49786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmYd-0003HZ-BC for importer@patchew.org; Mon, 06 Nov 2017 13:55:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKm-0007jt-7X for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKh-0005Rb-Aw for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKh-0005R3-4h for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:15 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3331D13A8A; Mon, 6 Nov 2017 18:41:14 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 814315C8AC; Mon, 6 Nov 2017 18:41:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3331D13A8A Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:19 +0100 Message-Id: <20171106183925.16747-23-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Nov 2017 18:41:14 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 22/28] tpm-emulator: add a FIXME comment about blocking cancel X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_emulator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index ff5fcbae03..b77c0238c7 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -328,6 +328,7 @@ static void tpm_emulator_cancel_cmd(TPMBackend *tb) return; } =20 + /* FIXME: make the function non-blocking, or it may block a VCPU */ if (tpm_emulator_ctrlcmd(&tpm_emu->ctrl_chr, CMD_CANCEL_TPM_CMD, &res,= 0, sizeof(res)) < 0) { error_report("tpm-emulator: Could not cancel command: %s", --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994398490829.3762634151329; Mon, 6 Nov 2017 10:53:18 -0800 (PST) Received: from localhost ([::1]:49770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmWD-00014w-LL for importer@patchew.org; Mon, 06 Nov 2017 13:53:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKm-0007ju-7Z for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKk-0005TT-Bm for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55466) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKk-0005T2-5b for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:18 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1BD1880484; Mon, 6 Nov 2017 18:41:17 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D1865C8AC; Mon, 6 Nov 2017 18:41:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1BD1880484 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:20 +0100 Message-Id: <20171106183925.16747-24-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 06 Nov 2017 18:41:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 23/28] tpm-tis: remove redundant 'tpm_tis:' in error messages X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The reported error message is already prefixed with the -device name & arguments. Before: qemu-system-x86_64: -device tpm-tis,id=3Dfoo,tpmdev=3Dfoo,irq=3D21: tpm_tis= : IRQ 21 is outside valid range of 0 to 15 After: qemu-system-x86_64: -device tpm-tis,id=3Dfoo,tpmdev=3Dfoo,irq=3D21: IRQ 21 = is outside valid range of 0 to 15 Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_tis.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index d313347144..175785b9c4 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -1059,8 +1059,8 @@ static void tpm_tis_realizefn(DeviceState *dev, Error= **errp) =20 s->be_driver =3D qemu_find_tpm_be(s->backend); if (!s->be_driver) { - error_setg(errp, "tpm_tis: backend driver with id %s could not be " - "found", s->backend); + error_setg(errp, "backend driver with id %s could not be found", + s->backend); return; } =20 @@ -1069,8 +1069,8 @@ static void tpm_tis_realizefn(DeviceState *dev, Error= **errp) } =20 if (s->irq_num > 15) { - error_setg(errp, "tpm_tis: IRQ %d for TPM TIS is outside valid ran= ge " - "of 0 to 15", s->irq_num); + error_setg(errp, "IRQ %d is outside valid range of 0 to 15", + s->irq_num); return; } =20 --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994672050161.5239875069242; Mon, 6 Nov 2017 10:57:52 -0800 (PST) Received: from localhost ([::1]:49795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmai-0005SL-JN for importer@patchew.org; Mon, 06 Nov 2017 13:57:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmKr-0007on-1n for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKq-0005Xx-Cq for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60396) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKq-0005XJ-6h for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:24 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37707B5B9; Mon, 6 Nov 2017 18:41:23 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F5635D9C7; Mon, 6 Nov 2017 18:41:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 37707B5B9 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:21 +0100 Message-Id: <20171106183925.16747-25-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 06 Nov 2017 18:41:23 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 24/28] tpm-tis: check that at most one TPM device exists X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_tis.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 175785b9c4..dccc56ab09 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -1057,6 +1057,11 @@ static void tpm_tis_realizefn(DeviceState *dev, Erro= r **errp) { TPMState *s =3D TPM(dev); =20 + if (!tpm_find()) { + error_setg(errp, "at most one TPM device is permitted"); + return; + } + s->be_driver =3D qemu_find_tpm_be(s->backend); if (!s->be_driver) { error_setg(errp, "backend driver with id %s could not be found", --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994797528676.381711694462; Mon, 6 Nov 2017 10:59:57 -0800 (PST) Received: from localhost ([::1]:49801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmcj-00077O-Jo for importer@patchew.org; Mon, 06 Nov 2017 13:59:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmL0-0007xt-Gu for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmKv-0005c7-Qr for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46708) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmKv-0005bI-Hm for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:29 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F0875F7AD; Mon, 6 Nov 2017 18:41:28 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 686DA6A023; Mon, 6 Nov 2017 18:41:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8F0875F7AD Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:22 +0100 Message-Id: <20171106183925.16747-26-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 06 Nov 2017 18:41:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 25/28] tpm-emulator: protect concurrent ctrl_chr access X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The control chardev is being used from the data thread to set the locality of the next request. Altough the chr has a write mutex, we may potentially read the reply from another thread request. Add a mutex to protect from concurrent control commands. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_emulator.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index b77c0238c7..24cb61162f 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -71,15 +71,21 @@ typedef struct TPMEmulator { ptm_cap caps; /* capabilities of the TPM */ uint8_t cur_locty_number; /* last set locality */ Error *migration_blocker; + + QemuMutex mutex; } TPMEmulator; =20 =20 -static int tpm_emulator_ctrlcmd(CharBackend *dev, unsigned long cmd, void = *msg, +static int tpm_emulator_ctrlcmd(TPMEmulator *tpm, unsigned long cmd, void = *msg, size_t msg_len_in, size_t msg_len_out) { + CharBackend *dev =3D &tpm->ctrl_chr; uint32_t cmd_no =3D cpu_to_be32(cmd); ssize_t n =3D sizeof(uint32_t) + msg_len_in; uint8_t *buf =3D NULL; + int ret =3D -1; + + qemu_mutex_lock(&tpm->mutex); =20 buf =3D g_alloca(n); memcpy(buf, &cmd_no, sizeof(cmd_no)); @@ -87,17 +93,21 @@ static int tpm_emulator_ctrlcmd(CharBackend *dev, unsig= ned long cmd, void *msg, =20 n =3D qemu_chr_fe_write_all(dev, buf, n); if (n <=3D 0) { - return -1; + goto end; } =20 if (msg_len_out !=3D 0) { n =3D qemu_chr_fe_read_all(dev, msg, msg_len_out); if (n <=3D 0) { - return -1; + goto end; } } =20 - return 0; + ret =3D 0; + +end: + qemu_mutex_unlock(&tpm->mutex); + return ret; } =20 static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu, @@ -154,7 +164,7 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_e= mu, uint8_t locty_number, =20 DPRINTF("setting locality : 0x%x", locty_number); loc.u.req.loc =3D locty_number; - if (tpm_emulator_ctrlcmd(&tpm_emu->ctrl_chr, CMD_SET_LOCALITY, &loc, + if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_LOCALITY, &loc, sizeof(loc), sizeof(loc)) < 0) { error_setg(errp, "tpm-emulator: could not set locality : %s", strerror(errno)); @@ -200,8 +210,8 @@ error: static int tpm_emulator_probe_caps(TPMEmulator *tpm_emu) { DPRINTF("%s", __func__); - if (tpm_emulator_ctrlcmd(&tpm_emu->ctrl_chr, CMD_GET_CAPABILITY, - &tpm_emu->caps, 0, sizeof(tpm_emu->caps)) < 0) { + if (tpm_emulator_ctrlcmd(tpm_emu, CMD_GET_CAPABILITY, + &tpm_emu->caps, 0, sizeof(tpm_emu->caps)) < 0= ) { error_report("tpm-emulator: probing failed : %s", strerror(errno)); return -1; } @@ -252,8 +262,8 @@ static int tpm_emulator_startup_tpm(TPMBackend *tb) ptm_res res; =20 DPRINTF("%s", __func__); - if (tpm_emulator_ctrlcmd(&tpm_emu->ctrl_chr, CMD_INIT, &init, sizeof(i= nit), - sizeof(init)) < 0) { + if (tpm_emulator_ctrlcmd(tpm_emu, CMD_INIT, &init, sizeof(init), + sizeof(init)) < 0) { error_report("tpm-emulator: could not send INIT: %s", strerror(errno)); goto err_exit; @@ -276,7 +286,7 @@ static bool tpm_emulator_get_tpm_established_flag(TPMBa= ckend *tb) ptm_est est; =20 DPRINTF("%s", __func__); - if (tpm_emulator_ctrlcmd(&tpm_emu->ctrl_chr, CMD_GET_TPMESTABLISHED, &= est, + if (tpm_emulator_ctrlcmd(tpm_emu, CMD_GET_TPMESTABLISHED, &est, 0, sizeof(est)) < 0) { error_report("tpm-emulator: Could not get the TPM established flag= : %s", strerror(errno)); @@ -300,7 +310,7 @@ static int tpm_emulator_reset_tpm_established_flag(TPMB= ackend *tb, } =20 reset_est.u.req.loc =3D tpm_emu->cur_locty_number; - if (tpm_emulator_ctrlcmd(&tpm_emu->ctrl_chr, CMD_RESET_TPMESTABLISHED, + if (tpm_emulator_ctrlcmd(tpm_emu, CMD_RESET_TPMESTABLISHED, &reset_est, sizeof(reset_est), sizeof(reset_est)) < 0) { error_report("tpm-emulator: Could not reset the establishment bit:= %s", @@ -329,7 +339,7 @@ static void tpm_emulator_cancel_cmd(TPMBackend *tb) } =20 /* FIXME: make the function non-blocking, or it may block a VCPU */ - if (tpm_emulator_ctrlcmd(&tpm_emu->ctrl_chr, CMD_CANCEL_TPM_CMD, &res,= 0, + if (tpm_emulator_ctrlcmd(tpm_emu, CMD_CANCEL_TPM_CMD, &res, 0, sizeof(res)) < 0) { error_report("tpm-emulator: Could not cancel command: %s", strerror(errno)); @@ -377,8 +387,8 @@ static int tpm_emulator_prepare_data_fd(TPMEmulator *tp= m_emu) =20 qemu_chr_fe_set_msgfds(&tpm_emu->ctrl_chr, fds + 1, 1); =20 - if (tpm_emulator_ctrlcmd(&tpm_emu->ctrl_chr, CMD_SET_DATAFD, &res, 0, - sizeof(res)) || res !=3D 0) { + if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_DATAFD, &res, 0, + sizeof(res)) < 0 || res !=3D 0) { error_report("tpm-emulator: Failed to send CMD_SET_DATAFD: %s", strerror(errno)); goto err_exit; @@ -494,6 +504,7 @@ static void tpm_emulator_inst_init(Object *obj) DPRINTF("%s", __func__); tpm_emu->options =3D g_new0(TPMEmulatorOptions, 1); tpm_emu->cur_locty_number =3D ~0; + qemu_mutex_init(&tpm_emu->mutex); } =20 /* @@ -503,8 +514,7 @@ static void tpm_emulator_shutdown(TPMEmulator *tpm_emu) { ptm_res res; =20 - if (tpm_emulator_ctrlcmd(&tpm_emu->ctrl_chr, CMD_SHUTDOWN, &res, 0, - sizeof(res)) < 0) { + if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SHUTDOWN, &res, 0, sizeof(res)) = < 0) { error_report("tpm-emulator: Could not cleanly shutdown the TPM: %s= ", strerror(errno)); } else if (res !=3D 0) { @@ -529,6 +539,8 @@ static void tpm_emulator_inst_finalize(Object *obj) migrate_del_blocker(tpm_emu->migration_blocker); error_free(tpm_emu->migration_blocker); } + + qemu_mutex_destroy(&tpm_emu->mutex); } =20 static void tpm_emulator_class_init(ObjectClass *klass, void *data) --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994778399625.1124732291416; Mon, 6 Nov 2017 10:59:38 -0800 (PST) Received: from localhost ([::1]:49800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmcO-0006pS-Lf for importer@patchew.org; Mon, 06 Nov 2017 13:59:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmL2-0007zJ-3o for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmL0-0005jR-Qo for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55894) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmL0-0005h7-Il for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:34 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92FF585541; Mon, 6 Nov 2017 18:41:33 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id C99A85C8BA; Mon, 6 Nov 2017 18:41:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 92FF585541 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:23 +0100 Message-Id: <20171106183925.16747-27-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 06 Nov 2017 18:41:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 26/28] qdev: add DEFINE_PROP_TPMBE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A property to lookup a tpm backend. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/hw/qdev-properties.h | 3 ++ hw/core/qdev-properties-system.c | 64 ++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 67 insertions(+) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index e2321f1cc1..4d24cdf8d6 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -17,6 +17,7 @@ extern const PropertyInfo qdev_prop_int64; extern const PropertyInfo qdev_prop_size; extern const PropertyInfo qdev_prop_string; extern const PropertyInfo qdev_prop_chr; +extern const PropertyInfo qdev_prop_tpm; extern const PropertyInfo qdev_prop_ptr; extern const PropertyInfo qdev_prop_macaddr; extern const PropertyInfo qdev_prop_on_off_auto; @@ -186,6 +187,8 @@ extern const PropertyInfo qdev_prop_link; =20 #define DEFINE_PROP_CHR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharBackend) +#define DEFINE_PROP_TPMBE(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_tpm, TPMBackend *) #define DEFINE_PROP_STRING(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*) #define DEFINE_PROP_NETDEV(_n, _s, _f) \ diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index ec10da7424..c17364655c 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -21,6 +21,7 @@ #include "net/hub.h" #include "qapi/visitor.h" #include "chardev/char-fe.h" +#include "sysemu/tpm_backend.h" #include "sysemu/iothread.h" =20 static void get_pointer(Object *obj, Visitor *v, Property *prop, @@ -236,6 +237,69 @@ const PropertyInfo qdev_prop_chr =3D { .release =3D release_chr, }; =20 +/* --- character device --- */ + +static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaqu= e, + Error **errp) +{ + DeviceState *dev =3D DEVICE(obj); + TPMBackend **be =3D qdev_get_prop_ptr(dev, opaque); + char *p; + + p =3D g_strdup(*be ? (*be)->id : ""); + visit_type_str(v, name, &p, errp); + g_free(p); +} + +static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaqu= e, + Error **errp) +{ + DeviceState *dev =3D DEVICE(obj); + Error *local_err =3D NULL; + Property *prop =3D opaque; + TPMBackend *s, **be =3D qdev_get_prop_ptr(dev, prop); + char *str; + + if (dev->realized) { + qdev_prop_set_after_realize(dev, name, errp); + return; + } + + visit_type_str(v, name, &str, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + s =3D qemu_find_tpm_be(str); + if (s =3D=3D NULL) { + error_setg(errp, "Property '%s.%s' can't find value '%s'", + object_get_typename(obj), prop->name, str); + } else if (tpm_backend_init(s, TPM_IF(obj), errp) =3D=3D 0) { + *be =3D s; /* weak reference, avoid cyclic ref */ + } + g_free(str); +} + +static void release_tpm(Object *obj, const char *name, void *opaque) +{ + DeviceState *dev =3D DEVICE(obj); + Property *prop =3D opaque; + TPMBackend **be =3D qdev_get_prop_ptr(dev, prop); + + if (*be) { + tpm_backend_reset(*be); + } +} + +const PropertyInfo qdev_prop_tpm =3D { + .name =3D "str", + .description =3D "ID of a tpm to use as a backend", + .get =3D get_tpm, + .set =3D set_tpm, + .release =3D release_tpm, +}; + /* --- netdev device --- */ static void get_netdev(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509994349366825.078468720814; Mon, 6 Nov 2017 10:52:29 -0800 (PST) Received: from localhost ([::1]:49768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmVV-0000SW-Am for importer@patchew.org; Mon, 06 Nov 2017 13:52:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmL6-00087Q-5m for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmL5-0005rN-CA for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41932) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmL5-0005qA-5h for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:39 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2678F13AAB; Mon, 6 Nov 2017 18:41:38 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id B96F05D967; Mon, 6 Nov 2017 18:41:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2678F13AAB Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:24 +0100 Message-Id: <20171106183925.16747-28-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Nov 2017 18:41:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 27/28] tpm-tis: use DEFINE_PROP_TPMBE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- hw/tpm/tpm_tis.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index dccc56ab09..a00779f3aa 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -86,7 +86,6 @@ typedef struct TPMState { =20 TPMBackendCmd cmd; =20 - char *backend; TPMBackend *be_driver; TPMVersion be_tpm_version; } TPMState; @@ -1049,7 +1048,7 @@ static const VMStateDescription vmstate_tpm_tis =3D { =20 static Property tpm_tis_properties[] =3D { DEFINE_PROP_UINT32("irq", TPMState, irq_num, TPM_TIS_IRQ), - DEFINE_PROP_STRING("tpmdev", TPMState, backend), + DEFINE_PROP_TPMBE("tpmdev", TPMState, be_driver), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -1062,17 +1061,10 @@ static void tpm_tis_realizefn(DeviceState *dev, Err= or **errp) return; } =20 - s->be_driver =3D qemu_find_tpm_be(s->backend); if (!s->be_driver) { - error_setg(errp, "backend driver with id %s could not be found", - s->backend); + error_setg(errp, "'tpmdev' property is required"); return; } - - if (tpm_backend_init(s->be_driver, TPM_IF(s), errp)) { - return; - } - if (s->irq_num > 15) { error_setg(errp, "IRQ %d is outside valid range of 0 to 15", s->irq_num); --=20 2.15.0.rc0.40.gaefcc5f6f From nobody Mon Apr 29 05:17:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150999505876445.49738386987167; Mon, 6 Nov 2017 11:04:18 -0800 (PST) Received: from localhost ([::1]:49826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmgo-000216-Fb for importer@patchew.org; Mon, 06 Nov 2017 14:04:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBmLB-0008Gm-WC for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBmLB-0005wk-6N for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42278) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBmLB-0005wD-0H for qemu-devel@nongnu.org; Mon, 06 Nov 2017 13:41:45 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 14C94358; Mon, 6 Nov 2017 18:41:44 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87F0F5E1B7; Mon, 6 Nov 2017 18:41:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 14C94358 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 19:39:25 +0100 Message-Id: <20171106183925.16747-29-marcandre.lureau@redhat.com> In-Reply-To: <20171106183925.16747-1-marcandre.lureau@redhat.com> References: <20171106183925.16747-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Nov 2017 18:41:44 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 28/28] tpm: remove tpm_register_model() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , amarnath.valluri@intel.com, stefanb@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Query object classes that implements TPMIf instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm_backend.h | 2 -- hw/tpm/tpm_tis.c | 1 - tpm.c | 20 ++++++-------------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index c42d83aaef..590e8b42de 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -194,6 +194,4 @@ TPMInfo *tpm_backend_query_tpm(TPMBackend *s); =20 TPMBackend *qemu_find_tpm_be(const char *id); =20 -void tpm_register_model(enum TpmModel model); - #endif diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index a00779f3aa..cc32fcde36 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -1115,7 +1115,6 @@ static const TypeInfo tpm_tis_info =3D { static void tpm_tis_register(void) { type_register_static(&tpm_tis_info); - tpm_register_model(TPM_MODEL_TPM_TIS); } =20 type_init(tpm_tis_register) diff --git a/tpm.c b/tpm.c index 4661dfc46e..61a434185a 100644 --- a/tpm.c +++ b/tpm.c @@ -23,13 +23,6 @@ static QLIST_HEAD(, TPMBackend) tpm_backends =3D QLIST_HEAD_INITIALIZER(tpm_backends); =20 -static bool tpm_models[TPM_MODEL__MAX]; - -void tpm_register_model(enum TpmModel model) -{ - tpm_models[model] =3D true; -} - static const TPMBackendClass * tpm_be_find_by_type(enum TpmType type) { @@ -236,18 +229,16 @@ TpmTypeList *qmp_query_tpm_types(Error **errp) =20 return head; } - TpmModelList *qmp_query_tpm_models(Error **errp) { - unsigned int i =3D 0; TpmModelList *head =3D NULL, *prev =3D NULL, *cur_item; + GSList *e, *l =3D object_class_get_list(TYPE_TPM_IF, false); + + for (e =3D l; e; e =3D e->next) { + TPMIfClass *c =3D TPM_IF_CLASS(e->data); =20 - for (i =3D 0; i < TPM_MODEL__MAX; i++) { - if (!tpm_models[i]) { - continue; - } cur_item =3D g_new0(TpmModelList, 1); - cur_item->value =3D i; + cur_item->value =3D c->model; =20 if (prev) { prev->next =3D cur_item; @@ -257,6 +248,7 @@ TpmModelList *qmp_query_tpm_models(Error **errp) } prev =3D cur_item; } + g_slist_free(l); =20 return head; } --=20 2.15.0.rc0.40.gaefcc5f6f