diff options
author | Subrata Banik <subratabanik@google.com> | 2022-07-04 07:33:49 +0000 |
---|---|---|
committer | Subrata Banik <subratabanik@google.com> | 2022-08-02 07:06:30 +0000 |
commit | 2d20b68b6e0bb2ca8c9072261c77beb33762f9c0 (patch) | |
tree | 5bab164318fb157ca05ab42da547f13fcd2326a5 /src | |
parent | 8c2cef02ac9d10b596db5f3fe7c9660973fec125 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/commonlib/bsd/include/commonlib/bsd/elog.h | 5 | ||||
-rw-r--r-- | src/vendorcode/google/chromeos/elog.c | 29 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/commonlib/bsd/include/commonlib/bsd/elog.h b/src/commonlib/bsd/include/commonlib/bsd/elog.h index 44f1051957..63761ebf53 100644 --- a/src/commonlib/bsd/include/commonlib/bsd/elog.h +++ b/src/commonlib/bsd/include/commonlib/bsd/elog.h @@ -314,6 +314,11 @@ struct elog_event_extended_event { uint32_t event_complement; } __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 */ #define ELOG_MAX_EVENT_SIZE 0x7F diff --git a/src/vendorcode/google/chromeos/elog.c b/src/vendorcode/google/chromeos/elog.c index b7f7c8d8fc..d8304f8b30 100644 --- a/src/vendorcode/google/chromeos/elog.c +++ b/src/vendorcode/google/chromeos/elog.c @@ -6,8 +6,9 @@ #include <elog.h> #include <security/vboot/misc.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 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); |