]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
rasdaemon: Add support to parse microcode field of mce tracepoint
authorAvadhut Naik <avadhut.naik@amd.com>
Tue, 2 Apr 2024 05:07:38 +0000 (00:07 -0500)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 11 Jun 2024 09:48:07 +0000 (11:48 +0200)
Support for exporting the Microcode Revision is being added to the
mce_record tracepoint.

Add the required, corresponding support in the rasdaemon for the field
to be parsed and logged or added to the database and viewed later through
ras-mc-ctl utility.

Signed-off-by: Avadhut Naik <avadhut.naik@amd.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
ras-mce-handler.c
ras-mce-handler.h
ras-record.c
util/ras-mc-ctl.in

index c9e8687e4595e6bb44ba9fe2f89bb2966756ec02..0f0913244e03b0b6058e0ff05b25050342251ffb 100644 (file)
@@ -375,6 +375,9 @@ static void report_mce_event(struct ras_events *ras,
        if (e->ppin)
                trace_seq_printf(s, ", ppin= %llx", (long long)e->ppin);
 
+       if (e->microcode)
+               trace_seq_printf(s, ", microcode= %x", e->microcode);
+
        if (!e->vdata_len)
                return;
 
@@ -573,6 +576,10 @@ int ras_mce_event_handler(struct trace_seq *s,
        if (!tep_get_field_val(s, event, "ppin", record, &val, 1))
                e.ppin = val;
 
+       /* Get Microcode Revision */
+       if (!tep_get_field_val(s, event, "microcode", record, &val, 1))
+               e.microcode = val;
+
        /* Get Vendor-specfic Data, if any */
        e.vdata = tep_get_field_raw(s, event, "v_data", record, &e.vdata_len, 1);
 
index f3003d2e01802d4a73d596adc237c1f4b339f1b3..b8ae3892b069f4e1437854889e0f98526cb106f3 100644 (file)
@@ -76,6 +76,7 @@ struct mce_event {
        uint64_t        synd;   /* MCA_SYND MSR: only valid on SMCA systems */
        uint64_t        ipid;   /* MCA_IPID MSR: only valid on SMCA systems */
        uint64_t        ppin;
+       uint32_t        microcode;
        int32_t         vdata_len;
        const uint64_t  *vdata;
 
index 327d6baa8501bc76c20b2096e36ae1d8299d417e..56c25cbede62f1be2ff0a983a86f51a35fb93c07 100644 (file)
@@ -338,11 +338,12 @@ static const struct db_fields mce_record_fields[] = {
                { .name = "cs",                 .type = "INTEGER" }, // 15
                { .name = "bank",                       .type = "INTEGER" },
                { .name = "cpuvendor",          .type = "INTEGER" },
+               { .name = "microcode",      .type = "INTEGER" },
 
                /* Parsed data - will likely change */
                { .name = "bank_name",          .type = "TEXT" },
-               { .name = "error_msg",          .type = "TEXT" },
-               { .name = "mcgstatus_msg",      .type = "TEXT" },// 20
+               { .name = "error_msg",          .type = "TEXT" }, // 20
+               { .name = "mcgstatus_msg",      .type = "TEXT" },
                { .name = "mcistatus_msg",      .type = "TEXT" },
                { .name = "mcastatus_msg",      .type = "TEXT" },
                { .name = "user_action",                .type = "TEXT" },
@@ -381,14 +382,15 @@ int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev)
        sqlite3_bind_int   (priv->stmt_mce_record, 15, ev->cs);
        sqlite3_bind_int   (priv->stmt_mce_record, 16, ev->bank);
        sqlite3_bind_int   (priv->stmt_mce_record, 17, ev->cpuvendor);
-
-       sqlite3_bind_text(priv->stmt_mce_record, 18, ev->bank_name, -1, NULL);
-       sqlite3_bind_text(priv->stmt_mce_record, 19, ev->error_msg, -1, NULL);
-       sqlite3_bind_text(priv->stmt_mce_record, 20, ev->mcgstatus_msg, -1, NULL);
-       sqlite3_bind_text(priv->stmt_mce_record, 21, ev->mcistatus_msg, -1, NULL);
-       sqlite3_bind_text(priv->stmt_mce_record, 22, ev->mcastatus_msg, -1, NULL);
-       sqlite3_bind_text(priv->stmt_mce_record, 23, ev->user_action, -1, NULL);
-       sqlite3_bind_text(priv->stmt_mce_record, 24, ev->mc_location, -1, NULL);
+       sqlite3_bind_int   (priv->stmt_mce_record, 18, ev->microcode);
+
+       sqlite3_bind_text(priv->stmt_mce_record, 19, ev->bank_name, -1, NULL);
+       sqlite3_bind_text(priv->stmt_mce_record, 20, ev->error_msg, -1, NULL);
+       sqlite3_bind_text(priv->stmt_mce_record, 21, ev->mcgstatus_msg, -1, NULL);
+       sqlite3_bind_text(priv->stmt_mce_record, 22, ev->mcistatus_msg, -1, NULL);
+       sqlite3_bind_text(priv->stmt_mce_record, 23, ev->mcastatus_msg, -1, NULL);
+       sqlite3_bind_text(priv->stmt_mce_record, 24, ev->user_action, -1, NULL);
+       sqlite3_bind_text(priv->stmt_mce_record, 25, ev->mc_location, -1, NULL);
 
        rc = sqlite3_step(priv->stmt_mce_record);
        if (rc != SQLITE_OK && rc != SQLITE_DONE)
index fdbcd625c6cd2abe660d06de68b5b037b657eb35..f9328b241f221e8efe8a25f57acd875f75bf7078 100755 (executable)
@@ -1743,7 +1743,7 @@ sub errors
 {
     require DBI;
     my ($query, $query_handle, $id, $time, $devname, $count, $type, $msg, $label, $mc, $top, $mid, $low, $addr, $grain, $syndrome, $detail, $out);
-    my ($mcgcap,$mcgstatus, $status, $misc, $ip, $tsc, $walltime, $ppin, $cpu, $cpuid, $apicid, $socketid, $cs, $bank, $cpuvendor, $bank_name, $mcgstatus_msg, $mcistatus_msg, $mcastatus_msg, $user_action, $mc_location);
+    my ($mcgcap,$mcgstatus, $status, $misc, $ip, $tsc, $walltime, $ppin, $cpu, $cpuid, $apicid, $socketid, $cs, $bank, $cpuvendor, $microcode, $bank_name, $mcgstatus_msg, $mcistatus_msg, $mcastatus_msg, $user_action, $mc_location);
     my ($timestamp, $etype, $severity, $etype_string, $severity_string, $fru_id, $fru_text, $cper_data);
     my ($bus_name, $dev_name, $driver_name, $reporter_name);
     my ($dev, $sector, $nr_sector, $error, $rwbs, $cmd);
@@ -2192,10 +2192,10 @@ sub errors
 
     # MCE mce_record errors
     if ($has_mce == 1) {
-        $query = "select id, timestamp, mcgcap, mcgstatus, status, addr, misc, ip, tsc, walltime, ppin, cpu, cpuid, apicid, socketid, cs, bank, cpuvendor, bank_name, error_msg, mcgstatus_msg, mcistatus_msg, mcastatus_msg, user_action, mc_location from mce_record$conf{opt}{since} order by id";
+        $query = "select id, timestamp, mcgcap, mcgstatus, status, addr, misc, ip, tsc, walltime, ppin, cpu, cpuid, apicid, socketid, cs, bank, cpuvendor, microcode, bank_name, error_msg, mcgstatus_msg, mcistatus_msg, mcastatus_msg, user_action, mc_location from mce_record$conf{opt}{since} order by id";
         $query_handle = $dbh->prepare($query);
         $query_handle->execute();
-        $query_handle->bind_columns(\($id, $time, $mcgcap,$mcgstatus, $status, $addr, $misc, $ip, $tsc, $walltime, $ppin, $cpu, $cpuid, $apicid, $socketid, $cs, $bank, $cpuvendor, $bank_name, $msg, $mcgstatus_msg, $mcistatus_msg, $mcastatus_msg, $user_action, $mc_location));
+        $query_handle->bind_columns(\($id, $time, $mcgcap,$mcgstatus, $status, $addr, $misc, $ip, $tsc, $walltime, $ppin, $cpu, $cpuid, $apicid, $socketid, $cs, $bank, $cpuvendor, $microcode, $bank_name, $msg, $mcgstatus_msg, $mcistatus_msg, $mcastatus_msg, $user_action, $mc_location));
         $out = "";
         while($query_handle->fetch()) {
             $out .= "$id $time error: $msg";
@@ -2221,6 +2221,7 @@ sub errors
            $out .= sprintf ", socketid=0x%08x", $socketid if ($socketid);
            $out .= sprintf ", cs=0x%08x", $cs if ($cs);
            $out .= sprintf ", bank=0x%08x", $bank if ($bank);
+               $out .= sprintf ", microcode=0x%08x", $microcode if ($microcode);
 
            $out .= "\n";
         }