diff options
author | Jerome Forissier <jerome@forissier.org> | 2019-09-18 18:03:43 +0200 |
---|---|---|
committer | Jérôme Forissier <jerome@forissier.org> | 2019-09-30 09:44:47 +0200 |
commit | a2087649ca68f259e980594f536ea3ff19c4bbe3 (patch) | |
tree | fb48c9551efa982906e5961bfb5b1d910bbf183f | |
parent | dfb96021b49bf16f050fead3a9cea46f071b1bc4 (diff) | |
download | optee_os-a2087649ca68f259e980594f536ea3ff19c4bbe3.tar.gz |
core: add support for dumping build configuration info on boot
During development, we occasionally experience crashes within the TEE
core. When the tests are run locally, the developer has all the needed
information to troubleshoot the issue. But when the crash occurs on a
remote host (CI for instance), it is sometimes inconvenient or even
impossible to retrieve files other than the console logs. As a result,
it is equally inconvenient or impossible to obtain a symbolized crash
dump (scripts/symbolize.py needs the dump message but also tee.elf).
If the exact build configuration is known, then it is possible to
reproduce the build locally (assuming the same toolchain is also used
which is not a problem in practice) and proceed with debugging.
Unfortunately the values of the CFG_ flags are not always shown in the
logs and omitting only one flag can significantly change the TEE
binary.
This commit introduces CFG_SHOW_CONF_ON_BOOT (default n). When enabled,
the contents of the build configuration file $O/conf.mk is printed
to the secure console during initialization with TRACE_INFO severity.
The file is compressed to reduce memory usage and space used in the
logs, and it is encoded into printable text.
To obtain the conf.mk file, one needs to copy and paste the encoded
text into 'base64 -d | xz -d'. These two commands are also required at
build time when CFG_SHOW_CONF_ON_BOOT is y.
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
-rw-r--r-- | core/kernel/show_conf.c | 19 | ||||
-rw-r--r-- | core/kernel/sub.mk | 1 | ||||
-rw-r--r-- | core/sub.mk | 17 | ||||
-rw-r--r-- | mk/config.mk | 4 |
4 files changed, 41 insertions, 0 deletions
diff --git a/core/kernel/show_conf.c b/core/kernel/show_conf.c new file mode 100644 index 000000000..c6495ed5b --- /dev/null +++ b/core/kernel/show_conf.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (c) 1019 Huawei Technologies Co., Ltd + */ + +#include <initcall.h> +#include <trace.h> + +extern const char conf_str[]; + +static TEE_Result show_conf(void) +{ +#if (TRACE_LEVEL >= TRACE_INFO) + IMSG("Contents of conf.mk (decode with 'base64 -d | xz -d'):"); + trace_ext_puts(conf_str); +#endif + return TEE_SUCCESS; +} +service_init(show_conf); diff --git a/core/kernel/sub.mk b/core/kernel/sub.mk index b847f39f1..2841bd30f 100644 --- a/core/kernel/sub.mk +++ b/core/kernel/sub.mk @@ -15,3 +15,4 @@ srcs-y += tee_ta_manager.c srcs-$(CFG_CORE_SANITIZE_UNDEFINED) += ubsan.c srcs-y += scattered_array.c srcs-y += huk_subkey.c +srcs-$(CFG_SHOW_CONF_ON_BOOT) += show_conf.c diff --git a/core/sub.mk b/core/sub.mk index e966dc89f..4f38eb99d 100644 --- a/core/sub.mk +++ b/core/sub.mk @@ -50,3 +50,20 @@ recipe-embedded_secure_dtb = scripts/bin_to_c.py \ --out $(core-embed-fdt-c) $(eval $(call gen-dtb-file,$(core-embed-fdt-dts),$(core-embed-fdt-dtb))) endif + +ifeq ($(CFG_SHOW_CONF_ON_BOOT),y) +conf-mk-xz-base64 := $(sub-dir-out)/conf.mk.xz.base64 +cleanfiles += $(conf-mk-xz-base64) + +$(conf-mk-xz-base64): $(conf-mk-file) + @$(cmd-echo-silent) ' GEN $@' + $(q)tail +3 $< | xz | base64 -w 100 >$@ + +gensrcs-y += conf_str +produce-conf_str = conf.mk.xz.base64.c +depends-conf_str = $(conf-mk-xz-base64) +recipe-conf_str = scripts/bin_to_c.py --text --bin $(conf-mk-xz-base64) \ + --out $(sub-dir-out)/conf.mk.xz.base64.c \ + --vname conf_str +cleanfiles += $(sub-dir-out)/conf.mk.xz.base64.c +endif diff --git a/mk/config.mk b/mk/config.mk index cb4f968bb..a1aab816f 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -494,3 +494,7 @@ endif # Enables backwards compatible derivation of RPMB and SSK keys CFG_CORE_HUK_SUBKEY_COMPAT ?= y + +# Compress and encode conf.mk into the TEE core, and show the encoded string on +# boot (with severity TRACE_INFO). +CFG_SHOW_CONF_ON_BOOT ?= n |