From df805d082e0272060d2761bfb065b8421a8eabd9 Mon Sep 17 00:00:00 2001 From: Yicheng Li Date: Thu, 1 Aug 2019 13:16:23 -0700 Subject: common: Prepare always_memset() Add a config for using always_memset() from third_party/cryptoc BRANCH=nocturne BUG=chromium:968809,chromium:989594,b:130238794 TEST=make -j buildall Change-Id: I22c83512eb1b8bdc8dac1b26315d25b65831513c Signed-off-by: Yicheng Li Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1731543 Reviewed-by: Nicolas Norvez Reviewed-by: Tom Hughes --- board/hatch_fp/board.h | 2 ++ board/nocturne_fp/board.h | 2 ++ common/build.mk | 16 ++++++++++++++++ include/config.h | 6 ++++++ 4 files changed, 26 insertions(+) diff --git a/board/hatch_fp/board.h b/board/hatch_fp/board.h index c8b8bc726e..d51f57a7fb 100644 --- a/board/hatch_fp/board.h +++ b/board/hatch_fp/board.h @@ -165,6 +165,8 @@ #define CONFIG_RNG +#define CONFIG_ALWAYS_MEMSET + #define CONFIG_CMD_FLASH #define CONFIG_CMD_SPI_XFER diff --git a/board/nocturne_fp/board.h b/board/nocturne_fp/board.h index 82fa7805b7..4b0a3a5426 100644 --- a/board/nocturne_fp/board.h +++ b/board/nocturne_fp/board.h @@ -150,6 +150,8 @@ #define CONFIG_RNG +#define CONFIG_ALWAYS_MEMSET + #define CONFIG_CMD_FLASH #define CONFIG_CMD_SPI_XFER diff --git a/common/build.mk b/common/build.mk index ba8432b252..63e5d052dc 100644 --- a/common/build.mk +++ b/common/build.mk @@ -240,6 +240,22 @@ $(out)/rma_key_from_blob.h: board/$(BOARD)/$(BLOB_FILE) util/bin2h.sh endif +ifeq ($(CONFIG_ALWAYS_MEMSET),y) +CRYPTOCLIB := $(realpath ../../third_party/cryptoc) +CPPFLAGS += -I$(abspath ./builtin) +CPPFLAGS += -I$(CRYPTOCLIB)/include + +CRYPTOC_OBJS = $(shell find $(out)/cryptoc -name 'util.o') +$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: LDFLAGS_EXTRA += $(CRYPTOC_OBJS) +$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: cryptoc_objs + +# Force the external build each time, so it can look for changed sources. +.PHONY: cryptoc_objs +cryptoc_objs: + $(MAKE) obj=$(realpath $(out))/cryptoc SUPPORT_UNALIGNED=1 \ + CONFIG_UPTO_SHA512=$(CONFIG_UPTO_SHA512) -C $(CRYPTOCLIB) objs +endif + include $(_common_dir)fpsensor/build.mk include $(_common_dir)usbc/build.mk diff --git a/include/config.h b/include/config.h index 867b3a5dca..832f1a740a 100644 --- a/include/config.h +++ b/include/config.h @@ -299,6 +299,12 @@ /* Define which ALS sensor is used for dimming the lightbar when dark */ #undef CONFIG_ALS_LIGHTBAR_DIMMING +/* + * Support always_memset() defined in third_party/cryptoc, which will not be + * optimized out by compiler. + */ +#undef CONFIG_ALWAYS_MEMSET + /* Support AP hang detection host command and state machine */ #undef CONFIG_AP_HANG_DETECT -- cgit v1.2.1