diff options
author | Jakub Czapiga <jacz@semihalf.com> | 2023-09-08 13:17:21 +0000 |
---|---|---|
committer | Martin L Roth <gaumless@gmail.com> | 2023-09-18 15:40:40 +0000 |
commit | f64f3d00481ae45e1e70e804d5cb7907cac8abac (patch) | |
tree | b9a8cde4360af01dd1dde6a283c2ee7138d28340 /payloads/libpayload/libc/lp_vboot.c | |
parent | 58c2efc8e2cd5db065d0f4ab8678555e656e4a16 (diff) |
libpayload/vboot: Add vboot context initialization and management code
To fully and easily implement fallback/recovery in libcbfs with vboot
support the codebase requires access to vboot context. Moving context
management to libpayload allows to avoid unnecessary overhead and code
complication and still allows payloads to access it in a way it was
designed. Access to this codebase will also allow implementation of e.g.
vboot_fail_and_reboot() and other helpful utilities used by coreboot and
depthcharge.
BUG=b:197114807
TEST=make unit-tests
TEST=Build and boot on google/ovis4es with CL:4839296 and
VBOOT_CBFS_INTEGRATION enabled
Change-Id: Id719be7c4f07251201424b7dc6c1125c6b5756d8
Signed-off-by: Jakub Czapiga <jacz@semihalf.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/77635
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'payloads/libpayload/libc/lp_vboot.c')
-rw-r--r-- | payloads/libpayload/libc/lp_vboot.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/payloads/libpayload/libc/lp_vboot.c b/payloads/libpayload/libc/lp_vboot.c new file mode 100644 index 0000000000..b7717c7e78 --- /dev/null +++ b/payloads/libpayload/libc/lp_vboot.c @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#include <libpayload-config.h> +#include <arch/virtual.h> +#include <assert.h> +#include <libpayload.h> +#include <stdio.h> +#include <stdlib.h> +#include <sysinfo.h> +#include <vb2_api.h> +#include <lp_vboot.h> + +struct vb2_context *vboot_get_context(void) +{ + static struct vb2_context *ctx; + + if (ctx) + return ctx; + + die_if(lib_sysinfo.vboot_workbuf == 0, "vboot workbuf pointer is not set\n"); + + /* Use the firmware verification workbuf from coreboot. */ + vb2_error_t rv = vb2api_reinit(phys_to_virt(lib_sysinfo.vboot_workbuf), &ctx); + + die_if(rv, "vboot workbuf could not be initialized, error: %#x\n", rv); + + return ctx; +} |