25 #define VBDEBUG(format, args...) printk(BIOS_DEBUG, format, ## args)
32 size_t len = *response_length;
33 if (
tis_sendrecv(request, request_length, response, &len))
34 return VB2_ERROR_UNKNOWN;
36 if (len > *response_length)
37 return VB2_ERROR_UNKNOWN;
38 *response_length = len;
49 __attribute__((unused))
76 uint8_t *response,
int max_length)
78 uint32_t response_length = max_length;
82 response, &response_length);
85 VBDEBUG(
"TPM: command 0x%x send/receive failed: 0x%x\n",
96 VBDEBUG(
"TPM: command 0x%x returned 0x%x\n",
115 #if defined(TPM_BLOCKING_CONTINUESELFTEST) || defined(VB_RECOVERY_MODE)
151 return VB2_ERROR_UNKNOWN;
153 return VB2_ERROR_UNKNOWN;
180 VBDEBUG(
"TPM: Self test full\n");
187 VBDEBUG(
"TPM: Continue self test\n");
190 response,
sizeof(response));
208 const int total_length =
240 if (result_length >
length)
243 memcpy(data, nv_read_cursor, result_length);
251 VBDEBUG(
"TPM: Asserting physical presence\n");
257 VBDEBUG(
"TPM: Enable the physical presence command\n");
263 VBDEBUG(
"TPM: Enable PP cmd, disable HW pp, and set lifetime lock\n");
269 VBDEBUG(
"TPM: Set NV locked\n");
281 VBDEBUG(
"TPM: Enabling TPM\n");
288 VBDEBUG(
"TPM: SetDeactivated(%d)\n", flag);
322 VBDEBUG(
"TPM: flags disable=%d, deactivated=%d, nvlocked=%d\n",
330 VBDEBUG(
"TPM: Set global lock\n");
void * memcpy(void *dest, const void *src, size_t n)
#define assert(statement)
int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, uint8_t *recvbuf, size_t *rbuf_len)
u8 buffer[C2P_BUFFER_MAXSIZE]
uint32_t tlcl_send_receive(const uint8_t *request, uint8_t *response, int max_length)
Perform a raw TPM request/response transaction.
uint32_t tlcl_set_deactivated(uint8_t flag)
uint32_t tlcl_set_global_lock(void)
Set the bGlobalLock flag, which only a reboot can clear.
uint32_t tlcl_save_state(void)
Save TPM state by sending either TPM_SaveState() (TPM1.2) or TPM_Shutdown(ST_STATE) (TPM2....
uint32_t tlcl_assert_physical_presence(void)
Assert physical presence in software.
static uint8_t tlcl_init_done
uint32_t tlcl_set_enable(void)
uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size)
uint32_t tlcl_get_permissions(uint32_t index, uint32_t *permissions)
Get the permission bits for the NVRAM space with |index|.
uint32_t tlcl_continue_self_test(void)
Run the self test in the background.
static void set_tpm_command_size(uint8_t *buffer, uint32_t size)
uint32_t tlcl_force_clear(void)
Issue a ForceClear.
static uint32_t tlcl_send_receive_no_retry(const uint8_t *request, uint8_t *response, int max_length)
uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated, uint8_t *nvlocked)
uint32_t tlcl_self_test_full(void)
Run the self test.
uint32_t tlcl_finalize_physical_presence(void)
Finalize the physical presence settings: software PP is enabled, hardware PP is disabled,...
static uint32_t send(const uint8_t *command)
static int tpm_command_code(const uint8_t *buffer)
#define VBDEBUG(format, args...)
static int tpm_command_size(const uint8_t *buffer)
uint32_t tlcl_lib_init(void)
Call this first.
uint32_t tlcl_set_nv_locked(void)
Set the nvLocked bit.
uint32_t tlcl_startup(void)
Send a TPM_Startup(ST_CLEAR).
uint32_t tlcl_write(uint32_t index, const void *data, uint32_t length)
Write [length] bytes of [data] to space at [index].
uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest, uint8_t *out_digest)
Perform a TPM_Extend.
uint32_t tlcl_physical_presence_cmd_enable(void)
Enable the physical presence command.
uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags)
static int tpm_return_code(const uint8_t *buffer)
uint32_t tlcl_read(uint32_t index, void *data, uint32_t length)
Read [length] bytes from space at [index] into [data].
static int tpm_send_receive(const uint8_t *request, uint32_t request_length, uint8_t *response, uint32_t *response_length)
uint32_t tlcl_resume(void)
Resume by sending a TPM_Startup(ST_STATE).
#define TPM_LARGE_ENOUGH_COMMAND_SIZE
#define TPM_NV_INDEX_LOCK
const struct s_tpm_extend_cmd tpm_extend_cmd
const struct s_tpm_ppassert_cmd tpm_ppassert_cmd
const struct s_tpm_nv_definespace_cmd tpm_nv_definespace_cmd
const struct s_tpm_nv_write_cmd tpm_nv_write_cmd
const struct s_tpm_selftestfull_cmd tpm_selftestfull_cmd
const int kWriteInfoLength
const struct s_tpm_finalizepp_cmd tpm_finalizepp_cmd
const struct s_tpm_getflags_cmd tpm_getflags_cmd
const struct s_tpm_getpermissions_cmd tpm_getpermissions_cmd
const int kNvDataPublicPermissionsOffset
const struct s_tpm_startup_cmd tpm_startup_cmd
const struct s_tpm_physicalsetdeactivated_cmd tpm_physicalsetdeactivated_cmd
const struct s_tpm_ppenable_cmd tpm_ppenable_cmd
const struct s_tpm_savestate_cmd tpm_savestate_cmd
const struct s_tpm_forceclear_cmd tpm_forceclear_cmd
const struct s_tpm_nv_read_cmd tpm_nv_read_cmd
const struct s_tpm_physicalenable_cmd tpm_physicalenable_cmd
const struct s_tpm_resume_cmd tpm_resume_cmd
const struct s_tpm_continueselftest_cmd tpm_continueselftest_cmd
#define TPM_E_NEEDS_SELFTEST
#define TPM_E_DOING_SELFTEST
#define kTpmResponseHeaderLength
static void to_tpm_uint32(uint8_t *buffer, uint32_t x)
#define kTpmRequestHeaderLength
static void from_tpm_uint32(const uint8_t *buffer, uint32_t *x)