Skip to content

Commit

Permalink
treewide: stop calling custom TPM log "TCPA"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
SergiiDmytruk authored and felixheld committed Jan 11, 2023
1 parent 16a444c commit 2710df7
Show file tree
Hide file tree
Showing 26 changed files with 156 additions and 154 deletions.
4 changes: 2 additions & 2 deletions src/arch/x86/car.ld
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
VBOOT2_WORK(., 12K)
#endif
#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 */
TPM_TCPA_LOG(., 2K)
TPM_LOG(., 2K)
#endif
/* Stack for CAR stages. Since it persists across all stages that
* use CAR it can be reused. The chipset/SoC is expected to provide
Expand Down
4 changes: 2 additions & 2 deletions src/commonlib/bsd/include/commonlib/bsd/cbmem_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#define CBMEM_ID_STAGEx_CACHE 0x57a9e100
#define CBMEM_ID_STAGEx_RAW 0x57a9e200
#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_TIMESTAMP 0x54494d45
#define CBMEM_ID_TPM2_TCG_LOG 0x54504d32
Expand Down Expand Up @@ -139,7 +139,7 @@
{ CBMEM_ID_SMBIOS, "SMBIOS " }, \
{ CBMEM_ID_SMM_SAVE_SPACE, "SMM BACKUP " }, \
{ 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_TIMESTAMP, "TIME STAMP " }, \
{ CBMEM_ID_TPM2_TCG_LOG, "TPM2 TCGLOG" }, \
Expand Down
2 changes: 1 addition & 1 deletion src/commonlib/include/commonlib/coreboot_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ enum {
LB_TAG_MAC_ADDRS = 0x0033,
LB_TAG_VBOOT_WORKBUF = 0x0034,
LB_TAG_MMC_INFO = 0x0035,
LB_TAG_TCPA_LOG = 0x0036,
LB_TAG_TPM_CB_LOG = 0x0036,
LB_TAG_FMAP = 0x0037,
LB_TAG_PLATFORM_BLOB_VERSION = 0x0038,
LB_TAG_SMMSTOREV2 = 0x0039,
Expand Down
29 changes: 0 additions & 29 deletions src/commonlib/include/commonlib/tcpa_log_serialized.h

This file was deleted.

30 changes: 30 additions & 0 deletions src/commonlib/include/commonlib/tpm_log_serialized.h
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions src/include/memlayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@
STR(vboot2 work buffer size must be equivalent to \
VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE! (sz)));

#define TPM_TCPA_LOG(addr, size) \
REGION(tpm_tcpa_log, addr, size, 16) \
_ = ASSERT(size >= 2K, "tpm tcpa log buffer must be at least 2K!");
#define TPM_LOG(addr, size) \
REGION(tpm_log, addr, size, 16) \
_ = ASSERT(size >= 2K, "tpm log buffer must be at least 2K!");

#if ENV_SEPARATE_VERSTAGE
#define VERSTAGE(addr, sz) \
Expand Down
2 changes: 1 addition & 1 deletion src/include/symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ DECLARE_OPTIONAL_REGION(postram_cbfs_cache)
DECLARE_OPTIONAL_REGION(cbfs_cache)
DECLARE_REGION(cbfs_mcache)
DECLARE_REGION(fmap_cache)
DECLARE_REGION(tpm_tcpa_log)
DECLARE_REGION(tpm_log)

#if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
DECLARE_REGION(bss)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cbfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ static bool cbfs_file_hash_mismatch(const void *buffer, size_t size,

if (!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. */
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/coreboot_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ static void add_cbmem_pointers(struct lb_header *header)
{CBMEM_ID_ACPI_CNVS, LB_TAG_ACPI_CNVS},
{CBMEM_ID_VPD, LB_TAG_VPD},
{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_VBOOT_WORKBUF, LB_TAG_VBOOT_WORKBUF},
{CBMEM_ID_TYPE_C_INFO, LB_TAG_TYPE_C_INFO},
Expand Down
24 changes: 12 additions & 12 deletions src/security/tpm/tspi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define TSPI_H_

#include <security/tpm/tss.h>
#include <commonlib/tcpa_log_serialized.h>
#include <commonlib/tpm_log_serialized.h>
#include <commonlib/region.h>
#include <vb2_api.h>

Expand All @@ -13,33 +13,33 @@

/**
* 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
*/
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 pcr PCR used to extend hashed data
* @param diget_algo sets the digest algorithm
* @param digest sets the hash extended into the tpm
* @param digest_len the length of the digest
*/
void tcpa_log_add_table_entry(const char *name, const uint32_t pcr,
enum vb2_hash_algorithm digest_algo,
const uint8_t *digest,
const size_t digest_len);
void tpm_log_add_table_entry(const char *name, const uint32_t pcr,
enum vb2_hash_algorithm digest_algo,
const uint8_t *digest,
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.
Expand Down
32 changes: 16 additions & 16 deletions src/security/tpm/tspi/crtm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#include "crtm.h"
#include <string.h>

static int tcpa_log_initialized;
static inline int tcpa_log_available(void)
static int tpm_log_initialized;
static inline int tpm_log_available(void)
{
if (ENV_BOOTBLOCK)
return tcpa_log_initialized;
return tpm_log_initialized;

return 1;
}
Expand All @@ -33,10 +33,10 @@ static inline int tcpa_log_available(void)
*/
static uint32_t tspi_init_crtm(void)
{
/* Initialize TCPA PRERAM log. */
if (!tcpa_log_available()) {
tcpa_preram_log_clear();
tcpa_log_initialized = 1;
/* Initialize TPM PRERAM log. */
if (!tpm_log_available()) {
tpm_preram_log_clear();
tpm_log_initialized = 1;
} else {
printk(BIOS_WARNING, "TSPI: CRTM already initialized!\n");
return VB2_SUCCESS;
Expand Down Expand Up @@ -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 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) {
printk(BIOS_WARNING,
"Initializing CRTM failed!\n");
Expand Down Expand Up @@ -142,29 +142,29 @@ uint32_t tspi_cbfs_measurement(const char *name, uint32_t type, const struct vb2
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),
tcpa_metadata);
tpm_log_metadata);
}

int tspi_measure_cache_to_pcr(void)
{
int i;
struct tcpa_table *tclt = tcpa_log_init();
struct tpm_cb_log_table *tclt = tpm_log_init();

/* This means the table is empty. */
if (!tcpa_log_available())
if (!tpm_log_available())
return VB2_SUCCESS;

if (!tclt) {
printk(BIOS_WARNING, "TCPA: Log non-existent!\n");
printk(BIOS_WARNING, "TPM LOG: log non-existent!\n");
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++) {
struct tcpa_entry *tce = &tclt->entries[i];
struct tpm_cb_log_entry *tce = &tclt->entries[i];
if (tce) {
printk(BIOS_DEBUG, "TPM: Write digest for"
" %s into PCR %d\n",
Expand Down
2 changes: 1 addition & 1 deletion src/security/tpm/tspi/crtm.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#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);

Expand Down

0 comments on commit 2710df7

Please sign in to comment.