summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-07-16 11:08:21 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-25 16:57:39 +0000
commit5f11ae80512a57d18730c2bf345ea716bc138f0e (patch)
tree3a9aead276259295b59415065b42515d13f27075
parent0f5677d444d12814749559b71083a4130ac9dd4e (diff)
downloadchrome-ec-5f11ae80512a57d18730c2bf345ea716bc138f0e.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,b:161834994 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> (cherry picked from commit e425f0d7ef7f6e56b783e20a35709fbb1cc2e2b7) Change-Id: I771dc588af5fb26a7b9fe763d97cb24710818700 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2510889 Tested-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit ff122d136b67603c19be63d21bea5b190c8ac313) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2718414
-rw-r--r--common/tpm_registers.c39
-rwxr-xr-xutil/getversion.sh2
2 files changed, 36 insertions, 5 deletions
diff --git a/common/tpm_registers.c b/common/tpm_registers.c
index 841c1f59fe..9b01c7111c 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.
@@ -585,12 +594,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();
/*
@@ -621,6 +631,7 @@ static void tpm_init(void)
} else {
_plat__SetNvAvail();
}
+#endif
}
size_t tpm_get_burst_size(void)
@@ -923,7 +934,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;
@@ -1007,10 +1018,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 289365f7e7..4403872a67 100755
--- a/util/getversion.sh
+++ b/util/getversion.sh
@@ -77,7 +77,7 @@ get_tree_version() {
IFS="${dc}"
-ver="${CR50_DEV:+DBG/}${BOARD}_"
+ver="${CR50_SQA:+SQA/}${CR50_DEV:+DBG/}${CRYPTO_TEST:+CT/}${BOARD}_"
global_dirty= # set if any of the component repos is 'dirty'.
dir_list=( . ) # list of component directories, always includes the EC tree