krishnanadh / rpms / rasdaemon

Forked from rpms/rasdaemon a year ago
Clone

Blame SOURCES/0037-rasdaemon-sqlite-truncates-some-MCE-fields-to-32-bit.patch

ac32bf
commit 52e60e3050105a55e1ff2382979d5f370f398200
ac32bf
Author: Luck, Tony <tony.luck@intel.com>
ac32bf
Date:   Mon Apr 7 11:27:47 2014 -0700
ac32bf
ac32bf
    rasdaemon: sqlite truncates some MCE fields to 32-bit
ac32bf
    
ac32bf
    The sqlite3_bind_int() function takes an "int" as the argument value to
ac32bf
    save to the database. But some fields are wider than 32-bits.  Use
ac32bf
    sqlite3_bind_int64() for the fields where we know values can exceed
ac32bf
    4G.
ac32bf
    
ac32bf
    Before:
ac32bf
    
ac32bf
    # ./rasdaemon/util/ras-mc-ctl --errors
ac32bf
     ...
ac32bf
    MCE events:
ac32bf
    1 2014-04-04 08:50:32 -0700 error: MEMORY CONTROLLER RD_CHANNEL0_ERR Transaction: Memory read error, mcg mcgstatus= 0, mci Corrected_error, mcgcap=0x07000c16, status=0x00010090, addr=0x35fcb9c0, misc=0x5026a686, walltime=0x5342e4f9, cpu=0x0000000e, cpuid=0x000306f1, apicid=0x00000020, socketid=0x00000001, bank=0x00000008
ac32bf
    2 2014-04-04 08:50:35 -0700 error: MEMORY CONTROLLER RD_CHANNEL0_ERR Transaction: Memory read error, mcg mcgstatus= 0, mci Corrected_error, mcgcap=0x07000c16, status=0x00010090, addr=0x4187adc0, misc=0x4274f486, walltime=0x5342e4fc, cpu=0x0000000e, cpuid=0x000306f1, apicid=0x00000020, socketid=0x00000001, bank=0x00000007
ac32bf
    3 2014-04-04 08:50:37 -0700 error: MEMORY CONTROLLER RD_CHANNEL0_ERR Transaction: Memory read error, mcg mcgstatus= 0, mci Corrected_error, mcgcap=0x07000c16, status=0x00010090, addr=0x52efc600, misc=0x50028286, walltime=0x5342e4fd, cpu=0x0000000e, cpuid=0x000306f1, apicid=0x00000020, socketid=0x00000001, bank=0x00000008
ac32bf
    
ac32bf
    After:
ac32bf
    ./rasdaemon/util/ras-mc-ctl --errors
ac32bf
     ...
ac32bf
    1 2014-04-04 09:00:07 -0700 error: MEMORY CONTROLLER RD_CHANNEL0_ERR Transaction: Memory read error, mcg mcgstatus= 0, mci Corrected_error, mcgcap=0x07000c16, status=0x8c00004000010090, addr=0x45340a180, misc=0x140686886, walltime=0x5342e736, cpuid=0x000306f1, bank=0x00000008
ac32bf
    2 2014-04-04 09:00:08 -0700 error: MEMORY CONTROLLER RD_CHANNEL0_ERR Transaction: Memory read error, mcg mcgstatus= 0, mci Corrected_error, mcgcap=0x07000c16, status=0x8c00004000010090, addr=0x44d6e4780, misc=0x15060e086, walltime=0x5342e737, cpuid=0x000306f1, bank=0x00000007
ac32bf
    3 2014-04-04 09:00:10 -0700 error: MEMORY CONTROLLER RD_CHANNEL0_ERR Transaction: Memory read error, mcg mcgstatus= 0, mci Corrected_error, mcgcap=0x07000c16, status=0x8c00004000010090, addr=0x44cb64640, misc=0x140505086, walltime=0x5342e739, cpuid=0x000306f1, bank=0x00000008
ac32bf
    
ac32bf
    Signed-off-by: Tony Luck <tony.luck@intel.com>
ac32bf
    Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
ac32bf
ac32bf
diff --git a/ras-record.c b/ras-record.c
ac32bf
index e602edb..e5150ad 100644
ac32bf
--- a/ras-record.c
ac32bf
+++ b/ras-record.c
ac32bf
@@ -209,22 +209,22 @@ int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev)
ac32bf
 		return 0;
ac32bf
 	log(TERM, LOG_INFO, "mce_record store: %p\n", priv->stmt_mce_record);
ac32bf
 
ac32bf
-	sqlite3_bind_text(priv->stmt_mce_record,  1, ev->timestamp, -1, NULL);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record,  2, ev->mcgcap);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record,  3, ev->mcgstatus);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record,  4, ev->status);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record,  5, ev->addr);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record,  6, ev->misc);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record,  7, ev->ip);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record,  8, ev->tsc);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record,  9, ev->walltime);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record, 10, ev->cpu);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record, 11, ev->cpuid);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record, 12, ev->apicid);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record, 13, ev->socketid);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record, 14, ev->cs);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record, 15, ev->bank);
ac32bf
-	sqlite3_bind_int (priv->stmt_mce_record, 16, ev->cpuvendor);
ac32bf
+	sqlite3_bind_text  (priv->stmt_mce_record,  1, ev->timestamp, -1, NULL);
ac32bf
+	sqlite3_bind_int   (priv->stmt_mce_record,  2, ev->mcgcap);
ac32bf
+	sqlite3_bind_int   (priv->stmt_mce_record,  3, ev->mcgstatus);
ac32bf
+	sqlite3_bind_int64 (priv->stmt_mce_record,  4, ev->status);
ac32bf
+	sqlite3_bind_int64 (priv->stmt_mce_record,  5, ev->addr);
ac32bf
+	sqlite3_bind_int64 (priv->stmt_mce_record,  6, ev->misc);
ac32bf
+	sqlite3_bind_int64 (priv->stmt_mce_record,  7, ev->ip);
ac32bf
+	sqlite3_bind_int64 (priv->stmt_mce_record,  8, ev->tsc);
ac32bf
+	sqlite3_bind_int64 (priv->stmt_mce_record,  9, ev->walltime);
ac32bf
+	sqlite3_bind_int   (priv->stmt_mce_record, 10, ev->cpu);
ac32bf
+	sqlite3_bind_int   (priv->stmt_mce_record, 11, ev->cpuid);
ac32bf
+	sqlite3_bind_int   (priv->stmt_mce_record, 12, ev->apicid);
ac32bf
+	sqlite3_bind_int   (priv->stmt_mce_record, 13, ev->socketid);
ac32bf
+	sqlite3_bind_int   (priv->stmt_mce_record, 14, ev->cs);
ac32bf
+	sqlite3_bind_int   (priv->stmt_mce_record, 15, ev->bank);
ac32bf
+	sqlite3_bind_int   (priv->stmt_mce_record, 16, ev->cpuvendor);
ac32bf
 
ac32bf
 	sqlite3_bind_text(priv->stmt_mce_record, 17, ev->bank_name, -1, NULL);
ac32bf
 	sqlite3_bind_text(priv->stmt_mce_record, 18, ev->error_msg, -1, NULL);