2018-03-07 22:45:06 +03:00
|
|
|
/*
|
|
|
|
* QTest TPM utilities
|
|
|
|
*
|
|
|
|
* Copyright (c) 2018 IBM Corporation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Stefan Berger <stefanb@linux.vnet.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 TESTS_TPM_UTIL_H
|
|
|
|
#define TESTS_TPM_UTIL_H
|
|
|
|
|
|
|
|
#include "io/channel-socket.h"
|
|
|
|
|
2020-03-05 19:51:48 +03:00
|
|
|
extern uint64_t tpm_tis_base_addr;
|
|
|
|
|
|
|
|
#define TIS_REG(LOCTY, REG) \
|
|
|
|
(tpm_tis_base_addr + ((LOCTY) << 12) + REG)
|
|
|
|
|
2018-03-07 22:45:06 +03:00
|
|
|
typedef void (tx_func)(QTestState *s,
|
|
|
|
const unsigned char *req, size_t req_size,
|
|
|
|
unsigned char *rsp, size_t rsp_size);
|
|
|
|
|
|
|
|
void tpm_util_crb_transfer(QTestState *s,
|
|
|
|
const unsigned char *req, size_t req_size,
|
2018-05-30 20:44:41 +03:00
|
|
|
unsigned char *rsp, size_t rsp_size);
|
2018-03-07 22:45:06 +03:00
|
|
|
|
|
|
|
void tpm_util_startup(QTestState *s, tx_func *tx);
|
|
|
|
void tpm_util_pcrextend(QTestState *s, tx_func *tx);
|
|
|
|
void tpm_util_pcrread(QTestState *s, tx_func *tx,
|
|
|
|
const unsigned char *exp_resp, size_t exp_resp_size);
|
|
|
|
|
2018-10-03 16:21:29 +03:00
|
|
|
bool tpm_util_swtpm_has_tpm2(void);
|
|
|
|
|
2018-03-07 22:45:06 +03:00
|
|
|
gboolean tpm_util_swtpm_start(const char *path, GPid *pid,
|
|
|
|
SocketAddress **addr, GError **error);
|
|
|
|
void tpm_util_swtpm_kill(GPid pid);
|
|
|
|
|
2018-05-30 19:12:50 +03:00
|
|
|
void tpm_util_migrate(QTestState *who, const char *uri);
|
|
|
|
|
|
|
|
void tpm_util_migration_start_qemu(QTestState **src_qemu,
|
|
|
|
QTestState **dst_qemu,
|
|
|
|
SocketAddress *src_tpm_addr,
|
|
|
|
SocketAddress *dst_tpm_addr,
|
2018-05-30 21:31:12 +03:00
|
|
|
const char *miguri,
|
2020-03-05 19:51:47 +03:00
|
|
|
const char *ifmodel,
|
|
|
|
const char *machine_options);
|
2018-05-30 19:12:50 +03:00
|
|
|
|
|
|
|
void tpm_util_wait_for_migration_complete(QTestState *who);
|
2022-10-12 11:43:34 +03:00
|
|
|
void tpm_util_rmdir(const char *path);
|
2018-05-30 19:12:50 +03:00
|
|
|
|
2018-03-07 22:45:06 +03:00
|
|
|
#endif /* TESTS_TPM_UTIL_H */
|