From nobody Tue Feb 10 20:28:22 2026 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 150759123325644.39717871710752; Mon, 9 Oct 2017 16:20:33 -0700 (PDT) Received: from localhost ([::1]:60231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1hLS-000058-NJ for importer@patchew.org; Mon, 09 Oct 2017 19:20:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1h0R-000761-KU for qemu-devel@nongnu.org; Mon, 09 Oct 2017 18:58:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1h0Q-0005e3-Jz for qemu-devel@nongnu.org; Mon, 09 Oct 2017 18:58:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1h0Q-0005dp-Bw for qemu-devel@nongnu.org; Mon, 09 Oct 2017 18:58:38 -0400 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 3EA7E883C2; Mon, 9 Oct 2017 22:58:37 +0000 (UTC) Received: from localhost (unknown [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71DDA18990; Mon, 9 Oct 2017 22:58:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3EA7E883C2 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: Tue, 10 Oct 2017 00:56:18 +0200 Message-Id: <20171009225623.29232-38-marcandre.lureau@redhat.com> In-Reply-To: <20171009225623.29232-1-marcandre.lureau@redhat.com> References: <20171009225623.29232-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, 09 Oct 2017 22:58: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 37/42] 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_6 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 --- hw/tpm/tpm_int.h | 19 ------------------- include/sysemu/tpm.h | 52 ++++++++++++++++++++++++++++++++++++++----------= ---- hw/i386/acpi-build.c | 2 +- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/hw/tpm/tpm_int.h b/hw/tpm/tpm_int.h index 90e97b9170..86fadc16d3 100644 --- a/hw/tpm/tpm_int.h +++ b/hw/tpm/tpm_int.h @@ -15,25 +15,6 @@ #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; - - enum TpmModel model; - void (*request_completed)(TPMIf *obj); -} TPMIfClass; - #define TPM_STANDARD_CMDLINE_OPTS \ { \ .name =3D "type", \ diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 62b073beeb..dbd2b0cc7a 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -12,32 +12,56 @@ #ifndef QEMU_TPM_H #define QEMU_TPM_H =20 -#include "qemu/option.h" +#include "qom/object.h" +#include "qapi-types.h" =20 -int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); -int tpm_init(void); -void tpm_cleanup(void); - -typedef enum TPMVersion { +typedef enum TPMVersion { TPM_VERSION_UNSPEC =3D 0, TPM_VERSION_1_2 =3D 1, TPM_VERSION_2_0 =3D 2, } TPMVersion; =20 -TPMVersion tpm_tis_get_tpm_version(Object *obj); +#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; + + enum TpmModel model; + void (*request_completed)(TPMIf *obj); +} TPMIfClass; + +int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); +int tpm_init(void); +void tpm_cleanup(void); =20 #define TYPE_TPM_TIS "tpm-tis" =20 -static inline TPMVersion tpm_get_version(void) +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 2af37a9129..40371b6f75 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.14.1.146.gd35faa819