[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 18/28] tpm: lookup the the TPM interface instead
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v2 18/28] tpm: lookup the the TPM interface instead of TIS device |
Date: |
Mon, 6 Nov 2017 19:39:15 +0100 |
This will allow to introduce new devices implementing TPM.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Stefan Berger <address@hidden>
---
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);
-typedef enum TPMVersion {
+typedef enum TPMVersion {
TPM_VERSION_UNSPEC = 0,
TPM_VERSION_1_2 = 1,
TPM_VERSION_2_0 = 2,
@@ -44,20 +44,25 @@ typedef struct TPMIfClass {
void (*request_completed)(TPMIf *obj);
} TPMIfClass;
-TPMVersion tpm_tis_get_tpm_version(Object *obj);
-
#define TYPE_TPM_TIS "tpm-tis"
-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 = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
+ Object *obj = object_resolve_path_type("", TYPE_TPM_IF, NULL);
+
+ return TPM_IF(obj);
+}
- 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));
}
#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)
}
info->has_hpet = hpet_find();
- info->tpm_version = tpm_get_version();
+ info->tpm_version = tpm_get_version(tpm_find());
info->pvpanic_port = pvpanic_port();
info->applesmc_io_base = applesmc_port();
}
--
2.15.0.rc0.40.gaefcc5f6f
- [Qemu-devel] [PATCH v2 08/28] tpm: remove unused opened code, (continued)
- [Qemu-devel] [PATCH v2 08/28] tpm: remove unused opened code, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 09/28] tpm-passthrough: don't save guessed cancel_path in options, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 11/28] tpm-passthrough: pass TPMPassthruState to handle_device_opts, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 12/28] tpm-backend: move set 'id' to common code, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 10/28] tpm-be: update optional function pointers, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 13/28] tpm-passthrough: make it safer to destroy after creation, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 14/28] tpm-passthrough: simplify create(), Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 15/28] tpm-passthrough: workaround a possible race, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 16/28] tpm-tis: simplify header inclusion, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 17/28] tpm: rename qemu_find_tpm() -> qemu_find_tpm_be(), Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 18/28] tpm: lookup the the TPM interface instead of TIS device,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v2 19/28] tpm: add TPM interface to lookup TPM version, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 20/28] tpm: add tpm_cmd_get_size() to tpm_util, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 21/28] acpi: change TPM TIS data conditions, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 22/28] tpm-emulator: add a FIXME comment about blocking cancel, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 23/28] tpm-tis: remove redundant 'tpm_tis:' in error messages, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 24/28] tpm-tis: check that at most one TPM device exists, Marc-André Lureau, 2017/11/06
- [Qemu-devel] [PATCH v2 25/28] tpm-emulator: protect concurrent ctrl_chr access, Marc-André Lureau, 2017/11/06