blob: 3b97d690170c6a32a03c18e68d43426f16097780 [file] [log] [blame]
Stefan Bergerb21373d2018-03-07 14:45:06 -05001/*
2 * QTest TPM utilities
3 *
4 * Copyright (c) 2018 IBM Corporation
5 *
6 * Authors:
7 * Stefan Berger <stefanb@linux.vnet.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
11 */
12
13#ifndef TESTS_TPM_UTIL_H
14#define TESTS_TPM_UTIL_H
15
Stefan Bergerb21373d2018-03-07 14:45:06 -050016#include "io/channel-socket.h"
17
Eric Auger5166c322020-03-05 17:51:48 +010018extern uint64_t tpm_tis_base_addr;
19
20#define TIS_REG(LOCTY, REG) \
21 (tpm_tis_base_addr + ((LOCTY) << 12) + REG)
22
Stefan Bergerb21373d2018-03-07 14:45:06 -050023typedef void (tx_func)(QTestState *s,
24 const unsigned char *req, size_t req_size,
25 unsigned char *rsp, size_t rsp_size);
26
27void tpm_util_crb_transfer(QTestState *s,
28 const unsigned char *req, size_t req_size,
29 unsigned char *rsp, size_t rsp_size);
Stefan Berger70663852018-05-30 13:44:41 -040030void tpm_util_tis_transfer(QTestState *s,
31 const unsigned char *req, size_t req_size,
32 unsigned char *rsp, size_t rsp_size);
Stefan Bergerb21373d2018-03-07 14:45:06 -050033
34void tpm_util_startup(QTestState *s, tx_func *tx);
35void tpm_util_pcrextend(QTestState *s, tx_func *tx);
36void tpm_util_pcrread(QTestState *s, tx_func *tx,
37 const unsigned char *exp_resp, size_t exp_resp_size);
38
Marc-André Lureaue2f246a2018-10-03 17:21:29 +040039bool tpm_util_swtpm_has_tpm2(void);
40
Stefan Bergerb21373d2018-03-07 14:45:06 -050041gboolean tpm_util_swtpm_start(const char *path, GPid *pid,
42 SocketAddress **addr, GError **error);
43void tpm_util_swtpm_kill(GPid pid);
44
Stefan Bergerb1e4b7c2018-05-30 12:12:50 -040045void tpm_util_migrate(QTestState *who, const char *uri);
46
47void tpm_util_migration_start_qemu(QTestState **src_qemu,
48 QTestState **dst_qemu,
49 SocketAddress *src_tpm_addr,
50 SocketAddress *dst_tpm_addr,
Stefan Bergerea71a332018-05-30 14:31:12 -040051 const char *miguri,
Eric Auger551cabd2020-03-05 17:51:47 +010052 const char *ifmodel,
53 const char *machine_options);
Stefan Bergerb1e4b7c2018-05-30 12:12:50 -040054
55void tpm_util_wait_for_migration_complete(QTestState *who);
56
Stefan Bergerb21373d2018-03-07 14:45:06 -050057#endif /* TESTS_TPM_UTIL_H */