Skip to content

Commit 4a20083

Browse files
committed
security/tpm/tspi: allocate 64 KiB for TCG logs
That's the minimum log size for client platforms per "TCG PC Client Platform Firmware Profile Specification" [0]. [0]: https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firmware-profile-specification/ Upstream-Status: Pending Change-Id: Ifed85a91d5e2cf28fcc40262710e0ec688479a62 Signed-off-by: Sergii Dmytruk <[email protected]>
1 parent 5ab879c commit 4a20083

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/security/tpm/tspi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#define TPM_PCR_MAX_LEN 64
1515
#define HASH_DATA_CHUNK_SIZE 1024
16-
#define MAX_TPM_LOG_ENTRIES 50
1716
/* Assumption of 2K TCPA log size reserved for CAR/SRAM */
1817
#define MAX_PRERAM_TPM_LOG_ENTRIES 15
1918

src/security/tpm/tspi/log-tpm1.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,28 @@
1414
#include <cbmem.h>
1515
#include <vb2_sha.h>
1616

17+
#define TPM_LOG_SIZE (64 * KiB)
18+
#define MAX_TPM_LOG_ENTRIES ((TPM_LOG_SIZE - sizeof(struct tpm_1_log_table)) / \
19+
sizeof(struct tpm_1_log_entry))
20+
1721
void *tpm1_log_cbmem_init(void)
1822
{
1923
static struct tpm_1_log_table *tclt;
2024
if (tclt)
2125
return tclt;
2226

2327
if (ENV_HAS_CBMEM) {
24-
size_t tpm_log_len;
2528
struct spec_id_event_data *hdr;
2629

2730
tclt = cbmem_find(CBMEM_ID_TCPA_TCG_LOG);
2831
if (tclt)
2932
return tclt;
3033

31-
tpm_log_len = sizeof(*tclt) + MAX_TPM_LOG_ENTRIES * sizeof(tclt->entries[0]);
32-
tclt = cbmem_add(CBMEM_ID_TCPA_TCG_LOG, tpm_log_len);
34+
tclt = cbmem_add(CBMEM_ID_TCPA_TCG_LOG, TPM_LOG_SIZE);
3335
if (!tclt)
3436
return NULL;
3537

36-
memset(tclt, 0, tpm_log_len);
38+
memset(tclt, 0, TPM_LOG_SIZE);
3739
hdr = &tclt->spec_id;
3840

3941
/* Fill in first "header" entry. */

src/security/tpm/tspi/log-tpm2.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include <cbmem.h>
2323
#include <vb2_sha.h>
2424

25+
#define TPM_LOG_SIZE (64 * KiB)
26+
#define MAX_TPM_LOG_ENTRIES ((TPM_LOG_SIZE - sizeof(struct tpm_2_log_table)) / \
27+
sizeof(struct tpm_2_log_entry))
28+
2529
struct startup_locality_event {
2630
char signature[16]; /* "StartupLocality" (NUL-terminated) */
2731
uint8_t startup_locality; /* 0 or 3 */
@@ -34,20 +38,17 @@ void *tpm2_log_cbmem_init(void)
3438
return tclt;
3539

3640
if (ENV_HAS_CBMEM) {
37-
size_t tpm_log_len;
3841
struct tcg_efi_spec_id_event *hdr;
3942

4043
tclt = cbmem_find(CBMEM_ID_TPM2_TCG_LOG);
4144
if (tclt)
4245
return tclt;
4346

44-
tpm_log_len = sizeof(struct tpm_2_log_table) +
45-
MAX_TPM_LOG_ENTRIES * sizeof(struct tpm_2_log_entry);
46-
tclt = cbmem_add(CBMEM_ID_TPM2_TCG_LOG, tpm_log_len);
47+
tclt = cbmem_add(CBMEM_ID_TPM2_TCG_LOG, TPM_LOG_SIZE);
4748
if (!tclt)
4849
return NULL;
4950

50-
memset(tclt, 0, tpm_log_len);
51+
memset(tclt, 0, TPM_LOG_SIZE);
5152
hdr = &tclt->header;
5253

5354
hdr->event_type = htole32(EV_NO_ACTION);

src/security/tpm/tspi/log.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <cbmem.h>
1010
#include <vb2_sha.h>
1111

12+
#define MAX_TPM_LOG_ENTRIES 50
13+
1214
void *tpm_cb_log_cbmem_init(void)
1315
{
1416
static struct tpm_cb_log_table *tclt;

0 commit comments

Comments
 (0)