View | Details | Raw Unified | Return to bug 207145 | Differences between
and this patch

Collapse All | Expand All

(-)sysutils/mcelog/Makefile (-11 / +8 lines)
Lines 2-16 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	mcelog
4
PORTNAME=	mcelog
5
DISTVERSION=	1.0pre3
5
DISTVERSIONPREFIX=	v
6
DISTVERSION=	131
6
CATEGORIES=	sysutils
7
CATEGORIES=	sysutils
7
MASTER_SITES=	ftp://ftp.kernel.org/pub/linux/utils/cpu/mce/ \
8
		http://147.52.159.12/mirrors/ftp.kernel.org/pub/linux/utils/cpu/mce/ \
9
		http://ftp.sjtu.edu.cn/sites/ftp.kernel.org/pub/linux/utils/cpu/mce/ \
10
		http://mirror.be.gbxs.net/pub/linux/utils/cpu/mce/ \
11
		http://ftp.eu.openbsd.org/pub/linux/utils/cpu/mce/ \
12
		http://korg.cs.utah.edu/pub/linux/utils/cpu/mce/ \
13
		http://ftp.oregonstate.edu/pub/linux/utils/cpu/mce/
14
8
15
MAINTAINER=	jdc@koitsu.org
9
MAINTAINER=	jdc@koitsu.org
16
COMMENT=	Collects and decodes Machine Check Exception data
10
COMMENT=	Collects and decodes Machine Check Exception data
Lines 17-35 Link Here
17
11
18
LICENSE=	GPLv2
12
LICENSE=	GPLv2
19
13
14
USE_GITHUB=	yes
15
GH_ACCOUNT=	andikleen
16
20
ONLY_FOR_ARCHS=	amd64 i386 ia64
17
ONLY_FOR_ARCHS=	amd64 i386 ia64
21
18
22
PATCH_STRIP=	-p1
23
24
USES=		alias gmake
19
USES=		alias gmake
25
20
26
MAKE_ENV+=	FREEBSD=1
21
MAKE_ENV+=	FREEBSD=1
27
LDFLAGS=	-lkvm
22
LDFLAGS+=	-lkvm
28
23
29
PLIST_FILES=	bin/mcelog man/man8/mcelog.8.gz
24
PLIST_FILES=	bin/mcelog man/man8/mcelog.8.gz
30
25
31
post-patch:
26
post-patch:
32
	@${CP} ${FILESDIR}/memstream.c ${WRKSRC}/memstream.c
27
	@${CP} ${FILESDIR}/memstream.c ${WRKSRC}/memstream.c
28
	${REINPLACE_CMD} 's/\"unknown\"/\"${PORTVERSION}\"/' \
29
		${WRKSRC}/Makefile
33
30
34
do-install:
31
do-install:
35
	${INSTALL_PROGRAM} ${WRKSRC}/mcelog ${STAGEDIR}${PREFIX}/bin
32
	${INSTALL_PROGRAM} ${WRKSRC}/mcelog ${STAGEDIR}${PREFIX}/bin
(-)sysutils/mcelog/distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (mcelog-1.0pre3.tar.gz) = 0782e0aa952fa4bd641071e6b501774a63993a813a4f494ffd7819521a13c50c
1
SHA256 (andikleen-mcelog-v131_GH0.tar.gz) = 58a37bb49da350a0255bc3adfa327551e21a8b750066d5b246d8ea76fa8f6cb4
2
SIZE (mcelog-1.0pre3.tar.gz) = 176649
2
SIZE (andikleen-mcelog-v131_GH0.tar.gz) = 298539
(-)sysutils/mcelog/files/patch-Makefile (-14 / +26 lines)
Lines 1-4 Link Here
1
--- Makefile.orig	2010-01-21 02:36:52 UTC
1
--- Makefile.orig	2016-02-10 18:38:43 UTC
2
+++ Makefile
2
+++ Makefile
3
@@ -1,5 +1,4 @@
3
@@ -1,5 +1,4 @@
4
-CFLAGS := -g -Os
4
-CFLAGS := -g -Os
Lines 5-15 Link Here
5
-prefix := /usr
5
-prefix := /usr
6
+prefix := /usr/local
6
+prefix := /usr/local
7
 etcprefix :=
7
 etcprefix :=
8
 MANDIR := ${prefix}/share/man
8
 # Define appropiately for your distribution
9
 # Define appropiately for your distribution
9
 # DOCDIR := /usr/share/doc/packages/mcelog
10
@@ -32,13 +31,19 @@ all: mcelog
10
@@ -28,11 +27,18 @@ all: mcelog
11
 
11
 
12
 .PHONY: install clean depend
12
 .PHONY: install clean depend FORCE
13
 
13
 
14
+LIBS :=
14
+LIBS :=
15
 OBJ := p4.o k8.o mcelog.o dmi.o tsc.o core2.o bitfield.o intel.o \
15
 OBJ := p4.o k8.o mcelog.o dmi.o tsc.o core2.o bitfield.o intel.o \
Lines 16-26 Link Here
16
        nehalem.o dunnington.o tulsa.o config.o memutil.o msg.o   \
16
        nehalem.o dunnington.o tulsa.o config.o memutil.o msg.o   \
17
-       eventloop.o leaky-bucket.o memdb.o server.o trigger.o 	 \
17
-       eventloop.o leaky-bucket.o memdb.o server.o trigger.o 	 \
18
-       client.o cache.o sysfs.o yellow.o page.o rbtree.o 	 \
18
-       client.o cache.o sysfs.o yellow.o page.o rbtree.o 	 \
19
-       xeon75xx.o
19
-       xeon75xx.o sandy-bridge.o ivy-bridge.o haswell.o		 \
20
-       broadwell_de.o broadwell_epex.o msr.o bus.o \
21
-       unknown.o
20
+       eventloop.o leaky-bucket.o memdb.o server.o client.o 	 \
22
+       eventloop.o leaky-bucket.o memdb.o server.o client.o 	 \
21
+       cache.o rbtree.o xeon75xx.o
23
+       cache.o rbtree.o xeon75xx.o sandy-bridge.o ivy-bridge.o	\
24
+       haswell.o broadwell_de.o broadwell_epex.o msr.o
22
+ifndef FREEBSD
25
+ifndef FREEBSD
23
+OBJ += page.o trigger.o sysfs.o yellow.o
26
+OBJ += page.o trigger.o sysfs.o yellow.o bus.o unknown.o
24
+endif
27
+endif
25
+ifdef FREEBSD
28
+ifdef FREEBSD
26
+OBJ += memstream.o
29
+OBJ += memstream.o
Lines 27-44 Link Here
27
+LIBS += -lkvm
30
+LIBS += -lkvm
28
+endif
31
+endif
29
 DISKDB_OBJ := diskdb.o dimm.o db.o
32
 DISKDB_OBJ := diskdb.o dimm.o db.o
30
 CLEAN := mcelog dmi tsc dbquery .depend .depend.X dbquery.o ${DISKDB_OBJ}
33
 CLEAN := mcelog dmi tsc dbquery .depend .depend.X dbquery.o ${DISKDB_OBJ} \
31
 DOC := mce.pdf
34
 	version.o version.c version.tmp
32
@@ -48,7 +54,7 @@ endif
35
@@ -55,7 +60,7 @@ endif
33
 
36
 
34
 SRC := $(OBJ:.o=.c)
37
 SRC := $(OBJ:.o=.c)
35
 
38
 
36
-mcelog: ${OBJ}
39
-mcelog: ${OBJ} version.o
37
+mcelog: ${OBJ} ${LIBS}
40
+mcelog: ${OBJ} ${LIBS} version.o
38
 
41
 
39
 # dbquery intentionally not installed by default
42
 # dbquery intentionally not installed by default
40
 install: mcelog
43
 install: mcelog mcelog.conf mcelog.conf.5 mcelog.triggers.5
41
@@ -82,8 +88,6 @@ depend: .depend
44
@@ -94,7 +99,7 @@ depend: .depend
45
 
46
 version.tmp: FORCE
47
 	( echo -n "char version[] = \"" ; 	\
48
-	if type -p git >/dev/null; then 	\
49
+	if command -v git >/dev/null; then 	\
50
 	if [ -d .git ] ; then 			\
51
 		git describe --tags HEAD | tr -d '\n'; 	\
52
 	else 					\
53
@@ -110,8 +115,6 @@ version.c: version.tmp
42
 .depend: ${SRC}
54
 .depend: ${SRC}
43
 	${CC} -MM -I. ${SRC} > .depend.X && mv .depend.X .depend
55
 	${CC} -MM -I. ${SRC} > .depend.X && mv .depend.X .depend
44
 
56
 
(-)sysutils/mcelog/files/patch-cache.c (-3 / +3 lines)
Lines 1-5 Link Here
1
--- ./cache.c.orig	2009-12-15 07:18:40.000000000 -0500
1
--- cache.c.orig	2016-02-10 18:38:43 UTC
2
+++ ./cache.c	2011-10-14 22:36:47.000000000 -0400
2
+++ cache.c
3
@@ -27,6 +27,7 @@
3
@@ -27,6 +27,7 @@
4
 #include "sysfs.h"
4
 #include "sysfs.h"
5
 #include "cache.h"
5
 #include "cache.h"
Lines 8-14 Link Here
8
 struct cache { 
8
 struct cache { 
9
 	unsigned level;
9
 	unsigned level;
10
 	/* Numerical values must match MCACOD */
10
 	/* Numerical values must match MCACOD */
11
@@ -164,6 +165,15 @@
11
@@ -173,6 +174,15 @@ int cache_to_cpus(int cpu, unsigned leve
12
 	Wprintf("Cannot find sysfs cache for CPU %d", cpu);
12
 	Wprintf("Cannot find sysfs cache for CPU %d", cpu);
13
 	return -1;
13
 	return -1;
14
 }
14
 }
(-)sysutils/mcelog/files/patch-client.c (-3 / +3 lines)
Lines 1-5 Link Here
1
--- ./client.c.orig	2009-12-15 07:18:40.000000000 -0500
1
--- client.c.orig	2016-02-10 18:38:43 UTC
2
+++ ./client.c	2011-10-14 22:36:47.000000000 -0400
2
+++ client.c
3
@@ -18,6 +18,7 @@
3
@@ -18,6 +18,7 @@
4
 #include <stdio.h>
4
 #include <stdio.h>
5
 #include <sys/socket.h>
5
 #include <sys/socket.h>
Lines 8-14 Link Here
8
 #include <unistd.h>
8
 #include <unistd.h>
9
 #include "mcelog.h"
9
 #include "mcelog.h"
10
 #include "client.h"
10
 #include "client.h"
11
@@ -48,6 +49,9 @@
11
@@ -48,6 +49,9 @@ void ask_server(char *command) 
12
 			sizeof(struct sockaddr_un)) < 0)
12
 			sizeof(struct sockaddr_un)) < 0)
13
 		SYSERRprintf("client connect");
13
 		SYSERRprintf("client connect");
14
 	
14
 	
(-)sysutils/mcelog/files/patch-eventloop.c (-5 / +5 lines)
Lines 1-6 Link Here
1
--- eventloop.c.orig	2010-01-20 18:36:52.000000000 -0800
1
--- eventloop.c.orig	2016-02-10 18:38:43 UTC
2
+++ eventloop.c	2012-09-22 02:25:13.281116126 -0700
2
+++ eventloop.c
3
@@ -38,7 +38,9 @@
3
@@ -38,7 +38,9 @@ struct pollcb { 
4
 static struct pollfd pollfds[MAX_POLLFD];
4
 static struct pollfd pollfds[MAX_POLLFD];
5
 static struct pollcb pollcbs[MAX_POLLFD];	
5
 static struct pollcb pollcbs[MAX_POLLFD];	
6
 
6
 
Lines 10-16 Link Here
10
 
10
 
11
 static int closeonexec(int fd)
11
 static int closeonexec(int fd)
12
 {
12
 {
13
@@ -97,6 +99,7 @@
13
@@ -97,6 +99,7 @@ static void poll_callbacks(int n)
14
 }
14
 }
15
 
15
 
16
 /* Run signal handler only directly after event loop */
16
 /* Run signal handler only directly after event loop */
Lines 18-24 Link Here
18
 int event_signal(int sig)
18
 int event_signal(int sig)
19
 {
19
 {
20
 	static int first = 1;
20
 	static int first = 1;
21
@@ -126,17 +129,25 @@
21
@@ -126,17 +129,25 @@ static int ppoll_fallback(struct pollfd 
22
 
22
 
23
 static int (*ppoll_vec)(struct pollfd *, nfds_t, const struct timespec
23
 static int (*ppoll_vec)(struct pollfd *, nfds_t, const struct timespec
24
 			*, const sigset_t *);
24
 			*, const sigset_t *);
(-)sysutils/mcelog/files/patch-intel.c (-12 / +3 lines)
Lines 1-15 Link Here
1
--- intel.c.orig	2010-01-20 18:36:52.000000000 -0800
1
--- intel.c.orig	2016-02-10 18:38:43 UTC
2
+++ intel.c	2012-09-22 01:58:40.204115724 -0700
2
+++ intel.c
3
@@ -43,7 +43,7 @@
3
@@ -141,14 +141,18 @@ static int intel_memory_error(struct mce
4
 			return CPU_CORE2;
5
 		else if (model == 0x1d)
6
 			return CPU_DUNNINGTON;
7
-		else if (model == 0x1a)
8
+		else if (model == 0x1a || model == 0x2c) /* Nehalem/Westmere */
9
 			return CPU_NEHALEM;
10
 		else if (model == 0x2e)
11
 			return CPU_XEON75XX;
12
@@ -94,14 +94,18 @@
13
 		if (recordlen > offsetof(struct mce, mcgcap) && m->mcgcap & MCG_CMCI_P)
4
 		if (recordlen > offsetof(struct mce, mcgcap) && m->mcgcap & MCG_CMCI_P)
14
  			corr_err_cnt = EXTRACT(m->status, 38, 52);
5
  			corr_err_cnt = EXTRACT(m->status, 38, 52);
15
 		memory_error(m, channel[0], dimm[0], corr_err_cnt, recordlen);
6
 		memory_error(m, channel[0], dimm[0], corr_err_cnt, recordlen);
(-)sysutils/mcelog/files/patch-mcelog.c (-51 / +83 lines)
Lines 1-5 Link Here
1
--- mcelog.c.orig	2010-01-20 18:36:52.000000000 -0800
1
--- mcelog.c.orig	2016-02-10 18:38:43 UTC
2
+++ mcelog.c	2012-09-22 02:34:19.182116917 -0700
2
+++ mcelog.c
3
@@ -20,9 +20,22 @@
3
@@ -20,9 +20,22 @@
4
 #define _GNU_SOURCE 1
4
 #define _GNU_SOURCE 1
5
 #include <sys/fcntl.h>
5
 #include <sys/fcntl.h>
Lines 23-31 Link Here
23
 #include <stdlib.h>
23
 #include <stdlib.h>
24
 #include <stdio.h>
24
 #include <stdio.h>
25
 #include <string.h>
25
 #include <string.h>
26
@@ -58,9 +71,25 @@
26
@@ -61,9 +74,25 @@
27
 #include "yellow.h"
27
 #include "bus.h"
28
 #include "page.h"
28
 #include "unknown.h"
29
 
29
 
30
+struct mca_record {
30
+struct mca_record {
31
+	uint64_t	mr_status;
31
+	uint64_t	mr_status;
Lines 49-55 Link Here
49
 
49
 
50
 int ignore_nodev;
50
 int ignore_nodev;
51
 int filter_bogus = 1;
51
 int filter_bogus = 1;
52
@@ -71,12 +100,18 @@
52
@@ -74,7 +103,9 @@ int ascii_mode;
53
 int dump_raw_ascii;
53
 int dump_raw_ascii;
54
 int daemon_mode;
54
 int daemon_mode;
55
 static char *inputfile;
55
 static char *inputfile;
Lines 59-89 Link Here
59
 static int foreground;
59
 static int foreground;
60
 int filter_memory_errors;
60
 int filter_memory_errors;
61
 static struct config_cred runcred = { .uid = -1U, .gid = -1U };
61
 static struct config_cred runcred = { .uid = -1U, .gid = -1U };
62
 static int numerrors;
62
@@ -83,6 +114,10 @@ static char pidfile_default[] = PID_FILE
63
 static char *pidfile;
63
 static char logfile_default[] = LOG_FILE;
64
 static char *pidfile = pidfile_default;
65
 static char *logfile;
64
+#ifdef __FreeBSD__
66
+#ifdef __FreeBSD__
65
+static char *execfile;
67
+static char *execfile;
66
+static char *corefile;
68
+static char *corefile;
67
+#endif
69
+#endif
68
 
70
 static int debug_numerrors;
69
 static void check_cpu(void);
71
 int imc_log = -1;
70
 
72
 static int check_only = 0;
71
@@ -393,6 +428,7 @@
73
@@ -482,6 +517,7 @@ static void dump_mce_raw_ascii(struct mc
72
 	Wprintf("\n");
74
 	Wprintf("\n");
73
 }
75
 }
74
 
76
 
75
+#ifdef __Linux__
77
+#ifdef __Linux__
76
 void check_cpu(void)
78
 int is_cpu_supported(void)
77
 { 
79
 { 
78
 	enum { 
80
 	enum { 
79
@@ -460,7 +496,45 @@
81
@@ -552,13 +588,58 @@ int is_cpu_supported(void)
80
 	} else
82
 
81
 		Eprintf("warning: Cannot open /proc/cpuinfo\n");
83
 	return 1;
82
 } 
84
 } 
83
+#endif
85
+#endif
84
+
86
 
85
+#ifdef __FreeBSD__
87
+#ifdef __FreeBSD__
86
+void check_cpu(void)
88
+int is_cpu_supported(void)
87
+{
89
+{
88
+	char vendor[20];
90
+	char vendor[20];
89
+	u_int regs[4];
91
+	u_int regs[4];
Lines 92-98 Link Here
92
+	static int checked;
94
+	static int checked;
93
+
95
+
94
+	if (checked)
96
+	if (checked)
95
+		return;
97
+		return 1;
96
+
98
+
97
+	checked = 1;
99
+	checked = 1;
98
+
100
+
Lines 109-136 Link Here
109
+
111
+
110
+	if (cpu_forced)
112
+	if (cpu_forced)
111
+		;
113
+		;
112
+	else if (!strcmp(vendor,"AuthenticAMD") &&
114
+	else if (!strcmp(vendor,"AuthenticAMD")) {
113
+	    (family == 15 || family == 16 || family == 17))
115
+			if (family == 15) {
114
+		cputype = CPU_K8;
116
+				cputype = CPU_K8;
115
+	else if (!strcmp(vendor,"GenuineIntel"))
117
+			} else if (family >= 16) {
116
+		cputype = select_intel_cputype(family, model);
118
+				SYSERRprintf("ERROR: AMD Processor family %d: mcelog does not support this processor.  Please use the edac_mce_amd module instead.\n", family);
119
+				return 0;
120
+			}
121
+		} else if (!strcmp(vendor,"GenuineIntel"))
122
+			cputype = select_intel_cputype(family, model);
117
+	/* Add checks for other CPUs here */
123
+	/* Add checks for other CPUs here */
124
+		else
125
+		return 1;
118
+}
126
+}
119
+#endif
127
+#endif
120
 
128
+
121
+#ifdef __Linux__
129
+#ifdef __Linux__
122
 static char *skipspace(char *s)
130
 static char *skipspace(char *s)
123
 {
131
 {
124
 	while (isspace(*s))
132
 	while (isspace(*s))
125
@@ -484,6 +558,7 @@
133
 		++s;
126
 	}
134
 	return s;
127
 	return skipspace(s);
128
 }
135
 }
129
+#endif
136
+#endif
130
 
137
 
131
 static void dump_mce_final(struct mce *m, char *symbol, int missing, int recordlen, 
138
 static char *skip_syslog(char *s)
132
 			   int dseen)
139
 {
133
@@ -507,6 +582,7 @@
140
@@ -667,6 +748,7 @@ static int match_patterns(char *s, char 
134
 		recordlen = endof_field(struct mce, f)
141
 		recordlen = endof_field(struct mce, f)
135
 
142
 
136
 /* Decode ASCII input for fatal messages */
143
 /* Decode ASCII input for fatal messages */
Lines 138-144 Link Here
138
 static void decodefatal(FILE *inf)
145
 static void decodefatal(FILE *inf)
139
 {
146
 {
140
 	struct mce m;
147
 	struct mce m;
141
@@ -651,6 +727,227 @@
148
@@ -877,6 +959,227 @@ restart:
142
 	if (data)
149
 	if (data)
143
 		dump_mce_final(&m, symbol, missing, recordlen, disclaimer_seen);
150
 		dump_mce_final(&m, symbol, missing, recordlen, disclaimer_seen);
144
 }
151
 }
Lines 366-372 Link Here
366
 
373
 
367
 static void remove_pidfile(void)
374
 static void remove_pidfile(void)
368
 {
375
 {
369
@@ -709,6 +1006,10 @@
376
@@ -941,6 +1244,10 @@ void usage(void)
370
 "  mcelog [options] --ascii < log\n"
377
 "  mcelog [options] --ascii < log\n"
371
 "  mcelog [options] --ascii --file log\n"
378
 "  mcelog [options] --ascii --file log\n"
372
 "Decode machine check ASCII output from kernel logs\n"
379
 "Decode machine check ASCII output from kernel logs\n"
Lines 374-385 Link Here
374
+"  mcelog [options] -M vmcore -N kernel\n"
381
+"  mcelog [options] -M vmcore -N kernel\n"
375
+"Decode machine check error records from kernel crashdump.\n"
382
+"Decode machine check error records from kernel crashdump.\n"
376
+#endif
383
+#endif
384
 "\n"
377
 "Options:\n"  
385
 "Options:\n"  
378
 "--cpu CPU           Set CPU type CPU to decode (see below for valid types)\n"
386
 "--version           Show the version of mcelog and exit\n"
379
 "--cpumhz MHZ        Set CPU Mhz to decode time (output unreliable, not needed on new kernels)\n"
387
@@ -1147,6 +1454,14 @@ static int modifier(int opt)
380
@@ -889,6 +1190,14 @@
388
 	case O_IS_CPU_SUPPORTED:
381
 	case O_CONFIG_FILE:
389
 		check_only = 1;
382
 		/* parsed in config.c */
383
 		break;
390
 		break;
384
+#ifdef __FreeBSD__
391
+#ifdef __FreeBSD__
385
+	case 'M':
392
+	case 'M':
Lines 392-398 Link Here
392
 	case 0:
399
 	case 0:
393
 		break;
400
 		break;
394
 	default:
401
 	default:
395
@@ -923,8 +1232,10 @@
402
@@ -1197,10 +1512,12 @@ static int combined_modifier(int opt)
396
 
403
 
397
 static void general_setup(void)
404
 static void general_setup(void)
398
 {
405
 {
Lines 399-409 Link Here
399
+#ifdef __Linux__
406
+#ifdef __Linux__
400
 	trigger_setup();
407
 	trigger_setup();
401
 	yellow_setup();
408
 	yellow_setup();
409
 	bus_setup();
410
 	unknown_setup();
402
+#endif
411
+#endif
403
 	config_cred("global", "run-credentials", &runcred);
412
 	config_cred("global", "run-credentials", &runcred);
404
 	if (config_bool("global", "filter-memory-errors") == 1)
413
 	if (config_bool("global", "filter-memory-errors") == 1)
405
 		filter_memory_errors = 1;
414
 		filter_memory_errors = 1;
406
@@ -947,6 +1258,7 @@
415
@@ -1223,6 +1540,7 @@ static void drop_cred(void)
407
 	}
416
 	}
408
 }
417
 }
409
 
418
 
Lines 411-417 Link Here
411
 static void process(int fd, unsigned recordlen, unsigned loglen, char *buf)
420
 static void process(int fd, unsigned recordlen, unsigned loglen, char *buf)
412
 {	
421
 {	
413
 	int i; 
422
 	int i; 
414
@@ -987,6 +1299,173 @@
423
@@ -1275,6 +1593,173 @@ static void process(int fd, unsigned rec
415
 	if (finish)
424
 	if (finish)
416
 		exit(0);
425
 		exit(0);
417
 }
426
 }
Lines 585-591 Link Here
585
 
594
 
586
 static void noargs(int ac, char **av)
595
 static void noargs(int ac, char **av)
587
 {
596
 {
588
@@ -1045,22 +1524,30 @@
597
@@ -1333,12 +1818,14 @@ struct mcefd_data {
589
 	char *buf;
598
 	char *buf;
590
 };
599
 };
591
 
600
 
Lines 598-603 Link Here
598
 }
607
 }
599
+#endif
608
+#endif
600
 
609
 
610
 static void handle_sigusr1(int sig)
611
 {
612
@@ -1347,13 +1834,18 @@ static void handle_sigusr1(int sig)
613
 
601
 int main(int ac, char **av) 
614
 int main(int ac, char **av) 
602
 { 
615
 { 
603
+#ifdef __Linux__
616
+#ifdef __Linux__
Lines 604-616 Link Here
604
 	struct mcefd_data d = {};
617
 	struct mcefd_data d = {};
605
-	int opt;
618
-	int opt;
606
 	int fd;
619
 	int fd;
620
-
607
+#endif
621
+#endif
608
+	int opt;
622
+	int opt;
609
 
610
 	parse_config(av);
623
 	parse_config(av);
611
 
624
 
612
+#ifdef __FreeBSD__
625
+#ifdef __FreeBSD
613
+	while ((opt = getopt_long(ac, av, "M:N:", options, NULL)) != -1) { 
626
+	while ((opt = getopt_long(ac, av, "M:N:", options, NULL)) != -1) {
614
+#else
627
+#else
615
 	while ((opt = getopt_long(ac, av, "", options, NULL)) != -1) { 
628
 	while ((opt = getopt_long(ac, av, "", options, NULL)) != -1) { 
616
+#endif
629
+#endif
Lines 617-627 Link Here
617
 		if (opt == '?') {
630
 		if (opt == '?') {
618
 			usage(); 
631
 			usage(); 
619
 		} else if (combined_modifier(opt) > 0) {
632
 		} else if (combined_modifier(opt) > 0) {
620
@@ -1080,13 +1567,21 @@
633
@@ -1375,11 +1867,13 @@ int main(int ac, char **av) 
621
 		} else if (opt == 0)
622
 			break;		    
623
 	} 
634
 	} 
635
 
636
 	/* before doing anything else let's see if the CPUs are supported */
624
+#ifdef __Linux__
637
+#ifdef __Linux__
638
 	if (!cpu_forced && !is_cpu_supported()) {
639
 		if (!check_only)
640
 			fprintf(stderr, "CPU is unsupported\n");
641
 		exit(1);
642
 	}
643
+#endif
644
 	if (check_only)
645
 		exit(0);
646
 
647
@@ -1398,13 +1892,21 @@ int main(int ac, char **av) 
648
 	}
649
 
650
 	modifier_finish();
651
+#ifdef __Linux__
625
 	if (av[optind])
652
 	if (av[optind])
626
 		logfn = av[optind++];
653
 		logfn = av[optind++];
627
+#endif
654
+#endif
Lines 639-652 Link Here
639
 	fd = open(logfn, O_RDONLY); 
666
 	fd = open(logfn, O_RDONLY); 
640
 	if (fd < 0) {
667
 	if (fd < 0) {
641
 		if (ignore_nodev) 
668
 		if (ignore_nodev) 
642
@@ -1101,24 +1596,39 @@
669
@@ -1419,27 +1921,44 @@ int main(int ac, char **av) 
643
 		err("MCE_GET_LOG_LEN");
670
 		err("MCE_GET_LOG_LEN");
644
 
671
 
645
 	d.buf = xalloc(d.recordlen * d.loglen); 
672
 	d.buf = xalloc(d.recordlen * d.loglen); 
646
+#endif
673
+#endif
647
 	if (daemon_mode) {
674
 	if (daemon_mode) {
648
 		check_cpu();
675
 		prefill_memdb(do_dmi);
649
 		prefill_memdb();
650
 		if (!do_dmi)
676
 		if (!do_dmi)
651
 			closedmi();
677
 			closedmi();
652
 		server_setup();
678
 		server_setup();
Lines 653-658 Link Here
653
+#ifdef __Linux__
679
+#ifdef __Linux__
654
 		page_setup();
680
 		page_setup();
655
+#endif
681
+#endif
682
 		if (imc_log)
683
 			set_imc_log(cputype);
656
 		drop_cred();
684
 		drop_cred();
657
+#ifdef __Linux__
685
+#ifdef __Linux__
658
 		register_pollcb(fd, POLLIN, process_mcefd, &d);
686
 		register_pollcb(fd, POLLIN, process_mcefd, &d);
Lines 661-666 Link Here
661
 			err("daemon");
689
 			err("daemon");
662
 		if (pidfile)
690
 		if (pidfile)
663
 			write_pidfile();
691
 			write_pidfile();
692
 		signal(SIGUSR1, handle_sigusr1);
693
+#ifdef __Linux__
694
 		event_signal(SIGUSR1);
695
+#endif
664
 		eventloop();
696
 		eventloop();
665
 	} else {
697
 	} else {
666
+#ifdef __Linux__
698
+#ifdef __Linux__
(-)sysutils/mcelog/files/patch-mcelog.h (-7 / +8 lines)
Lines 1-19 Link Here
1
--- ./mcelog.h.orig	2009-12-15 07:18:40.000000000 -0500
1
--- mcelog.h.orig	2016-02-10 18:38:43 UTC
2
+++ ./mcelog.h	2011-10-14 22:37:06.000000000 -0400
2
+++ mcelog.h
3
@@ -64,9 +64,11 @@
3
@@ -67,10 +67,12 @@ struct mce {
4
 #define MCI_STATUS_ADDRV (1ULL<<58)  /* addr reg. valid */
4
 #define MCI_STATUS_AR	 (1ULL<<55)  /* action-required */
5
 #define MCI_STATUS_PCC   (1ULL<<57)  /* processor context corrupt */
5
 #define MCI_STATUS_FWST  (1ULL<<37)  /* Firmware updated status indicator */
6
 
6
 
7
+#ifndef MCG_STATUS_RIPV
7
+#ifndef MCG_STATUS_RIPV
8
 #define MCG_STATUS_RIPV  (1ULL<<0)   /* restart ip valid */
8
 #define MCG_STATUS_RIPV  (1ULL<<0)   /* restart ip valid */
9
 #define MCG_STATUS_EIPV  (1ULL<<1)   /* eip points to correct instruction */
9
 #define MCG_STATUS_EIPV  (1ULL<<1)   /* eip points to correct instruction */
10
 #define MCG_STATUS_MCIP  (1ULL<<2)   /* machine check in progress */
10
 #define MCG_STATUS_MCIP  (1ULL<<2)   /* machine check in progress */
11
 #define MCG_STATUS_LMCES (1ULL<<3)   /* local machine check signaled */
11
+#endif
12
+#endif
12
 
13
 
13
 #define MCG_CMCI_P		(1ULL<<10)   /* CMCI supported */
14
 #define MCG_CMCI_P		(1ULL<<10)   /* CMCI supported */
14
 #define MCG_TES_P		(1ULL<<11)   /* Yellow bit cache threshold supported */
15
 #define MCG_TES_P		(1ULL<<11)   /* Yellow bit cache threshold supported */
15
@@ -89,6 +91,10 @@
16
@@ -97,6 +99,10 @@ struct mce {
16
 #define PRINTFLIKE 
17
 #define noreturn
17
 #endif
18
 #endif
18
 
19
 
19
+#if defined(__FreeBSD__) && defined(_STDIO_H_)
20
+#if defined(__FreeBSD__) && defined(_STDIO_H_)
(-)sysutils/mcelog/files/patch-memdb.c (-4 / +4 lines)
Lines 1-7 Link Here
1
--- ./memdb.c.orig	2009-12-15 07:18:40.000000000 -0500
1
--- memdb.c.orig	2016-02-10 18:38:43 UTC
2
+++ ./memdb.c	2011-10-14 22:36:47.000000000 -0400
2
+++ memdb.c
3
@@ -170,7 +170,9 @@
3
@@ -172,7 +172,9 @@ void memdb_trigger(char *msg, struct mem
4
 	asprintf(&env[ei++], "THRESHOLD_COUNT=%d", bucket->count + bucket->excess);
4
 	asprintf(&env[ei++], "THRESHOLD_COUNT=%d", bucket->count);
5
 	env[ei] = NULL;	
5
 	env[ei] = NULL;	
6
 	assert(ei < MAX_ENV);
6
 	assert(ei < MAX_ENV);
7
+#ifdef __Linux__
7
+#ifdef __Linux__
(-)sysutils/mcelog/files/patch-p4.c (-4 / +65 lines)
Lines 1-13 Link Here
1
--- ./p4.c.orig	2009-12-15 07:18:40.000000000 -0500
1
--- p4.c.orig	2016-02-10 18:38:43 UTC
2
+++ ./p4.c	2011-10-14 22:36:47.000000000 -0400
2
+++ p4.c
3
@@ -175,8 +175,10 @@
3
@@ -175,8 +175,10 @@ static int decode_mca(u64 status, u64 mi
4
 		levelnum = mca & 3;
5
 		level = get_LL_str(levelnum);
6
 		Wprintf("%s Generic cache hierarchy error\n", level);
7
+#ifdef __Linux__
8
 		if (track == 2)
9
 			run_yellow_trigger(cpu, -1, levelnum, "unknown", level, socket);
10
+#endif
11
 	} else if (test_prefix(4, mca)) {
12
 		unsigned levelnum, typenum;
13
 		char *level, *type;
14
@@ -185,8 +187,10 @@ static int decode_mca(u64 status, u64 mi
15
 		levelnum = (mca & TLB_LL_MASK) >> TLB_LL_SHIFT;
16
 		level = get_LL_str(levelnum);
17
 		Wprintf("%s TLB %s Error\n", type, level);
18
+#ifdef __Linux__
19
 		if (track == 2)
20
 			run_yellow_trigger(cpu, typenum, levelnum, type, level, socket);
21
+#endif
22
 	} else if (test_prefix(8, mca)) {
23
 		unsigned typenum = (mca & CACHE_TT_MASK) >> CACHE_TT_SHIFT;
24
 		unsigned levelnum = (mca & CACHE_LL_MASK) >> CACHE_LL_SHIFT;
25
@@ -195,8 +199,10 @@ static int decode_mca(u64 status, u64 mi
4
 		Wprintf("%s CACHE %s %s Error\n", type, level,
26
 		Wprintf("%s CACHE %s %s Error\n", type, level,
5
 				get_RRRR_str((mca & CACHE_RRRR_MASK) >> 
27
 				get_RRRR_str((mca & CACHE_RRRR_MASK) >> 
6
 					      CACHE_RRRR_SHIFT));
28
 					      CACHE_RRRR_SHIFT));
7
+#ifdef __Linux__
29
+#ifdef __Linux__
8
 		if (track == 2)
30
 		if (track == 2)
9
 			run_yellow_trigger(cpu, typenum, levelnum, type, level, socket);
31
 			run_yellow_trigger(cpu, typenum, levelnum, type, level,socket);
10
+#endif
32
+#endif
11
 	} else if (test_prefix(10, mca)) {
33
 	} else if (test_prefix(10, mca)) {
12
 		if (mca == 0x400)
34
 		if (mca == 0x400)
13
 			Wprintf("Internal Timer error\n");
35
 			Wprintf("Internal Timer error\n");
36
@@ -215,7 +221,9 @@ static int decode_mca(u64 status, u64 mi
37
 
38
 		Wprintf("BUS error: %d %d %s %s %s %s %s\n", socket, cpu,
39
 			level, pp, rrrr, ii, timeout);
40
+#ifdef __Linux__
41
 		run_bus_trigger(socket, cpu, level, pp, rrrr, ii, timeout);
42
+#endif
43
 		/* IO MCA - reported as bus/interconnect with specific PP,T,RRRR,II,LL values
44
 		 * and MISCV set. MISC register points to root port that reported the error
45
 		 * need to cross check with AER logs for more details.
46
@@ -231,7 +239,9 @@ static int decode_mca(u64 status, u64 mi
47
 			fn = EXTRACT(misc, 16, 18);
48
 			Wprintf("IO MCA reported by root port %x:%02x:%02x.%x\n",
49
 				seg, bus, dev, fn);
50
+#ifdef __Linux__
51
 			run_iomca_trigger(socket, cpu, seg, bus, dev, fn);
52
+#endif
53
 		}
54
 	} else if (test_prefix(7, mca)) {
55
 		decode_memory_controller(mca, bank);
56
@@ -365,14 +375,18 @@ void decode_intel_mc(struct mce *log, in
57
 
58
 	if (log->bank == MCE_THERMAL_BANK) { 
59
 		decode_thermal(log, cpu);
60
+#ifdef __Linux__
61
 		run_unknown_trigger(socket, cpu, log);
62
+#endif
63
 		return;
64
 	}
65
 
66
 	decode_mcg(log->mcgstatus);
67
+#ifdef __Linux__
68
 	if (decode_mci(log->status, log->misc, cpu, log->mcgcap, ismemerr,
69
 		socket, log->bank))
70
 		run_unknown_trigger(socket, cpu, log);
71
+#endif
72
 
73
 	if (test_prefix(11, (log->status & 0xffffL))) {
74
 		switch (cputype) {
(-)sysutils/mcelog/files/patch-server.c (-8 / +17 lines)
Lines 1-6 Link Here
1
--- server.c.orig	2010-01-20 18:36:52.000000000 -0800
1
--- server.c.orig	2016-02-10 18:38:43 UTC
2
+++ server.c	2012-09-22 02:39:04.991117023 -0700
2
+++ server.c
3
@@ -101,7 +101,9 @@
3
@@ -101,7 +101,9 @@ static void dispatch_dump(FILE *fh, char
4
 
4
 
5
 static void dispatch_pages(FILE *fh)
5
 static void dispatch_pages(FILE *fh)
6
 {
6
 {
Lines 10-16 Link Here
10
 	fprintf(fh, "done\n");
10
 	fprintf(fh, "done\n");
11
 }
11
 }
12
 
12
 
13
@@ -137,6 +139,7 @@
13
@@ -137,6 +139,7 @@ static void process_cmd(struct clientcon
14
 		Enomem();
14
 		Enomem();
15
 }
15
 }
16
 
16
 
Lines 18-24 Link Here
18
 /* check if client is allowed to access */
18
 /* check if client is allowed to access */
19
 static int access_check(int fd, struct msghdr *msg)
19
 static int access_check(int fd, struct msghdr *msg)
20
 {
20
 {
21
@@ -162,6 +165,35 @@
21
@@ -162,11 +165,44 @@ static int access_check(int fd, struct m
22
 	sendstring(fd, "permission denied\n");
22
 	sendstring(fd, "permission denied\n");
23
 	return -1;
23
 	return -1;
24
 }
24
 }
Lines 54-61 Link Here
54
 
54
 
55
 /* retrieve commands from client */
55
 /* retrieve commands from client */
56
 static int client_input(int fd, struct clientcon *cc)
56
 static int client_input(int fd, struct clientcon *cc)
57
@@ -242,18 +274,22 @@
58
 {
57
 {
58
+#ifdef __Linux__
59
 	char ctlbuf[CMSG_SPACE(sizeof(struct ucred))];
60
+#else
61
+	char ctlbuf[CMSG_SPACE(sizeof(struct cmsgcred))];
62
+#endif
63
 	struct iovec miov;
64
 	struct msghdr msg = {
65
 		.msg_iov = &miov,
66
@@ -242,18 +278,22 @@ static void client_accept(struct pollfd 
67
 {
59
 	struct clientcon *cc = NULL;
68
 	struct clientcon *cc = NULL;
60
 	int nfd = accept(pfd->fd, NULL, 0);	
69
 	int nfd = accept(pfd->fd, NULL, 0);	
61
+#ifdef __Linux__
70
+#ifdef __Linux__
Lines 77-85 Link Here
77
 
86
 
78
 	cc = xalloc(sizeof(struct clientcon));
87
 	cc = xalloc(sizeof(struct clientcon));
79
 	if (register_pollcb(nfd, POLLIN, client_event, cc) < 0) {
88
 	if (register_pollcb(nfd, POLLIN, client_event, cc) < 0) {
80
@@ -300,7 +336,12 @@
89
@@ -301,7 +341,12 @@ static int server_ping(struct sockaddr_u
81
 	sigaction(SIGALRM, &sa, &oldsa);	
82
 	if (sigsetjmp(ping_timeout_ctx, 1) == 0) {
90
 	if (sigsetjmp(ping_timeout_ctx, 1) == 0) {
91
 		ret = -1;
83
 		alarm(initial_ping_timeout);
92
 		alarm(initial_ping_timeout);
84
+#ifdef __Linux__
93
+#ifdef __Linux__
85
 		if (connect(fd, un, sizeof(struct sockaddr_un)) < 0)
94
 		if (connect(fd, un, sizeof(struct sockaddr_un)) < 0)
(-)sysutils/mcelog/files/patch-tsc.c (-5 / +5 lines)
Lines 1-5 Link Here
1
--- ./tsc.c.orig	2009-12-15 07:18:40.000000000 -0500
1
--- tsc.c.orig	2016-02-10 18:38:43 UTC
2
+++ ./tsc.c	2011-10-14 22:36:47.000000000 -0400
2
+++ tsc.c
3
@@ -15,6 +15,12 @@
3
@@ -15,6 +15,12 @@
4
    on your Linux system; if not, write to the Free Software Foundation,
4
    on your Linux system; if not, write to the Free Software Foundation,
5
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
5
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
Lines 13-19 Link Here
13
 #include <string.h>
13
 #include <string.h>
14
 #include <stdio.h>
14
 #include <stdio.h>
15
 #include <stdlib.h>
15
 #include <stdlib.h>
16
@@ -46,6 +52,7 @@
16
@@ -46,6 +52,7 @@ static int fmt_tsc(char **buf, u64 tsc, 
17
 	return 0;
17
 	return 0;
18
 }
18
 }
19
 
19
 
Lines 21-27 Link Here
21
 static double cpufreq_mhz(int cpu, double infomhz)
21
 static double cpufreq_mhz(int cpu, double infomhz)
22
 {
22
 {
23
 	double mhz;
23
 	double mhz;
24
@@ -68,12 +75,29 @@
24
@@ -68,12 +75,29 @@ static double cpufreq_mhz(int cpu, doubl
25
 	fclose(f);
25
 	fclose(f);
26
 	return mhz;
26
 	return mhz;
27
 }
27
 }
Lines 51-57 Link Here
51
 static int deep_sleep_states(int cpu)
51
 static int deep_sleep_states(int cpu)
52
 {
52
 {
53
 	int ret;
53
 	int ret;
54
@@ -132,6 +156,41 @@
54
@@ -132,6 +156,41 @@ static int tsc_reliable(int cputype, int
55
 		return 0;
55
 		return 0;
56
 	return 1;
56
 	return 1;
57
 }
57
 }

Return to bug 207145