From 5220aeab6ef62e26f92e64ce4bab20d26e53420f Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Wed, 24 Oct 2018 15:57:03 +0200 Subject: [PATCH] security/vboot: build vboot_fw20.a per stage When used more widely across the tree, we don't want to have to worry if all its users are on the same architecture (eg. aarch32 vs aarch64), so just build their own library for each stage. Change-Id: Ib6807ff73c2713f3b23f43055325b2c40ff1a17d Signed-off-by: Patrick Georgi Reviewed-on: https://review.coreboot.org/29253 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh Reviewed-by: Paul Menzel --- src/security/vboot/Makefile.inc | 49 +++++++++++++++------------------ 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/src/security/vboot/Makefile.inc b/src/security/vboot/Makefile.inc index 781aa5ebd0..c9dd39f3f4 100644 --- a/src/security/vboot/Makefile.inc +++ b/src/security/vboot/Makefile.inc @@ -80,44 +80,39 @@ postcar-y += common.c romstage-$(CONFIG_FSP2_0_USES_TPM_MRC_HASH) += mrc_cache_hash_tpm.c -ifeq ($(CONFIG_VBOOT_SEPARATE_VERSTAGE),y) -VB_FIRMWARE_ARCH := $(ARCHDIR-$(ARCH-verstage-y)) -else -ifeq ($(CONFIG_VBOOT_STARTS_IN_BOOTBLOCK),y) -VB_FIRMWARE_ARCH := $(ARCHDIR-$(ARCH-bootblock-y)) -else -VB_FIRMWARE_ARCH := $(ARCHDIR-$(ARCH-romstage-y)) -endif -endif # CONFIG_VBOOT_SEPARATE_VERSTAGE -VB2_LIB = $(obj)/external/vboot_reference/vboot_fw20.a -VBOOT_CFLAGS += $(patsubst -I%,-I$(top)/%,\ - $(patsubst $(src)/%.h,$(top)/$(src)/%.h,\ - $(filter-out -I$(obj), $(CPPFLAGS_verstage)))) -VBOOT_CFLAGS += $(CFLAGS_verstage) -VBOOT_CFLAGS += $(verstage-c-ccopts) -VBOOT_CFLAGS += -I$(abspath $(obj)) -Wno-missing-prototypes -VBOOT_CFLAGS += -DVBOOT_DEBUG +# call with $1 = stage name to create rules for building the library +# for the stage and adding it to the stage's set of object files. +define vboot-for-stage +VB2_LIB_$(1) = $(obj)/external/vboot_reference-$(1)/vboot_fw20.a +VBOOT_CFLAGS_$(1) += $$(patsubst -I%,-I$(top)/%,\ + $$(patsubst $(src)/%.h,$(top)/$(src)/%.h,\ + $$(filter-out -I$(obj), $$(CPPFLAGS_$(1))))) +VBOOT_CFLAGS_$(1) += $$(CFLAGS_$(1)) +VBOOT_CFLAGS_$(1) += $$($(1)-c-ccopts) +VBOOT_CFLAGS_$(1) += -I$(abspath $(obj)) -Wno-missing-prototypes +VBOOT_CFLAGS_$(1) += -DVBOOT_DEBUG -$(VB2_LIB): $(obj)/config.h +$$(VB2_LIB_$(1)): $(obj)/config.h printf " MAKE $(subst $(obj)/,,$(@))\n" - +FIRMWARE_ARCH=$(VB_FIRMWARE_ARCH) \ - CC="$(CC_verstage)" \ - CFLAGS="$(VBOOT_CFLAGS)" VBOOT2="y" \ + +FIRMWARE_ARCH=$$(ARCHDIR-$$(ARCH-$(1)-y)) \ + CC="$$(CC_$(1))" \ + CFLAGS="$$(VBOOT_CFLAGS_$(1))" VBOOT2="y" \ $(MAKE) -C $(VBOOT_SOURCE) \ - BUILD=$(abspath $(dir $(VB2_LIB))) \ + BUILD=$$(abspath $$(dir $$(VB2_LIB_$(1)))) \ V=$(V) \ fwlib20 -verstage-srcs += $(VB2_LIB) +$(1)-srcs += $$(VB2_LIB_$(1)) + +endef # vboot-for-stage + +$(eval $(call vboot-for-stage,verstage)) ifeq ($(CONFIG_VBOOT_SEPARATE_VERSTAGE),y) -# This works under the assumption that romstage and verstage use the same -# architecture and thus CC_verstage is the same as CC_romstage. If this is not -# true, VB2_LIB needs to ensure that correct CC is being used. ifeq ($(CONFIG_VBOOT_HAS_REC_HASH_SPACE),y) -romstage-srcs += $(VB2_LIB) +$(eval $(call vboot-for-stage,romstage)) endif cbfs-files-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += $(CONFIG_CBFS_PREFIX)/verstage