From 57640072aead2e00037749d66f05fc26e3fe3071 Mon Sep 17 00:00:00 2001 From: Lostwayzxc Date: Tue, 25 May 2021 20:07:26 +0800 Subject: [PATCH 2/2] add trace print of new information and add it to sqilte Since we add new information of the event, we add trace print and store it to Sqlite. Signed-off-by: Luo Shengwei --- ras-arm-handler.c | 10 ++++++++++ ras-record.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/ras-arm-handler.c b/ras-arm-handler.c index 10d0099..23ad470 100644 --- a/ras-arm-handler.c +++ b/ras-arm-handler.c @@ -23,6 +23,13 @@ #include "ras-cpu-isolation.h" #ifdef HAVE_CPU_FAULT_ISOLATION +static void trace_print_hex(struct trace_seq *s, const uint8_t *buf, int buf_len) +{ + for (int i = 0; i < buf_len; ++i) { + trace_seq_printf(s, "%2.2x", buf[i]); + } +} + static int is_core_failure(unsigned long value) { /* @@ -135,6 +142,7 @@ int ras_arm_event_handler(struct trace_seq *s, case GHES_SEV_PANIC: ev.severity = "Fatal"; } + trace_seq_printf(s, "\n severity: %s", ev.severity); if (val == GHES_SEV_CORRECTED || val == GHES_SEV_RECOVERABLE) { int len, nums; @@ -142,6 +150,8 @@ int ras_arm_event_handler(struct trace_seq *s, if (!ev.error_info) return -1; ev.length = len; + trace_seq_printf(s, "\n processor_err_info: "); + trace_print_hex(s, ev.error_info, len); /* relate to enum error_type */ nums = count_errors(event, ev.error_info, len); if (nums > 0) { diff --git a/ras-record.c b/ras-record.c index 549c494..33d4741 100644 --- a/ras-record.c +++ b/ras-record.c @@ -210,6 +210,10 @@ static const struct db_fields arm_event_fields[] = { { .name="mpidr", .type="INTEGER" }, { .name="running_state", .type="INTEGER" }, { .name="psci_state", .type="INTEGER" }, +#ifdef HAVE_CPU_FAULT_ISOLATION + { .name="severity", .type="TEXT" }, + { .name="error_info", .type="BLOB" }, +#endif }; static const struct db_table_descriptor arm_event_tab = { @@ -233,6 +237,10 @@ int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev) sqlite3_bind_int64 (priv->stmt_arm_record, 4, ev->mpidr); sqlite3_bind_int (priv->stmt_arm_record, 5, ev->running_state); sqlite3_bind_int (priv->stmt_arm_record, 6, ev->psci_state); +#ifdef HAVE_CPU_FAULT_ISOLATION + sqlite3_bind_text (priv->stmt_arm_record, 7, ev->severity, -1, NULL); + sqlite3_bind_blob (priv->stmt_arm_record, 8, ev->error_info, ev->length, NULL); +#endif rc = sqlite3_step(priv->stmt_arm_record); if (rc != SQLITE_OK && rc != SQLITE_DONE) -- 2.27.0