Blame SOURCES/0067-rasdaemon-add-support-for-non-standard-CPER-section-.patch

b18917
From 624d8a1d99a2f3bd06cbc537aff3cc30201ba7c2 Mon Sep 17 00:00:00 2001
b18917
From: Tyler Baicar <tbaicar@codeaurora.org>
b18917
Date: Mon, 12 Jun 2017 16:16:04 -0600
b18917
Subject: [PATCH 1/2] rasdaemon: add support for non standard CPER section
b18917
 events
b18917
b18917
Add support to handle the non standard CPER section kernel trace
b18917
events which cover RAS errors who's section type is unknown.
b18917
b18917
Signed-off-by: Tyler Baicar <tbaicar@codeaurora.org>
b18917
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
b18917
---
b18917
 Makefile.am                |   3 +
b18917
 configure.ac               |   9 +++
b18917
 ras-events.c               |  15 +++++
b18917
 ras-events.h               |   8 +++
b18917
 ras-non-standard-handler.c | 147 +++++++++++++++++++++++++++++++++++++++++++++
b18917
 ras-non-standard-handler.h |  26 ++++++++
b18917
 ras-record.c               |  59 ++++++++++++++++++
b18917
 ras-record.h               |  15 +++++
b18917
 ras-report.c               |  80 ++++++++++++++++++++++++
b18917
 ras-report.h               |  18 +++++-
b18917
 10 files changed, 379 insertions(+), 1 deletion(-)
b18917
 create mode 100644 ras-non-standard-handler.c
b18917
 create mode 100644 ras-non-standard-handler.h
b18917
b18917
diff --git a/Makefile.am b/Makefile.am
b18917
index a10e4b3..c5811e8 100644
b18917
--- a/Makefile.am
b18917
+++ b/Makefile.am
b18917
@@ -24,6 +24,9 @@ endif
b18917
 if WITH_AER
b18917
    rasdaemon_SOURCES += ras-aer-handler.c
b18917
 endif
b18917
+if WITH_NON_STANDARD
b18917
+   rasdaemon_SOURCES += ras-non-standard-handler.c
b18917
+endif
b18917
 if WITH_MCE
b18917
    rasdaemon_SOURCES += ras-mce-handler.c mce-intel.c mce-amd-k8.c \
b18917
 			mce-intel-p4-p6.c mce-intel-nehalem.c \
b18917
diff --git a/configure.ac b/configure.ac
b18917
index 5af5227..31bf6bd 100644
b18917
--- a/configure.ac
b18917
+++ b/configure.ac
b18917
@@ -44,6 +44,15 @@ AS_IF([test "x$enable_aer" = "xyes"], [
b18917
 ])
b18917
 AM_CONDITIONAL([WITH_AER], [test x$enable_aer = xyes])
b18917
 
b18917
+AC_ARG_ENABLE([non_standard],
b18917
+    AS_HELP_STRING([--enable-non-standard], [enable NON_STANDARD events (currently experimental)]))
b18917
+
b18917
+AS_IF([test "x$enable_non_standard" = "xyes"], [
b18917
+  AC_DEFINE(HAVE_NON_STANDARD,1,"have UNKNOWN_SEC events collect")
b18917
+  AC_SUBST([WITH_NON_STANDARD])
b18917
+])
b18917
+AM_CONDITIONAL([WITH_NON_STANDARD], [test x$enable_non_standard = xyes])
b18917
+
b18917
 AC_ARG_ENABLE([mce],
b18917
     AS_HELP_STRING([--enable-mce], [enable MCE events (currently experimental)]))
b18917
 
b18917
diff --git a/ras-events.c b/ras-events.c
b18917
index 0be7c3f..96aa6f1 100644
b18917
--- a/ras-events.c
b18917
+++ b/ras-events.c
b18917
@@ -29,6 +29,7 @@
b18917
 #include "libtrace/event-parse.h"
b18917
 #include "ras-mc-handler.h"
b18917
 #include "ras-aer-handler.h"
b18917
+#include "ras-non-standard-handler.h"
b18917
 #include "ras-mce-handler.h"
b18917
 #include "ras-extlog-handler.h"
b18917
 #include "ras-record.h"
b18917
@@ -208,6 +209,10 @@ int toggle_ras_mc_event(int enable)
b18917
 	rc |= __toggle_ras_mc_event(ras, "ras", "extlog_mem_event", enable);
b18917
 #endif
b18917
 
b18917
+#ifdef HAVE_NON_STANDARD
b18917
+	rc |= __toggle_ras_mc_event(ras, "ras", "non_standard_event", enable);
b18917
+#endif
b18917
+
b18917
 free_ras:
b18917
 	free(ras);
b18917
 	return rc;
b18917
@@ -676,6 +681,16 @@ int handle_ras_events(int record_events)
b18917
 		    "ras", "aer_event");
b18917
 #endif
b18917
 
b18917
+#ifdef HAVE_NON_STANDARD
b18917
+        rc = add_event_handler(ras, pevent, page_size, "ras", "non_standard_event",
b18917
+                               ras_non_standard_event_handler);
b18917
+        if (!rc)
b18917
+                num_events++;
b18917
+        else
b18917
+                log(ALL, LOG_ERR, "Can't get traces from %s:%s\n",
b18917
+                    "ras", "non_standard_event");
b18917
+#endif
b18917
+
b18917
 	cpus = get_num_cpus(ras);
b18917
 
b18917
 #ifdef HAVE_MCE
b18917
diff --git a/ras-events.h b/ras-events.h
b18917
index 64e045a..3e1008f 100644
b18917
--- a/ras-events.h
b18917
+++ b/ras-events.h
b18917
@@ -68,6 +68,14 @@ enum hw_event_mc_err_type {
b18917
 	HW_EVENT_ERR_INFO,
b18917
 };
b18917
 
b18917
+/* Should match the code at Kernel's include/acpi/ghes.h */
b18917
+enum ghes_severity {
b18917
+	GHES_SEV_NO,
b18917
+	GHES_SEV_CORRECTED,
b18917
+	GHES_SEV_RECOVERABLE,
b18917
+	GHES_SEV_PANIC,
b18917
+};
b18917
+
b18917
 /* Function prototypes */
b18917
 int toggle_ras_mc_event(int enable);
b18917
 int handle_ras_events(int record_events);
b18917
diff --git a/ras-non-standard-handler.c b/ras-non-standard-handler.c
b18917
new file mode 100644
b18917
index 0000000..4c154e5
b18917
--- /dev/null
b18917
+++ b/ras-non-standard-handler.c
b18917
@@ -0,0 +1,147 @@
b18917
+/*
b18917
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
b18917
+ *
b18917
+ * This program is free software; you can redistribute it and/or modify
b18917
+ * it under the terms of the GNU General Public License version 2 and
b18917
+ * only version 2 as published by the Free Software Foundation.
b18917
+
b18917
+ * This program is distributed in the hope that it will be useful,
b18917
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
b18917
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b18917
+ * GNU General Public License for more details.
b18917
+ */
b18917
+
b18917
+#include <stdio.h>
b18917
+#include <stdlib.h>
b18917
+#include <string.h>
b18917
+#include <unistd.h>
b18917
+#include "libtrace/kbuffer.h"
b18917
+#include "ras-non-standard-handler.h"
b18917
+#include "ras-record.h"
b18917
+#include "ras-logger.h"
b18917
+#include "ras-report.h"
b18917
+
b18917
+void print_le_hex(struct trace_seq *s, const uint8_t *buf, int index) {
b18917
+	trace_seq_printf(s, "%02x%02x%02x%02x", buf[index+3], buf[index+2], buf[index+1], buf[index]);
b18917
+}
b18917
+
b18917
+static char *uuid_le(const char *uu)
b18917
+{
b18917
+	static char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
b18917
+	char *p = uuid;
b18917
+	int i;
b18917
+	static const unsigned char le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
b18917
+
b18917
+	for (i = 0; i < 16; i++) {
b18917
+		p += sprintf(p, "%.2x", uu[le[i]]);
b18917
+		switch (i) {
b18917
+		case 3:
b18917
+		case 5:
b18917
+		case 7:
b18917
+		case 9:
b18917
+			*p++ = '-';
b18917
+			break;
b18917
+		}
b18917
+	}
b18917
+
b18917
+	*p = 0;
b18917
+
b18917
+	return uuid;
b18917
+}
b18917
+
b18917
+int ras_non_standard_event_handler(struct trace_seq *s,
b18917
+			 struct pevent_record *record,
b18917
+			 struct event_format *event, void *context)
b18917
+{
b18917
+	int len, i, line_count;
b18917
+	unsigned long long val;
b18917
+	struct ras_events *ras = context;
b18917
+	time_t now;
b18917
+	struct tm *tm;
b18917
+	struct ras_non_standard_event ev;
b18917
+
b18917
+	/*
b18917
+	 * Newer kernels (3.10-rc1 or upper) provide an uptime clock.
b18917
+	 * On previous kernels, the way to properly generate an event would
b18917
+	 * be to inject a fake one, measure its timestamp and diff it against
b18917
+	 * gettimeofday. We won't do it here. Instead, let's use uptime,
b18917
+	 * falling-back to the event report's time, if "uptime" clock is
b18917
+	 * not available (legacy kernels).
b18917
+	 */
b18917
+
b18917
+	if (ras->use_uptime)
b18917
+		now = record->ts/user_hz + ras->uptime_diff;
b18917
+	else
b18917
+		now = time(NULL);
b18917
+
b18917
+	tm = localtime(&now;;
b18917
+	if (tm)
b18917
+		strftime(ev.timestamp, sizeof(ev.timestamp),
b18917
+			 "%Y-%m-%d %H:%M:%S %z", tm);
b18917
+	trace_seq_printf(s, "%s ", ev.timestamp);
b18917
+
b18917
+	if (pevent_get_field_val(s, event, "sev", record, &val, 1) < 0)
b18917
+		return -1;
b18917
+	switch (val) {
b18917
+	case GHES_SEV_NO:
b18917
+		ev.severity = "Informational";
b18917
+		break;
b18917
+	case GHES_SEV_CORRECTED:
b18917
+		ev.severity = "Corrected";
b18917
+		break;
b18917
+	case GHES_SEV_RECOVERABLE:
b18917
+		ev.severity = "Recoverable";
b18917
+		break;
b18917
+	default:
b18917
+	case GHES_SEV_PANIC:
b18917
+		ev.severity = "Fatal";
b18917
+	}
b18917
+	trace_seq_printf(s, "\n %s", ev.severity);
b18917
+
b18917
+	ev.sec_type = pevent_get_field_raw(s, event, "sec_type", record, &len, 1);
b18917
+	if(!ev.sec_type)
b18917
+		return -1;
b18917
+	trace_seq_printf(s, "\n section type: %s", uuid_le(ev.sec_type));
b18917
+	ev.fru_text = pevent_get_field_raw(s, event, "fru_text",
b18917
+						record, &len, 1);
b18917
+	ev.fru_id = pevent_get_field_raw(s, event, "fru_id",
b18917
+						record, &len, 1);
b18917
+	trace_seq_printf(s, " fru text: %s fru id: %s ",
b18917
+				ev.fru_text,
b18917
+				uuid_le(ev.fru_id));
b18917
+
b18917
+	if (pevent_get_field_val(s, event, "len", record, &val, 1) < 0)
b18917
+		return -1;
b18917
+	ev.length = val;
b18917
+	trace_seq_printf(s, "\n length: %d\n", ev.length);
b18917
+
b18917
+	ev.error = pevent_get_field_raw(s, event, "buf", record, &len, 1);
b18917
+	if(!ev.error)
b18917
+		return -1;
b18917
+	len = ev.length;
b18917
+	i = 0;
b18917
+	line_count = 0;
b18917
+	trace_seq_printf(s, " error:\n  %08x: ", i);
b18917
+	while(len >= 4) {
b18917
+		print_le_hex(s, ev.error, i);
b18917
+		i+=4;
b18917
+		len-=4;
b18917
+		if(++line_count == 4) {
b18917
+			trace_seq_printf(s, "\n  %08x: ", i);
b18917
+			line_count = 0;
b18917
+		} else
b18917
+			trace_seq_printf(s, " ");
b18917
+	}
b18917
+
b18917
+	/* Insert data into the SGBD */
b18917
+#ifdef HAVE_SQLITE3
b18917
+	ras_store_non_standard_record(ras, &ev;;
b18917
+#endif
b18917
+
b18917
+#ifdef HAVE_ABRT_REPORT
b18917
+	/* Report event to ABRT */
b18917
+	ras_report_non_standard_event(ras, &ev;;
b18917
+#endif
b18917
+
b18917
+	return 0;
b18917
+}
b18917
diff --git a/ras-non-standard-handler.h b/ras-non-standard-handler.h
b18917
new file mode 100644
b18917
index 0000000..2b5ac35
b18917
--- /dev/null
b18917
+++ b/ras-non-standard-handler.h
b18917
@@ -0,0 +1,26 @@
b18917
+/*
b18917
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
b18917
+ *
b18917
+ * This program is free software; you can redistribute it and/or modify
b18917
+ * it under the terms of the GNU General Public License version 2 and
b18917
+ * only version 2 as published by the Free Software Foundation.
b18917
+
b18917
+ * This program is distributed in the hope that it will be useful,
b18917
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
b18917
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b18917
+ * GNU General Public License for more details.
b18917
+ */
b18917
+
b18917
+#ifndef __RAS_NON_STANDARD_HANDLER_H
b18917
+#define __RAS_NON_STANDARD_HANDLER_H
b18917
+
b18917
+#include "ras-events.h"
b18917
+#include "libtrace/event-parse.h"
b18917
+
b18917
+int ras_non_standard_event_handler(struct trace_seq *s,
b18917
+			 struct pevent_record *record,
b18917
+			 struct event_format *event, void *context);
b18917
+
b18917
+void print_le_hex(struct trace_seq *s, const uint8_t *buf, int index);
b18917
+
b18917
+#endif
b18917
diff --git a/ras-record.c b/ras-record.c
b18917
index 3dc4493..357ab61 100644
b18917
--- a/ras-record.c
b18917
+++ b/ras-record.c
b18917
@@ -1,5 +1,6 @@
b18917
 /*
b18917
  * Copyright (C) 2013 Mauro Carvalho Chehab <mchehab@redhat.com>
b18917
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
b18917
  *
b18917
  * This program is free software; you can redistribute it and/or modify
b18917
  * it under the terms of the GNU General Public License as published by
b18917
@@ -157,6 +158,57 @@ int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
b18917
 }
b18917
 #endif
b18917
 
b18917
+/*
b18917
+ * Table and functions to handle ras:non standard
b18917
+ */
b18917
+
b18917
+#ifdef HAVE_NON_STANDARD
b18917
+static const struct db_fields non_standard_event_fields[] = {
b18917
+		{ .name="id",			.type="INTEGER PRIMARY KEY" },
b18917
+		{ .name="timestamp",		.type="TEXT" },
b18917
+		{ .name="sec_type",		.type="BLOB" },
b18917
+		{ .name="fru_id",		.type="BLOB" },
b18917
+		{ .name="fru_text",		.type="TEXT" },
b18917
+		{ .name="severity",		.type="TEXT" },
b18917
+		{ .name="error",		.type="BLOB" },
b18917
+};
b18917
+
b18917
+static const struct db_table_descriptor non_standard_event_tab = {
b18917
+	.name = "non_standard_event",
b18917
+	.fields = non_standard_event_fields,
b18917
+	.num_fields = ARRAY_SIZE(non_standard_event_fields),
b18917
+};
b18917
+
b18917
+int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standard_event *ev)
b18917
+{
b18917
+	int rc;
b18917
+	struct sqlite3_priv *priv = ras->db_priv;
b18917
+
b18917
+	if (!priv || !priv->stmt_non_standard_record)
b18917
+		return 0;
b18917
+	log(TERM, LOG_INFO, "non_standard_event store: %p\n", priv->stmt_non_standard_record);
b18917
+
b18917
+	sqlite3_bind_text (priv->stmt_non_standard_record,  1, ev->timestamp, -1, NULL);
b18917
+	sqlite3_bind_blob (priv->stmt_non_standard_record,  2, ev->sec_type, -1, NULL);
b18917
+	sqlite3_bind_blob (priv->stmt_non_standard_record,  3, ev->fru_id, 16, NULL);
b18917
+	sqlite3_bind_text (priv->stmt_non_standard_record,  4, ev->fru_text, -1, NULL);
b18917
+	sqlite3_bind_text (priv->stmt_non_standard_record,  5, ev->severity, -1, NULL);
b18917
+	sqlite3_bind_blob (priv->stmt_non_standard_record,  6, ev->error, ev->length, NULL);
b18917
+
b18917
+	rc = sqlite3_step(priv->stmt_non_standard_record);
b18917
+	if (rc != SQLITE_OK && rc != SQLITE_DONE)
b18917
+		log(TERM, LOG_ERR,
b18917
+		    "Failed to do non_standard_event step on sqlite: error = %d\n", rc);
b18917
+	rc = sqlite3_reset(priv->stmt_non_standard_record);
b18917
+	if (rc != SQLITE_OK && rc != SQLITE_DONE)
b18917
+		log(TERM, LOG_ERR,
b18917
+		    "Failed reset non_standard_event on sqlite: error = %d\n", rc);
b18917
+	log(TERM, LOG_INFO, "register inserted at db\n");
b18917
+
b18917
+	return rc;
b18917
+}
b18917
+#endif
b18917
+
b18917
 #ifdef HAVE_EXTLOG
b18917
 static const struct db_fields extlog_event_fields[] = {
b18917
 		{ .name="id",			.type="INTEGER PRIMARY KEY" },
b18917
@@ -450,6 +502,13 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
b18917
 					 &mce_record_tab);
b18917
 #endif
b18917
 
b18917
+#ifdef HAVE_NON_STANDARD
b18917
+	rc = ras_mc_create_table(priv, &non_standard_event_tab);
b18917
+	if (rc == SQLITE_OK)
b18917
+		rc = ras_mc_prepare_stmt(priv, &priv->stmt_non_standard_record,
b18917
+					&non_standard_event_tab);
b18917
+#endif
b18917
+
b18917
 		ras->db_priv = priv;
b18917
 	return 0;
b18917
 }
b18917
diff --git a/ras-record.h b/ras-record.h
b18917
index 5d84297..473ae40 100644
b18917
--- a/ras-record.h
b18917
+++ b/ras-record.h
b18917
@@ -1,5 +1,6 @@
b18917
 /*
b18917
  * Copyright (C) 2013 Mauro Carvalho Chehab <mchehab@redhat.com>
b18917
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
b18917
  *
b18917
  * This program is free software; you can redistribute it and/or modify
b18917
  * it under the terms of the GNU General Public License as published by
b18917
@@ -56,9 +57,18 @@ struct ras_extlog_event {
b18917
 	unsigned short cper_data_length;
b18917
 };
b18917
 
b18917
+struct ras_non_standard_event {
b18917
+	char timestamp[64];
b18917
+	const char *sec_type, *fru_id, *fru_text;
b18917
+	const char *severity;
b18917
+	const uint8_t *error;
b18917
+	uint32_t length;
b18917
+};
b18917
+
b18917
 struct ras_mc_event;
b18917
 struct ras_aer_event;
b18917
 struct ras_extlog_event;
b18917
+struct ras_non_standard_event;
b18917
 struct mce_event;
b18917
 
b18917
 #ifdef HAVE_SQLITE3
b18917
@@ -77,6 +87,9 @@ struct sqlite3_priv {
b18917
 #ifdef HAVE_EXTLOG
b18917
 	sqlite3_stmt	*stmt_extlog_record;
b18917
 #endif
b18917
+#ifdef HAVE_NON_STANDARD
b18917
+	sqlite3_stmt	*stmt_non_standard_record;
b18917
+#endif
b18917
 };
b18917
 
b18917
 int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras);
b18917
@@ -84,6 +97,7 @@ int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev);
b18917
 int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev);
b18917
 int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev);
b18917
 int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event *ev);
b18917
+int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standard_event *ev);
b18917
 
b18917
 #else
b18917
 static inline int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras) { return 0; };
b18917
@@ -91,6 +105,7 @@ static inline int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event
b18917
 static inline int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev) { return 0; };
b18917
 static inline int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev) { return 0; };
b18917
 static inline int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event *ev) { return 0; };
b18917
+static inline int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standard_event *ev) { return 0; };
b18917
 
b18917
 #endif
b18917
 
b18917
diff --git a/ras-report.c b/ras-report.c
b18917
index 0a05732..1eb9f79 100644
b18917
--- a/ras-report.c
b18917
+++ b/ras-report.c
b18917
@@ -1,3 +1,16 @@
b18917
+/*
b18917
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
b18917
+ *
b18917
+ * This program is free software; you can redistribute it and/or modify
b18917
+ * it under the terms of the GNU General Public License version 2 and
b18917
+ * only version 2 as published by the Free Software Foundation.
b18917
+
b18917
+ * This program is distributed in the hope that it will be useful,
b18917
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
b18917
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b18917
+ * GNU General Public License for more details.
b18917
+ */
b18917
+
b18917
 #include <stdio.h>
b18917
 #include <string.h>
b18917
 #include <unistd.h>
b18917
@@ -196,6 +209,25 @@ static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev){
b18917
 	return 0;
b18917
 }
b18917
 
b18917
+static int set_non_standard_event_backtrace(char *buf, struct ras_non_standard_event *ev){
b18917
+	char bt_buf[MAX_BACKTRACE_SIZE];
b18917
+
b18917
+	if(!buf || !ev)
b18917
+		return -1;
b18917
+
b18917
+	sprintf(bt_buf, "BACKTRACE="	\
b18917
+						"timestamp=%s\n"	\
b18917
+						"severity=%s\n"	\
b18917
+						"length=%d\n",	\
b18917
+						ev->timestamp,	\
b18917
+						ev->severity,	\
b18917
+						ev->length);
b18917
+
b18917
+	strcat(buf, bt_buf);
b18917
+
b18917
+	return 0;
b18917
+}
b18917
+
b18917
 static int commit_report_backtrace(int sockfd, int type, void *ev){
b18917
 	char buf[MAX_BACKTRACE_SIZE];
b18917
 	char *pbuf = buf;
b18917
@@ -218,6 +250,9 @@ static int commit_report_backtrace(int sockfd, int type, void *ev){
b18917
 	case MCE_EVENT:
b18917
 		rc = set_mce_event_backtrace(buf, (struct mce_event *)ev);
b18917
 		break;
b18917
+	case NON_STANDARD_EVENT:
b18917
+		rc = set_non_standard_event_backtrace(buf, (struct ras_non_standard_event *)ev);
b18917
+		break;
b18917
 	default:
b18917
 		return -1;
b18917
 	}
b18917
@@ -345,6 +380,51 @@ aer_fail:
b18917
 	}
b18917
 }
b18917
 
b18917
+int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev){
b18917
+	char buf[MAX_MESSAGE_SIZE];
b18917
+	int sockfd = 0;
b18917
+	int rc = -1;
b18917
+
b18917
+	memset(buf, 0, sizeof(buf));
b18917
+
b18917
+	sockfd = setup_report_socket();
b18917
+	if(sockfd < 0){
b18917
+		return rc;
b18917
+	}
b18917
+
b18917
+	rc = commit_report_basic(sockfd);
b18917
+	if(rc < 0){
b18917
+		goto non_standard_fail;
b18917
+	}
b18917
+
b18917
+	rc = commit_report_backtrace(sockfd, NON_STANDARD_EVENT, ev);
b18917
+	if(rc < 0){
b18917
+		goto non_standard_fail;
b18917
+	}
b18917
+
b18917
+	sprintf(buf, "ANALYZER=%s", "rasdaemon-non-standard");
b18917
+	rc = write(sockfd, buf, strlen(buf) + 1);
b18917
+	if(rc < strlen(buf) + 1){
b18917
+		goto non_standard_fail;
b18917
+	}
b18917
+
b18917
+	sprintf(buf, "REASON=%s", "Unknown CPER section problem");
b18917
+	rc = write(sockfd, buf, strlen(buf) + 1);
b18917
+	if(rc < strlen(buf) + 1){
b18917
+		goto non_standard_fail;
b18917
+	}
b18917
+
b18917
+	rc = 0;
b18917
+
b18917
+non_standard_fail:
b18917
+
b18917
+	if(sockfd > 0){
b18917
+		close(sockfd);
b18917
+	}
b18917
+
b18917
+	return rc;
b18917
+}
b18917
+
b18917
 int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev){
b18917
 	char buf[MAX_MESSAGE_SIZE];
b18917
 	int sockfd = 0;
b18917
diff --git a/ras-report.h b/ras-report.h
b18917
index 7920cdf..c2fcf42 100644
b18917
--- a/ras-report.h
b18917
+++ b/ras-report.h
b18917
@@ -1,3 +1,16 @@
b18917
+/*
b18917
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
b18917
+ *
b18917
+ * This program is free software; you can redistribute it and/or modify
b18917
+ * it under the terms of the GNU General Public License version 2 and
b18917
+ * only version 2 as published by the Free Software Foundation.
b18917
+
b18917
+ * This program is distributed in the hope that it will be useful,
b18917
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
b18917
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b18917
+ * GNU General Public License for more details.
b18917
+ */
b18917
+
b18917
 #ifndef __RAS_REPORT_H
b18917
 #define __RAS_REPORT_H
b18917
 
b18917
@@ -19,7 +32,8 @@
b18917
 enum {
b18917
 	MC_EVENT,
b18917
 	MCE_EVENT,
b18917
-	AER_EVENT
b18917
+	AER_EVENT,
b18917
+	NON_STANDARD_EVENT
b18917
 };
b18917
 
b18917
 #ifdef HAVE_ABRT_REPORT
b18917
@@ -27,12 +41,14 @@ enum {
b18917
 int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev);
b18917
 int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev);
b18917
 int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev);
b18917
+int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev);
b18917
 
b18917
 #else
b18917
 
b18917
 static inline int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev) { return 0; };
b18917
 static inline int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev) { return 0; };
b18917
 static inline int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev) { return 0; };
b18917
+static inline int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev) { return 0; };
b18917
 
b18917
 #endif
b18917
 
b18917
-- 
b18917
1.8.3.1
b18917