From 78c483d9c9303354a2ff4b15f4939951fd8a6eff Mon Sep 17 00:00:00 2001 From: Brian Granaghan Date: Fri, 17 Feb 2023 23:28:55 +0000 Subject: gsctool: Add command to get console logs. Add '-l' command to fetch GSC console logs and print them to stdsout. BUG=b:268396021 TEST=localhost ~ # gsctool -aDl Valid CCD config found CCD_MODE: deasserted AP RO verification result: setting unprovisioned PLT_RST_L DEASSERTED WARNING: with `AllowUnverifiedRo` disabled EC will be kept in reset in future Ti50 versions Unverified AP RO allowed ERROR: failed to retrieve key ladder state, setting to dev libtpm initialized Deferring NV write. Deferring NV write. Servo: debouncing -> disconnected Starting erase Change-Id: I59db7ebba0517d89900f31451b0d919712d2c564 Signed-off-by: Brian Granaghan Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4266190 Reviewed-by: Mary Ruthven --- extra/usb_updater/gsctool.c | 39 +++++++++++++++++++++++++++++++++++---- include/tpm_vendor_cmds.h | 1 + 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index b7fc2c02e2..bfe02915fb 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -478,6 +478,9 @@ static const struct option_container cmd_line_options[] = { {{"flog", optional_argument, NULL, 'L'}, "[prev entry]%Retrieve contents of the flash log" " (newer than if specified)"}, + {{"console", no_argument, NULL, 'l'}, + "Get console logs. This may need to be run multiple times to collect " + "all available logs."}, {{"machine", no_argument, NULL, 'M'}, "Output in a machine-friendly way. " "Effective with -b, -f, -i, and -O."}, @@ -523,7 +526,7 @@ static const struct option_container cmd_line_options[] = { "[id]%Retrieve contents of the crash log with id "}, {{"reboot", optional_argument, NULL, 'z'}, "Tell the GSC to reboot with an optional reset timeout parameter " - "in milliseconds"} + "in milliseconds"}, }; /* Helper to print debug messages when verbose flag is specified. */ @@ -3926,6 +3929,25 @@ static int get_crashlog(struct transfer_descriptor *td, uint32_t id) return 0; } +static int get_console_logs(struct transfer_descriptor *td) +{ + uint32_t rv; + uint8_t response[2048] = {0}; + size_t response_size = sizeof(response); + + rv = send_vendor_command(td, VENDOR_CC_GET_CONSOLE_LOGS, NULL, + 0, response, &response_size); + if (rv != VENDOR_RC_SUCCESS) { + printf("Get console logs failed. (%X)\n", rv); + return 1; + } + + printf("%s", response); + printf("\n"); + return 0; +} + + int main(int argc, char *argv[]) { struct transfer_descriptor td; @@ -3989,6 +4011,7 @@ int main(int argc, char *argv[]) size_t reboot_gsc_timeout = 0; int get_clog = 0; uint32_t clog_id = 0; + int get_console = 0; /* * All options which result in setting a Boolean flag to True, along @@ -4141,6 +4164,9 @@ int main(int argc, char *argv[]) if (optarg) prev_log_entry = strtoul(optarg, NULL, 0); break; + case 'l': + get_console = 1; + break; case 'M': show_machine_output = true; break; @@ -4276,6 +4302,7 @@ int main(int argc, char *argv[]) !get_apro_boot_status && !get_boot_mode && !get_clog && + !get_console && !get_flog && !get_endorsement_seed && !factory_mode && @@ -4330,11 +4357,12 @@ int main(int argc, char *argv[]) !!ccd_unlock + !!ccd_lock + !!ccd_info + !!get_flog + !!get_boot_mode + !!openbox_desc_file + !!factory_mode + (wp != WP_NONE) + !!get_endorsement_seed + - !!erase_ap_ro_hash + !!set_capability + !!get_clog) > 1) { + !!erase_ap_ro_hash + !!set_capability + !!get_clog + + !!get_console) > 1) { fprintf(stderr, "ERROR: options " - "-e, -F, -g, -H, -I, -i, -k, -L, -O, -o, -P, -r, -U, -x" - " and -w are mutually exclusive\n"); + "-e, -F, -g, -H, -I, -i, -k, -L, -l, -O, -o, -P, -r," + "-U, -x and -w are mutually exclusive\n"); exit(update_error); } @@ -4433,6 +4461,9 @@ int main(int argc, char *argv[]) if (get_clog) exit(get_crashlog(&td, clog_id)); + if (get_console) + exit(get_console_logs(&td)); + if (data || show_fw_ver) { setup_connection(&td); diff --git a/include/tpm_vendor_cmds.h b/include/tpm_vendor_cmds.h index 9815f297d6..0eab55da7b 100644 --- a/include/tpm_vendor_cmds.h +++ b/include/tpm_vendor_cmds.h @@ -196,6 +196,7 @@ enum vendor_cmd_cc { VENDOR_CC_SET_CAPABILITY = 64, VENDOR_CC_GET_TI50_STATS = 65, VENDOR_CC_GET_CRASHLOG = 66, + VENDOR_CC_GET_CONSOLE_LOGS = 67, LAST_VENDOR_COMMAND = 65535, }; -- cgit v1.2.1