vc/google/elog: Record vboot FW boot information into elog

This patch calls into vboot API (vb2api_get_fw_boot_info) to retrieve
FW slot boot information like (tries count, current boot slot, previous
boot slot, previous boot status and boot mode).

Upon retrieval of the vboot information, elog callback from ramstage
records the info into the eventlog.

Additionally, this patch refactors the existing event logging mechanism
to add newer APIs to record vboot firmware boot related information.

BUG=b:215615970
TEST=Build and boot google/kano to ChromeOS and run below command to
check the cbmem log:
Scenario 1:
localhost ~ # cbmem -c | grep VB2
[INFO ]  VB2:vb2_check_recovery() Recovery reason from previous boot:
         0x0 / 0x0
[INFO ]  VB2:vb2api_fill_boot_config() boot_mode=`Developer boot`
         VB2:vb2api_get_fw_boot_info() fw_tried=`A` fw_try_count=0
            fw_prev_tried=`A` fw_prev_result=`Success`.
....

Scenario 2:
localhost ~ # crossystem recovery_request=1
localhost ~ # cbmem -c | grep VB2
[INFO ]  VB2:vb2api_fill_boot_config() boot_mode=`Manual recovery boot`
         VB2:vb2api_fill_boot_config() recovery_reason=0x13 / 0x00
         VB2:vb2api_get_fw_boot_info() fw_tried=`A` fw_try_count=0
            fw_prev_tried=`A` fw_prev_result=`Unknown`.

Signed-off-by: Subrata Banik <subratabanik@google.com>
Change-Id: I6882cd1c4dbe5e24f6460388cd1af4e4a05fc4da
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65561
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Subrata Banik 2022-07-04 07:33:49 +00:00
parent 8c2cef02ac
commit 2d20b68b6e
2 changed files with 32 additions and 2 deletions

View File

@ -314,6 +314,11 @@ struct elog_event_extended_event {
uint32_t event_complement; uint32_t event_complement;
} __packed; } __packed;
/*
* Firmware boot related information retrieved from vboot and store as
* per `union vb2_fw_boot_info` data structure.
*/
#define ELOG_TYPE_FW_VBOOT_INFO 0xb7
/* Only the 7-LSB are used for size */ /* Only the 7-LSB are used for size */
#define ELOG_MAX_EVENT_SIZE 0x7F #define ELOG_MAX_EVENT_SIZE 0x7F

View File

@ -6,8 +6,9 @@
#include <elog.h> #include <elog.h>
#include <security/vboot/misc.h> #include <security/vboot/misc.h>
#include <security/vboot/vboot_common.h> #include <security/vboot/vboot_common.h>
#include <vb2_api.h>
static void elog_add_boot_reason(void *unused) static void elog_add_boot_reason(void)
{ {
const int rec = vboot_recovery_mode_enabled(); const int rec = vboot_recovery_mode_enabled();
const int dev = vboot_developer_mode_enabled(); const int dev = vboot_developer_mode_enabled();
@ -33,4 +34,28 @@ static void elog_add_boot_reason(void *unused)
} }
} }
BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, elog_add_boot_reason, NULL); static void elog_add_vboot_info(void)
{
/* Skip logging boot info in ACPI resume path */
if (acpi_is_wakeup_s3())
return;
struct vb2_context *ctx = vboot_get_context();
union vb2_fw_boot_info data = vb2api_get_fw_boot_info(ctx);
uint8_t width = offsetof(union vb2_fw_boot_info, recovery_reason);
if (vboot_recovery_mode_enabled())
width = sizeof(union vb2_fw_boot_info);
elog_add_event_raw(ELOG_TYPE_FW_VBOOT_INFO, &data, width);
}
static void elog_add_boot_records(void *unused)
{
/* Log boot reason into the eventlog */
elog_add_boot_reason();
/* Log fw vboot info into the eventlog */
elog_add_vboot_info();
}
BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, elog_add_boot_records, NULL);