coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
secdata_tpm.c File Reference
Include dependency graph for secdata_tpm.c:

Go to the source code of this file.

Macros

#define VBDEBUG(format, args...)    printk(BIOS_INFO, "%s():%d: " format, __func__, __LINE__, ## args)
 
#define RETURN_ON_FAILURE(tpm_cmd)
 

Functions

static uint32_t safe_write (uint32_t index, const void *data, uint32_t length)
 Like tlcl_write(), but checks for write errors due to hitting the 64-write limit and clears the TPM when that happens. More...
 
static uint32_t read_space_firmware (struct vb2_context *ctx)
 
uint32_t antirollback_read_space_kernel (struct vb2_context *ctx)
 Read and write kernel space in TPM. More...
 
static uint32_t safe_define_space (uint32_t index, uint32_t perm, uint32_t size)
 Similarly to safe_write(), this ensures we don't fail a DefineSpace because we hit the TPM write limit. More...
 
static uint32_t _factory_initialize_tpm (struct vb2_context *ctx)
 
uint32_t antirollback_lock_space_firmware (void)
 Lock must be called. More...
 
static uint32_t factory_initialize_tpm (struct vb2_context *ctx)
 Perform one-time initializations. More...
 
uint32_t antirollback_read_space_firmware (struct vb2_context *ctx)
 
uint32_t antirollback_write_space_firmware (struct vb2_context *ctx)
 Write may be called if the versions change. More...
 
uint32_t antirollback_write_space_kernel (struct vb2_context *ctx)
 
vb2_error_t vb2ex_tpm_clear_owner (struct vb2_context *ctx)
 

Macro Definition Documentation

◆ RETURN_ON_FAILURE

#define RETURN_ON_FAILURE (   tpm_cmd)
Value:
do { \
uint32_t result_; \
if ((result_ = (tpm_cmd)) != TPM_SUCCESS) { \
VBDEBUG("Antirollback: %08x returned by " #tpm_cmd \
"\n", (int)result_); \
return result_; \
} \
} while (0)
#define TPM_SUCCESS
Definition: tss_common.h:9

Definition at line 20 of file secdata_tpm.c.

◆ VBDEBUG

#define VBDEBUG (   format,
  args... 
)     printk(BIOS_INFO, "%s():%d: " format, __func__, __LINE__, ## args)

Definition at line 17 of file secdata_tpm.c.

Function Documentation

◆ _factory_initialize_tpm()

static uint32_t _factory_initialize_tpm ( struct vb2_context *  ctx)
static

◆ antirollback_lock_space_firmware()

uint32_t antirollback_lock_space_firmware ( void  )

Lock must be called.

Definition at line 543 of file secdata_tpm.c.

References tlcl_set_global_lock().

Referenced by verstage_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ antirollback_read_space_firmware()

uint32_t antirollback_read_space_firmware ( struct vb2_context *  ctx)

Definition at line 595 of file secdata_tpm.c.

References factory_initialize_tpm(), read_space_firmware(), RETURN_ON_FAILURE, TPM_E_BADINDEX, TPM_E_CORRUPTED_STATE, TPM_SUCCESS, and VBDEBUG.

Referenced by verstage_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ antirollback_read_space_kernel()

uint32_t antirollback_read_space_kernel ( struct vb2_context *  ctx)

Read and write kernel space in TPM.

Definition at line 39 of file secdata_tpm.c.

References BIOS_ERR, CONFIG, KERNEL_NV_INDEX, printk, RETURN_ON_FAILURE, tlcl_get_permissions(), tlcl_read(), TPM2, TPM_E_CORRUPTED_STATE, TPM_E_RANGE, TPM_NV_PER_PPWRITE, TPM_SUCCESS, and VBDEBUG.

Referenced by verstage_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ antirollback_write_space_firmware()

uint32_t antirollback_write_space_firmware ( struct vb2_context *  ctx)

Write may be called if the versions change.

Definition at line 613 of file secdata_tpm.c.

References CONFIG, FIRMWARE_NV_INDEX, safe_write(), and tlcl_cr50_enable_nvcommits().

Referenced by vboot_save_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ antirollback_write_space_kernel()

uint32_t antirollback_write_space_kernel ( struct vb2_context *  ctx)

Definition at line 621 of file secdata_tpm.c.

References CONFIG, KERNEL_NV_INDEX, safe_write(), and tlcl_cr50_enable_nvcommits().

Referenced by vboot_save_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ factory_initialize_tpm()

static uint32_t factory_initialize_tpm ( struct vb2_context *  ctx)
static

Perform one-time initializations.

Create the NVRAM spaces, and set their initial values as needed. Sets the nvLocked bit and ensures the physical presence command is enabled and locked.

Definition at line 557 of file secdata_tpm.c.

References _factory_initialize_tpm(), tlcl_self_test_full(), TPM_SUCCESS, and VBDEBUG.

Referenced by antirollback_read_space_firmware().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_space_firmware()

static uint32_t read_space_firmware ( struct vb2_context *  ctx)
static

Definition at line 31 of file secdata_tpm.c.

References FIRMWARE_NV_INDEX, RETURN_ON_FAILURE, tlcl_read(), and TPM_SUCCESS.

Referenced by antirollback_read_space_firmware().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ safe_define_space()

static uint32_t safe_define_space ( uint32_t  index,
uint32_t  perm,
uint32_t  size 
)
static

Similarly to safe_write(), this ensures we don't fail a DefineSpace because we hit the TPM write limit.

This is even less likely to happen than with writes because we only define spaces once at initialization, but we'd rather be paranoid about this.

Definition at line 475 of file secdata_tpm.c.

References RETURN_ON_FAILURE, tlcl_define_space(), tpm_clear_and_reenable(), and TPM_E_MAXNVWRITES.

Referenced by _factory_initialize_tpm().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ safe_write()

static uint32_t safe_write ( uint32_t  index,
const void data,
uint32_t  length 
)
static

Like tlcl_write(), but checks for write errors due to hitting the 64-write limit and clears the TPM when that happens.

This can only happen when the TPM is unowned, so it is OK to clear it (and we really have no choice). This is not expected to happen frequently, but it could happen.

Definition at line 458 of file secdata_tpm.c.

References length, RETURN_ON_FAILURE, tlcl_write(), tpm_clear_and_reenable(), and TPM_E_MAXNVWRITES.

Referenced by _factory_initialize_tpm(), antirollback_write_space_firmware(), and antirollback_write_space_kernel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vb2ex_tpm_clear_owner()

vb2_error_t vb2ex_tpm_clear_owner ( struct vb2_context *  ctx)

Definition at line 640 of file secdata_tpm.c.

References BIOS_INFO, printk, and tpm_clear_and_reenable().

Here is the call graph for this function: