summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-07-16 11:08:21 -0700
committerCommit Bot <commit-bot@chromium.org>2019-07-17 19:39:52 +0000
commite425f0d7ef7f6e56b783e20a35709fbb1cc2e2b7 (patch)
tree404e6ba89b8524819c192691cc09a98ae43d3451
parente7d2f636cb9c80e0c391b0eb4dddd5f15cd15d21 (diff)
downloadchrome-ec-e425f0d7ef7f6e56b783e20a35709fbb1cc2e2b7.tar.gz
cr50: do not enable TPM when compiling for dcrypto tests
There is no room in the flash for both dcrypto tests and the TPM library. Let's disable TPM function (and not link the library) when the image is compiled with dcrypto tests included. BRANCH=cr50, cr50-mp BUG=b:137659935 TEST=verified that there is plenty of room for tests now: $ make BOARD=cr50 -j -k CRYPTO_TEST=1 CR50_DEV=1 . . . *** 8124 bytes in flash and 61564 bytes in RAM still ... in cr50 RO *** *** 66100 bytes in flash and 6000 bytes in RAM still ... in cr50 RW *** - building without CRYPTO_TEST=1 still produces a functional Cr50 image; - when building with CRYPTO_TEST=1, the version string reflects it: $ strings build/cr50/ec.bin | grep cr50_v | head -1 DBG/CT/cr50_v2.0.1776-46b015f6a - CCD of the images built with crypto test enabled is fully functional, in particular USB updates are operational. Change-Id: Iae91ca36dc203301ac423fe048fc67eb44ef5de6 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704608 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
-rw-r--r--common/tpm_registers.c42
-rwxr-xr-xutil/getversion.sh2
2 files changed, 38 insertions, 6 deletions
diff --git a/common/tpm_registers.c b/common/tpm_registers.c
index e7cfeff547..f228503e7a 100644
--- a/common/tpm_registers.c
+++ b/common/tpm_registers.c
@@ -26,12 +26,21 @@
#include "watchdog.h"
#include "wp.h"
+/*
+ * Do not enable TPM if crypto test is enabled - there is no room in the flash
+ * for both.
+ */
+#ifndef CRYPTO_TEST_SETUP
+#define ENABLE_TPM
+
/* TPM2 library includes. */
#include "ExecCommand_fp.h"
#include "Platform.h"
#include "_TPM_Init_fp.h"
#include "Manufacture_fp.h"
+#endif
+
/****************************************************************************/
/*
* CAUTION: Variables defined in this in this file are treated specially.
@@ -549,12 +558,13 @@ void tpm_register_interface(interface_control_func interface_start,
static void tpm_init(void)
{
+#ifdef ENABLE_TPM
/*
* 0xc0 Means successful endorsement. Actual endorsement reasult code
* is added in lower bits to indicate endorsement failure, if any.
*/
uint8_t underrun_char = 0xc0;
-
+#endif
/* This is more related to TPM task activity than TPM transactions */
cprints(CC_TASK, "%s", __func__);
@@ -573,12 +583,13 @@ static void tpm_init(void)
tpm_.regs.sts = (tpm_family_tpm2 << tpm_family_shift) |
(63 << burst_count_shift) | sts_valid;
- /* TPM2 library functions. */
- _plat__Signal_PowerOn();
-
/* Create version string to be read by host */
set_version_string();
+#ifdef ENABLE_TPM
+ /* TPM2 library functions. */
+ _plat__Signal_PowerOn();
+
watchdog_reload();
/*
@@ -620,6 +631,7 @@ static void tpm_init(void)
_plat__SetNvAvail();
}
+#endif
}
size_t tpm_get_burst_size(void)
@@ -939,7 +951,7 @@ void tpm_task(void *u)
tpm_reset_now(0);
while (1) {
- uint8_t *response;
+ uint8_t *response = NULL;
unsigned response_size;
uint32_t command_code;
struct tpm_cmd_header *tpmh;
@@ -1023,10 +1035,30 @@ void tpm_task(void *u)
memcpy(response, tpm_broken_response,
response_size);
} else {
+#ifdef ENABLE_TPM
ExecuteCommand(tpm_.fifo_write_index,
(uint8_t *)tpmh,
&response_size,
&response);
+#else
+ {
+ /*
+ * This response is sent by actual
+ * TPM2 when replying to gibberish
+ * input. Copy it here to avoid the
+ * need to add conditional compilation
+ * cases below.
+ */
+ const uint8_t bad_cmd_resp[] = {
+ 0x00, 0xc4, 0x00, 0x00, 0x00,
+ 0x0a, 0x00, 0x00, 0x00, 0x1e
+ };
+ response = (uint8_t *)tpmh;
+ response_size = sizeof(bad_cmd_resp);
+ memcpy(response, bad_cmd_resp,
+ response_size);
+ }
+#endif
}
}
CPRINTF("got %d bytes in response\n", response_size);
diff --git a/util/getversion.sh b/util/getversion.sh
index de9a74fc52..d775100e8d 100755
--- a/util/getversion.sh
+++ b/util/getversion.sh
@@ -89,7 +89,7 @@ main() {
local ver
IFS="${dc}"
- ver="${CR50_SQA:+SQA/}${CR50_DEV:+DBG/}${BOARD}_"
+ ver="${CR50_SQA:+SQA/}${CR50_DEV:+DBG/}${CRYPTO_TEST:+CT/}${BOARD}_"
tool_ver=""
global_dirty= # set if any of the component repos is 'dirty'.
dir_list=( . ) # list of component directories, always includes the EC tree