dm: TPM2 passthrough for post-launched VM with eventlog support

This patch enables TPM2 passthrough to post-launched VM with eventlog
support.
User starts by providing command line "--acpidev_pt <TPM2_HID>",
of which the <TPM2_HID> will be searched from /proc/iomem for TPM2 buffer
start address and size. Furthermore, If TPM2 eventlog is supported,
TPM2 eventlog information will be retrieved from sysfs TPM2 table and
passed-through as well.

v4 -> v5:
move tpm2 related logic from acpi.c to tpm.c
multiple API rename

Tracked-On: #6686
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Yifan Liu
2021-10-15 14:34:23 +08:00
committed by wenlingz
parent ad5eb6e23d
commit 00631f113f
6 changed files with 226 additions and 80 deletions

View File

@@ -65,6 +65,9 @@ struct acpi_table_hdr {
/* All dynamic table entry no. */
#define NHLT_ENTRY_NO 8
#define EFPRINTF(...) fprintf(__VA_ARGS__)
#define EFFLUSH(x) fflush(x)
void acpi_table_enable(int num);
uint32_t get_acpi_base(void);
uint32_t get_acpi_table_length(void);

View File

@@ -38,7 +38,6 @@ int init_mmio_devs(struct vmctx *ctx);
void deinit_mmio_devs(struct vmctx *ctx);
int mmio_dev_alloc_gpa_resource32(uint32_t *addr, uint32_t size_in);
uint64_t get_mmio_dev_tpm2_base_gpa(void);
#define MMIO_DEV_BASE 0xF0000000U
#define MMIO_DEV_LIMIT 0xFE000000U

View File

@@ -8,11 +8,26 @@
#ifndef _TPM_H_
#define _TPM_H_
#include "mmio_dev.h"
#include "acpi.h"
#define TPM_CRB_MMIO_ADDR 0xFED40000UL
#define TPM_CRB_MMIO_SIZE 0x5000U
uint32_t get_vtpm_crb_mmio_addr(void);
uint32_t get_tpm_crb_mmio_addr(void);
int basl_fwrite_tpm2(FILE *fp, struct vmctx *ctx);
struct acpi_table_tpm2 {
struct acpi_table_hdr header;
uint16_t platform_class;
uint16_t reserved;
uint64_t control_address;
uint32_t start_method;
uint8_t start_method_spec_para[12];
uint32_t laml;
uint64_t lasa;
} __attribute__((packed));
/* TPM CRB registers */
enum {