summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2020-06-28 21:07:16 +0000
committerCommit Bot <commit-bot@chromium.org>2020-07-02 11:31:05 +0000
commit68de90c7e2f4a27d3a76489199176d2ab8f56de1 (patch)
tree81d04d60a551bd36c70a107b06f106b6144e2023
parent4b3e5288ec913f2f4f9e9ce9fda5dae1aba92186 (diff)
downloadvboot-68de90c7e2f4a27d3a76489199176d2ab8f56de1.tar.gz
Allow building for non-CrOS environments
There's some code that is architecture specific, but looking at it, it's code for Chrome OS devices that just happens to be split along ISA lines. When building on systems that we don't ship crossystems integration for, these parts are replaced by stubs that always return error conditions, which allows building on unsupported ISA (such as POWER). The issue was reported at https://ticket.coreboot.org/issues/145 where a coreboot user wanted to build a vboot-enabled coreboot configuration (which builds futility for the signing part) on a POWER host system, which failed because we lack an implementation of the crossystem interfaces for POWER. BUG=none BRANCH=none TEST=Built upstream coreboot with a vboot-enabled target inside qemu-user-ppc64. Doing so works with these patches applied while it failed without them. Change-Id: I4aaeb56d4521c426a520bc9a1bb49497bec86c35 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2270096 Commit-Queue: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--Makefile10
-rw-r--r--host/arch/stub/lib/crossystem_arch.c49
2 files changed, 57 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index e3b66303..274fe2a0 100644
--- a/Makefile
+++ b/Makefile
@@ -104,6 +104,12 @@ else ifeq (${ARCH},amd64)
override ARCH := x86_64
endif
+ifneq ($(wildcard host/arch/${ARCH}/lib/crossystem_arch.c),)
+ CROSSYSTEM_ARCH_C := host/arch/${ARCH}/lib/crossystem_arch.c
+else
+ CROSSYSTEM_ARCH_C := host/arch/stub/lib/crossystem_arch.c
+endif
+
# FIRMWARE_ARCH is only defined by the Chromium OS ebuild if compiling
# for a firmware target (coreboot or depthcharge). It must map to the same
# consistent set of architectures as the host.
@@ -445,7 +451,7 @@ UTILLIB_SRCS = \
cgpt/cgpt_repair.c \
cgpt/cgpt_show.c \
futility/dump_kernel_config_lib.c \
- host/arch/${ARCH}/lib/crossystem_arch.c \
+ $(CROSSYSTEM_ARCH_C) \
host/lib/chromeos_config.c \
host/lib/crossystem.c \
host/lib/crypto.c \
@@ -505,7 +511,7 @@ HOSTLIB_SRCS = \
firmware/stub/vboot_api_stub_disk.c \
firmware/stub/vboot_api_stub_init.c \
futility/dump_kernel_config_lib.c \
- host/arch/${ARCH}/lib/crossystem_arch.c \
+ $(CROSSYSTEM_ARCH_C) \
host/lib/chromeos_config.c \
host/lib/crossystem.c \
host/lib/crypto.c \
diff --git a/host/arch/stub/lib/crossystem_arch.c b/host/arch/stub/lib/crossystem_arch.c
new file mode 100644
index 00000000..4a71dddc
--- /dev/null
+++ b/host/arch/stub/lib/crossystem_arch.c
@@ -0,0 +1,49 @@
+/* Copyright (c) 2020 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "crossystem_arch.h"
+#include "crossystem.h"
+#include "crossystem_vbnv.h"
+#include "host_common.h"
+#include "vboot_struct.h"
+
+int vb2_read_nv_storage(struct vb2_context *ctx)
+{
+ return -1;
+}
+
+
+int vb2_write_nv_storage(struct vb2_context *ctx)
+{
+ return -1;
+}
+
+VbSharedDataHeader* VbSharedDataRead(void)
+{
+ return NULL;
+}
+
+int VbGetArchPropertyInt(const char* name)
+{
+ return -1;
+}
+
+
+const char* VbGetArchPropertyString(const char* name, char* dest,
+ size_t size)
+{
+ return NULL;
+}
+
+
+int VbSetArchPropertyInt(const char* name, int value)
+{
+ return -1;
+}
+
+int VbSetArchPropertyString(const char* name, const char* value)
+{
+ return -1;
+}