treewide: stop calling custom TPM log "TCPA"

TCPA usually refers to log described by TPM 1.2 specification.

Change-Id: I896bd94f18b34d6c4b280f58b011d704df3d4022
Ticket: https://ticket.coreboot.org/issues/423
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/69444
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Sergii Dmytruk
2022-11-10 00:40:51 +02:00
committed by Felix Held
parent 16a444c501
commit 2710df765b
26 changed files with 156 additions and 154 deletions

View File

@ -20,9 +20,9 @@
VBOOT2_WORK(., 12K) VBOOT2_WORK(., 12K)
#endif #endif
#if CONFIG(TPM_MEASURED_BOOT) #if CONFIG(TPM_MEASURED_BOOT)
/* Vboot measured boot TCPA log measurements. /* Vboot measured boot TPM log measurements.
* Needs to be transferred until CBMEM is available */ * Needs to be transferred until CBMEM is available */
TPM_TCPA_LOG(., 2K) TPM_LOG(., 2K)
#endif #endif
/* Stack for CAR stages. Since it persists across all stages that /* Stack for CAR stages. Since it persists across all stages that
* use CAR it can be reused. The chipset/SoC is expected to provide * use CAR it can be reused. The chipset/SoC is expected to provide

View File

@ -60,7 +60,7 @@
#define CBMEM_ID_STAGEx_CACHE 0x57a9e100 #define CBMEM_ID_STAGEx_CACHE 0x57a9e100
#define CBMEM_ID_STAGEx_RAW 0x57a9e200 #define CBMEM_ID_STAGEx_RAW 0x57a9e200
#define CBMEM_ID_STORAGE_DATA 0x53746f72 #define CBMEM_ID_STORAGE_DATA 0x53746f72
#define CBMEM_ID_TCPA_LOG 0x54435041 #define CBMEM_ID_TPM_CB_LOG 0x54435041
#define CBMEM_ID_TCPA_TCG_LOG 0x54445041 #define CBMEM_ID_TCPA_TCG_LOG 0x54445041
#define CBMEM_ID_TIMESTAMP 0x54494d45 #define CBMEM_ID_TIMESTAMP 0x54494d45
#define CBMEM_ID_TPM2_TCG_LOG 0x54504d32 #define CBMEM_ID_TPM2_TCG_LOG 0x54504d32
@ -139,7 +139,7 @@
{ CBMEM_ID_SMBIOS, "SMBIOS " }, \ { CBMEM_ID_SMBIOS, "SMBIOS " }, \
{ CBMEM_ID_SMM_SAVE_SPACE, "SMM BACKUP " }, \ { CBMEM_ID_SMM_SAVE_SPACE, "SMM BACKUP " }, \
{ CBMEM_ID_STORAGE_DATA, "SD/MMC/eMMC" }, \ { CBMEM_ID_STORAGE_DATA, "SD/MMC/eMMC" }, \
{ CBMEM_ID_TCPA_LOG, "TCPA LOG " }, \ { CBMEM_ID_TPM_CB_LOG, "TPM CB LOG " }, \
{ CBMEM_ID_TCPA_TCG_LOG, "TCPA TCGLOG" }, \ { CBMEM_ID_TCPA_TCG_LOG, "TCPA TCGLOG" }, \
{ CBMEM_ID_TIMESTAMP, "TIME STAMP " }, \ { CBMEM_ID_TIMESTAMP, "TIME STAMP " }, \
{ CBMEM_ID_TPM2_TCG_LOG, "TPM2 TCGLOG" }, \ { CBMEM_ID_TPM2_TCG_LOG, "TPM2 TCGLOG" }, \

View File

@ -77,7 +77,7 @@ enum {
LB_TAG_MAC_ADDRS = 0x0033, LB_TAG_MAC_ADDRS = 0x0033,
LB_TAG_VBOOT_WORKBUF = 0x0034, LB_TAG_VBOOT_WORKBUF = 0x0034,
LB_TAG_MMC_INFO = 0x0035, LB_TAG_MMC_INFO = 0x0035,
LB_TAG_TCPA_LOG = 0x0036, LB_TAG_TPM_CB_LOG = 0x0036,
LB_TAG_FMAP = 0x0037, LB_TAG_FMAP = 0x0037,
LB_TAG_PLATFORM_BLOB_VERSION = 0x0038, LB_TAG_PLATFORM_BLOB_VERSION = 0x0038,
LB_TAG_SMMSTOREV2 = 0x0039, LB_TAG_SMMSTOREV2 = 0x0039,

View File

@ -1,29 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __TCPA_LOG_SERIALIZED_H__
#define __TCPA_LOG_SERIALIZED_H__
#include <stdint.h>
#define MAX_TCPA_LOG_ENTRIES 50
#define TCPA_DIGEST_MAX_LENGTH 64
#define TCPA_PCR_HASH_NAME 50
#define TCPA_PCR_HASH_LEN 10
/* Assumption of 2K TCPA log size reserved for CAR/SRAM */
#define MAX_PRERAM_TCPA_LOG_ENTRIES 15
struct tcpa_entry {
uint32_t pcr;
char digest_type[TCPA_PCR_HASH_LEN];
uint8_t digest[TCPA_DIGEST_MAX_LENGTH];
uint32_t digest_length;
char name[TCPA_PCR_HASH_NAME];
} __packed;
struct tcpa_table {
uint16_t max_entries;
uint16_t num_entries;
struct tcpa_entry entries[0]; /* Variable number of entries */
} __packed;
#endif

View File

@ -0,0 +1,30 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef COMMONLIB_TPM_LOG_SERIALIZED_H
#define COMMONLIB_TPM_LOG_SERIALIZED_H
#include <commonlib/bsd/helpers.h>
#include <stdint.h>
#define MAX_TPM_LOG_ENTRIES 50
#define TPM_CB_LOG_DIGEST_MAX_LENGTH 64
#define TPM_CB_LOG_PCR_HASH_NAME 50
#define TPM_CB_LOG_PCR_HASH_LEN 10
/* Assumption of 2K TCPA log size reserved for CAR/SRAM */
#define MAX_PRERAM_TPM_LOG_ENTRIES 15
struct tpm_cb_log_entry {
uint32_t pcr;
char digest_type[TPM_CB_LOG_PCR_HASH_LEN];
uint8_t digest[TPM_CB_LOG_DIGEST_MAX_LENGTH];
uint32_t digest_length;
char name[TPM_CB_LOG_PCR_HASH_NAME];
} __packed;
struct tpm_cb_log_table {
uint16_t max_entries;
uint16_t num_entries;
struct tpm_cb_log_entry entries[0]; /* Variable number of entries */
} __packed;
#endif

View File

@ -168,9 +168,9 @@
STR(vboot2 work buffer size must be equivalent to \ STR(vboot2 work buffer size must be equivalent to \
VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE! (sz))); VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE! (sz)));
#define TPM_TCPA_LOG(addr, size) \ #define TPM_LOG(addr, size) \
REGION(tpm_tcpa_log, addr, size, 16) \ REGION(tpm_log, addr, size, 16) \
_ = ASSERT(size >= 2K, "tpm tcpa log buffer must be at least 2K!"); _ = ASSERT(size >= 2K, "tpm log buffer must be at least 2K!");
#if ENV_SEPARATE_VERSTAGE #if ENV_SEPARATE_VERSTAGE
#define VERSTAGE(addr, sz) \ #define VERSTAGE(addr, sz) \

View File

@ -37,7 +37,7 @@ DECLARE_OPTIONAL_REGION(postram_cbfs_cache)
DECLARE_OPTIONAL_REGION(cbfs_cache) DECLARE_OPTIONAL_REGION(cbfs_cache)
DECLARE_REGION(cbfs_mcache) DECLARE_REGION(cbfs_mcache)
DECLARE_REGION(fmap_cache) DECLARE_REGION(fmap_cache)
DECLARE_REGION(tpm_tcpa_log) DECLARE_REGION(tpm_log)
#if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE) #if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
DECLARE_REGION(bss) DECLARE_REGION(bss)

View File

@ -190,7 +190,7 @@ static bool cbfs_file_hash_mismatch(const void *buffer, size_t size,
if (!hash || if (!hash ||
tspi_cbfs_measurement(mdata->h.filename, be32toh(mdata->h.type), hash)) tspi_cbfs_measurement(mdata->h.filename, be32toh(mdata->h.type), hash))
ERROR("failed to measure '%s' into TCPA log\n", mdata->h.filename); ERROR("failed to measure '%s' into TPM log\n", mdata->h.filename);
/* We intentionally continue to boot on measurement errors. */ /* We intentionally continue to boot on measurement errors. */
} }

View File

@ -267,7 +267,7 @@ static void add_cbmem_pointers(struct lb_header *header)
{CBMEM_ID_ACPI_CNVS, LB_TAG_ACPI_CNVS}, {CBMEM_ID_ACPI_CNVS, LB_TAG_ACPI_CNVS},
{CBMEM_ID_VPD, LB_TAG_VPD}, {CBMEM_ID_VPD, LB_TAG_VPD},
{CBMEM_ID_WIFI_CALIBRATION, LB_TAG_WIFI_CALIBRATION}, {CBMEM_ID_WIFI_CALIBRATION, LB_TAG_WIFI_CALIBRATION},
{CBMEM_ID_TCPA_LOG, LB_TAG_TCPA_LOG}, {CBMEM_ID_TPM_CB_LOG, LB_TAG_TPM_CB_LOG},
{CBMEM_ID_FMAP, LB_TAG_FMAP}, {CBMEM_ID_FMAP, LB_TAG_FMAP},
{CBMEM_ID_VBOOT_WORKBUF, LB_TAG_VBOOT_WORKBUF}, {CBMEM_ID_VBOOT_WORKBUF, LB_TAG_VBOOT_WORKBUF},
{CBMEM_ID_TYPE_C_INFO, LB_TAG_TYPE_C_INFO}, {CBMEM_ID_TYPE_C_INFO, LB_TAG_TYPE_C_INFO},

View File

@ -4,7 +4,7 @@
#define TSPI_H_ #define TSPI_H_
#include <security/tpm/tss.h> #include <security/tpm/tss.h>
#include <commonlib/tcpa_log_serialized.h> #include <commonlib/tpm_log_serialized.h>
#include <commonlib/region.h> #include <commonlib/region.h>
#include <vb2_api.h> #include <vb2_api.h>
@ -13,33 +13,33 @@
/** /**
* Get the pointer to the single instance of global * Get the pointer to the single instance of global
* tcpa log data, and initialize it when necessary * TPM log data, and initialize it when necessary
*/ */
struct tcpa_table *tcpa_log_init(void); struct tpm_cb_log_table *tpm_log_init(void);
/** /**
* Clears the pre-RAM tcpa log data and initializes * Clears the pre-RAM TPM log data and initializes
* any content with default values * any content with default values
*/ */
void tcpa_preram_log_clear(void); void tpm_preram_log_clear(void);
/** /**
* Add table entry for cbmem TCPA log. * Add table entry for cbmem TPM log.
* @param name Name of the hashed data * @param name Name of the hashed data
* @param pcr PCR used to extend hashed data * @param pcr PCR used to extend hashed data
* @param diget_algo sets the digest algorithm * @param diget_algo sets the digest algorithm
* @param digest sets the hash extended into the tpm * @param digest sets the hash extended into the tpm
* @param digest_len the length of the digest * @param digest_len the length of the digest
*/ */
void tcpa_log_add_table_entry(const char *name, const uint32_t pcr, void tpm_log_add_table_entry(const char *name, const uint32_t pcr,
enum vb2_hash_algorithm digest_algo, enum vb2_hash_algorithm digest_algo,
const uint8_t *digest, const uint8_t *digest,
const size_t digest_len); const size_t digest_len);
/** /**
* Dump TCPA log entries on console * Dump TPM log entries on console
*/ */
void tcpa_log_dump(void *unused); void tpm_log_dump(void *unused);
/** /**
* Ask vboot for a digest and extend a TPM PCR with it. * Ask vboot for a digest and extend a TPM PCR with it.

View File

@ -6,11 +6,11 @@
#include "crtm.h" #include "crtm.h"
#include <string.h> #include <string.h>
static int tcpa_log_initialized; static int tpm_log_initialized;
static inline int tcpa_log_available(void) static inline int tpm_log_available(void)
{ {
if (ENV_BOOTBLOCK) if (ENV_BOOTBLOCK)
return tcpa_log_initialized; return tpm_log_initialized;
return 1; return 1;
} }
@ -33,10 +33,10 @@ static inline int tcpa_log_available(void)
*/ */
static uint32_t tspi_init_crtm(void) static uint32_t tspi_init_crtm(void)
{ {
/* Initialize TCPA PRERAM log. */ /* Initialize TPM PRERAM log. */
if (!tcpa_log_available()) { if (!tpm_log_available()) {
tcpa_preram_log_clear(); tpm_preram_log_clear();
tcpa_log_initialized = 1; tpm_log_initialized = 1;
} else { } else {
printk(BIOS_WARNING, "TSPI: CRTM already initialized!\n"); printk(BIOS_WARNING, "TSPI: CRTM already initialized!\n");
return VB2_SUCCESS; return VB2_SUCCESS;
@ -109,9 +109,9 @@ static bool is_runtime_data(const char *name)
uint32_t tspi_cbfs_measurement(const char *name, uint32_t type, const struct vb2_hash *hash) uint32_t tspi_cbfs_measurement(const char *name, uint32_t type, const struct vb2_hash *hash)
{ {
uint32_t pcr_index; uint32_t pcr_index;
char tcpa_metadata[TCPA_PCR_HASH_NAME]; char tpm_log_metadata[TPM_CB_LOG_PCR_HASH_NAME];
if (!tcpa_log_available()) { if (!tpm_log_available()) {
if (tspi_init_crtm() != VB2_SUCCESS) { if (tspi_init_crtm() != VB2_SUCCESS) {
printk(BIOS_WARNING, printk(BIOS_WARNING,
"Initializing CRTM failed!\n"); "Initializing CRTM failed!\n");
@ -142,29 +142,29 @@ uint32_t tspi_cbfs_measurement(const char *name, uint32_t type, const struct vb2
break; break;
} }
snprintf(tcpa_metadata, TCPA_PCR_HASH_NAME, "CBFS: %s", name); snprintf(tpm_log_metadata, TPM_CB_LOG_PCR_HASH_NAME, "CBFS: %s", name);
return tpm_extend_pcr(pcr_index, hash->algo, hash->raw, vb2_digest_size(hash->algo), return tpm_extend_pcr(pcr_index, hash->algo, hash->raw, vb2_digest_size(hash->algo),
tcpa_metadata); tpm_log_metadata);
} }
int tspi_measure_cache_to_pcr(void) int tspi_measure_cache_to_pcr(void)
{ {
int i; int i;
struct tcpa_table *tclt = tcpa_log_init(); struct tpm_cb_log_table *tclt = tpm_log_init();
/* This means the table is empty. */ /* This means the table is empty. */
if (!tcpa_log_available()) if (!tpm_log_available())
return VB2_SUCCESS; return VB2_SUCCESS;
if (!tclt) { if (!tclt) {
printk(BIOS_WARNING, "TCPA: Log non-existent!\n"); printk(BIOS_WARNING, "TPM LOG: log non-existent!\n");
return VB2_ERROR_UNKNOWN; return VB2_ERROR_UNKNOWN;
} }
printk(BIOS_DEBUG, "TPM: Write digests cached in TCPA log to PCR\n"); printk(BIOS_DEBUG, "TPM: Write digests cached in TPM log to PCR\n");
for (i = 0; i < tclt->num_entries; i++) { for (i = 0; i < tclt->num_entries; i++) {
struct tcpa_entry *tce = &tclt->entries[i]; struct tpm_cb_log_entry *tce = &tclt->entries[i];
if (tce) { if (tce) {
printk(BIOS_DEBUG, "TPM: Write digest for" printk(BIOS_DEBUG, "TPM: Write digest for"
" %s into PCR %d\n", " %s into PCR %d\n",

View File

@ -31,7 +31,7 @@
#endif #endif
/** /**
* Measure digests cached in TCPA log entries into PCRs * Measure digests cached in TPM log entries into PCRs
*/ */
int tspi_measure_cache_to_pcr(void); int tspi_measure_cache_to_pcr(void);

View File

@ -9,20 +9,20 @@
#include <bootstate.h> #include <bootstate.h>
#include <vb2_sha.h> #include <vb2_sha.h>
static struct tcpa_table *tcpa_cbmem_init(void) static struct tpm_cb_log_table *tpm_log_cbmem_init(void)
{ {
static struct tcpa_table *tclt; static struct tpm_cb_log_table *tclt;
if (tclt) if (tclt)
return tclt; return tclt;
if (cbmem_possibly_online()) { if (cbmem_possibly_online()) {
tclt = cbmem_find(CBMEM_ID_TCPA_LOG); tclt = cbmem_find(CBMEM_ID_TPM_CB_LOG);
if (!tclt) { if (!tclt) {
size_t tcpa_log_len = sizeof(struct tcpa_table) + size_t tpm_log_len = sizeof(struct tpm_cb_log_table) +
MAX_TCPA_LOG_ENTRIES * sizeof(struct tcpa_entry); MAX_TPM_LOG_ENTRIES * sizeof(struct tpm_cb_log_entry);
tclt = cbmem_add(CBMEM_ID_TCPA_LOG, tcpa_log_len); tclt = cbmem_add(CBMEM_ID_TPM_CB_LOG, tpm_log_len);
if (tclt) { if (tclt) {
tclt->max_entries = MAX_TCPA_LOG_ENTRIES; tclt->max_entries = MAX_TPM_LOG_ENTRIES;
tclt->num_entries = 0; tclt->num_entries = 0;
} }
} }
@ -30,39 +30,39 @@ static struct tcpa_table *tcpa_cbmem_init(void)
return tclt; return tclt;
} }
struct tcpa_table *tcpa_log_init(void) struct tpm_cb_log_table *tpm_log_init(void)
{ {
static struct tcpa_table *tclt; static struct tpm_cb_log_table *tclt;
/* We are dealing here with pre CBMEM environment. /* We are dealing here with pre CBMEM environment.
* If cbmem isn't available use CAR or SRAM */ * If cbmem isn't available use CAR or SRAM */
if (!cbmem_possibly_online() && if (!cbmem_possibly_online() &&
!CONFIG(VBOOT_RETURN_FROM_VERSTAGE)) !CONFIG(VBOOT_RETURN_FROM_VERSTAGE))
return (struct tcpa_table *)_tpm_tcpa_log; return (struct tpm_cb_log_table *)_tpm_log;
else if (ENV_CREATES_CBMEM else if (ENV_CREATES_CBMEM
&& !CONFIG(VBOOT_RETURN_FROM_VERSTAGE)) { && !CONFIG(VBOOT_RETURN_FROM_VERSTAGE)) {
tclt = tcpa_cbmem_init(); tclt = tpm_log_cbmem_init();
if (!tclt) if (!tclt)
return (struct tcpa_table *)_tpm_tcpa_log; return (struct tpm_cb_log_table *)_tpm_log;
} else { } else {
tclt = tcpa_cbmem_init(); tclt = tpm_log_cbmem_init();
} }
return tclt; return tclt;
} }
void tcpa_log_dump(void *unused) void tpm_log_dump(void *unused)
{ {
int i, j; int i, j;
struct tcpa_table *tclt; struct tpm_cb_log_table *tclt;
tclt = tcpa_log_init(); tclt = tpm_log_init();
if (!tclt) if (!tclt)
return; return;
printk(BIOS_INFO, "coreboot TCPA measurements:\n\n"); printk(BIOS_INFO, "coreboot TPM log measurements:\n\n");
for (i = 0; i < tclt->num_entries; i++) { for (i = 0; i < tclt->num_entries; i++) {
struct tcpa_entry *tce = &tclt->entries[i]; struct tpm_cb_log_entry *tce = &tclt->entries[i];
if (tce) { if (tce) {
printk(BIOS_INFO, " PCR-%u ", tce->pcr); printk(BIOS_INFO, " PCR-%u ", tce->pcr);
@ -76,85 +76,87 @@ void tcpa_log_dump(void *unused)
printk(BIOS_INFO, "\n"); printk(BIOS_INFO, "\n");
} }
void tcpa_log_add_table_entry(const char *name, const uint32_t pcr, void tpm_log_add_table_entry(const char *name, const uint32_t pcr,
enum vb2_hash_algorithm digest_algo, enum vb2_hash_algorithm digest_algo,
const uint8_t *digest, const uint8_t *digest,
const size_t digest_len) const size_t digest_len)
{ {
struct tcpa_table *tclt = tcpa_log_init(); struct tpm_cb_log_table *tclt = tpm_log_init();
if (!tclt) { if (!tclt) {
printk(BIOS_WARNING, "TCPA: Log non-existent!\n"); printk(BIOS_WARNING, "TPM LOG: Log non-existent!\n");
return; return;
} }
if (tclt->num_entries >= tclt->max_entries) { if (tclt->num_entries >= tclt->max_entries) {
printk(BIOS_WARNING, "TCPA: TCPA log table is full\n"); printk(BIOS_WARNING, "TPM LOG: log table is full\n");
return; return;
} }
if (!name) { if (!name) {
printk(BIOS_WARNING, "TCPA: TCPA entry name not set\n"); printk(BIOS_WARNING, "TPM LOG: entry name not set\n");
return; return;
} }
struct tcpa_entry *tce = &tclt->entries[tclt->num_entries++]; struct tpm_cb_log_entry *tce = &tclt->entries[tclt->num_entries++];
strncpy(tce->name, name, TCPA_PCR_HASH_NAME - 1); strncpy(tce->name, name, TPM_CB_LOG_PCR_HASH_NAME - 1);
tce->pcr = pcr; tce->pcr = pcr;
if (digest_len > TCPA_DIGEST_MAX_LENGTH) { if (digest_len > TPM_CB_LOG_DIGEST_MAX_LENGTH) {
printk(BIOS_WARNING, "TCPA: PCR digest too long for TCPA log entry\n"); printk(BIOS_WARNING, "TPM LOG: PCR digest too long for log entry\n");
return; return;
} }
strncpy(tce->digest_type, strncpy(tce->digest_type,
vb2_get_hash_algorithm_name(digest_algo), vb2_get_hash_algorithm_name(digest_algo),
TCPA_PCR_HASH_LEN - 1); TPM_CB_LOG_PCR_HASH_LEN - 1);
tce->digest_length = digest_len; tce->digest_length = digest_len;
memcpy(tce->digest, digest, tce->digest_length); memcpy(tce->digest, digest, tce->digest_length);
} }
void tcpa_preram_log_clear(void) void tpm_preram_log_clear(void)
{ {
printk(BIOS_INFO, "TCPA: Clearing coreboot TCPA log\n"); printk(BIOS_INFO, "TPM LOG: clearing preram log\n");
struct tcpa_table *tclt = (struct tcpa_table *)_tpm_tcpa_log; struct tpm_cb_log_table *tclt = (struct tpm_cb_log_table *)_tpm_log;
tclt->max_entries = MAX_TCPA_LOG_ENTRIES; tclt->max_entries = MAX_TPM_LOG_ENTRIES;
tclt->num_entries = 0; tclt->num_entries = 0;
} }
#if !CONFIG(VBOOT_RETURN_FROM_VERSTAGE) #if !CONFIG(VBOOT_RETURN_FROM_VERSTAGE)
static void recover_tcpa_log(int is_recovery) static void recover_tpm_log(int is_recovery)
{ {
struct tcpa_table *preram_log = (struct tcpa_table *)_tpm_tcpa_log; struct tpm_cb_log_table *preram_log = (struct tpm_cb_log_table *)_tpm_log;
struct tcpa_table *ram_log = NULL; struct tpm_cb_log_table *ram_log = NULL;
int i; int i;
if (preram_log->num_entries > MAX_PRERAM_TCPA_LOG_ENTRIES) { if (preram_log->num_entries > MAX_PRERAM_TPM_LOG_ENTRIES) {
printk(BIOS_WARNING, "TCPA: Pre-RAM TCPA log is too full, possible corruption\n"); printk(BIOS_WARNING, "TPM LOG: pre-RAM log is too full, possible corruption\n");
return; return;
} }
ram_log = tcpa_cbmem_init(); ram_log = tpm_log_cbmem_init();
if (!ram_log) { if (!ram_log) {
printk(BIOS_WARNING, "TCPA: CBMEM not available something went wrong\n"); printk(BIOS_WARNING, "TPM LOG: CBMEM not available something went wrong\n");
return; return;
} }
for (i = 0; i < preram_log->num_entries; i++) { for (i = 0; i < preram_log->num_entries; i++) {
struct tcpa_entry *tce = &ram_log->entries[ram_log->num_entries++]; struct tpm_cb_log_entry *tce = &ram_log->entries[ram_log->num_entries++];
strncpy(tce->name, preram_log->entries[i].name, TCPA_PCR_HASH_NAME - 1); strncpy(tce->name, preram_log->entries[i].name, TPM_CB_LOG_PCR_HASH_NAME - 1);
tce->pcr = preram_log->entries[i].pcr; tce->pcr = preram_log->entries[i].pcr;
if (preram_log->entries[i].digest_length > TCPA_DIGEST_MAX_LENGTH) { if (preram_log->entries[i].digest_length > TPM_CB_LOG_DIGEST_MAX_LENGTH) {
printk(BIOS_WARNING, "TCPA: PCR digest too long for TCPA log entry\n"); printk(BIOS_WARNING, "TPM LOG: PCR digest too long for log entry\n");
return; return;
} }
strncpy(tce->digest_type, preram_log->entries[i].digest_type, TCPA_PCR_HASH_LEN - 1); strncpy(tce->digest_type, preram_log->entries[i].digest_type,
tce->digest_length = MIN(preram_log->entries[i].digest_length, TCPA_DIGEST_MAX_LENGTH); TPM_CB_LOG_PCR_HASH_LEN - 1);
tce->digest_length = MIN(preram_log->entries[i].digest_length,
TPM_CB_LOG_DIGEST_MAX_LENGTH);
memcpy(tce->digest, preram_log->entries[i].digest, tce->digest_length); memcpy(tce->digest, preram_log->entries[i].digest, tce->digest_length);
} }
} }
CBMEM_CREATION_HOOK(recover_tcpa_log); CBMEM_CREATION_HOOK(recover_tpm_log);
#endif #endif
BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, tcpa_log_dump, NULL); BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, tpm_log_dump, NULL);

View File

@ -242,8 +242,7 @@ uint32_t tpm_extend_pcr(int pcr, enum vb2_hash_algorithm digest_algo,
} }
if (CONFIG(TPM_MEASURED_BOOT)) if (CONFIG(TPM_MEASURED_BOOT))
tcpa_log_add_table_entry(name, pcr, digest_algo, tpm_log_add_table_entry(name, pcr, digest_algo, digest, digest_len);
digest, digest_len);
printk(BIOS_DEBUG, "TPM: Digest of `%s` to PCR %d %s\n", printk(BIOS_DEBUG, "TPM: Digest of `%s` to PCR %d %s\n",
name, pcr, tspi_tpm_is_setup() ? "measured" : "logged"); name, pcr, tspi_tpm_is_setup() ? "measured" : "logged");

View File

@ -23,7 +23,7 @@ SECTIONS
BOOTBLOCK(BOOTROM_OFFSET + 0x20000, 56K) BOOTBLOCK(BOOTROM_OFFSET + 0x20000, 56K)
CBFS_MCACHE(BOOTROM_OFFSET + 0x2e000, 8K) CBFS_MCACHE(BOOTROM_OFFSET + 0x2e000, 8K)
VBOOT2_WORK(BOOTROM_OFFSET + 0x30000, 12K) VBOOT2_WORK(BOOTROM_OFFSET + 0x30000, 12K)
TPM_TCPA_LOG(BOOTROM_OFFSET + 0x33000, 2K) TPM_LOG(BOOTROM_OFFSET + 0x33000, 2K)
VERSTAGE(BOOTROM_OFFSET + 0x33800, 50K) VERSTAGE(BOOTROM_OFFSET + 0x33800, 50K)
ROMSTAGE(BOOTROM_OFFSET + 0x40000, 256K) ROMSTAGE(BOOTROM_OFFSET + 0x40000, 256K)

View File

@ -26,7 +26,7 @@ SECTIONS
SRAM_START(0x00100000) SRAM_START(0x00100000)
VBOOT2_WORK(0x00100000, 12K) VBOOT2_WORK(0x00100000, 12K)
TPM_TCPA_LOG(0x00103000, 2K) TPM_LOG(0x00103000, 2K)
FMAP_CACHE(0x00103800, 2K) FMAP_CACHE(0x00103800, 2K)
PRERAM_CBMEM_CONSOLE(0x00104000, 12K) PRERAM_CBMEM_CONSOLE(0x00104000, 12K)
WATCHDOG_TOMBSTONE(0x00107000, 4) WATCHDOG_TOMBSTONE(0x00107000, 4)

View File

@ -23,7 +23,7 @@ SECTIONS
{ {
SRAM_START(0x00100000) SRAM_START(0x00100000)
VBOOT2_WORK(0x00100000, 12K) VBOOT2_WORK(0x00100000, 12K)
TPM_TCPA_LOG(0x00103000, 2K) TPM_LOG(0x00103000, 2K)
FMAP_CACHE(0x00103800, 2K) FMAP_CACHE(0x00103800, 2K)
WATCHDOG_TOMBSTONE(0x00104000, 4) WATCHDOG_TOMBSTONE(0x00104000, 4)
PRERAM_CBMEM_CONSOLE(0x00104004, 63K - 4) PRERAM_CBMEM_CONSOLE(0x00104004, 63K - 4)

View File

@ -31,7 +31,7 @@ SECTIONS
/* EMPTY(0x0010a804, 1K - 4) */ /* EMPTY(0x0010a804, 1K - 4) */
/* Regions that can also be moved to SRAM_L2C. */ /* Regions that can also be moved to SRAM_L2C. */
TIMESTAMP(0x0010ac00, 1K) TIMESTAMP(0x0010ac00, 1K)
TPM_TCPA_LOG(0x0010b000, 2K) TPM_LOG(0x0010b000, 2K)
FMAP_CACHE(0x0010b800, 2K) FMAP_CACHE(0x0010b800, 2K)
CBFS_MCACHE(0x0010c000, 16K) CBFS_MCACHE(0x0010c000, 16K)
SRAM_END(0x00110000) SRAM_END(0x00110000)

View File

@ -34,7 +34,7 @@ SECTIONS
CBFS_MCACHE(0x00120000, 16k) CBFS_MCACHE(0x00120000, 16k)
VBOOT2_WORK(0x00124000, 12K) VBOOT2_WORK(0x00124000, 12K)
FMAP_CACHE(0x00127000, 2k) FMAP_CACHE(0x00127000, 2k)
TPM_TCPA_LOG(0x00127800, 2k) TPM_LOG(0x00127800, 2k)
TIMESTAMP(0x00128000, 1k) TIMESTAMP(0x00128000, 1k)
/* End of regions that can also be moved to SRAM_L2C. */ /* End of regions that can also be moved to SRAM_L2C. */
/* EMPTY(0x00128400, 31K) */ /* EMPTY(0x00128400, 31K) */

View File

@ -23,7 +23,7 @@ SECTIONS
{ {
SRAM_START(0x00100000) SRAM_START(0x00100000)
VBOOT2_WORK(0x00100000, 12K) VBOOT2_WORK(0x00100000, 12K)
TPM_TCPA_LOG(0x00103000, 2K) TPM_LOG(0x00103000, 2K)
FMAP_CACHE(0x00103800, 2K) FMAP_CACHE(0x00103800, 2K)
WATCHDOG_TOMBSTONE(0x00104000, 4) WATCHDOG_TOMBSTONE(0x00104000, 4)
CBFS_MCACHE(0x00107c00, 8K) CBFS_MCACHE(0x00107c00, 8K)

View File

@ -26,7 +26,7 @@ SECTIONS
{ {
SRAM_START(0x00100000) SRAM_START(0x00100000)
VBOOT2_WORK(0x00100000, 12K) VBOOT2_WORK(0x00100000, 12K)
TPM_TCPA_LOG(0x00103000, 2K) TPM_LOG(0x00103000, 2K)
FMAP_CACHE(0x00103800, 2K) FMAP_CACHE(0x00103800, 2K)
WATCHDOG_TOMBSTONE(0x00104000, 4) WATCHDOG_TOMBSTONE(0x00104000, 4)
EARLY_INIT(0x00104010, 128) EARLY_INIT(0x00104010, 128)

View File

@ -19,7 +19,7 @@ SECTIONS
CBFS_MCACHE(0x40006000, 8K) CBFS_MCACHE(0x40006000, 8K)
PRERAM_CBFS_CACHE(0x40008000, 6K) PRERAM_CBFS_CACHE(0x40008000, 6K)
VBOOT2_WORK(0x40009800, 12K) VBOOT2_WORK(0x40009800, 12K)
TPM_TCPA_LOG(0x4000D800, 2K) TPM_LOG(0x4000D800, 2K)
STACK(0x4000E000, 8K) STACK(0x4000E000, 8K)
BOOTBLOCK(0x40010000, 32K) BOOTBLOCK(0x40010000, 32K)
VERSTAGE(0x40018000, 70K) VERSTAGE(0x40018000, 70K)

View File

@ -19,7 +19,7 @@ SECTIONS
PRERAM_CBFS_CACHE(0x40001000, 20K) PRERAM_CBFS_CACHE(0x40001000, 20K)
CBFS_MCACHE(0x40006000, 8K) CBFS_MCACHE(0x40006000, 8K)
VBOOT2_WORK(0x40008000, 12K) VBOOT2_WORK(0x40008000, 12K)
TPM_TCPA_LOG(0x4000B000, 2K) TPM_LOG(0x4000B000, 2K)
#if ENV_ARM64 #if ENV_ARM64
STACK(0x4000B800, 3K) STACK(0x4000B800, 3K)
#else /* AVP gets a separate stack to avoid any chance of handoff races. */ #else /* AVP gets a separate stack to avoid any chance of handoff races. */

View File

@ -32,7 +32,7 @@ SECTIONS
REGION(pbl_timestamps, 0x14800000, 83K, 4K) REGION(pbl_timestamps, 0x14800000, 83K, 4K)
WATCHDOG_TOMBSTONE(0x14814FFC, 4) WATCHDOG_TOMBSTONE(0x14814FFC, 4)
BOOTBLOCK(0x14815000, 48K) BOOTBLOCK(0x14815000, 48K)
TPM_TCPA_LOG(0x14821000, 2K) TPM_LOG(0x14821000, 2K)
PRERAM_CBFS_CACHE(0x14821800, 60K) PRERAM_CBFS_CACHE(0x14821800, 60K)
PRERAM_CBMEM_CONSOLE(0x14830800, 32K) PRERAM_CBMEM_CONSOLE(0x14830800, 32K)
TIMESTAMP(0x14838800, 1K) TIMESTAMP(0x14838800, 1K)

View File

@ -21,7 +21,7 @@ SECTIONS
PRERAM_CBFS_CACHE(0x205C000, 68K) PRERAM_CBFS_CACHE(0x205C000, 68K)
CBFS_MCACHE(0x206D000, 8K) CBFS_MCACHE(0x206D000, 8K)
FMAP_CACHE(0x206F000, 2K) FMAP_CACHE(0x206F000, 2K)
TPM_TCPA_LOG(0x206F800, 2K) TPM_LOG(0x206F800, 2K)
VBOOT2_WORK(0x2070000, 12K) VBOOT2_WORK(0x2070000, 12K)
STACK(0x2074000, 16K) STACK(0x2074000, 16K)
SRAM_END(0x2078000) SRAM_END(0x2078000)

View File

@ -21,7 +21,7 @@
#include <commonlib/bsd/cbmem_id.h> #include <commonlib/bsd/cbmem_id.h>
#include <commonlib/loglevel.h> #include <commonlib/loglevel.h>
#include <commonlib/timestamp_serialized.h> #include <commonlib/timestamp_serialized.h>
#include <commonlib/tcpa_log_serialized.h> #include <commonlib/tpm_log_serialized.h>
#include <commonlib/coreboot_tables.h> #include <commonlib/coreboot_tables.h>
#ifdef __OpenBSD__ #ifdef __OpenBSD__
@ -267,7 +267,7 @@ static int find_cbmem_entry(uint32_t id, uint64_t *addr, size_t *size)
static struct lb_cbmem_ref timestamps; static struct lb_cbmem_ref timestamps;
static struct lb_cbmem_ref console; static struct lb_cbmem_ref console;
static struct lb_cbmem_ref tcpa_log; static struct lb_cbmem_ref tpm_cb_log;
static struct lb_memory_range cbmem; static struct lb_memory_range cbmem;
/* This is a work-around for a nasty problem introduced by initially having /* This is a work-around for a nasty problem introduced by initially having
@ -336,9 +336,9 @@ static int parse_cbtable_entries(const struct mapping *table_mapping)
console = parse_cbmem_ref((struct lb_cbmem_ref *)lbr_p); console = parse_cbmem_ref((struct lb_cbmem_ref *)lbr_p);
continue; continue;
} }
case LB_TAG_TCPA_LOG: { case LB_TAG_TPM_CB_LOG: {
debug(" Found tcpa log table.\n"); debug(" Found TPM CB log table.\n");
tcpa_log = tpm_cb_log =
parse_cbmem_ref((struct lb_cbmem_ref *)lbr_p); parse_cbmem_ref((struct lb_cbmem_ref *)lbr_p);
continue; continue;
} }
@ -843,35 +843,35 @@ static void timestamp_add_now(uint32_t timestamp_id)
unmap_memory(&timestamp_mapping); unmap_memory(&timestamp_mapping);
} }
/* dump the tcpa log table */ /* dump the TPM CB log table */
static void dump_tcpa_log(void) static void dump_tpm_cb_log(void)
{ {
const struct tcpa_table *tclt_p; const struct tpm_cb_log_table *tclt_p;
size_t size; size_t size;
struct mapping tcpa_mapping; struct mapping log_mapping;
if (tcpa_log.tag != LB_TAG_TCPA_LOG) { if (tpm_cb_log.tag != LB_TAG_TPM_CB_LOG) {
fprintf(stderr, "No tcpa log found in coreboot table.\n"); fprintf(stderr, "No TPM log found in coreboot table.\n");
return; return;
} }
size = sizeof(*tclt_p); size = sizeof(*tclt_p);
tclt_p = map_memory(&tcpa_mapping, tcpa_log.cbmem_addr, size); tclt_p = map_memory(&log_mapping, tpm_cb_log.cbmem_addr, size);
if (!tclt_p) if (!tclt_p)
die("Unable to map tcpa log header\n"); die("Unable to map TPM log header\n");
size += tclt_p->num_entries * sizeof(tclt_p->entries[0]); size += tclt_p->num_entries * sizeof(tclt_p->entries[0]);
unmap_memory(&tcpa_mapping); unmap_memory(&log_mapping);
tclt_p = map_memory(&tcpa_mapping, tcpa_log.cbmem_addr, size); tclt_p = map_memory(&log_mapping, tpm_cb_log.cbmem_addr, size);
if (!tclt_p) if (!tclt_p)
die("Unable to map full tcpa log table\n"); die("Unable to map full TPM log table\n");
printf("coreboot TCPA log:\n\n"); printf("coreboot TPM log:\n\n");
for (uint16_t i = 0; i < tclt_p->num_entries; i++) { for (uint16_t i = 0; i < tclt_p->num_entries; i++) {
const struct tcpa_entry *tce = &tclt_p->entries[i]; const struct tpm_cb_log_entry *tce = &tclt_p->entries[i];
printf(" PCR-%u ", tce->pcr); printf(" PCR-%u ", tce->pcr);
@ -881,7 +881,7 @@ static void dump_tcpa_log(void)
printf(" %s [%s]\n", tce->digest_type, tce->name); printf(" %s [%s]\n", tce->digest_type, tce->name);
} }
unmap_memory(&tcpa_mapping); unmap_memory(&log_mapping);
} }
struct cbmem_console { struct cbmem_console {
@ -1339,7 +1339,7 @@ static void print_usage(const char *name, int exit_code)
" -T | --parseable-timestamps: print parseable timestamps\n" " -T | --parseable-timestamps: print parseable timestamps\n"
" -S | --stacked-timestamps: print stacked timestamps (e.g. for flame graph tools)\n" " -S | --stacked-timestamps: print stacked timestamps (e.g. for flame graph tools)\n"
" -a | --add-timestamp ID: append timestamp with ID\n" " -a | --add-timestamp ID: append timestamp with ID\n"
" -L | --tcpa-log print TCPA log\n" " -L | --tcpa-log print TPM log\n"
" -V | --verbose: verbose (debugging) output\n" " -V | --verbose: verbose (debugging) output\n"
" -v | --version: print the version\n" " -v | --version: print the version\n"
" -h | --help: print this help\n" " -h | --help: print this help\n"
@ -1677,7 +1677,7 @@ int main(int argc, char** argv)
dump_timestamps(timestamp_type); dump_timestamps(timestamp_type);
if (print_tcpa_log) if (print_tcpa_log)
dump_tcpa_log(); dump_tpm_cb_log();
unmap_memory(&lbtable_mapping); unmap_memory(&lbtable_mapping);