![]() |
coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
|
#include <assert.h>
#include <string.h>
#include <security/tpm/tis.h>
#include <vb2_api.h>
#include <security/tpm/tss.h>
#include "tss_internal.h"
#include "tss_commands.h"
#include <console/console.h>
Go to the source code of this file.
Macros | |
#define | VBDEBUG(format, args...) printk(BIOS_DEBUG, format, ## args) |
Functions | |
static int | tpm_send_receive (const uint8_t *request, uint32_t request_length, uint8_t *response, uint32_t *response_length) |
static void | set_tpm_command_size (uint8_t *buffer, uint32_t size) |
static int | tpm_command_size (const uint8_t *buffer) |
static int | tpm_command_code (const uint8_t *buffer) |
static int | tpm_return_code (const uint8_t *buffer) |
static uint32_t | tlcl_send_receive_no_retry (const uint8_t *request, uint8_t *response, int max_length) |
uint32_t | tlcl_send_receive (const uint8_t *request, uint8_t *response, int max_length) |
Perform a raw TPM request/response transaction. More... | |
static uint32_t | send (const uint8_t *command) |
uint32_t | tlcl_lib_init (void) |
Call this first. More... | |
uint32_t | tlcl_startup (void) |
Send a TPM_Startup(ST_CLEAR). More... | |
uint32_t | tlcl_resume (void) |
Resume by sending a TPM_Startup(ST_STATE). More... | |
uint32_t | tlcl_save_state (void) |
Save TPM state by sending either TPM_SaveState() (TPM1.2) or TPM_Shutdown(ST_STATE) (TPM2.0). More... | |
uint32_t | tlcl_self_test_full (void) |
Run the self test. More... | |
uint32_t | tlcl_continue_self_test (void) |
Run the self test in the background. More... | |
uint32_t | tlcl_define_space (uint32_t index, uint32_t perm, uint32_t size) |
uint32_t | tlcl_write (uint32_t index, const void *data, uint32_t length) |
Write [length] bytes of [data] to space at [index]. More... | |
uint32_t | tlcl_read (uint32_t index, void *data, uint32_t length) |
Read [length] bytes from space at [index] into [data]. More... | |
uint32_t | tlcl_assert_physical_presence (void) |
Assert physical presence in software. More... | |
uint32_t | tlcl_physical_presence_cmd_enable (void) |
Enable the physical presence command. More... | |
uint32_t | tlcl_finalize_physical_presence (void) |
Finalize the physical presence settings: software PP is enabled, hardware PP is disabled, and the lifetime lock is set. More... | |
uint32_t | tlcl_set_nv_locked (void) |
Set the nvLocked bit. More... | |
uint32_t | tlcl_force_clear (void) |
Issue a ForceClear. More... | |
uint32_t | tlcl_set_enable (void) |
uint32_t | tlcl_set_deactivated (uint8_t flag) |
uint32_t | tlcl_get_permanent_flags (TPM_PERMANENT_FLAGS *pflags) |
uint32_t | tlcl_get_flags (uint8_t *disable, uint8_t *deactivated, uint8_t *nvlocked) |
uint32_t | tlcl_set_global_lock (void) |
Set the bGlobalLock flag, which only a reboot can clear. More... | |
uint32_t | tlcl_extend (int pcr_num, const uint8_t *in_digest, uint8_t *out_digest) |
Perform a TPM_Extend. More... | |
uint32_t | tlcl_get_permissions (uint32_t index, uint32_t *permissions) |
Get the permission bits for the NVRAM space with |index|. More... | |
Variables | |
static uint8_t | tlcl_init_done |
#define VBDEBUG | ( | format, | |
args... | |||
) | printk(BIOS_DEBUG, format, ## args) |
Definition at line 135 of file tss.c.
References tlcl_send_receive(), and TPM_LARGE_ENOUGH_COMMAND_SIZE.
Referenced by tlcl_assert_physical_presence(), tlcl_define_space(), tlcl_finalize_physical_presence(), tlcl_force_clear(), tlcl_physical_presence_cmd_enable(), tlcl_resume(), tlcl_save_state(), tlcl_self_test_full(), tlcl_set_deactivated(), tlcl_set_enable(), and tlcl_startup().
Definition at line 43 of file tss.c.
References buffer, and to_tpm_uint32().
Referenced by tlcl_write().
Assert physical presence in software.
The TPM error code is returned.
Definition at line 249 of file tss.c.
References s_tpm_ppassert_cmd::buffer, send(), tpm_ppassert_cmd, and VBDEBUG.
Referenced by tpm_setup().
Run the self test in the background.
Definition at line 184 of file tss.c.
References s_tpm_continueselftest_cmd::buffer, tlcl_send_receive_no_retry(), tpm_continueselftest_cmd, TPM_LARGE_ENOUGH_COMMAND_SIZE, and VBDEBUG.
Referenced by tlcl_send_receive().
Definition at line 193 of file tss.c.
References s_tpm_nv_definespace_cmd::buffer, s_tpm_nv_definespace_cmd::index, memcpy(), s_tpm_nv_definespace_cmd::perm, send(), s_tpm_nv_definespace_cmd::size, to_tpm_uint32(), tpm_nv_definespace_cmd, and VBDEBUG.
Referenced by safe_define_space(), and tlcl_set_nv_locked().
Perform a TPM_Extend.
Definition at line 334 of file tss.c.
References s_tpm_extend_cmd::buffer, s_tpm_extend_cmd::inDigest, kPcrDigestLength, kTpmResponseHeaderLength, memcpy(), s_tpm_extend_cmd::pcrNum, tlcl_send_receive(), to_tpm_uint32(), tpm_extend_cmd, and TPM_SUCCESS.
Referenced by tpm_extend_pcr(), and tspi_measure_cache_to_pcr().
Finalize the physical presence settings: software PP is enabled, hardware PP is disabled, and the lifetime lock is set.
The TPM error code is returned.
Definition at line 261 of file tss.c.
References s_tpm_finalizepp_cmd::buffer, send(), tpm_finalizepp_cmd, and VBDEBUG.
Referenced by _factory_initialize_tpm().
Issue a ForceClear.
The TPM error code is returned.
Definition at line 273 of file tss.c.
References s_tpm_forceclear_cmd::buffer, send(), tpm_forceclear_cmd, and VBDEBUG.
Referenced by tpm_clear_and_reenable().
Definition at line 310 of file tss.c.
References s_tpm_physicalsetdeactivated_cmd::deactivated, tdTPM_PERMANENT_FLAGS::deactivated, tdTPM_PERMANENT_FLAGS::disable, tdTPM_PERMANENT_FLAGS::nvLocked, tlcl_get_permanent_flags(), TPM_SUCCESS, and VBDEBUG.
uint32_t tlcl_get_permanent_flags | ( | TPM_PERMANENT_FLAGS * | pflags | ) |
Definition at line 294 of file tss.c.
References s_tpm_getflags_cmd::buffer, from_tpm_uint32(), kTpmResponseHeaderLength, memcpy(), tlcl_send_receive(), TPM_E_IOERROR, tpm_getflags_cmd, TPM_LARGE_ENOUGH_COMMAND_SIZE, and TPM_SUCCESS.
Referenced by _factory_initialize_tpm(), and tlcl_get_flags().
Get the permission bits for the NVRAM space with |index|.
Definition at line 355 of file tss.c.
References s_tpm_getpermissions_cmd::buffer, from_tpm_uint32(), s_tpm_getpermissions_cmd::index, kNvDataPublicPermissionsOffset, kTpmResponseHeaderLength, memcpy(), tlcl_send_receive(), to_tpm_uint32(), tpm_getpermissions_cmd, TPM_LARGE_ENOUGH_COMMAND_SIZE, and TPM_SUCCESS.
Referenced by antirollback_read_space_kernel().
Call this first.
Returns 0 if success, nonzero if error.
Definition at line 145 of file tss.c.
References tis_init(), tis_open(), and tlcl_init_done.
Referenced by mainboard_update_soc_chip_config(), mrc_cache_update_hash(), mrc_cache_verify_hash(), tpm_extend_pcr(), tpm_setup(), and vboot_save_data().
Enable the physical presence command.
The TPM error code is returned.
Definition at line 255 of file tss.c.
References s_tpm_ppenable_cmd::buffer, send(), tpm_ppenable_cmd, and VBDEBUG.
Referenced by tpm_setup().
Read [length] bytes from space at [index] into [data].
The TPM error code is returned.
Definition at line 224 of file tss.c.
References s_tpm_nv_read_cmd::buffer, from_tpm_uint32(), s_tpm_nv_read_cmd::index, kTpmResponseHeaderLength, length, s_tpm_nv_read_cmd::length, memcpy(), tlcl_send_receive(), to_tpm_uint32(), TPM_E_IOERROR, TPM_LARGE_ENOUGH_COMMAND_SIZE, tpm_nv_read_cmd, TPM_SUCCESS, and VBDEBUG.
Referenced by antirollback_read_space_kernel(), and read_space_firmware().
Resume by sending a TPM_Startup(ST_STATE).
The TPM error code is returned (0 for success).
Definition at line 166 of file tss.c.
References s_tpm_resume_cmd::buffer, send(), tpm_resume_cmd, and VBDEBUG.
Referenced by tpm_setup_s3_helper().
Save TPM state by sending either TPM_SaveState() (TPM1.2) or TPM_Shutdown(ST_STATE) (TPM2.0).
The TPM error code is returned (0 for success).
Definition at line 172 of file tss.c.
References s_tpm_savestate_cmd::buffer, send(), tpm_savestate_cmd, and VBDEBUG.
Run the self test.
Note—this is synchronous. To run this in parallel with other firmware, use ContinueSelfTest(). The TPM error code is returned.
Definition at line 178 of file tss.c.
References s_tpm_selftestfull_cmd::buffer, send(), tpm_selftestfull_cmd, and VBDEBUG.
Referenced by factory_initialize_tpm().
Perform a raw TPM request/response transaction.
Definition at line 104 of file tss.c.
References tlcl_continue_self_test(), tlcl_send_receive_no_retry(), TPM_E_DOING_SELFTEST, TPM_E_NEEDS_SELFTEST, and TPM_SUCCESS.
Referenced by send(), tlcl_extend(), tlcl_get_permanent_flags(), tlcl_get_permissions(), tlcl_read(), and tlcl_write().
|
static |
Definition at line 75 of file tss.c.
References tpm_command_code(), tpm_command_size(), tpm_return_code(), tpm_send_receive(), and VBDEBUG.
Referenced by tlcl_continue_self_test(), and tlcl_send_receive().
Definition at line 285 of file tss.c.
References s_tpm_physicalsetdeactivated_cmd::buffer, s_tpm_physicalsetdeactivated_cmd::deactivated, memcpy(), send(), tpm_physicalsetdeactivated_cmd, and VBDEBUG.
Referenced by tpm_clear_and_reenable().
Definition at line 279 of file tss.c.
References s_tpm_physicalenable_cmd::buffer, send(), tpm_physicalenable_cmd, and VBDEBUG.
Referenced by tpm_clear_and_reenable().
Set the bGlobalLock flag, which only a reboot can clear.
The TPM error code is returned.
Definition at line 328 of file tss.c.
References NULL, tlcl_write(), TPM_NV_INDEX0, and VBDEBUG.
Referenced by antirollback_lock_space_firmware().
Set the nvLocked bit.
The TPM error code is returned.
Definition at line 267 of file tss.c.
References tlcl_define_space(), TPM_NV_INDEX_LOCK, and VBDEBUG.
Referenced by _factory_initialize_tpm().
Send a TPM_Startup(ST_CLEAR).
The TPM error code is returned (0 for success).
Definition at line 160 of file tss.c.
References s_tpm_startup_cmd::buffer, send(), tpm_startup_cmd, and VBDEBUG.
Referenced by tpm_setup().
Write [length] bytes of [data] to space at [index].
The TPM error code is returned.
Definition at line 204 of file tss.c.
References assert, s_tpm_nv_write_cmd::buffer, s_tpm_nv_write_cmd::data, s_tpm_nv_write_cmd::index, kTpmRequestHeaderLength, kWriteInfoLength, length, s_tpm_nv_write_cmd::length, memcpy(), set_tpm_command_size(), tlcl_send_receive(), to_tpm_uint32(), TPM_LARGE_ENOUGH_COMMAND_SIZE, tpm_nv_write_cmd, and VBDEBUG.
Referenced by safe_write(), and tlcl_set_global_lock().
|
inlinestatic |
Definition at line 58 of file tss.c.
References buffer, and from_tpm_uint32().
Referenced by tlcl_send_receive_no_retry(), and tpm_return_code().
|
inlinestatic |
Definition at line 50 of file tss.c.
References buffer, and from_tpm_uint32().
Referenced by tlcl_send_receive_no_retry().
|
inlinestatic |
Definition at line 66 of file tss.c.
References buffer, and tpm_command_code().
Referenced by tlcl_send_receive_no_retry().
|
static |
Definition at line 27 of file tss.c.
References tis_sendrecv().
Referenced by tlcl_send_receive_no_retry().
|
static |
Definition at line 143 of file tss.c.
Referenced by tlcl_lib_init().