2020-04-02 23:48:53 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2014-10-10 19:51:06 +02:00
|
|
|
|
2015-04-29 18:59:04 +02:00
|
|
|
#include <console/cbmem_console.h>
|
2015-04-11 02:50:11 +02:00
|
|
|
#include <reset.h>
|
2019-11-27 02:58:11 +01:00
|
|
|
#include <security/vboot/misc.h>
|
2017-10-17 17:02:29 +02:00
|
|
|
#include <security/vboot/vboot_common.h>
|
2018-04-26 03:15:44 +02:00
|
|
|
#include <security/vboot/vbnv.h>
|
2019-04-25 13:11:13 +02:00
|
|
|
#include <vb2_api.h>
|
2014-10-10 19:51:06 +02:00
|
|
|
|
2020-04-20 15:15:22 +02:00
|
|
|
#include "antirollback.h"
|
|
|
|
|
|
|
|
void vboot_save_data(struct vb2_context *ctx)
|
|
|
|
{
|
|
|
|
if (ctx->flags & VB2_CONTEXT_SECDATA_FIRMWARE_CHANGED &&
|
|
|
|
(CONFIG(VBOOT_MOCK_SECDATA) || tlcl_lib_init() == VB2_SUCCESS)) {
|
|
|
|
printk(BIOS_INFO, "Saving secdata firmware\n");
|
|
|
|
antirollback_write_space_firmware(ctx);
|
|
|
|
ctx->flags &= ~VB2_CONTEXT_SECDATA_FIRMWARE_CHANGED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->flags & VB2_CONTEXT_SECDATA_KERNEL_CHANGED &&
|
|
|
|
(CONFIG(VBOOT_MOCK_SECDATA) || tlcl_lib_init() == VB2_SUCCESS)) {
|
|
|
|
printk(BIOS_INFO, "Saving secdata kernel\n");
|
|
|
|
antirollback_write_space_kernel(ctx);
|
|
|
|
ctx->flags &= ~VB2_CONTEXT_SECDATA_KERNEL_CHANGED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->flags & VB2_CONTEXT_NVDATA_CHANGED) {
|
|
|
|
printk(BIOS_INFO, "Saving nvdata\n");
|
|
|
|
save_vbnv(ctx->nvdata);
|
|
|
|
ctx->flags &= ~VB2_CONTEXT_NVDATA_CHANGED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 03:15:44 +02:00
|
|
|
/* Check if it is okay to enable USB Device Controller (UDC). */
|
|
|
|
int vboot_can_enable_udc(void)
|
|
|
|
{
|
2020-01-14 16:18:27 +01:00
|
|
|
/* Allow UDC in all vboot modes. */
|
|
|
|
if (!CONFIG(CHROMEOS) && CONFIG(VBOOT_ALWAYS_ALLOW_UDC))
|
|
|
|
return 1;
|
|
|
|
|
2018-04-26 03:15:44 +02:00
|
|
|
/* Always disable if not in developer mode */
|
|
|
|
if (!vboot_developer_mode_enabled())
|
|
|
|
return 0;
|
|
|
|
/* Enable if GBB flag is set */
|
2019-11-27 02:58:11 +01:00
|
|
|
if (vboot_is_gbb_flag_set(VB2_GBB_FLAG_ENABLE_UDC))
|
2018-04-26 03:15:44 +02:00
|
|
|
return 1;
|
|
|
|
/* Enable if VBNV flag is set */
|
|
|
|
if (vbnv_udc_enable_flag())
|
|
|
|
return 1;
|
|
|
|
/* Otherwise disable */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-22 15:59:40 +02:00
|
|
|
/* ============================ VBOOT REBOOT ============================== */
|
2018-04-21 22:45:32 +02:00
|
|
|
void __weak vboot_platform_prepare_reboot(void)
|
2016-01-22 23:33:57 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-04-11 02:50:11 +02:00
|
|
|
void vboot_reboot(void)
|
|
|
|
{
|
2019-03-06 01:53:33 +01:00
|
|
|
if (CONFIG(CONSOLE_CBMEM_DUMP_TO_UART))
|
2022-01-11 20:44:38 +01:00
|
|
|
cbmem_dump_console_to_uart();
|
2016-01-22 23:33:57 +01:00
|
|
|
vboot_platform_prepare_reboot();
|
2018-10-05 23:40:21 +02:00
|
|
|
board_reset();
|
2015-04-11 02:50:11 +02:00
|
|
|
}
|