Support for TPM command line options
This patch adds support for TPM command line options.
The command line options supported here are
./qemu-... -tpmdev passthrough,path=<path to TPM device>,id=<id>
-device tpm-tis,tpmdev=<id>,id=<other id>
and
./qemu-... -tpmdev help
where the latter works similar to -soundhw help and shows a list of
available TPM backends (for example 'passthrough').
Using the type parameter, the backend is chosen, i.e., 'passthrough' for the
passthrough driver. The interpretation of the other parameters along
with determining whether enough parameters were provided is pushed into
the backend driver, which needs to implement the interface function
'create' and return a TPMDriverOpts structure if the VM can be started or
'NULL' if not enough or bad parameters were provided.
Monitor support for 'info tpm' has been added. It for example prints the
following:
(qemu) info tpm
TPM devices:
tpm0: model=tpm-tis
\ tpm0: type=passthrough,path=/dev/tpm0,cancel-path=/sys/devices/pnp0/00:09/cancel
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-2-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-28 01:47:49 +08:00
|
|
|
/*
|
|
|
|
* Public TPM functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011-2013 IBM Corporation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Stefan Berger <stefanb@us.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
#ifndef QEMU_TPM_H
|
|
|
|
#define QEMU_TPM_H
|
|
|
|
|
2018-02-11 17:36:01 +08:00
|
|
|
#include "qapi/qapi-types-tpm.h"
|
2017-10-24 20:20:42 +08:00
|
|
|
#include "qom/object.h"
|
Support for TPM command line options
This patch adds support for TPM command line options.
The command line options supported here are
./qemu-... -tpmdev passthrough,path=<path to TPM device>,id=<id>
-device tpm-tis,tpmdev=<id>,id=<other id>
and
./qemu-... -tpmdev help
where the latter works similar to -soundhw help and shows a list of
available TPM backends (for example 'passthrough').
Using the type parameter, the backend is chosen, i.e., 'passthrough' for the
passthrough driver. The interpretation of the other parameters along
with determining whether enough parameters were provided is pushed into
the backend driver, which needs to implement the interface function
'create' and return a TPMDriverOpts structure if the VM can be started or
'NULL' if not enough or bad parameters were provided.
Monitor support for 'info tpm' has been added. It for example prints the
following:
(qemu) info tpm
TPM devices:
tpm0: model=tpm-tis
\ tpm0: type=passthrough,path=/dev/tpm0,cancel-path=/sys/devices/pnp0/00:09/cancel
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-2-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-28 01:47:49 +08:00
|
|
|
|
|
|
|
int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);
|
2018-10-17 16:26:53 +08:00
|
|
|
void tpm_init(void);
|
Support for TPM command line options
This patch adds support for TPM command line options.
The command line options supported here are
./qemu-... -tpmdev passthrough,path=<path to TPM device>,id=<id>
-device tpm-tis,tpmdev=<id>,id=<other id>
and
./qemu-... -tpmdev help
where the latter works similar to -soundhw help and shows a list of
available TPM backends (for example 'passthrough').
Using the type parameter, the backend is chosen, i.e., 'passthrough' for the
passthrough driver. The interpretation of the other parameters along
with determining whether enough parameters were provided is pushed into
the backend driver, which needs to implement the interface function
'create' and return a TPMDriverOpts structure if the VM can be started or
'NULL' if not enough or bad parameters were provided.
Monitor support for 'info tpm' has been added. It for example prints the
following:
(qemu) info tpm
TPM devices:
tpm0: model=tpm-tis
\ tpm0: type=passthrough,path=/dev/tpm0,cancel-path=/sys/devices/pnp0/00:09/cancel
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-2-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-28 01:47:49 +08:00
|
|
|
void tpm_cleanup(void);
|
|
|
|
|
2017-11-07 02:39:15 +08:00
|
|
|
typedef enum TPMVersion {
|
2015-05-27 04:51:05 +08:00
|
|
|
TPM_VERSION_UNSPEC = 0,
|
|
|
|
TPM_VERSION_1_2 = 1,
|
|
|
|
TPM_VERSION_2_0 = 2,
|
|
|
|
} TPMVersion;
|
|
|
|
|
2017-11-07 02:38:59 +08:00
|
|
|
#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)
|
|
|
|
|
2018-12-04 22:20:06 +08:00
|
|
|
typedef struct TPMIf TPMIf;
|
2017-11-07 02:38:59 +08:00
|
|
|
|
|
|
|
typedef struct TPMIfClass {
|
|
|
|
InterfaceClass parent_class;
|
|
|
|
|
2017-11-07 02:39:04 +08:00
|
|
|
enum TpmModel model;
|
2018-01-30 02:33:06 +08:00
|
|
|
void (*request_completed)(TPMIf *obj, int ret);
|
2017-11-07 02:39:16 +08:00
|
|
|
enum TPMVersion (*get_version)(TPMIf *obj);
|
2017-11-07 02:38:59 +08:00
|
|
|
} TPMIfClass;
|
|
|
|
|
2014-08-12 04:33:36 +08:00
|
|
|
#define TYPE_TPM_TIS "tpm-tis"
|
2018-01-30 02:33:07 +08:00
|
|
|
#define TYPE_TPM_CRB "tpm-crb"
|
2014-08-12 04:33:36 +08:00
|
|
|
|
2017-11-07 02:39:18 +08:00
|
|
|
#define TPM_IS_TIS(chr) \
|
|
|
|
object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS)
|
2018-01-30 02:33:07 +08:00
|
|
|
#define TPM_IS_CRB(chr) \
|
|
|
|
object_dynamic_cast(OBJECT(chr), TYPE_TPM_CRB)
|
2017-11-07 02:39:18 +08:00
|
|
|
|
2017-11-07 02:39:15 +08:00
|
|
|
/* returns NULL unless there is exactly one TPM device */
|
|
|
|
static inline TPMIf *tpm_find(void)
|
2014-08-12 04:33:36 +08:00
|
|
|
{
|
2017-11-07 02:39:15 +08:00
|
|
|
Object *obj = object_resolve_path_type("", TYPE_TPM_IF, NULL);
|
|
|
|
|
|
|
|
return TPM_IF(obj);
|
|
|
|
}
|
2015-05-27 04:51:07 +08:00
|
|
|
|
2017-11-07 02:39:15 +08:00
|
|
|
static inline TPMVersion tpm_get_version(TPMIf *ti)
|
|
|
|
{
|
|
|
|
if (!ti) {
|
|
|
|
return TPM_VERSION_UNSPEC;
|
2015-05-27 04:51:07 +08:00
|
|
|
}
|
2017-11-07 02:39:15 +08:00
|
|
|
|
2017-11-07 02:39:16 +08:00
|
|
|
return TPM_IF_GET_CLASS(ti)->get_version(ti);
|
2014-08-12 04:33:36 +08:00
|
|
|
}
|
|
|
|
|
Support for TPM command line options
This patch adds support for TPM command line options.
The command line options supported here are
./qemu-... -tpmdev passthrough,path=<path to TPM device>,id=<id>
-device tpm-tis,tpmdev=<id>,id=<other id>
and
./qemu-... -tpmdev help
where the latter works similar to -soundhw help and shows a list of
available TPM backends (for example 'passthrough').
Using the type parameter, the backend is chosen, i.e., 'passthrough' for the
passthrough driver. The interpretation of the other parameters along
with determining whether enough parameters were provided is pushed into
the backend driver, which needs to implement the interface function
'create' and return a TPMDriverOpts structure if the VM can be started or
'NULL' if not enough or bad parameters were provided.
Monitor support for 'info tpm' has been added. It for example prints the
following:
(qemu) info tpm
TPM devices:
tpm0: model=tpm-tis
\ tpm0: type=passthrough,path=/dev/tpm0,cancel-path=/sys/devices/pnp0/00:09/cancel
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-2-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-28 01:47:49 +08:00
|
|
|
#endif /* QEMU_TPM_H */
|