Provide CAR decoration for tpm2 statics

Decorated tpm2 statics with CAR_GLOBAL

BUG=chrome-os-partner:55083
BRANCH=none
TEST=none

Change-Id: I85620d5c6ffddab5514c01c2c652670bf33b4e7e
Signed-off-by: Martin Roth <martinroth@chromium.org>
Original-Commit-Id: ae43d3bb7fed5b891ed38cd268bfe4e1416b77e2
Original-Change-Id: I871442ec096836a86870f8d53a3058c9c040cff8
Original-Signed-off-by: Victor Prupis <vprupis@google.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/373243
Original-Commit-Ready: Stefan Reinauer <reinauer@google.com>
Original-Tested-by: Stefan Reinauer <reinauer@google.com>
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/16366
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Victor Prupis 2016-08-19 10:45:04 -07:00 committed by Martin Roth
parent 70c496b24e
commit f706020ed6
2 changed files with 15 additions and 9 deletions

View File

@ -4,6 +4,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#include <arch/early_variables.h>
#include <commonlib/endian.h> #include <commonlib/endian.h>
#include <console/console.h> #include <console/console.h>
#include <stdlib.h> #include <stdlib.h>
@ -11,7 +12,7 @@
#include "tpm2_marshaling.h" #include "tpm2_marshaling.h"
static uint16_t tpm_tag; /* Depends on the command type. */ static uint16_t tpm_tag CAR_GLOBAL; /* Depends on the command type. */
/* /*
* Each unmarshaling function receives a pointer to the buffer pointer and a * Each unmarshaling function receives a pointer to the buffer pointer and a
@ -268,7 +269,7 @@ static void marshal_common_session_header(void **buffer,
int i; int i;
struct tpm2_session_header session_header; struct tpm2_session_header session_header;
tpm_tag = TPM_ST_SESSIONS; car_set_var(tpm_tag, TPM_ST_SESSIONS);
for (i = 0; i < handle_count; i++) for (i = 0; i < handle_count; i++)
marshal_TPM_HANDLE(buffer, handles[i], buffer_space); marshal_TPM_HANDLE(buffer, handles[i], buffer_space);
@ -380,7 +381,7 @@ int tpm_marshal_command(TPM_CC command, void *tpm_command_body,
size_t body_size = max_body_size; size_t body_size = max_body_size;
/* Will be modified when marshaling some commands. */ /* Will be modified when marshaling some commands. */
tpm_tag = TPM_ST_NO_SESSIONS; car_set_var(tpm_tag, TPM_ST_NO_SESSIONS);
switch (command) { switch (command) {
case TPM2_Startup: case TPM2_Startup:
@ -437,7 +438,9 @@ int tpm_marshal_command(TPM_CC command, void *tpm_command_body,
/* Total size includes the header size. */ /* Total size includes the header size. */
marshaled_size += sizeof(struct tpm_header); marshaled_size += sizeof(struct tpm_header);
marshal_u16(&buffer, tpm_tag, &header_room); uint16_t tpm_tag_value = car_get_var(tpm_tag);
marshal_u16(&buffer, tpm_tag_value, &header_room);
marshal_u32(&buffer, marshaled_size, &header_room); marshal_u32(&buffer, marshaled_size, &header_room);
marshal_u32(&buffer, command, &header_room); marshal_u32(&buffer, command, &header_room);
return marshaled_size; return marshaled_size;

View File

@ -4,6 +4,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#include <arch/early_variables.h>
#include <console/console.h> #include <console/console.h>
#include <endian.h> #include <endian.h>
#include <lib/tpm2_tlcl_structures.h> #include <lib/tpm2_tlcl_structures.h>
@ -24,10 +25,12 @@ static void *tpm_process_command(TPM_CC command, void *command_body)
ssize_t out_size; ssize_t out_size;
size_t in_size; size_t in_size;
/* Command/response buffer. */ /* Command/response buffer. */
static uint8_t cr_buffer[TPM_BUFFER_SIZE]; static uint8_t cr_buffer[TPM_BUFFER_SIZE] CAR_GLOBAL;
uint8_t *cr_buffer_ptr = car_get_var_ptr(cr_buffer);
out_size = tpm_marshal_command(command, command_body, out_size = tpm_marshal_command(command, command_body,
cr_buffer, sizeof(cr_buffer)); cr_buffer_ptr, sizeof(cr_buffer));
if (out_size < 0) { if (out_size < 0) {
printk(BIOS_ERR, "command %#x, cr size %zd\n", printk(BIOS_ERR, "command %#x, cr size %zd\n",
command, out_size); command, out_size);
@ -35,13 +38,13 @@ static void *tpm_process_command(TPM_CC command, void *command_body)
} }
in_size = sizeof(cr_buffer); in_size = sizeof(cr_buffer);
if (tis_sendrecv(cr_buffer, out_size, if (tis_sendrecv(cr_buffer_ptr, out_size,
cr_buffer, &in_size)) { cr_buffer_ptr, &in_size)) {
printk(BIOS_ERR, "tpm transaction failed\n"); printk(BIOS_ERR, "tpm transaction failed\n");
return NULL; return NULL;
} }
return tpm_unmarshal_response(command, cr_buffer, in_size); return tpm_unmarshal_response(command, cr_buffer_ptr, in_size);
} }